Training AI models to detect false positives using LoRA.
Training AI models to detect false positives using LoRA. Increasing false positive detection from 11.5% to 42.5%.
Noise > Signal#
Here's our scenario: We run a web3 security scanner. It reads open-source smart contracts on GitHub, mostly from projects with bug bounties on Immunefi ↗, and documents every vulnerability it finds.
The problem, as many have found this year, is the signal to noise ratio is terrible. There are way too many false positives. So we add a validation workflow, using DeepSeek to catch them.
Out of 17,624 findings, the validation workflow marks 2,988 as true positives.
Unfortunately, about 30% of these 2,988 are actually false positives.
So roughly 3 in 10 of the vulnerabilities sent to a human are false positives.
That's a lot of wasted time.
The Fix#
There's always better tooling, better prompts, better workflows.
Everyone's doing that. The entire industry is focused on that.
Better models? Supposedly that's only for the big boys with billions in compute to spend.
But, I have heard someone mention the word 'lora' before, so I do a quick Google search:
LoRA (Low-Rank Adaptation) is a parameter-efficient fine-tuning technique that customizes large AI models without retraining their entire core architecture.
Sweet. So I'll give this LoRA thing a shot.
I choose Qwen3.8-27B. It's lightweight, all the rage, and runs on MacBooks.
So I replace DeepSeek with Qwen3.8-27B...
Out of the box, it catches 20/174 invalid findings. 11.5%.
Even worse, it's calling 96% of findings valid, when only 70% of them are.
This is basically a rubber stamp.
Figure 1
Where the noise goes
The validator thins the pile, but about 3 in 10 of the reports it accepts are still invalid. An untrained open model as a second check caught 11.5% of those. The rest reached an auditor.
Figure 2
Out of the box, it caught 11.5% of the invalid findings
Our test set has 174 invalid findings. The untrained open model caught 20 of them. The other 154 went on to a human to rule out.
One man's trash is a LoRA's dataset#
We had all this data on false positives.
Could we use it to make an AI better at spotting them?
After dropping the ones whose source code I couldn't recover, I trim our 17,624 findings to 1,405. Every one is labeled valid or invalid under one written rule.
A finding is valid when the code allows the reported vulnerability to happen, even if the attack needs a privileged role, a specific deployment order, or money the attacker won't get back.
A finding is invalid when the code stops it: a guard blocks it, the code can't be reached that way, the claimed outcome doesn't follow, the report misreads the code, or nothing harmful happens.
I kept only Medium, High and Critical findings, because those are the ones that matter.
| Split | Findings | Valid | Invalid | What it's for |
|---|---|---|---|---|
| Train | 699 | 70.0% | 30.0% | The findings the model learns from |
| Validation | 133 | 63.2% | 36.8% | Never trained on. Checked after each training pass to pick the best one |
| Test | 573 | 69.6% | 30.4% | Never trained on. Scored once at the end. Every result below comes from it |
| All | 1,405 | 69.2% | 30.8% |
Figure 3
1,405 findings, split by codebase
Bar length is the number of findings. Every split is about 7 in 10 valid. No codebase group appears in two splits.
The experiment: teaching a model to spot false positives#
The plan was to take the open model that had caught only 11.5%, train it on the 699 training findings, and score it again on the 573 test findings it had never seen.
How a LoRA works#
A model like Qwen3.8-27B is 27 billion numbers. Fine-tuning the whole thing means changing all of them and saving a new copy of the model. A LoRA (low-rank adaptation) leaves those numbers alone. It adds a small set of new numbers next to them and trains only those.
Figure 4
A LoRA is a small add-on next to a locked model
The original model's numbers stay locked. A small add-on sits next to them, and it's the only part that learns. Every time the model runs, the add-on's output is added to the original's and nudges the answer. This happens inside every layer of the model.
Think of the model as a huge textbook that's already printed. Fine-tuning reprints the whole book. A LoRA is a pack of sticky notes instead. The book stays exactly as it was, all 54 GB of it. The sticky notes hold 117 million numbers, less than half a percent of the book, and fit in a 467 MB file.
To use it, you open the book and put the notes on top. You can keep a different pack of notes for each job.
Figure 5
Why one GPU is enough
A GPU can only run a model that fits in its memory. Qwen3.8-27B plus its LoRA takes 54.5 GB. That fits on an RTX PRO 6000 (96 GB) with about 42 GB to spare, and on a B200 (180 GB) with about 126 GB to spare. Training uses the spare memory for its working data.
Why Qwen3.8-27B#
I needed a model that met three conditions. Qwen3.8-27B meets all three.
- Open source. You need the weights to train a LoRA at all.
- Runs on a MacBook. At 8-bit, Qwen3.8-27B takes about 27 GB and fits in a 48 GB MacBook. DeepSeek V4 Pro has 1.6 trillion parameters and needs a multi-GPU server just to load.
- Cheap to train. Qwen3.8-27B trains on one GPU for $13. DeepSeek would cost an estimated $130-$260 on an 8-GPU server.
And on public benchmarks, Qwen3.8-27B scores close to DeepSeek V4 Pro.
| Public benchmark | DeepSeek V4 Pro | Qwen3.8-27B |
|---|---|---|
| Parameters | 1.6T (49B active) | 27B |
| Released | April 2026 | August 2026 |
| GPQA (graduate-level science) | 90.1 | 89.2 |
| Humanity's Last Exam | 37.7 | 30.8 |
| LiveCodeBench | 93.5 | 90.3 |
| SWE-bench Pro | 55.4 | 61.7 |
| Terminal-Bench 2.1 | 72.1 | 73.0 |
| CyberGym | 52.7 | 54.5 |
Training it on RunPod and on Together.ai#
I used both. They solve different problems.
RunPod ↗#
RunPod rents you a GPU by the hour, and you bring your own code. I drove it with a small controller, five commands per run:
- plan: GPU prices, stock, my balance and a cost estimate.
- up: start one pod and wait for SSH.
- push: copy the dataset and the training code over.
- run: install stable PyTorch, transformers and peft, download the model, score the untrained model, train three passes over the data and score each one.
- watch: pull results every few minutes and shut the pod down when the job ends.
The final run used one B200 (180 GB, $8/hour). Training took 1.65 hours and cost $13.15. The whole pod cost $23.61 for 2.96 hours, which includes setup, the model download, both scorings, and 42 minutes billed after the job finished because my watcher stalled on an SSH call.
A 96 GB RTX PRO 6000 at $2.49/hour also fits the 27B.
Cheaper is not better. It trains about 2.7x slower, so the same run would take 4.5 hours and cost $11. Nobody has time for that.
Together.ai ↗#
Together runs the fine-tuning for you. You upload a JSONL file of chats (the system prompt, the finding as the user message, REAL or NOT_REAL as the reply), start a LoRA job with your settings, deploy the adapter to an endpoint, and score through it.
I used it for one round and hit four snags:
- It could train Qwen3.8-27B but had no hardware to serve it, so I trained the older Qwen3.5-27B instead.
- The 27B job billed $12.33 against a $9.85 quote, because it counted 5.87M tokens per pass instead of the 4.7M estimated.
- Packing about two examples into each 32K sequence is what kept it inside my budget. Without packing, every row is billed at the full length.
- Together retired its endpoint API in the middle of the project, so I moved to its new CLI.
That adapter gained nothing measurable. It doesn't say much about Together: the base was weaker, only 357 of the 699 training findings had their context built, and the job made 46 updates.
| RunPod | Together.ai | |
|---|---|---|
| You pay for | GPU time, by the hour | Tokens trained, plus endpoint time to score |
| You write | The training and scoring code | A JSONL file and a few settings |
| Models | Anything that fits on the GPU | Their catalog. Training a model there doesn't mean they can serve it |
| Loss | Whatever you want. Mine was one answer token | Loss on the assistant's reply |
| Scoring | Same GPU and code before and after | A dedicated endpoint per adapter |
| My 27B run | $13.15 training, $23.61 whole pod | $12.33 training, about $20 for the round |
If the model you want can be trained and served on Together, it's the faster start.
If you need a specific model, a custom loss, or before-and-after scores from identical hardware, use RunPod. Everything below came from RunPod.
What it trained on#
Each example is one prompt and one answer token.
The prompt holds the rule for valid and invalid, the finding as the scanner wrote it, the flagged file, and, where needed, the minimal context from outside that file to decide whether it's valid.
Only 25% of the vulnerabilities were contained in a single file. It's often the case that additional context outside of the flagged file is needed to make a proper judgement.
Figure 6
One training example
What the model reads for one finding, and the one-word answer it learns to give.
withdraw() sends ETH to the caller before it sets their balance to zero. If the caller is a malicious contract, it can call withdraw() again the moment the ETH arrives, while its balance is still there, and take the same money twice.
How each split was used in the run:
- Train: 699 findings, 489 valid and 210 invalid. With more than twice as many valid examples, the model could get away with answering "valid" most of the time. So during training I showed it each invalid finding two or three times, until it saw 489 of each: an even 50/50 split.
- Validation: Checked after each full pass through the training findings. It picked the third pass.
- Test: Scored twice, once without the adapter and once with it. Same prompts, GPU and code.
| Setting | What I used |
|---|---|
| Model | Qwen3.8-27B, answering straight away (thinking off) |
| What gets trained | Only the LoRA add-on: 117 million numbers, 0.43% of the model |
| What it learns to say | One word: REAL or NOT_REAL |
| Training passes | 3 passes over the 699 training findings |
| Hardware | One B200 GPU for 1.65 hours, $13.15 |
| Longest prompt | About 57,000 characters of finding and code |
Results: $13 and 699 findings#
With $13 of training and 699 findings, the same model caught 74 of the 174 invalid findings instead of 20.
Figure 7
The same 573 findings, before and after a $13 LoRA
Each square is one held-out finding: filled means it was passed on to an auditor, hollow means the model rejected it. Positions match across both grids, so the squares that flip are the LoRA's doing.
| 573 test findings | Untrained 27B | 27B + LoRA | Change |
|---|---|---|---|
| Invalid findings caught | 11.5% | 42.5% | +31.0% |
| Valid findings kept | 98.5% | 91.0% | -7.5% |
| Findings called valid (69.6% are) | 95.5% | 80.8% | -14.7% |
Figure 8
Invalid findings caught, by why they're invalid
Gray is the untrained model, green the same model with the LoRA. The count after each reason is how many findings carry it.
Lessons learned#
- The base model decides whether a LoRA helps. The same recipe on Qwen3.5-9B gained nothing measurable: it caught 36.8% of invalid findings before training and 36.2% after.
- One training pass was enough. After one pass it already caught 40.8% of invalid findings and kept 92.0% of valid ones, close to the final 42.5% and 91.0%.