cd /news/large-language-models/i-stopped-tweaking-prompts-here-s-ho… · home topics large-language-models article
[ARTICLE · art-27455] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=↑ positive

I Stopped Tweaking Prompts. Here's How I Cut LLM Hallucinations to 6%.

A developer built a pipeline using a Judge-Write loop with experience replay to reduce LLM hallucinations from 23% to 6% in automated technical documentation. The system decouples generation from evaluation with an independent Judge Agent and stores successful patterns in a vector database for reuse, cutting costs by 90%.

read2 min publishedJun 15, 2026

LLMs are great at writing code, but ask them to generate strictly formatted Markdown? That's a different story. We spent weeks optimizing our prompts to fix technical hallucinations and structural chaos, but hit a wall. Eventually, we stopped trying to solve it with words alone and built a pipeline using a Judge-Write loop with experience replay.

The result was immediate: content generation accuracy jumped from 77% to 94%.

While building an automated technical documentation system, our Writer Agent kept producing content with SQL syntax errors and logic gaps. It couldn't guarantee strict Markdown compliance, causing frequent crashes in the rendering layer.

The core challenge was maintaining strict data structure rigor without sacrificing speed (latency < 3s) or falling into infinite retry loops. If left unchecked, our online error rate would stay above 20%, triggering over 40 weekly alerts and destroying user trust.

1. Prompt Engineering Failed

Simply increasing prompt complexity (like Chain of Thought) didn't fix structural errors. LLMs still struggle with complex Markdown tables. Asking one model to be purely creative yet strictly rigorous is a losing battle.

2. No Immediate Feedback

The Writer Agent was a one-shot process. If it generated an error, it outputted it directly. There was no mechanism for self-correction or intermediate quality control—like taking an exam without a teacher to grade it.

3. Experience Wasn't Reusable

Every generation was independent. The system couldn't remember which patterns (like specific SQL syntax) were correct, leading to repeated errors. The agent kept falling into the same holes.

We decoupled generation from evaluation by introducing an independent Judge Agent for syntax validation and logic review. If the Writer can't be trusted, we gave it a strict quality control officer.

The Judge-Write Loop:

response = writer_agent.generate(prompt)
return response

max_retries = 3
for i in range(max_retries):
    draft = writer_agent.generate(prompt)
    feedback = judge_agent.evaluate(draft)
    if feedback.is_valid:
        return draft
    else:
        prompt = refine_prompt_with_feedback(prompt, feedback)
raise MaxRetriesExceededError()

Pattern-Based Experience Storage:

Instead of guessing blindly every time, the Writer now references "top student" homework. We extract high-quality code blocks approved by the Judge and store them as patterns in a Vector DB.

messages = [{'role': 'system', 'content': 'You are a writer...'}]

relevant_patterns = memory.search(query=current_topic)
system_prompt = f"You are a writer. Reference these successful patterns: {relevant_patterns}"
messages = [{'role': 'system', 'content': system_prompt}]
Decision Alternative Rationale
Independent Judge Agent Self-Correction (Self-Refine) The same model has "blind spots." An independent model offers a more objective view and allows us to fine-tune the Judge specifically for inspection tasks.
Pattern Storage Pure Fine-tuning Fine-tuning is costly and lags behind. Vector DB storage of high-frequency successful patterns enables "next-day" iteration, cutting costs by 90%.

Next time your LLM output is full of hallucinations, stop tweaking the prompt. Try giving it a strict Judge instead.

── more in #large-language-models 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-stopped-tweaking-p…] indexed:0 read:2min 2026-06-15 ·