Skip to content

feat(fine_tuning): fine-tune a decision model on 100 rows and serve it with SIE; move to SIE v0.11.1 - #35

Merged
rparundekar merged 5 commits into
mainfrom
recipe/fine-tune-decision-models
Nov 14, 2026
Merged

rparundekar merged 5 commits into
mainfrom
recipe/fine-tune-decision-models

Conversation

@rparundekar

Copy link
Copy Markdown
Collaborator

What

New recipe: fine_tuning/fine_tune_a_decision_model. It fine-tunes GLiClass edge v3.0 on about 100 labelled rows on your own machine and compares it with the zero-shot model:

  • Banking77 (public): 67.3% → 93.3%
  • Synthetic parsed-document quality checks (private): 30.0% → 86.7%

Training takes about 5 s per dataset on a laptop. The recipe isn't an agent, so it gets a new fine_tuning/ folder and its own section in the root README.

Serving your own weights with SIE. sie_models/*.yaml holds an SIE model config for each fine-tuned model, with weights_path in place of hf_id. The README shows how to start SIE Local in Docker and ask it for a decision, with both curl and the Python SDK. serve.py scores the test rows through SIE.

Cookbook moves to SIE v0.11.1. Every recipe now needs sie-sdk>=0.11.1 and is relocked; the relock changed only sie-sdk. Image tags and the Helm chart move to v0.11.1.

Tested

  • Docker: ran v0.11.1-cpu-default (emulated on Apple Silicon) with the fine-tuned weights mounted. The README's curl and Python examples ran as written. serve.py gave the same decision as the local run on all 420 rows, and the container used under 1 GB of memory.
  • Offline checks: recipe.py --help and selfcheck.py pass in all 48 recipes. check_tree.py, check_locks.py, ruff and mypy --strict (on the new recipe) pass.

Notes on v0.11.1

  • SIE's compatibility matrix still covers v0.10.1. No cookbook model changes image between the two releases (I compared the model configs and bundles), but SIE hasn't published smoke tests for the v0.11.1 images. SELF_HOSTING.md says so.
  • Qwen/Qwen3-Embedding-4B now has an image, cuda12-sglang-embedding, first published in v0.11.1 and not yet smoke-tested. The docs name it and keep the 8B swap as the one-image option.
  • The v0.11.1 images serve fastino/gliner2-large-v1 with gliner2 2.0.0 instead of 1.3.2, which changes its output according to SIE's own notes. I didn't re-run those 14 recipes. SELF_HOSTING.md flags the change.

🤖 Generated with Claude Code

rparundekar and others added 4 commits November 14, 2026 09:00
…mpare it with zero-shot

Banking77 (public) 67.3% to 93.3%, synthetic parsed-document quality checks
(private) 30.0% to 86.7%, about 5 s of training on a laptop.
The recipe trains locally and is not an agent, so it gets its own
fine_tuning/ folder and root README section. sie_models/ holds an SIE
model config per fine-tuned model (weights_path instead of hf_id), and
serve.py scores the test rows through SIE. Tested with
v0.11.1-cpu-default in Docker: all 420 decisions match the local run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sie-sdk>=0.11.1 and relocked in every recipe (only sie-sdk changed),
v0.11.1 image tags and Helm chart. No cookbook model changes image.
Qwen3-Embedding-4B now has the cuda12-sglang-embedding image (not yet
smoke-tested by SIE), and SELF_HOSTING.md notes that v0.11.1 serves
gliner2-large-v1 with gliner2 2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rparundekar
rparundekar requested a review from a team as a code owner November 14, 2026 20:21
- Serve the fine-tuned models multi-label, as recipe.py trains and
  scores, so SIE's scores match the local ones (within 0.0001) and a
  low top score means the same thing in both.
- Check each data row against rules.yaml, and stop when a model
  returns no labels instead of counting the row as a miss.
- Move scoring settings and the base model revision into rules.yaml;
  pin Banking77 to a commit (rebuilt data is byte-identical).
- serve.py reuses recipe.py's scoring (per-label accuracy included)
  and saves results after each model.
- Add selfcheck.py; fix README claims (SIE call count, configs, LoRA,
  timings, score scale) and a SELF_HOSTING.md contradiction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rparundekar

Copy link
Copy Markdown
Collaborator Author

Self-review

Six passes: code, silent failures, test coverage, comments, types, security. Nothing Critical. All fixes are in 30cd7f8.

Important (6, all fixed)

  • The fine-tuned model scored on a different scale through SIE. recipe.py scored multi-label, but sie_models/*.yaml served single-label. The top label was the same, but the purchase order scored 0.97 through SIE against 0.09 locally, so the README's "low score, send it to a person" advice broke once you served the model. Fixed: the configs now serve multi-label. On a re-run in Docker, all 420 labels match and every score is within 0.0001.
  • Training and scoring read labels from different places. Training takes each row's all_labels; scoring takes rules.yaml. A label renamed in one place would quietly lower accuracy. Fixed: load_rows() checks every row against rules.yaml and stops on a mismatch.
  • A reply with no labels counted as a wrong answer. In both scripts it lowered accuracy instead of raising an error. Fixed: top_pick() now stops with an error.
  • Banking77 came from a moving branch (refs/convert/parquet), and the README named no revision. Fixed: pinned to commit 5724874e and named in the README. The rebuilt data is byte-identical.
  • Settings were hard-coded: label mode, threshold, batch size, max length, and the base model revision. Fixed: moved to rules.yaml. The revision is SIE's catalog pin, which is also current main.
  • Two doc errors. The root README said 0 SIE calls; serve.py makes 28. SELF_HOSTING.md said every model keeps its image, then said Qwen3-Embedding-4B has a new one. Fixed: both corrected.

Suggestions (fixed)

  • Added selfcheck.py. It checks that the data and SIE configs agree with rules.yaml, and tests top_pick and score on hand-written replies, with no SIE call. serve.py now reuses recipe.py's score(), so its results.json has per-label accuracy, and it saves after each model.
  • The README's Python snippet now takes the top label with max() instead of relying on order. The LoRA wording now says adapters are named in the config and picked per request. The training time now reads "about 5 s", the configs' header comments describe what was actually changed, and accelerate has a comment saying why it's listed.

Skipped

  • Security notes, low: -p 8080:8080 publishes the port on every interface. This matches SELF_HOSTING.md, and the server only classifies text you send it. No other security findings.
  • Section order: "Serve your fine-tuned model with SIE" stays after the results. check_tree.py passes, and it reads in the order you'd do it.
  • Recording which run's weights SIE served, and dataset keys that could collide with top-level keys in results.json: minor, left as is.

Verified: selfcheck, ruff and mypy --strict pass. recipe.py re-ran with unchanged numbers (67.3% → 93.3%, 30.0% → 86.7%). serve.py and both README prediction examples re-ran against v0.11.1-cpu-default in Docker.

@rparundekar
rparundekar merged commit d21a563 into main Nov 14, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant