# xevyo-01 code The code that renders requests for xevyo-01, checks its plans, serves it, retrains it and scores it. Training data and the evaluation sets are not included. | Path | What it does | Needs | |---|---|---| | `spec/render.py` | Builds the exact system and user messages the model was trained on (`render_messages(example, window)`), and the canonical plan text (`render_target`) | Python standard library | | `spec/validate.py` | Checks a plan: the JSON schema plus the rules a schema cannot express (offered tools, argument shapes, field conditions, directive preconditions) | `jsonschema` | | `spec/*.json`, `spec/system_prompt.md`, `spec/examples.jsonl` | The prompt template, tool and directive catalogues, schemas and 20 worked examples the two files above read | | | `spec/test_spec.py` | 69 tests for rendering and validation | `pytest` | | `serve/vllm_schema.py` | The per-turn JSON schema for vLLM guided decoding (`response_format(offered_tools)`) | | | `serve/hard_rules.py` | Safety and consistency rules to apply to every plan before acting on it (`apply(plan, example)`) | | | `serve/merge_adapter.py` | Merges a LoRA adapter into the base weights (W + (alpha/r)·B·A) so vLLM can serve it | `torch`, `safetensors` | | `train/sft_lora.py`, `train/configs/r4.yaml` | LoRA supervised fine-tuning, loss on the plan tokens only; the round-4 settings | `train/requirements.txt` | | `train/Dockerfile` | The training image (PyTorch 2.10, CUDA 12.8, pinned stack) | Docker | | `eval/run_eval.py`, `eval/score.py` | Sends rows to an endpoint, validates each answer and scores it field by field | `jsonschema` | ## Render a request and check a plan ```python import json, sys sys.path[:0] = ["code/spec", "code/serve"] import render, validate, hard_rules from vllm_schema import response_format example = json.loads(open("code/spec/examples.jsonl", encoding="utf-8").readline())["input"] messages = render.render_messages(example) # window="agent" for the longer history window fmt = response_format(example["offered_tools"]) # pass as response_format to vLLM # ... call the model with `messages` and `fmt`, then: plan = json.loads(reply_text) plan, changes = hard_rules.apply(plan, example) errors = validate.validate_plan(plan, example) # [] when the plan is usable ``` `example` follows `spec/example_input.schema.json`: the message, the earlier turns, the tools on offer and a few flags (image attached, memory on, locale). ## Context windows - `trained` (the default): the last 8 messages; user turns up to 500 characters, answers up to 600. - `agent`: newest first, up to 24 messages within 12,000 characters; user turns up to 2,000 characters, the latest answer up to 6,000, older answers up to 1,200. Round 4 was trained on both. Use the window that matches how much history your application has. ## Retrain ```bash docker build -t xv01-train code/train # rows: {"input": , "target": ""} in data/train.jsonl and data/eval.jsonl torchrun --nproc_per_node 2 code/train/sft_lora.py --config code/train/configs/r4.yaml python code/serve/merge_adapter.py --adapter runs/xevyo01-r4/adapter_vllm --out models/xevyo-01 ``` The image sets `HF_HUB_OFFLINE=1`; download `Qwen/Qwen3.5-9B` at the pinned revision into `HF_HOME` first, or unset it. ## Score ```bash python code/eval/run_eval.py --base http://localhost:8000 --model xevyo-01 \ --gold your_rows.jsonl --out results/run1 ``` Rows: `{"id", "input": , "target": ""}`. The report gives schema-valid %, exact plan %, safety failures and accuracy per field. `--traffic` (in `score.py`) re-weights by a traffic mix you set in `TRAFFIC_WEIGHTS`. ## Licence Apache 2.0, like the model.