Skip to main content

rulesmith

rulesmith: rules that ask a local model for typed decisions

rulesmith lets DSPy build decision graphs for you. Give it a classification task and labeled examples. It searches for a small program of rules: cheap tests on the input's fields settle the cases they can, and a local or hosted judge is asked typed questions about the rest. GEPA keeps the revisions that score better, and the result is a rules file you can read, edit, run, and serve.

read has_company_logo in [0, 1]
read length of company_profile in [0, 10000]
when has_company_logo == 0 and length of company_profile == 0: fraudulent
always: ask "Is this job posting a scam?" [fraudulent: "fraudulent"] [genuine: "genuine"]

Same 4B judge, same 100 examples: rulesmith beat DSPy's tuned classifier by 6.7 points on job-fraud detection with 29% of the model calls, and tied it on clothing reviews with 6%

The benchmarks have every dataset, including where rulesmith does not help: on one-sentence inputs it ties DSPy, and on job postings a TF-IDF classifier still beats it.

An independent research prototype, not affiliated with TypeSafe.

Installation

pip install rulesmith

Python 3.12 to 3.14. Extras for the games and benchmarks are listed in the quickstart.

Quickstart

With a judge running (Ruling on a Mac or through vLLM, Cloudflare's Clef-flash on an NVIDIA GPU or a Mac, TypeSafe's hosted Jev, or any OpenAI-compatible chat API that returns log-probabilities), any OpenAI-compatible model to write the rules, and a labeled task such as this one:

export OPENAI_API_KEY=local-no-auth   # a local model server takes any key
rulesmith optimize task.json --backend ruling \
  --reflection-model "openai/<model>" --reflection-base-url http://127.0.0.1:8080/v1 \
  --output runs/my-task
rulesmith run runs/my-task/plan.rules input.json --backend ruling

The quickstart walks through it with every command's output.

Beyond classification

The same search plays games. Pitted against a league of other graphs, this one learned to hunt in Doom deathmatch and beat the champion 12-0, with no model calls at all (how):

A searched rules graph hunting down the Doom champion it dethroned

Learn more

  • Quickstart: installation, judges, and a task to a running graph.
  • Notebook: rules for spotting fake job postings, end to end in Colab with an OpenAI key.
  • Local notebook: the same with Clef-flash judging on your Mac or NVIDIA GPU, free per call.
  • Tasks: the task file, drafting labels, structured inputs, costs, and graders.
  • Rules: the language search writes, confidence, calibration, escalation, and extraction.
  • Graph format: the JSON behind each node, execution, and drawing a graph.
  • Maps: many decisions as one map, searched a unit at a time.
  • Optimization: how search runs, its settings, and its limits.
  • Command line: every command, including serve and drift, and the backends.
  • Python: running and building graphs from code.
  • Benchmarks: rulesmith against DSPy, TF-IDF and direct calls on five public datasets.
  • Related work: when to use rulesmith and when DSPy, and what came before.
  • Doom and Chess: graphs that play.
  • Claude Code skill: copy skills/rulesmith into ~/.claude/skills/.

Development

uv sync --locked
uv run pytest -q

License

MIT.

Metadata

Release files for rulesmith 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rulesmith 0.1.2
File Size Uploaded
rulesmith-0.1.2.tar.gz 602.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rulesmith 0.1.2
File Interpreter ABI Platform
rulesmith-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 740.9 kB

Release files / rulesmith-0.1.2.tar.gz

Download URL rulesmith-0.1.2.tar.gz
Size 602.0 kB
Tags Source
SHA-256 checksum
How to use checksums
717abccc11df300e2f01a145823b006366e366dcc9781e44ab30d488207f6646
BLAKE2b-256 checksum
How to use checksums
6d376bdb43c04de150366bb27a19a9fc0501263ed77c403809e1d43fedac3aaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / rulesmith-0.1.2-py3-none-any.whl

Download URL rulesmith-0.1.2-py3-none-any.whl
Size 138.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45a0e6ca1ba6eb95913adb8a34ee8f608d71c96b124c7e26b06c394b80420058
BLAKE2b-256 checksum
How to use checksums
12512094640ffaed65b43387cab449a9f8423385f8bbec18dbbb097baadd7274
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page