Repository navigation
Releases
0.5.1
- Exports no longer contain a
__pycache__folder. The check that compares an export withload()used to leave Python's bytecode cache next to the runtime. - Price quotes count prompt caching.
label(dry_run=True)andcheck_teachers(dry_run=True), for classifiers and panels, now price a long system prompt on Anthropic models as a cached read after the first call, which is what those calls are billed. An optimized prompt was quoted several times over before.estimate_calls()takescached_prompt=Truefor the same. Spending caps (budget_usd=,autotune()) keep the full price, since the first calls of a run can miss the cache.
Backward compatible: nothing existing changed apart from the dry-run quotes, which are now closer to what's billed.
0.5.0
- Run a model without shrewd.
shrewd.export(dir, out_dir)writes the shipped model into a folder you can copy into any project, checked againstload()before it returns.- tf-idf and embedding models (classifiers and panels) come with a small runtime:
shrewd_model.pyneeds only numpy, andshrewd_model.jsneeds nothing (Node, Deno, Bun or a browser). The calls matchload()'s:predict,predict_probaanddecide.precision="float16"stores an embedding model at about half size. - Encoder and SetFit classifiers export as ONNX with the
tokenizer.jsonthey expect (format="onnx",pip install "shrewd[onnx]"). Encoders also export as a Hugging Face folder (format="hf"). - A routing threshold travels as metadata, and
confident(texts)says which texts clear it. The teacher fallback stays in shrewd. - Not yet: panels built on an encoder, and panels with a zero-shot stack.
- tf-idf and embedding models (classifiers and panels) come with a small runtime:
- Serving notes in the README: load once, pass batches, and a minimal FastAPI endpoint.
Backward compatible: nothing existing changed. export and the [onnx] extra are new.
0.4.0
- Several teachers, weighted by how well they match you. Give
Decisionsa list of teachers and each answers every document, your dev split included; their answers are combined per question by how often each matched your labels. Classifiers get the same withlabel(pool, combine="weighted"). For panels,judge(pool, escalate=0.05)asks the first teacher everywhere and the others only where it might be overruled. - Check the teachers first.
check_teachers()has each teacher answer only your dev split, so you see how each one matches you before paying for the pool. - Routing for classifiers.
distill(route_budget=0.02)sets a confidence threshold with the same guarantee panels already had, andload(dir).predict(texts, fallback=proj.ask)sends the rest to the teacher.shrewd.route.curve()andrebudget()change the limit later without retraining. - Review and editing in code.
review()andunreview()record or take back your answers without editingneeds_review.csv.add_examples(),fix_example()andremove_examples()change your examples without re-splitting. Labels and questions can be changed, merged or removed in place. - Smaller things.
prune(dir)strips a shipped project down to whatload()needs.checkpoint_dir=lets an encoder fine-tune resume after an interruption.Decisions.compare()ranks featurizations on dev. A score answer keyed by its level name ("low") is now read instead of dropped. model2vec is pinned below 0.10, which can't load the pre-built embed panels.
Backward compatible: existing calls, defaults, saved models and answers are unchanged, and models saved by 0.4.0 load in 0.3.1.
0.3.1
- Quickstart notebook.
examples/quickstart.ipynbruns the whole workflow on the SMS demo data in a couple of minutes, with no API key: it uses the teacher's cached answers. Open it in Colab. - Clearer report. The routing section wraps to the terminal width, and the last column of the question table names its metric (
acc,AUROCorMAE) instead of being headedaccfor all of them. - README. A new opening, and the four prebuilt panels are now presented as demos, with the guardrail and email panels' known gaps written up.
- Package metadata. The PyPI summary matches the new tagline, and PyPI now lists the supported Python versions (3.11–3.14).
No changes to answers, saved models or the API: everything behaves as in 0.3.0.
0.3.0
distill(route_budget=0.02)picks the confidence threshold for you, with a guarantee: with 95% probability, at most 2% of requests are answered locally and disagree with the teacher. The threshold is set on 30% of the judged pool held out of training, so it's checked on the model you actually save.decide(texts, fallback=d.ask)sends the documents below the threshold to the teacher and returns the same answer format.route=Trueleaves them asNoneinstead, and.local(texts)tells you which documents clear it.- The report now checks the locally answered test documents against your human labels.
examples/panels/routing_study.pyreproduces the results on the four pre-built panels from the committed teacher answers. Reading the threshold off the curve broke the 2% budget in 4-7 of 10 draws; the guaranteed threshold held about as often as a 95% bound promises. Details in BENCHMARKS.
Everything is opt-in. Existing code and saved models behave exactly as in 0.2.0, and models saved by 0.3.0 still load in 0.2.0.
0.2.0
distill(calibration="auto-full")adds vector and matrix scaling to the calibration search for multi-option questions. On the pre-built panels it fit the teacher better on all six multi-option questions and moved them closer to gold where gold could be derived. It can change the predicted option (1-10% of documents there) and makes the top option's stated confidence less calibrated on some questions, so it's opt-in."auto"is unchanged. Details in BENCHMARKS.md.- Reports split Brier into reliability, resolution and uncertainty, with a
resolcolumn and a warning when a multi-option head barely moves from the base rates. - Clearer load errors: a calibrator this version doesn't recognize now says which shrewd version saved it.
- New examples:
examples/panels/consistency.py,calibration_study.py,description_prior.py, plusbuild.py --calibration.fetch.pynow says it needshuggingface_hubandpyarrow.
Panels saved with calibration="auto-full" need shrewd ≥ 0.2.0 to load.
Example decision panels, v1
Four compiled decision panels built by examples/panels/. They're examples of what shrewd's calibrated-decisions path produces, not models to adopt as is. The teacher was Fable 5.1, and each panel was scored on a separate holdout that played no part in training. Numbers and data sources are in the README under "Try a pre-built panel".
from shrewd import load
pii = load("https://github.com/sshah03/shrewd/releases/download/panels-v1/panel-pii.tar.gz")
pii.decide("my password is hunter2 and the PIN is 4471")| panel | decides | student | size |
|---|---|---|---|
| messages | SMS spam/scam triage | fine-tuned encoder | ~555 MB |
| spam/phishing triage | tf-idf | ~26 MB | |
| guardrail | harmful / jailbreak / injection | static embeddings | ~28 MB |
| pii | contact / identity / financial / credentials / device | fine-tuned encoder | ~555 MB |
The guardrail panel's training data includes lmsys/toxic-chat, which is CC BY-NC 4.0, so that panel is for non-commercial use only.
Every panel can be rebuilt with no API calls from the committed teacher answers: python examples/panels/build.py <panel> --from-judged.