
The Model Finds the Defect. The Standard Decides What It Means.
A local YOLOv8 and offline LLM pipeline maps PCB defects to the right IPC standard and process cause, with a regex firewall between the bare-board and assembly domains and a recall floor I could not beat.
- Published
- July 6, 2026
- Author
- Hrushiekesh Reddy Kanjula
- Read time
- ~5 min
- Category
- engineering
The bare-board YOLOv8n baseline reaches mAP@50 of 0.991 on the direct PKU HRIPCB ingest, at 1.43 ms per image on an M5 Pro. The assembly baseline is weaker. It reached mAP@50 0.855, and tuning lifted it to 0.877. One class, poor_solder, stayed at 0.583 recall through every attempt.
The detector was never the hard part. A bounding box says where something is wrong. It does not say whether that is a problem, which standard governs the call, or which upstream process step broke. That is what pcb-defect-copilot adds.
The first time the app did this, I did not trust it. I uploaded a bare board with spurious copper crowding a fine-pitch pad. YOLOv8 drew its usual green rectangle. Next to it, a new column rendered three lines: IPC-A-600, spacing reduction, conductor spacing section. Class 2: accept if spacing holds above minimum. Class 3: reject regardless. Probable cause: under-etch, or a scratch on the phototool.
I have written that exact sentence in a real 8D report, for a real board, at a real company. Here, a local model produced it unprompted. It was grounded in a Markdown table I wrote, and it ran offline on my laptop.
The box is the easy part
Public repos already fork the HRIPCB dataset, add Ultralytics, and ship a Streamlit demo with boxes over missing holes and mouse bites. I studied two of them before writing my own code. They showed me where the real work starts.
IPC-A-600 and IPC-6012 govern bare-board acceptability: hole presence, conductor spacing, etch quality. They draw a hard Class 2 versus Class 3 line. The same physical defect gets a different verdict depending on who is buying the board.
IPC-A-610 is a different standard for a different domain. It covers solder joints and component placement after assembly, not the bare board underneath.
Inspectors know this distinction. Their failure mode is fatigue, not ignorance. Accuracy drops after an hour or two of looking at the same six defect classes under a scope. A vision model does not get tired. But it does not know IPC-A-600 from IPC-A-610 either, unless someone who has read both teaches it, row by row. Which class of board gets which verdict, and which process step to check first? That table is the part nobody forks.

The architecture
YOLOv8n trains locally on an M5 Pro over MPS. There is no cloud GPU and no API bill for the vision half.
The IPC mapping is static Markdown tables, one per domain. I wrote them from the actual standards, and they are checked into the repo as the single source of truth. At inference, a local Ollama model (gemma3:12b, fully offline) takes the detected classes plus the relevant table rows. It phrases them as a sentence a process engineer would say. There is no retrieval index and no vector store. The whole knowledge base is a page of Markdown small enough to paste into a prompt.
The regex firewall
I did not plan the firewall. Early in testing, the model cited IPC-A-610, the assembly standard, for a bare-board defect. Nothing stopped it from mixing the domains.
So the mapping layer now validates every LLM response against the class it was asked about. A bare-board row that mentions "IPC-A-610" anywhere is rejected. An assembly row that leaks "IPC-6012" is rejected the same way.
It is a few lines of regex, not a clever model. It is also the difference between a demo that sounds right and a tool I would trust to draft the first line of a nonconformance report. That validator and the rest of the test suite sat at 110 passing checks after Phase 2. They grew to 157 once the assembly domain landed in Phase 3.

The number that would not move
Phase 3 added assembly defects using the SolDef_AI dataset. It was messier than the bare-board work.
| Stage | mAP@50 | Notes |
|---|---|---|
| Bare-board baseline | 0.991 | Direct PKU HRIPCB ingest, 1.43 ms per image |
| First assembly baseline | 0.855 | |
| After augmentation tuning | 0.877 | spike recall +6.9 points, no_good +10.5, exc_solder +3.3 |
poor_solder did not move. Recall was 0.583 before the tuning pass and 0.583 after, whichever augmentation settings I tried. The class has exactly twelve instances in the validation set. No amount of hyperparameter search makes more data.
I tried once more with segmentation masks and class weighting. That is a genuinely different approach, not another augmentation sweep. It did not beat the number either.
The shipped model is the one from the tuning pass. The newer attempt is documented as a no-win. poor_solder stays flagged as a known limitation instead of being rounded up in a README. A twelve-instance floor is a data problem, not a modeling problem.

What carries over
The YOLOv8 weights are not the point. Training a model is table stakes. The point is the mapping from defect to IPC criteria to probable process cause. That came from four years on a PCBA floor, not from a paper. It now lives in a repo with a test suite that enforces its boundaries.
pcb-defect-copilot is the first of a small portfolio built on that idea: know which standard applies and why, then make a machine say it correctly, offline, on hardware I own. The pcb-defect-copilot project page has the architecture, the training ladder and the limits in one place.