How RNNs Power Risk Control in O2O Food Delivery: A TensorFlow Case Study

This article explains how Baidu Waimai's risk‑control team uses recurrent neural networks, especially LSTM, within TensorFlow to detect fraudulent merchants and users, compares static and dynamic RNN implementations, demonstrates a MNIST digit‑recognition example, and discusses optimization algorithms and model trade‑offs for real‑time fraud detection.

ITPUB
ITPUB
ITPUB
How RNNs Power Risk Control in O2O Food Delivery: A TensorFlow Case Study

1. Business Background

In the O2O food‑delivery market, each order carries platform subsidies, creating incentives for merchants, users, or even BD staff to fabricate transactions and claim subsidies, potentially costing millions daily. Baidu Waimai's risk‑control center builds a multi‑layer strategy to identify and punish such fraudulent behavior using AI and deep‑learning techniques.

The overall architecture consists of five parts: raw data collection (users, merchants, staff, logs, customer service), big‑data processing and feature extraction, model training (natural‑person, collusion, health, acquisition, extreme‑value, rule models), platform services (data query, monitoring, health display, audit), and strategy application (user profiling, interception, merchant penalization).

2. Recurrent Neural Networks (RNN)

RNNs introduce directed cycles that allow information to persist across time steps, making them suitable for sequential data. They comprise input, hidden, and output units, with hidden states feeding back into the next step. Standard RNNs suffer from vanishing or exploding gradients, limiting long‑range dependencies.

Long Short‑Term Memory (LSTM) networks overcome this by using a cell state and three gates (forget, input, output) to regulate information flow, enabling learning of long‑term dependencies.

3. TensorFlow Overview

TensorFlow is an open‑source deep‑learning library that represents computations as data‑flow graphs, supporting heterogeneous devices and automatic differentiation. It simplifies building, training, and deploying models such as CNNs, RNNs, and LSTMs.

4. Implementing RNNs in TensorFlow

Two TensorFlow APIs are highlighted:

Static RNN : Requires a list of tensors, one per time step. Users must transpose the input tensor, unstack it into a list, feed it to static_rnn, then stack the outputs and transpose back.

Dynamic RNN : Accepts a single 3‑D tensor [batch_size, n_steps, n_input], automatically handling time‑step iteration via a while_loop. It supports variable‑length sequences and is generally more efficient.

Both APIs return a tuple (outputs, state); the final output outputs[-1] is typically used for classification.

5. MNIST Handwritten Digit Example

Using the classic MNIST dataset (28×28 images flattened to 784‑dimensional vectors), a two‑step RNN (or LSTM) is built with n_input=28, n_steps=28, n_neurons=10, and n_classes=10. Training parameters: learning_rate=0.001, training_iters=100000, batch_size=128. The model achieves 98‑99% accuracy.

6. Optimization Algorithms

The article reviews common optimizers:

Stochastic Gradient Descent (SGD) : Simple but noisy gradients; may require learning‑rate decay.

Momentum : Adds a velocity term to smooth updates.

Adam : Combines adaptive first‑ and second‑moment estimates; default parameters (ε=10⁻⁸, β₁=0.9, β₂=0.999) provide stable and fast convergence.

Loss is defined as softmax cross‑entropy, and gradients are back‑propagated through the network.

7. Model Comparison for Risk Control

Three models are compared on the health‑score task:

RNN/LSTM : Captures temporal patterns, high accuracy, but less interpretable and sensitive to class imbalance.

Gradient Boosted Decision Trees (GBDT) : Good interpretability, moderate timeliness, robust to imbalance.

Logistic Regression (LR) : Simple, highly interpretable, lower accuracy.

In practice, Baidu Waimai combines these models to leverage the strengths of each.

8. Practical Considerations

Key requirements for a production risk‑control system include real‑time detection, high accuracy to avoid false positives, and explainability for operational staff to justify penalties. Data characteristics involve daily‑level time series, bursty abnormal events, and severe class imbalance, all of which influence model design and training.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

optimizationDeep LearningTensorFlowMNISTrisk controlLSTMRNN
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.