Each swipe, switch, and fee on a contemporary monetary community encodes a sample of human conduct. Transaction knowledge is without doubt one of the richest alerts an enterprise owns. But most manufacturing use circumstances for such tabular knowledge nonetheless rely on hand-engineered options and rule units which might be brittle, costly to keep up, and blind to the sequential construction inside a buyer historical past.
Basis fashions, pre-trained on giant volumes of unlabeled transaction sequences, change this equation by producing general-purpose representations of economic conduct that switch throughout a wide selection of downstream duties. A single spine covers fraud detection, credit score scoring, lifetime worth prediction, segmentation, customized suggestions, recurrent-transaction detection, and extra.
The business sign is robust and accelerating. Progressive monetary corporations are coaching transformer-based fashions on billions of transactions, reporting double-digit relative lifts on production-scale duties whereas concurrently streamlining operations. See Stripe’s funds basis mannequin, Nubank’s NuFormer, Visa’s TransactionGPT, Mastercard’s giant tabular mannequin, Revolut’s PRAGMA, Plaid’s transaction basis mannequin, and extra.
The NVIDIA Construct Your Personal Transaction Mannequin developer instance walks via construct a transaction basis mannequin end-to-end utilizing accelerated computing.
You’ll progress via 5 steps on this workflow:
GPU-accelerated knowledge processing with NVIDIA CUDA-X library cuDF
Customized tokenization with NVIDIA CUDA-X libraries cuDF and cuML
Transformer decoder mannequin pretraining from scratch with NVIDIA NeMo AutoModel open library, a part of NVIDIA NeMo framework
Extracting discovered embeddings
Augmenting a downstream fraud classifier with embeddings
By the tip, you’ll reproduce a near-50% elevate in Common Precision (“AP”)— the realm beneath the precision-recall curve—capturing how properly the mannequin ranks fraud throughout all working thresholds), over a robust XGBoost baseline on the IBM TabFormer fraud dataset. Determine 1, beneath, reveals the end-to-end pipeline.


Why transformers match transaction histories
Giant language fashions study from sequences of phrases. Throughout pretraining, a mannequin sees textual content and learns that phrases, phrases, and sentences carry that means via order and context. A transaction basis mannequin applies the identical precept to monetary conduct. A sequence resembling “paycheck deposit, grocery buy, transit fare, recurring subscription, card-present restaurant fee” carries info that no single transaction row can specific alone.
Transformers are properly suited to this construction as a result of self-attention can join occasions that sit far aside in historical past. A fraudulent transaction could solely look suspicious when paired with a current journey sample or a sudden burst of small authorizations. Conventional tabular options can approximate these patterns, however engineers should determine which home windows, aggregates, and guidelines to construct up entrance. A pretrained transformer learns these relationships instantly from the sequence.
This strategy enhances different NVIDIA monetary AI workflows, together with the NVIDIA AI Blueprint for monetary fraud detection utilizing graph neural networks (GNNs). GNNs seize relationships throughout related entities resembling accounts, retailers, gadgets, and transactions. Transaction basis fashions concentrate on behavioral histories inside a buyer or account sequence. In apply, each strategies produce wealthy embeddings with complementary info that pair naturally.
Load the information and set a baseline
Pocket book 01_dataset_baseline.ipynb masses the IBM TabFormer dataset, roughly 24.4M artificial card transactions with a ~0.12% fraud price, instantly into GPU reminiscence with cuDF.
The dataset splits are partitioned temporally by cumulative transaction depend: the primary 80% of transactions by date is used for coaching; the subsequent 10% turns into validation; and the ultimate 10% turns into take a look at. These splits subsequently occupy disjoint and ordered time home windows, stopping knowledge leakage and reflecting real-world manufacturing environments.
With the splits in place, the pocket book trains an XGBoost classifier using native GPU acceleration with tree_method=”hist” and machine=”cuda” on a 1M-row balanced coaching pattern. Analysis runs on a 100k stratified holdout that preserves the life like ~0.1% fraud prevalence.
The baseline numbers set the bar for the remainder of the tutorial:
Take a look at ROC-AUC: 0.9885
Take a look at AP: 0.1238
Take note of AP slightly than ROC-AUC. Below 0.1% class imbalance, ROC-AUC saturates shortly and hides significant variations in excessive scoring areas. AP measures throughout the total recall curve and responds to enhancements the place they matter operationally. Each subsequent mannequin on this tutorial is judged by AP first.
Tokenize transactions on the GPU
Basic-purpose LLM tokenizers waste capability on tabular monetary knowledge. For instance, a byte pair encoding (BPE) tokenizer splits a single transaction into roughly 39 subword tokens, the place most encode commas and greenback indicators slightly than conduct. Pocket book 02_seq_preproc_tokenization.ipynb introduces a customized area tokenizer that converts every transaction into roughly 12 semantic tokens with a a lot smaller vocabulary (6,251 symbols vs. 50,257 from BPE).
Along with token info density, this effectivity additionally permits greater than 3x the variety of transactions for a set token finances. Virtually talking, a mannequin with a context window of 4,092 can match a historical past of ~315 transactions from the area tokenizer and solely ~102 transactions from a BPE tokenizer.
Determine 2, beneath, compares token counts per transaction between the 2 tokenization strategies on the identical data.
The area tokenizer is applied in src/tokenizer/financial_pipeline.py. This versatile pipeline handles quantity binning, service provider hashing, hour-of-day and day-of-week, month, card id, chip kind, ZIP3 and state, and buyer id. Each step runs on the GPU via cuDF.
The tokenizer could be readily tailored to completely different transaction schema by including or changing particular person steps within the modular pipeline. Every step implements a small BaseTokenizer interface, so extending protection to new fields resembling machine ID or beneficiary nation takes only a quick subclass.


