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.3.tar.gz (26.8 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.3-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_feedback_control-0.2.3.tar.gz
  • Upload date:
  • Size: 26.8 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.3.tar.gz
Algorithm Hash digest
SHA256 b6b977d26c7e569a5708279454d0558537766b35348f520775027d6bd623aa4b
MD5 58d2fc0652c346fa30961a48b6c57a83
BLAKE2b-256 319a9e5b7cfb9bf0f1a3c0a1e8d0b57de3f13428c63044d448c673287ca369e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llm_feedback_control-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a228a059ec80c1ea4e4dc42fe89ff5a06a1e5f69cb447a473d6bec5fd527c917
MD5 71f517b890e6fae128867a9221eba147
BLAKE2b-256 0bb1dc322f5e08db385910b0a7de72f90c53115ced31bd3adc79f345eea73ad7

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