Run this model with HF Jobs

Run lxls/typed-decider-150m-v1 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/lxls/typed-decider-150m-v1. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/lxls/typed-decider-150m-v1 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

TD-v1 (typed-decider-150m-v1)

TD-v1 (typed-decider-150m-v1)

TD-v1 is a 150M-parameter encoder that answers typed decision questions: pick one option (choice), pick a level on a scale (score) or answer yes/no (noul), given a state (free text or JSON). It is a student of OpenDecider-nano (~400M), distilled on the teacher's option probabilities, and uses the same input format.

Results

Accuracy vs. model size

JevBench (JevBench/jevbench, config questions, split test), accuracy, questions with gold unknown skipped (1,938 questions):

Model Params JevBench
OpenDecider-nano (teacher, own measurement) ~400M 81.0%
TD-v1 150M 73.4%

Per question type:

TD-v1 per question type

Type Questions Accuracy
noul (yes/no) 1,152 79.7%
choice 548 76.8%
score 238 35.3%

Caveat: the checkpoint was selected on JevBench (best of evaluations every 1,000 steps), so the score is slightly optimistic. Scale questions (score) are a known weakness.

Speed

Latency per question

Median latency per question on an Apple M2, batch size 1, 60 JevBench test questions (5 warm-up questions excluded), same questions and machine for both models. TD-v1 runs in fp16 on MPS and fp32 on CPU; OpenDecider-nano uses the opendecider package defaults. On this machine TD-v1 is about 1.5x faster on MPS (74 vs. 113 ms) and about 3x faster on CPU (84 vs. 251 ms). The ONNX graph (145 ms on CPU with default ONNX Runtime settings) is slower than PyTorch here, so use it for portability, not for speed. Numbers vary per machine and run; the script is bench_speed.py.

Memory

Peak memory

Peak resident memory of a fresh process after loading the model and answering 20 JevBench questions (batch size 1), same machine. On MPS the CPU and GPU share memory, so the bar adds the bytes allocated through Metal to the process memory; that sum is an upper bound. On CPU, TD-v1 peaks at 1.3 GB against 2.8 GB for OpenDecider-nano (about half). The script is bench_ram.py.

Usage

With transformers (the repo ships its own modeling code, so trust_remote_code=True is required):

from transformers import AutoModel

m = AutoModel.from_pretrained("lxls/typed-decider-150m-v1", trust_remote_code=True)
m.decide(
    "A customer reports a failed export; additionally reports slow performance.",
    {"type": "choice", "instructions": "Route this ticket.",
     "criteria": {"technical_support": None, "billing": None, "account_security": None}},
)
# {"answer": "technical_support", "probabilities": {...}}

Or without remote code, with system_one.py from this repo (only needs torch, transformers, safetensors):

from system_one import SystemOne

m = SystemOne.from_pretrained("lxls/typed-decider-150m-v1")
m.decide(state, question)

A notebook with the same examples is in td-v1.ipynb (runs on the free Colab runtime).

Inference Endpoints and SageMaker

The repo has a handler.py, so Deploy > Inference Endpoints (or SageMaker) works out of the box. Request body:

{"inputs": {"state": "I was charged twice this month.",
            "question": {"type": "choice", "instructions": "Route this ticket.",
                         "criteria": {"technical_support": null, "billing": null}}}}

inputs may also be a list of such objects. The response is a list of {"answer": ..., "probabilities": {...}}.

Question formats:

  • choice: {"type": "choice", "instructions": ..., "criteria": {"option": "description or None", ...}}
  • score: {"type": "score", "instructions": ..., "criteria": ["level 0", "level 1", ...]}, answer is "0", "1", ...
  • noul: {"type": "noul", "instructions": ...}, answer is True or False

Requirements: torch, transformers, safetensors (and huggingface_hub to load from the Hub). Weights are fp16; on CPU they are loaded as fp32.

ONNX

onnx/model.onnx (fp32, opset 17) contains the encoder and the head in one graph. Inputs input_ids and attention_mask (int64, [batch, tokens]), output logits ([batch, tokens], one score per token). Build the ids with prompt_ids from system_one.py, take the logits at the [MASK] positions and apply a softmax over them. With ONNX Runtime on CPU it scores 73.4% on JevBench (73.37% vs 73.43% for the fp16 safetensors, one question apart).

import numpy as np, onnxruntime as ort
from transformers import AutoTokenizer
from system_one import options, prompt_ids

tok = AutoTokenizer.from_pretrained("lxls/typed-decider-150m-v1")
sess = ort.InferenceSession("onnx/model.onnx")
q = {"type": "noul", "instructions": "Is this urgent?"}
ids = prompt_ids(tok, "The production database is down.", q["instructions"], options(q))
logits = sess.run(["logits"], {"input_ids": np.array([ids]), "attention_mask": np.ones((1, len(ids)), dtype=np.int64)})[0][0]
marks = [i for i, t in enumerate(ids) if t == tok.mask_token_id]
p = np.exp(logits[marks] - logits[marks].max()); p /= p.sum()   # yes, no

How it works

Input: [CLS] question: <instructions> [SEP] [MASK] opt1 [MASK] opt2 ... [SEP] input: <state> [SEP], max 512 tokens (the state is truncated, options never are). A small head (Linear, GELU, LayerNorm, Linear) scores the hidden state at every [MASK]; a softmax over those scores gives the option probabilities.

Training

  • Base: jhu-clsp/ettin-encoder-150m (MIT), fully fine-tuned.
  • Teacher: OpenDecider-nano (Apache-2.0) in fp16 labelled 182,048 questions with option probabilities: 80,000 from SargeDev/jev-distill-corpus-v3 (Apache-2.0) and 102,048 from tasksource/tasksource-jev-typed-decisions (mixed licenses). After deduplication: 175,048 training and 500 validation questions. Questions whose state appears in JevBench were removed (none were found).
  • Loss: KL divergence to the teacher at temperature 2, plus 0.3 × cross-entropy on the dataset's gold label where present.
  • 5,000 of 8,000 planned optimizer steps, effective batch up to 64 (token budget 4,096 per micro-batch), AdamW, lr 5e-5 with layer-wise decay 0.9, head lr 1e-3, cosine schedule, EMA 0.999, bf16 on one RTX 3080.

License

CC BY-NC 4.0. Part of the training data (from tasksource/tasksource-jev-typed-decisions) is licensed for non-commercial use only, so these weights are released for non-commercial use. The base model (MIT), teacher (Apache-2.0) and Sarge corpus (Apache-2.0) permit this.

Downloads last month
22
Safetensors
Model size
0.1B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for lxls/typed-decider-150m-v1

Finetuned
(50)
this model

Datasets used to train lxls/typed-decider-150m-v1

Evaluation results