Train transaction sequence models on Chalk GPUs
This demo shows how to run PyTorch training on a Chalk GPU to fit a small transformer that forecasts transactions and scores synthetic fraud patterns. Pick a customer scenario to try the CPU-served model, then explore the code to see how it works.
Compare fraud predictions with the synthetic labels
The model uses the current transaction and earlier history. Coral borders identify the generator’s fraud labels.
Try this experiment · expected results
1Compare normal and card-testing scenarios
Choose Normal customer, then Card testing and inspect the transaction rows.
Expected: The score bar is the model prediction; the border is the label to compare it against.
2Inspect the sequence context
Compare surprise and the next-transaction forecast around a flagged row.
Expected: A surprising event and a fraud prediction are different outputs; legitimate look-alikes can be surprising too.
Compare a normal customer with a fraud scenario. Chalk trained the model on a GPU and serves it on CPUs; red scores are predictions, borders are labels.
The data is synthetic: customers have generated spending personas, and about 12% receive labelled card-testing, account-takeover or ATM-drain patterns. Legitimate look-alikes are included too. The causal transformer sees only the current transaction and earlier history; separate heads forecast the next category, amount and channel and score the current transaction. This small model demonstrates the training and serving workflow, rather than validated fraud detection on real customers.
Built on Chalk
Chalk supplies the dataset, GPU training run, model storage and CPU serving infrastructure. The example defines the synthetic transactions, causal transformer, training objective and fraud labels.
A dataset for training
Upload columns as a named Chalk dataset. The training function receives the dataset’s latest revision as a Polars LazyFrame, along with the run configuration.
Run PyTorch on a GPU
The training decorator specifies an NVIDIA L4 and the container dependencies. Chalk runs the training function in that environment and exposes its run status.
Save weights for serving
The training function writes model.pt to a Chalk Volume. The serving app reads it at startup using its workload identity.
Serve inference on CPUs
Chalk hosts the trained model and its web app in a CPU ScalingGroup. This example uses two CPU cores to score transaction histories with the small transformer.
Run it on your own
You will need uv and a Chalk environment with NVIDIA L4 capacity. Clone the example, log in and run train.py to upload the synthetic dataset and train the model. Then run deploy.py to serve the saved weights and print the demo URL.
The transformer and dataset are deliberately small. Replace the generator with your transaction sequences and labels, then evaluate on held-out customers. The same workflow takes a dataset through training, model storage and serving.
git clone https://github.com/chalk-ai/transaction-sequence-model
cd transaction-sequence-model
# Or export CHALK_CLIENT_ID and CHALK_CLIENT_SECRET.
chalk login
# Generate 20k customers, upload them as a dataset, and train on an L4.
./train.py
# Serve the trained weights behind the page you see above.
./deploy.pyTrain on your own transactions
Fraud, credit risk, and next-best-action all start from sequences. Talk to an engineer about training sequence models on GPUs and serving them in your Chalk environment.