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

Get 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.4.tar.gz (29.2 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.4-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_feedback_control-0.2.4.tar.gz
  • Upload date:
  • Size: 29.2 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.4.tar.gz
Algorithm Hash digest
SHA256 01fa8c8a032615e5041dfe658e7dc32baee6685a4438bb47df31df95970b4043
MD5 695bf94a83b4d9a6be9d8c1ad287aaf2
BLAKE2b-256 e09f2475eb49cca9328afb5163cb485fb508a9fe883d83f11f8bff107c417f28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llm_feedback_control-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0ef6f95fa51ea947c7d9814503535d8a89c40934c085585d05531923dab565ae
MD5 495b40bf2a06308ed07d8428a2f98123
BLAKE2b-256 e73f13de155c875ae6bb845e88f9fc4fc693e47c536f1e9969c7a20c07684504

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