leeky.sh

Back

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.

Scanner open-source contracts on GitHub findings LLM validator DeepSeek V4 Pro, accepted 2,988 of 17,624 findings accepted Second AI check open 27B model, untrained passed Auditor reviews whatever gets through about 3 in 10 still invalid caught 11.5% of them

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.

20 154 Caught 20 of 174, 11.5% Missed, sent on to a human 154 of 174, 88.5%

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.

SplitFindingsValidInvalidWhat it's for
Train69970.0%30.0%The findings the model learns from
Validation13363.2%36.8%Never trained on. Checked after each training pass to pick the best one
Test57369.6%30.4%Never trained on. Scored once at the end. Every result below comes from it
All1,40569.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.

ValidInvalid
Train 699 findings Train: 489 valid of 699 Train: 210 invalid of 699 489 210 70.0% valid the model learns from these Validation 133 findings Validation: 84 valid of 133 Validation: 49 invalid of 133 84 49 63.2% valid picks the best training pass Test 573 findings Test: 399 valid of 573 Test: 174 invalid of 573 399 174 69.6% valid scored once, at the end

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.

Input finding + code Original model: locked 27 billion numbers. Training never changes them. LoRA add-on: trained 117 million numbers (0.43%). The only part that learns. + Output REAL or NOT_REAL

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.

Qwen3.8-27B + LoRA, 54.5 GBFree GPU memory
0 GB 45 GB 90 GB 135 GB 180 GB RTX PRO 6000 96 GB 54.5 GB 42 GB free B200 180 GB 54.5 GB 126 GB free

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 benchmarkDeepSeek V4 ProQwen3.8-27B
Parameters1.6T (49B active)27B
ReleasedApril 2026August 2026
GPQA (graduate-level science)90.189.2
Humanity's Last Exam37.730.8
LiveCodeBench93.590.3
SWE-bench Pro55.461.7
Terminal-Bench 2.172.173.0
CyberGym52.754.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:

  1. plan: GPU prices, stock, my balance and a cost estimate.
  2. up: start one pod and wait for SSH.
  3. push: copy the dataset and the training code over.
  4. run: install stable PyTorch, transformers and peft, download the model, score the untrained model, train three passes over the data and score each one.
  5. 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.

RunPodTogether.ai
You pay forGPU time, by the hourTokens trained, plus endpoint time to score
You writeThe training and scoring codeA JSONL file and a few settings
ModelsAnything that fits on the GPUTheir catalog. Training a model there doesn't mean they can serve it
LossWhatever you want. Mine was one answer tokenLoss on the assistant's reply
ScoringSame GPU and code before and afterA 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.

Rule
Answer REAL if the code lets the attack happen, even if it needs an admin account, a particular setup order, or an attack that loses the attacker money. Answer NOT_REAL if the code stops it.
Finding
Reentrancy in withdraw() drains the vault · High · contracts/Vault.sol:142
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.
Flagged file
contracts/Vault.sol, the whole file. Read on its own, the finding looks right: the ETH really does go out before the balance is cleared.
Minimal context
The code that decides it lives in a different file. withdraw() is marked nonReentrant, a guard defined in contracts/utils/Guard.sol. It works like a lock on a door. The first call to withdraw() locks it, and it only unlocks when that call finishes. When the malicious contract tries to call withdraw() again in the middle, the door is locked, and the whole transaction is cancelled. So the prompt adds just that guard, a few lines from Guard.sol, not the whole repository.
Answer
NOT_REAL The guard blocks the second call, so the attack can't happen. Without the minimal context the model would never see the guard, because the scanner didn't flag Guard.sol.

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.
SettingWhat I used
ModelQwen3.8-27B, answering straight away (thinking off)
What gets trainedOnly the LoRA add-on: 117 million numbers, 0.43% of the model
What it learns to sayOne word: REAL or NOT_REAL
Training passes3 passes over the 699 training findings
HardwareOne B200 GPU for 1.65 hours, $13.15
Longest promptAbout 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.

Invalid, rejected (caught) Invalid, passed (wasted review) Valid, passed (kept) Valid, rejected (lost)
Untrained Qwen3.8-27B 174 invalid findings 399 valid findings 20 of 174 invalid caught · 6 of 399 valid lost Same model + LoRA trained on 699 findings 174 invalid findings 399 valid findings 74 of 174 invalid caught · 36 of 399 valid lost
Invalid caught
11.5% → 42.5%
+31.0%
Valid kept
98.5% → 91.0%
−7.5%
Training cost
$13.15
1.65 h on one B200
Model weights
≈54 GB
16-bit, fits one GPU
573 test findingsUntrained 27B27B + LoRAChange
Invalid findings caught11.5%42.5%+31.0%
Valid findings kept98.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.

0%25%50%75%100%The claimed outcome doesn't follow · 48+27%6.3%33.3%The finding misreads the code · 44+25%18.2%43.2%Nothing harmful happens · 30+33%3.3%36.7%A guard blocks it · 26+38%26.9%65.4%The code can't be reached that way · 20+50%5.0%55.0%

Lessons learned#

  1. 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.
  2. 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%.