File size: 4,174 Bytes
da6d848
880179f
 
 
566917f
880179f
 
 
 
 
 
 
 
 
da6d848
566917f
 
880179f
566917f
880179f
566917f
880179f
566917f
880179f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566917f
880179f
 
 
 
 
 
 
 
566917f
 
880179f
566917f
880179f
 
 
566917f
880179f
 
 
 
566917f
880179f
 
 
 
 
 
 
 
 
566917f
880179f
566917f
880179f
 
 
 
566917f
880179f
566917f
880179f
 
 
566917f
880179f
566917f
 
880179f
 
 
 
 
566917f
880179f
 
 
 
 
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
---
language: en
library_name: unsloth
license: apache-2.0
tags:
  - spec-forge
  - command-runway
  - qwen2.5-coder
  - lora
  - code-generation
  - yaml
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
datasets:
  - githeri/spec-forge-training-data
pipeline_tag: text-generation
---

# qwen2.5-coder-7b-specforge

## Model Description

Fine-tuned [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) using LoRA adapters on the Spec-Forge training corpus.

The model converts natural-language feature requests into validated YAML specifications that conform to the COMMAND_RUNWAY methodology. Each spec contains:
- `task_id`, `summary`, `depends_on`, `local_goals`, `global_goals_refs`, `context`
- Every `local_goal` has an `Inspect → Create/Modify → Verify` verification flow
- Specs pass a hardened validator (canonical vocabulary, near-duplicate detection, YAML safety)
- Specs are scored against runbook-readiness criteria (hard gate: missing Inspect/Create/Verify stages = 0.0)

## Training Details

| Parameter | Value |
|-----------|-------|
| Base model | `unsloth/Qwen2.5-Coder-7B-Instruct` |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.1 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Epochs | 3 |
| Learning rate | 2e-4 |
| Batch size | 1 (effective: 4 via gradient accumulation) |
| Max sequence length | 2048 |
| Quantization | 4-bit NF4 |
| Optimizer | adamw_8bit |
| LR scheduler | cosine |
| Warmup ratio | 0.1 |

## Training Data

- **Source**: 475 seed prompts across 21 feature categories
- **Generation**: Ollama (qwen2.5-coder:7b-instruct) at temperature 0.2
- **Validation**: Hardened YAML spec validator (78 test cases)
- **Scoring**: Runbook scorer with hard gate (0.75 threshold)
- **Format**: Chat format (`system` + `user` + `assistant` turns)

## Evaluation

See `data/eval_results.json` after running `make eval-model`.

Metrics:
- **Validation rate**: percentage of specs that pass the hardened validator
- **Score pass rate**: percentage of specs scoring >= 0.75 on the runbook scorer
- **Target**: >80% score pass rate (held-out prompts)

## Usage

### Ollama (GGUF)

```bash
# Download GGUF from this repo's models/ directory
ollama create specforge -f models/qwen2.5-coder-7b-specforge-gguf/Modelfile
ollama run specforge
```

### HuggingFace Transformers

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct", torch_dtype="auto")
model = PeftModel.from_pretrained(base, "githeri/qwen2.5-coder-7b-specforge")
tokenizer = AutoTokenizer.from_pretrained("githeri/qwen2.5-coder-7b-specforge")

messages = [
    {"role": "system", "content": "You are a precise specification generator. Output ONLY a YAML document."},
    {"role": "user", "content": "Add a POST /health endpoint that returns 200 OK"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.2)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

## Limitations

- Trained on a synthetic corpus generated by the base model itself — quality is bounded by the base model's spec-generation ability
- Specs are scoped to a single-file, single-feature granularity (not multi-stage epics)
- Context is fixed to TypeScript/Express/Prisma/Vitest stack
- GGUF quantization (q4_k_m) introduces minor quality degradation vs the 16-bit merge

## Ethical Considerations

- This model generates structured specifications, not executable code
- All generated specs must pass the hardened validator before use
- Human review is required before feeding specs into a COMMAND_RUNWAY executor

## Citation

```bibtex
@misc{githeri-specforge,
  title={Spec-Forge: From Natural Language to Runbook-Ready YAML Specifications},
  author={Githeri},
  year={2026},
  url={https://github.com/nickrotich/githeri}
}
```

## License

Apache 2.0 — same as the base Qwen2.5-Coder-7B-Instruct model.