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
Get reliable, checkable structured data out of a small, local language model — by wrapping it in deterministic feedback.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_feedback_control-0.2.2.tar.gz.
File metadata
- Download URL: llm_feedback_control-0.2.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
151105f6ea46670e96b4b8d9cfc0ca5c756bff8bb9266b4d703cf1626d51083c
|
|
| MD5 |
8ff97d6fee4eedbb7002a7e673c94393
|
|
| BLAKE2b-256 |
231e9e0f18183d09ca2cd242c44cedd94db13326e7dc44fa7f577b87ec81a91e
|
File details
Details for the file llm_feedback_control-0.2.2-py3-none-any.whl.
File metadata
- Download URL: llm_feedback_control-0.2.2-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c92341c10a02195b85e998078b18d9f9116c6a6110504f1a11cd039c3bcf0d01
|
|
| MD5 |
c019e72e16b98e3eac3ec263e7df79d4
|
|
| BLAKE2b-256 |
c9efaaa75f5e1b046c8ce5bf3caa0529ad8df345a4577d455a882731eb8d98d1
|