Views
No views yet
| Parameter | Value |
|---|---|
| Base model | microsoft/Phi-4-mini-instruct (3.8B) |
| Method | QLoRA 4-bit NF4 + double quantization |
| LoRA rank | r=16, alpha=32 |
| Target modules | q_proj, k_proj, v_proj, o_proj |
| Training data | 2,624 topologies distilled from GPT-5.4 (reasoning=high) |
| Data sources | BigCodeBench (1,140), GSM8K (1,319), Code Contests (165) |
| Data format | Double-quote YAML (no multiline wrapping) |
| Epochs | 5 |
| Batch size | 1 (gradient accumulation 8) |
| Learning rate | 2e-4 |
| Max length | 1,280 tokens |
| Hardware | NVIDIA RTX 3500 Ada (12GB VRAM) |
| Training time | ~2 hours |
| Metric | Value |
|---|---|
| Train loss | 0.896 |
| Token accuracy | 77.2% |
| YAML validity | 70% (SFT only; GRPO expected to reach 100%) |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5# Load base model + adapter
6tokenizer = AutoTokenizer.from_pretrained("yannabadie/sage-topology-policy")
7base = AutoModelForCausalLM.from_pretrained(
8 "microsoft/Phi-4-mini-instruct",
9 trust_remote_code=False,
10 dtype=torch.float16,
11 device_map="cpu",
12)
13model = PeftModel.from_pretrained(base, "yannabadie/sage-topology-policy")
14model = model.to("cuda:0") # or keep on CPU
15model.eval()
16
17# Generate a topology
18prompt = (
19 '<|system|>You are a multi-agent topology designer. '
20 'Given a task, generate an optimal agent topology in YAML format.<|end|>\n'
21 '<|user|>Write a merge sort function<|end|>\n'
22 '<|assistant|>'
23)
24inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
25with torch.no_grad():
26 out = model.generate(**inputs, max_new_tokens=500, temperature=0.3, do_sample=True)
27print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))1"difficulty": "moderate"
2"edges":
3- "flow_type": "control"
4 "from_idx": 0
5 "to_idx": 1
6"nodes":
7- "model_tier": "reasoner"
8 "prompt": "Design the algorithm and plan the implementation..."
9 "role": "planner"
10- "model_tier": "fast"
11 "prompt": "Implement the planned solution in Python..."
12 "role": "coder"
13"reasoning": "This task requires planning then implementation..."