Training LabFlight recorder · M2 Max

Your project, translated into plain English

You did not just train a model.
You ran a controlled investigation.

We began with a 1.7-billion-parameter language model, discovered the limits of generative classification, moved to BERT and then DeBERTa, and learned that model architecture, numerical precision, data quality and honest evaluation all matter.

Start from the beginning
Machine
M2 Max · 32 GB
Frameworks
MLX + PyTorch MPS
Models
Qwen → BERT → DeBERTa
Task
77 banking intents
LIVE CONCEPT TRACE REC 102
A
Human request

“The cash machine charged me an extra fee.”

B
Architecture decision

Qwen generation → encoder classification

C
DeBERTa classifier headcash_withdrawal_charge

All three models already understood language. We changed how they were adapted to the same 77-intent decision problem.

01 · First principles

What are we actually building?

A specialist classifier—not a chatbot, not RAG, and not a model trained from zero.

The job

Turn messy human language into one controlled label

INPUT

“My transfer is still waiting.”

OUTPUTpending_transfer

Qwen solved this by generating label tokens. BERT and DeBERTa solve it with 77 output scores called logits. The highest score becomes the predicted intent.

The curriculum

BANKING77

10,003 public training questions and 3,080 test questions across 77 banking intents.

The first student

Qwen3 1.7B

A generative language model adapted with LoRA. It taught us the full training lifecycle, but generation was not the best architecture for closed 77-way classification.

“1.7B” means roughly 1.7 billion learned parameters. BF16 stores each weight with 16 bits. Qwen generated text, so invalid label strings were possible.

What changed later

Classifier fine-tuning

BERT and DeBERTa use a dedicated 77-class head. We first trained the full encoder, then refined only selected upper layers.

A classifier head is a small final layer that converts the encoder's representation into 77 scores. Unlike generation, it can never produce a label outside those 77 positions.

02 · The architecture lesson

Three models. One task. Three different ways to learn.

Follow the lineage from a general-purpose generator to a purpose-built encoder classifier. The switch was an engineering decision, not an admission that the first model was useless.

ERA AQwen3 1.7B

Generative language model

questionlabel tokens
Training
LoRA adapters
Best result
51.10% test
Main lesson
Complete LLM workflow

Qwen predicts the next token repeatedly. We needed constrained decoding because a reasonable phrase could still be an invalid BANKING77 label.

Why switch?

A closed classification task does not need open-ended generation.

ERA BBERT-Large

Bidirectional text encoder

question77 logits
Training
Full fine-tuning
Best result
91.56% validation
Main lesson
Architecture fit

BERT reads the entire question in both directions and compresses it into a representation. A new classifier head maps that representation directly to 77 choices.

Why switch?

DeBERTa improves how content and token position are represented.

ERA C · CHAMPIONDeBERTa-v3-large

Stronger encoder classifier

question77 logits
Training
Full + upper-layer refinement
Champion
94.12% test
Latest
Exp015 rejected

DeBERTa separates token content from token position inside attention. We had to force float32 on MPS because lower-precision parameter updates became non-finite.

03 · Model workbench

Compare the checkpoints without mixing their meaning

Pick a model state. Always read whether its score came from validation or reporting-only test data.

Recorded accuracy
Macro F1
Every intent gets equal importance.
Invalid outputs

04 · Data discipline

Three piles. Three different jobs.

Most beginner ML mistakes come from letting information leak between these piles.

TRAIN9,233

The practice questions

The optimizer sees these examples and updates either LoRA adapters or selected encoder weights.

VALIDATE770

The progress check

Ten held-out examples per intent tell us whether training is learning or becoming unstable.

TEST3,080

The final exam

Never used to update weights. It was used for reporting on finalized champions and is now locked from future selection.

What is data leakage?

It is like seeing exam answers while studying, then changing your study plan because of them. We verified zero text overlap, pinned checksums, and require every current experiment to print test_rows_loaded: 0.

05 · The flight recorder

How we got here, decision by decision