Pretrain with NeMo AutoModel
NeMo AutoModel is a Pytorch-native open-source coaching library beneath the NVIDIA NeMo Framework, designed to streamline and scale coaching and finetuning for LLMs and VLMs.
Pocket book 03_foundation_model_training.ipynb pretrains a decoder-only basis mannequin on the tokenized corpus utilizing causal language modeling. The target is easy — to foretell the subsequent token given each earlier token — however the supervision sign is dense. Each place in a sequence contributes a gradient, so a single packed transaction sequence yields 1000’s of next-event predictions.
The mannequin is a compact Llama decoder outlined in configs/pretrain_financial_decoder.yaml:
~29M parameters
Hidden dimension 512, 8 transformer layers
Grouped-Question Consideration with 8 question heads and a pair of KV heads
8,192-token RoPE context window
SwiGLU activation, RMSNorm, area vocabulary of 6,251 tokens
NeMo AutoModel handles the remainder of the stack. Kick off a single-GPU sanity run.
–config configs/pretrain_financial_decoder.yaml
–step_scheduler.max_steps 30
The 30-step demo drops coaching loss from ln(6251)≈8.74 (the random-guess baseline for this vocabulary) to round 6.0. To scale the identical run to eight GPUs, merely prefix the command with torchrun –nproc-per-node=8 —no adjustments to the script or distributed boilerplate required. Multi-node scaling is easy as properly. NeMo AutoModel wires up FSDP2 sharding, blended precision, gradient accumulation, and checkpoint consolidation from the YAML.
Checkpoints land as commonplace safetensors information, which implies the educated spine masses with a one-liner anyplace HuggingFace Transformers is put in:
mannequin = AutoModelForCausalLM.from_pretrained(“fashions/decoder-foundation-model”)
The repository ships a full checkpoint educated for 3,000 steps, which Notebooks 04 and 05 load; the 30-step take a look at is for demonstrative and validation functions.
To swap architectures, edit mannequin._target_ and mannequin.config._target_ within the YAML. Any HuggingFace-compatible decoder is designed to drop in with out training-code adjustments.
Pocket book 04_inference_embedding_extraction.ipynb turns the pretrained spine right into a characteristic extractor. It masses the checkpoint with AutoModelForCausalLM, requests output_hidden_states=True, and swimming pools the ultimate hidden layer right down to a 512-dim vector per person historical past.
For decoder-only fashions with causal consideration, solely the ultimate place has noticed the whole sequence whereas earlier positions are blind to later tokens. Final-token pooling subsequently picks probably the most informative location within the sequence. The implementation in src/decoder_inference.py makes use of the eye masks to search out the final non-pad token per row and gathers its hidden state.
The extraction loop is a single name:
padded_ids, batch_size=1024, show_progress=True
)
The pocket book extracts and saves practice, validation, and take a look at embeddings as .npy information. Moreover, a metadata.json describing shapes and row alignment is saved, which is later utilized in Pocket book 05 to affix embeddings again to the related uncooked tabular options.
Determine 3, beneath, reveals a 3D UMAP projection of 50k validation embeddings, coloured by service provider business class and zip code. Seen clusters in every area affirm that the spine has discovered semantically coherent representations with out ever seeing any goal labels throughout pretraining.


