[technology] [rulechef]
RuleChef
Rule synthesis for AI systems with hard constraints, where enforcement has to run locally and remain inspectable.
What it does
RuleChef turns labelled examples into rules a team can read, edit, version, and run.
It uses an LLM at synthesis time to propose regex patterns, Python predicates, or spaCy patterns from examples. Once the rules are written, the language model is removed from the inference path.
That matters in domains where the constraint is not a preference but a rule: a disclosure must appear, a clause must be present, a medical guideline must be followed, or an eligibility decision must be explainable.
The important artefact is the ruleset. It can be reviewed like code, tested against labelled cases, and logged when it fires.
- formats
- 3
- rule formats: regex, Python predicates, and spaCy patterns
- tasks
- 4
- task families: extraction, NER, classification, and transformation
- inference
- 0 LLM
- language model calls after the ruleset has been synthesised
- licence
- Apache-2.0
- repository licence for the public RuleChef package
How it works
RuleChef separates synthesis from enforcement: the model helps write the rule, but the rule makes the decision.
At synthesis time, examples and a task type produce a ruleset. At inference time, the same ruleset runs locally and returns decisions with rule ids.
Labelled examples
exampleInvoice INV-2026-104 is due on 2026-06-01.
labelclassification: invoice
LLM-assisted rule writing
- input
examples+task_type+rule_type- artefact
- regex, Python predicate, or spaCy pattern
- handoff
- ruleset is stored, reviewed, and versioned
Decision plus audit log
The local ruleset runs on the input, returns the matched span, and records the rule id that fired. No LLM call is needed at inference time.
- ruleset
- Inspectable rule artefact produced during synthesis.
- match
- Label, span, confidence, and rule id for each hit.
- audit_log
- Record of which rules fired and which inputs triggered them.
RuleChef is useful when a probabilistic answer still has to satisfy deterministic constraints. The LLM helps create candidate rules from examples, but the deployment surface is the ruleset: a local artefact that can be tested, reviewed, edited, and logged like normal software.
Where it fits
RuleChef belongs at the point where the system has to decide whether an output satisfies a written rule.
- Financial compliance disclosures
Validate that an answer about a regulated product carries the disclosures the product requires.
- Medical guidelines rules
Check that a suggested treatment follows the guideline that governs it.
- Contract review clauses
Verify that a draft includes the clauses the policy demands, in the form the policy demands.
- Eligibility logic decisions
Apply benefit rules to a generated case summary and record where a rule conflicts with the draft.
These are enforcement cases, not generation cases. The answer or draft may still come from an LLM, but the final rule check should be readable and repeatable.
For developers
Use RuleChef when you have labelled examples and want the deployment artefact to be a ruleset, not another prompt.
Inspect the moving parts
The package, docs, examples, and licence are public so teams can review the rule boundary before putting it into a workflow.
- GitHub Package source, examples, tests, docs, and licence.
- README Install path, supported rule types, task examples, and API shape.
- PyPI: rulechef Published Python package for rule synthesis and local rule execution.
- Examples Classification, extraction, NER, and transformation examples.
- Licence Apache-2.0 licence text for the public repository.
- Issues Public issue tracker for bugs, integration notes, and feature requests.
Start with synthesis, then run locally
The LLM call belongs to the synthesis step. The inference step runs the produced ruleset against new inputs.
Install
Add the package where rules are synthesised, evaluated, or served.
pip install rulechef Synthesise
Use labelled examples to produce a task-specific ruleset that can be reviewed before deployment.
from openai import OpenAI
from rulechef import RuleChef, Task, TaskType
client = OpenAI()
task = Task(
name="Intent Classification",
description="Classify banking customer queries",
input_schema={"text": "str"},
output_schema={"label": "str"},
type=TaskType.CLASSIFICATION,
text_field="text",
)
chef = RuleChef(task, client)
chef.add_example({"text": "what is the exchange rate?"}, {"label": "exchange_rate"})
chef.add_example({"text": "I want to know the rates"}, {"label": "exchange_rate"})
chef.add_example({"text": "my card hasn't arrived"}, {"label": "card_arrival"})
chef.learn_rules() Run
Execute the learned rules locally, then evaluate which rules are helping or hurting the task.
result = chef.extract({"text": "current exchange rate please"})
print(result)
evaluation = chef.evaluate()
print(evaluation)
metrics = chef.get_rule_metrics()
print(metrics) Software reference
@software{krlabs_rulechef,
title = {RuleChef},
author = {{KR Labs}},
url = {https://github.com/KRLabsOrg/rulechef},
year = {2026}
} Compatibility and licensing
The public package keeps the rule artefact separate from the LLM that helped produce it.
- code
github.com/KRLabsOrg/rulechef, Apache-2.0 licence.- formats
- Regex patterns, Python predicates, and spaCy patterns.
- tasks
- Extraction, named-entity recognition, classification, transformation, and similar rule-based NLP tasks.
- runtime
- LLM at synthesis time, local Python rule execution at inference time.
Combine with the rest of the stack
Each product can run on its own. Together, they turn an LLM answer into something a team can inspect, reject, or enforce.
RuleChef is the enforcement layer: it decides whether an output satisfies a written constraint. Pair it with an evidence extraction layer to ground the answer, and a support-check layer to flag unsupported spans before rules are applied. The result is not just a generated answer, but a record of source evidence, support status, and which rules fired.
Let the rule make the final call
Start with the docs, or inspect the repository for rule formats, examples, tests, and the Apache-2.0 licence.