Text Generation
Transformers
Safetensors
English
qwen2
code
coding-agent
tool-use
sft
rlvr
grpo
trl
security
conversational
text-generation-inference
Run this model with HF Jobs
Run SamJoshua/stacy 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 and TRL to fine-tune https://huggingface.co/SamJoshua/stacy. 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/SamJoshua/stacy 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.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/SamJoshua/stacy. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/SamJoshua/stacy. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use SamJoshua/stacy with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SamJoshua/stacy with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SamJoshua/stacy") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("SamJoshua/stacy") model = AutoModelForCausalLM.from_pretrained("SamJoshua/stacy", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SamJoshua/stacy with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SamJoshua/stacy" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SamJoshua/stacy", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/SamJoshua/stacy
- SGLang
How to use SamJoshua/stacy with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "SamJoshua/stacy" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SamJoshua/stacy", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "SamJoshua/stacy" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SamJoshua/stacy", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use SamJoshua/stacy with Docker Model Runner:
docker model run hf.co/SamJoshua/stacy
File size: 13,670 Bytes
2832cad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | # Enterprise coding agent: audit, baseline, and experiment plan
_Last updated: 2026-10-30. Primary model: **Qwen2.5-Coder-1.5B** post-trained in-repo (`/models/ckpts/`). Agent harness: `scripts/enterprise/assistant/tools/` + frozen suite `scripts/enterprise/agentbench/`._
This document satisfies the investigation, gap analysis, baseline protocol, and ranked experiment plan for turning the existing ~1.5B coding model into a **verified** coding agent. Full training provenance and HumanEval+/MBPP+ numbers live in [`REPORT.md`](../REPORT.md).
---
## 1. Model audit (evidence)
### 1.1 Architecture and inference
| Field | Value | Source |
|---|---|---|
| Base | `Qwen/Qwen2.5-Coder-1.5B` → CPT → SFT → GRPO variants | `scripts/enterprise/README.md`, `/models/ckpts/` |
| Architecture | `Qwen2ForCausalLM`, hidden 1536, 28 layers, GQA | `/models/ckpts/grpo_instruct/final/config.json` |
| Params | ~1.54B (HF config) | same |
| Tokenizer | Qwen2 BPE, vocab ~151k | `tokenizer.json` in checkpoint |
| Native context | 32768 positions in config; agent runs use **8192** vLLM max (`agentbench/runner.py`) | config + runner |
| Chat template | Qwen2.5 Instruct (`chat_template.jinja` in checkpoint) | checkpoint |
| Inference backend | **vLLM 0.32** (OpenAI-compatible), greedy for eval | `assistant/backend.py`, `eval/*.json` meta |
| Structured tool calls | **Native**: vLLM `structured_outputs` + JSON schema from `registry.action_schema` / `coder.final_schema` | `assistant/backend.py`, `tools/registry.py`, `tools/coder.py` |
| Best code checkpoint (single-shot) | `grpo_instruct/final` — HE+ chat **65.9%**, MBPP+ chat **64.0%** | `eval/grpo_nothink_abliterated.json` uses abliterated variant; `REPORT.md` table for `grpo_instruct` |
**Separate path (not the enterprise agent model):** from-scratch ~400M–1B GPT-style transformer (`configs/base.json`: `n_embed=1024`, `n_blocks=24`, r50k tokenizer, 1024 context) trained via `scripts/pretrain_base.py` / `POST_TRAINING.md`. That stack has no vLLM tool schema; the enterprise agent work targets the **Qwen 1.5B** checkpoints under `/models/ckpts/`.
### 1.2 Training stages (immutable baseline for ablations)
| Stage | Output | Notes |
|---|---|---|
| CPT | `/models/ckpts/cpt/final` | Primus Seed + FineWeb + FineWeb-Edu replay, 260M tokens |
| SFT | `/models/ckpts/sft/final` | Magicoder + Primus Instruct/Reasoning + CyberNative |
| GRPO (on SFT) | `/models/ckpts/grpo/final` | Verifiable coding + CTI + review + patch rewards |
| GRPO instruct | `/models/ckpts/grpo_instruct/final` | Same rewards on **Instruct** base (strongest general coding checkpoint) |
| Agent SFT (Experiment A) | `/models/ckpts/agent_A/final` | Trajectory SFT from oracle data, 531 train rows |
Configs: `configs/enterprise/*.json`, `configs/agentbench/sft_agent.json`. Logs: `/models/runs/<stage>/`. LoRA supported in `sft.py` (`lora` key) but agent run used full fine-tune with `fp32_master`.
### 1.3 Current limitations (measured)
| Area | Finding |
|---|---|
| Single-shot coding | Competitive with other ~1.5B coders on HE+/MBPP+ chat; far below 7B+ frontier |
| Tool agent (old harness) | **15%** success on 46-task dev suite; **83% false-completion** rate when claiming done | `/models/runs/agentbench/dbg__old__dev.json` |
| Tool agent (CodingHarness) | **48%** success dev with `agent_A`; blocked tasks recognized **100%** | `/models/runs/agentbench/agentA__new__dev.json` |
| Blind toolbench (author vs independent tasks) | 70% vs **6.7%** on independent set | `scripts/enterprise/README.md`, `eval/blind_validation.json` |
| Multi-file / refactor / testgen | Largest failure buckets on dev (see agentbench rows) | trajectory analysis |
| Long context | Agent context budget **~5600 tokens** repomap + transcript (`CoderConfig.context_tokens`) |
---
## 2. Runtime audit
### 2.1 Harness components
| Component | Role |
|---|---|
| `AgentHarness` | Legacy loop: JSON action → authorize → execute → observe |
| `CodingHarness` | OBSERVE→PLAN→ACT→VERIFY→REPAIR→FINAL_VERIFY; completion **gated** on real test runs |
| `registry.py` | Tool schemas; vLLM constrained decoding |
| `coder.validate_args` | Rejects bad args outside the model |
| `repomap.py` | Tree + symbols + relevant snippets (no full-repo dump) |
| `verify.py` | Compile + unittest after writes |
| `permissions.py` | Workspace confinement, approval hooks |
| `shell.py` + `rewards/sandbox.py` | bwrap execution, no network |
| `agentbench/` | Frozen suites (`dev_v1` 46 tasks, `test_v1` **94 held-out**), hidden tests, grader |
### 2.2 Failure detection without trusting the model
- Task pass/fail: `agentbench.task.grade` runs **hidden** tests not in the prompt.
- False completion: `final(status="done")` rejected unless harness recorded a passing verify after last edit (`gate=True`).
- Blocked tasks: must use `final(status="blocked")`; graded against unchanged workspace + keyword checks.
- Security: command audit in runner; `tests/enterprise/test_agent_security.py` (36 tests) + sandbox tests (8).
### 2.3 Security status
- **Sandbox tests: pass** on this host (`pytest tests/enterprise/test_sandbox.py`).
- **Harness security tests: pass** (`test_agent_security.py`).
- bwrap setuid fix documented in `scripts/enterprise/STATUS.md` (completed for this environment).
---
## 3. Gap analysis — top three capability gaps
1. **Unverified completion / false success (runtime + policy)**
Old harness allowed `final` without execution proof → 20/24 false completions on dev. **Mitigation shipped:** `CodingHarness` + verify gate. Residual: ~29% false-completion among claimed-done on dev with `agent_A` (needs more training on repair + blocked recognition under pressure).
2. **Tool-use and multi-step workflow quality (training)**
Syntax validity ~86% on dev; execution success ~79%. Model still under-explores on multi-file/refactor/testgen families. **Mitigation in progress:** oracle trajectory SFT (`agent_A` + dataset pipeline); needs larger mixture + hard-example mining from test failures.
3. **Generalization outside author-written benchmarks**
Blind independent toolbench **6.7%** vs 70% author set. **Mitigation:** hold-out `test_v1` suite (94 tasks), no training on test families; expand suite authorship; rejection-sample self trajectories only when grader passes.
---
## 4. Baseline evaluation protocol
### 4.1 Suite coverage (agentbench)
| Category | Examples in suite |
|---|---|
| Function implementation | `impl`, `bugfix` |
| Bug fixing / TDD | `tdd`, `tdd_indirect` |
| Unit-test generation | `testgen` |
| Syntax/lint | `lint` |
| Single-file refactor | `refactor_helper`, `refactor_split`, `refactor_*` |
| Multi-file | `multi_param`, `multi_rename`, `multi_config`, `multi_move` |
| Recovery | `recovery_flaky`, `recovery_path`, `recovery_*` |
| Blocked / impossible | `blocked_*` |
| Tool format & execution | enforced by schema + `invalid_args` / `parse_failures` metrics |
| Security | injection tasks + `violation` flag |
### 4.2 Variants (ablation matrix)
| ID | Description |
|---|---|
| `notools` | Full files in prompt, no execution |
| `old` | `AgentHarness` as shipped |
| `new` | `CodingHarness` defaults (repomap, autoverify, hints, gate, progress_stop) |
### 4.3 Metrics (per run)
Recorded in each `*/models/runs/agentbench/*__<suite>.json` → `summary`: `success`, `success_solve`, `hidden_pass`, `false_completion`, `tool_call_validity`, `tool_exec_success`, `mean_repairs`, `median_latency_s`, `p95_latency_s`, `tokens_per_success`, `security_violations`, etc.
### 4.4 Dev results (pre-test, **not** for training decisions)
| Run | Variant | Success | False completion | Hidden pass (solve) | Security viol. |
|---|---|---|---|---|---|
| dbg | old | 15.2% | 83.3% | 9.5% | 2 |
| dbg | new | 17.4% | — | — | — |
| dbg4 | new | 23.9% | — | — | — |
| agentA | new (`grpo_instruct` + agent SFT) | **47.8%** | 29.2% | 42.9% | 0 |
### 4.5 Held-out test suite (`test_v1`, n=94) — **primary gate**
Model: `/models/ckpts/grpo_instruct/final` (immutable baseline before agent SFT).
Artifacts: [`eval/agentbench_baseline_instruct_test.json`](../eval/agentbench_baseline_instruct_test.json), `/models/runs/agentbench/baseline_instruct__*__test.json`.
| Variant | Success | Hidden pass (solve) | False completion | Median latency | Notes |
|---|---|---|---|---|---|
| `notools` | **20.2%** (19/94) | 10.7% | 60.9% | 0.19s | Best on this suite; no repair loop |
| `old` | 10.6% | 6.0% | **88.7%** | 2.0s | False success dominates |
| `new` | 5.3% (5/94) | 4.8% | 75.0% | 6.3s | Gate reduces false done but **hurts pass rate** on hard tasks |
Category pass rates (`new` on test): blocked 1/10, bugfix 1/10, impl 1/12, tdd 1/12, testgen 1/8, **0/10** lint/multifile/refactor/recovery subsets.
**Interpretation:** Dev suite (`dev_v1`) overstated harness benefit. On held-out test, the model lacks skill for lint/multifile/refactor/recovery; the verify gate + step budget burn tokens without enough successful repairs. Next: train on oracle trajectories for failing families, then re-ablate `new` with `gate=0` on a slice to separate gate cost from capability.
**Pending:** `/models/ckpts/agent_A/final` on `test_v1` — blocked when run (2026-10-30) because GPU was occupied (~86 GiB by another job). Re-run:
```bash
PYTHONPATH=. python -m agentbench.runner --model /models/ckpts/agent_A/final --name agentA --suite test --variants new --gpu-mem 0.28
```
---
## 5. Experiment plan (ranked by expected benefit / cost)
| Rank | Experiment | Cost | Expected benefit | Stop criteria |
|---|---|---|---|---|
| 1 | **CodingHarness + gate** (done) | Engineering only | Large drop in false completion vs old | Already merged; keep if security tests pass |
| 2 | **Agent trajectory SFT** (A, partial) | ~1h GPU, 531 rows | +30pp dev success observed (`agent_A`) | Stop if test suite < +10pp vs baseline or false_completion > 40% |
| 3 | **Expand oracle trajectories** (`gen_data oracle`) | CPU/GPU medium | Better tool validity + recovery | Need ≥2000 accepted steps, deduped |
| 4 | **Hard-example mining** (D) | GPU + labeling | Target failing families (testgen, multi_file) | Only add rows that pass hidden grader |
| 5 | **Tool-use-only SFT** (B) | Low | Fix invalid_args / wrong tool choice | Measure syntactic validity > 95% |
| 6 | **LoRA agent SFT** | Lower VRAM | Faster iteration | Compare to full FT on dev only |
| 7 | **GRPO on agent trajectories** (F) | High | Only after test harness + held-out stable | Reward = hidden pass, not model self-report |
| 8 | **DPO** (E) | Medium | Defer until paired pass/fail trajectories exist | — |
---
## 6. Reproduce commands
```bash
cd /home/vortex/train-llm-from-scratch
source .venv/bin/activate
# Preflight + unit tests
pytest tests/enterprise/test_sandbox.py tests/enterprise/test_agent_security.py
# Validate suite integrity
cd scripts/enterprise && PYTHONPATH=. python -m agentbench.selftest
# Held-out agent benchmark (greedy, vLLM)
PYTHONPATH=. python -m agentbench.runner \
--model /models/ckpts/grpo_instruct/final \
--name baseline_instruct \
--suite test \
--variants notools,old,new \
--concurrency 2 --gpu-mem 0.28 --verbose
PYTHONPATH=. python -m agentbench.runner \
--model /models/ckpts/agent_A/final \
--name agentA \
--suite test \
--variants new \
--concurrency 2 --gpu-mem 0.28 --verbose
# Oracle trajectory generation
PYTHONPATH=. python -m agentbench.gen_data oracle --n 700 --seed 1 --out /models/agent_data/v1
# Build SFT JSONL (task-level val holdout)
PYTHONPATH=. python -m agentbench.build_sft \
--inputs accepted_oracle.jsonl \
--components core,blocked,recovery \
--out /models/agent_data/v1/sft_B
# Agent SFT (Experiment A)
python scripts/enterprise/sft.py --config configs/agentbench/sft_agent.json
# Single-shot coding eval (existing)
python scripts/enterprise/eval.py --model /models/ckpts/grpo_instruct/final \
--name grpo_instruct --tasks humaneval,mbpp --gpu_mem 0.3
```
---
## 7. Production readiness (snapshot)
| Item | Status |
|---|---|
| Reproducible deps | `requirements-enterprise.txt`, `REPORT.md` env pin |
| Checkpoint integrity | HF format under `/models/ckpts/*/final` |
| Structured traces | `agentbench.runner --trace`, `CodingHarness` trace hashes |
| Sandboxed execution | bwrap + seccomp, tested |
| Regression gates | `agentbench` test suite + `test_agent_security.py` |
| Known blockers | Agent still weak on independent blind tasks; test suite baseline pending |
---
## 8. Known failures and next interventions
1. **testgen / multi_file families** — model skips writing tests or edits wrong files → add oracle trajectories + mine failures from test run.
2. **Residual false completion (~29%)** — tighten gate messages; SFT on rejected `final` attempts from `gen_data model`.
3. **Blind toolbench 6.7%** — do not trust dev-only numbers; prioritize `test_v1` and external task authorship.
4. **Context** — increase `context_tokens` only if repomap ablation shows recall-limited failures.
---
## 9. Where this competes vs fails
| Competes | Fails |
|---|---|
| HE+/MBPP+ chat vs other 1.5B instruct coders | vs 7B+ / frontier agents |
| Blocked-task recognition with CodingHarness + agent_A | Independent multi-step repo tasks without hints |
| Verifiable single-file bugfix/lint with gate | testgen quality; complex multi-file refactors under unittest-only sandbox |
| Latency ~2s median per dev task, ~13k tokens/success | Cost still high vs single-shot completion for easy tasks |
Numbers updated when `/models/runs/agentbench/baseline_instruct__*__test.json` completes.
|