shorthand-worker-v4

LoRA adapter (r=64, 3 epochs, bf16) on Qwen3.5-9B. The worker half of the v4 translator–worker system: a shorthand-native coding agent. It reads a slot-marker task spec (produced by GreenPT/shorthand-translator-v4) and works entirely in shorthand — it never sees the English task.

Each turn it emits exactly ONE shorthand step:

Slot Meaning
<act>read <file> view the sandbox file
<act>edit <file> L<n> <fix>… describe the fix (code synthesized env-side)
<test>pytest … run the test suite
<done>… <test>n/n pass final shorthand report
<need>… question back to the translator

Usage

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

BASE = "Qwen/Qwen3.5-9B"
tok = AutoTokenizer.from_pretrained(BASE)
base = AutoModelForCausalLM.from_pretrained(
    BASE, dtype=torch.bfloat16, device_map="cuda")
model = PeftModel.from_pretrained(base, "GreenPT/shorthand-worker-v4")
model.eval()

WORKER_SYSTEM = (
    "You are a coding agent that works entirely in terse shorthand. Read the "
    "task and history, then emit exactly ONE next step as slot-marker "
    "shorthand (<act> <fix> <test> <done> or <need> question). Keep numbers, "
    "paths, identifiers verbatim. No English sentences."
)

def next_step(spec, history, max_new=192):
    parts = [f"task: {spec}"]
    if history:
        parts.append("history:")
        parts.extend(history)
    parts.append("next step:")
    msgs = [{"role": "system", "content": WORKER_SYSTEM},
            {"role": "user", "content": "\n".join(parts)}]
    ids = tok.apply_chat_template(
        msgs, add_generation_prompt=True, return_tensors="pt",
        return_dict=False, enable_thinking=False).to(model.device)
    out = model.generate(ids, max_new_tokens=max_new, do_sample=False)
    return tok.decode(out[0][ids.shape[-1]:], skip_special_tokens=True).strip()

spec = ("<goal>fix clamp in mod.py <bug>only applies lower bound, ignores "
        "upper <fix>wrap w/ min() enforce hi <test>pytest test_mod.py")
print(next_step(spec, []))
# -> <act>read mod.py <fact>locate clamp

The full agentic loop (observation feeding, edit application, pytest runs, token accounting) is implemented as run_shorthand in eval/loop_bench.py and wrapped by the Gradio demo (demo/app.py) in the code repo.

Execution semantics (how the sandbox runs a step)

  1. The sandbox parses the first slot marker of the worker's turn.
  2. <act>read / <test> map directly to file view / pytest.
  3. <act>edit … <fix>…: the <fix> line is turned into real code by a code-synthesis call to the worker model itself, and the result is patched into the sandbox. Code is payload and passes verbatim (v1 lesson: data-dominant payloads must not go through lossy compression).
  4. <done> ends the loop; the shorthand report goes to the translator for the SH→EN expansion.

Required settings

  • enable_thinking=False, greedy decoding (do_sample=False).
  • Truncate runaway generations at \n(system|user|assistant)\n.
  • One base + both adapters: load this as adapter_name="worker" next to the translator and switch with model.set_adapter(...) (see GUIDE.md).

Training data

v4_worker_train.jsonl (11,532 rows) in GreenPT/shorthand-agent-comm. Each row: user = shorthand spec + shorthand history + sandbox observation, assistant = next shorthand step. Scripted ground-truth trajectories (read→edit→test→done); teacher Qwen/Qwen3.5-397B-A17B:deepinfra only compressed the narrations.

Validation (measured)

Full 195-task held-out bench with the translator adapter (pytest-verified, token-accounted): 60.0% task success (117/195; 54.9% on the 173 tasks whose tests catch the bug), median 1,436 total tokens/task. Baselines on the same tasks: vanilla 9B with a worked-example prompt reaches 79.5% at median 293 tokens/task — the shorthand loop is ~5.3x more expensive and 19.5pp less successful than a functional English loop on this benchmark. Per-snippet breakdown and raw records (v4_bench_heldout.jsonl, v4_bench_heldout_a2.jsonl): see the dataset and report repos. (Supersedes an earlier 20-task smoke claim of 100%.)

Related artifacts

Artifact Repo
Translator LoRA (v4) GreenPT/shorthand-translator-v4
Dataset + scripts GreenPT/shorthand-agent-comm
Report + guide GreenPT/trained-shorthand-report
Downloads last month
14
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for GreenPT/shorthand-worker-v4

Finetuned
Qwen/Qwen3.5-9B
Adapter
(598)
this model