Select a stage to see what we did, why it mattered, and what it taught us.

    06 · Inside one training step

    The same learning loop, with different moving weights

    1

    Encode

    Turn a banking question into token IDs and attach its correct class number.

    2

    Predict

    The model produces token probabilities or 77 class logits, depending on architecture.

    3

    Measure loss

    Cross-entropy measures how much probability the model failed to give the correct answer.

    4

    Update weights

    AdamW nudges adapters, the full encoder, or only unfrozen upper layers.

    LoRA microscope

    Frozen model, tiny moving parts

    Use the switch to compare the two adapter designs we tested.

    Trainable values
    917,504
    Share of model
    0.053%
    Adapter file
    3.68 MB

    07 · Failure lab

    The errors were part of the curriculum

    Open each incident. Learn to separate a code bug, a data problem, numerical instability, and an infrastructure limitation.

    08 · Reading the instruments

    Loss is not accuracy. Accuracy is not the whole story.

    L

    Training loss

    How surprising the correct output tokens were during training. Useful for stability and convergence—not a final product score.

    %

    Accuracy

    The fraction of test questions with the exact correct label. Easy to explain, but frequent classes can dominate.

    F1

    Macro F1

    Compute F1 separately for each intent, then average. Every one of the 77 intents gets equal weight.

    Ø

    Invalid rate

    Relevant to Qwen generation. Encoder classifier heads always choose one of their 77 output positions.

    Think before revealing

    A model’s loss falls, but test accuracy falls too. Did training “work”?

    09 · What Qwen taught us

    Constrained decoding puts guardrails on generation

    Allowed token paths

    start
    card_arrival · linking · swallowed…
    cash_withdrawal_charge · …
    pending_transfer · top_up · …

    At every generated token, we mask paths that cannot finish as one of the 77 labels.

    BEFOREget_virtual_cardMeaningful, but invalid
    AFTERgetting_virtual_cardCanonical taxonomy label

    The mask changes logits before greedy selection. It never looks at the expected answer. Our matched batch-size experiment exists because changing batch shape can introduce tiny floating-point differences, so a fair A/B comparison must hold batch size constant.

    10 · Current investigation

    When “hard examples” may actually be noisy labels

    Exp012–015 changed our question from “How can we push the model harder?” to “Should the model trust every training label equally?”

    EXP012Audit

    Five-fold out-of-fold predictions examined 9,233 training rows without reading validation or test data.

    1,186 disagreements
    EXP013 / 014Hard negatives

    We retained original labels and pushed against likely rival labels. Both experiments lost one validation answer.

    Hypothesis rejected
    EXP015 · REJECTEDNoise pruning

    Removed 1,078 confidently suspicious training rows and rewrote no labels. The stable run reached only 90.78% validation.

    17 fewer correct than Exp011
    REMOVE

    The OOF model disagrees and gives the supplied label less than 25% probability.

    DO NOT RELABEL

    A prediction is evidence of suspicion, not proof of the correct replacement label.

    DO NOT TOUCH TEST

    All preparation and probing report zero validation/test rows loaded.

    Out-of-fold means each training example is scored by a model that did not train on that example. This reduces self-confirmation, but it does not make the predictions ground truth. Exp015 proved that our threshold removed useful training signal along with suspected noise.

    11 · Interview room

    Explain the project like you own it

    Say your answer aloud, then reveal the model answer. The phrasing is based on what we actually did.

    Tap reveal only after answering

    12 · Knowledge check

    Can you now reason about the lab?

    This is not trivia. Each question tests a decision you will face in another training project.

    13 · Pocket glossary

    Terms you should be comfortable saying

    Current lab checkpoint

    103

    Exp015 is closed

    The noise-pruned child reached 0.907792 validation accuracy versus Exp011's 0.929870. We reject the child, preserve Exp011, and do not open the locked test for a model that already lost on validation.

    champion = exp-011 · next hypothesis not yet selected

    Scientific decision: a stable training run is not automatically a successful model. Exp015 completed correctly and still failed its promotion rule.