Determine 3. 3D UMAP projection of fifty,000 validation-set transaction embeddings. Factors coloured by service provider business and person zip code every present clear behavioral clusters within the discovered illustration house
Measure elevate on a downstream activity
Pocket book 05_xgboost_fraud_detection.ipynb solutions the billion greenback query: Can transaction basis mannequin embeddings transfer downstream metrics?
It trains three GPU XGBoost classifiers and evaluates all of them on the identical 100k stratified take a look at set:
Uncooked—13 hand-engineered tabular options (the baseline from Step 1)
Embeddings—512-dim foundation-model vectors compressed to 64d with PCA (~78% variance retained)
Mixed—uncooked options concatenated with the 64d embeddings, 77d whole
Desk 1, beneath, summarizes the take a look at outcomes.
The mixed mannequin lifts ROC-AUC by 0.41% and AP by 41.76% over the baseline. That AP delta is the operational win: a overview group with mounted each day capability catches materially extra fraud on the identical workload.
Embeddings encode the person’s transaction historical past and supply predictive energy, however underperform the baseline as lone options. The mixed mannequin leverages event-level info from the uncooked tabular row and sequence-level historic context from embeddings that had been discovered throughout pretraining. Determine 4, beneath, reveals the comparability visually.


Customise the developer instance
The repository is structured so that every part is swappable independently:
—Tokenizer: Adapt the pipeline in src/tokenizer/ to any transaction schema by including or changing steps. Every step is a small subclass of BaseTokenizer, so supporting new fields resembling machine fingerprint, beneficiary nation, and service provider nation is a brief addition.
—Mannequin structure: Edit mannequin._target_ and mannequin.config._target_ within the coaching YAML to level at any HuggingFace-compatible decoder. The remainder of the coaching pipeline utilizing NeMo (knowledge loader, FSDP2, checkpointing, analysis) stays put.
—Downstream activity: Substitute XGBoost with any mannequin that consumes fixed-length characteristic vectors. Churn prediction, buyer segmentation, lifetime worth regression, next-best-action rating, and credit score scoring all match the identical embedding-plus-head sample.
The developer instance is designed to increase to labels aside from fraud as properly, exhibiting foundational capabilities. Swap Is Fraud? in Step 5, above, for any occasion label that aligns with the person histories encoded by the spine.
Get began
You now have a reference path from uncooked transaction logs to a pretrained basis mannequin that augments a downstream classifier, accelerated end-to-end with NVIDIA. The three elements — a customized tokenizer, a transformer decoder spine, and an embedding-driven XGBoost head — collectively ship a near-50% AP elevate over a robust business commonplace baseline on the TabFormer fraud benchmark.
Go to construct.nvidia.com to deploy the pocket book in a GPU-accelerated surroundings by way of NVIDIA Launchable or your individual surroundings by way of GitHub repository.

