k-LLMs adds consensus and field-level likelihoods to the OpenAI SDK.
Run K independent generations on the same prompt, align structured outputs, and reconcile every field into one parsed result with measurable uncertainty.
Built by retab
pip install k-llmsHow it works
Basic usage
k-LLMs keeps the OpenAI call shape and adds consensus with n. In Retab extraction APIs, the equivalent control is n_consensus.
Each candidate is parsed to your schema, then reconciled field-by-field. For arrays of objects, alignment runs first so equivalent items are compared even when order differs across model outputs.
Alignment uses stable-key discovery (or composite keys), fuzzy normalization for near-equivalent keys, multi-pass semantic matching for residuals, and preserves unmatched items as solo rows (zero-loss) before consensus scoring.
Why k-llms?
Make non-deterministic extraction operationally reliable
Single-run outputs hide ambiguity. k-LLMs makes disagreement explicit by returning likelihoods that mirror your schema.
You can route high-likelihood fields automatically and send ambiguous fields to validation or human review policies.
Background: this approach follows broader K-LLM patterns explored by teams like Palantir.