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, 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 --max-workers 1 \
  --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.1

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.1
File Size Uploaded
rulesmith-0.1.1.tar.gz 595.7 kB Details

Built distribution (wheel)

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

Total release size: 731.3 kB

Release files / rulesmith-0.1.1.tar.gz

Download URL rulesmith-0.1.1.tar.gz
Size 595.7 kB
Tags Source
SHA-256 checksum
How to use checksums
979c290bb70f7877bdfc3b401e37f43605af036c677a15a03c7455f37a2e1cb4
BLAKE2b-256 checksum
How to use checksums
7eb96f15e532389d88706da50c9341bf85a4050c6f5c827b6b9b88d9b75b2cfb
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.1-py3-none-any.whl

Download URL rulesmith-0.1.1-py3-none-any.whl
Size 135.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0381acfd6bde97621864a50b4c2eded69b345e10b23afba66515a979228f2943
BLAKE2b-256 checksum
How to use checksums
5fd5f561b6ea3e082130cd001833813bd5ec9035fd3d1dc22870d66f21744bb0
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

0.1.2

2 release files

This release

0.1.1 This release

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