Skip to main content

Reliable, checkable structured output from a small local LLM, by wrapping it in a deterministic feedback loop: a regime gate + exact graph analysis + explicit refusal, plus a bounded re-extraction loop. Zero runtime dependencies; runs with no model at all.

Project description

llm-feedback-control

Reliable, checkable structured data out of a small, local language model — by wrapping it in deterministic feedback.

CI

What it does

Language models are fluent but they make things up — and they sound just as sure when they're wrong. That bites hardest when you ask one to pull structure out of text (the steps of a process, the fields of a form): it gets most of it right, then quietly invents or drops the rest.

This library turns free text into structured data you can trust. It pairs the model with a deterministic reference — real checking code suited to what you're extracting — and runs a feedback loop that:

  • verifies the model's answer against that reference,
  • fills in what the model missed by re-asking with the gaps pointed out,
  • refuses — says "I'm not sure" — when it can't verify the result, instead of guessing.

Because the checking (not the model's size) does the heavy lifting, a small model you run for free on a laptop becomes reliable enough to use. In our tests a 3.8B model wrapped this way matches one about seven times larger.

What you can extract

It's one engine pointed at different targets. A target is anything you can pair with a schema and a deterministic check — two ship today, more are a small addition (the loop is public and injectable):

  • workflows / processes → state machines (run_audit) — states, transitions, dead ends, unreachable steps, loops;
  • form fields (invoices, applications, claims) against a field schema (extract_form) — verifies each value against the source, recovers ones the model hallucinated, refuses on missing required fields;
  • records / tables, entities & relations, configs / specs — bring a schema + a reference and call feedback_loop.

It helps on the structured, verifiable slice — where a deterministic reference exists. For open-ended generation (summaries, sentiment) there's nothing to check against, so it refuses to claim exactness, by design.

Documentation

The full user manual is in docs/:

chapter contents
Getting started install, the API, the lfc CLI, choosing/bringing a model, configuration
How it works the op-amp model: negative/positive feedback, refusal-as-stabilizer, the general engine
API reference every public function
Results measured numbers, method, honest scope
Worked examples actual run transcripts
FAQ GPU? models? offline? why did it refuse?
Changelog release history

Install

pip install llm-feedback-control     # zero dependencies

Then follow Getting started. The deterministic parts run with no model at all; a model (local Ollama, OpenAI, or your own callable) is a pure upgrade.

License

MIT with an attribution clause — see LICENSE. Built with llm-feedback-control by Edward Chalk (sapientronic.ai).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_feedback_control-0.2.1.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_feedback_control-0.2.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file llm_feedback_control-0.2.1.tar.gz.

File metadata

  • Download URL: llm_feedback_control-0.2.1.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for llm_feedback_control-0.2.1.tar.gz
Algorithm Hash digest
SHA256 abed345a6b55c0b99203dc3bf760920f2f1a79b8dc32ae8f41f3f58dc18c774c
MD5 4821de5b6387fd88529f9f9209b9dafc
BLAKE2b-256 47e34134c93e7e33fe0cd558f525c5f7a3f8c7417a9733ba2087014c9bc6d346

See more details on using hashes here.

File details

Details for the file llm_feedback_control-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_feedback_control-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 701d19ae9b6f5598bdf204894a2154459f319a225282fdec9aa6f13653e9f567
MD5 471ab726b12127a33d86ccc39c1f3a71
BLAKE2b-256 47df102ba25d48015c1122de532a48563d57ac350f6d91356f9b9a03b56feb20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page