Files

213 lines
5.3 KiB
Markdown
Raw Permalink Normal View History

---
license: apache-2.0
base_model: Qwen/Qwen3-8B
tags:
- qwen3
- agentic
- coding-agent
- tool-use
- finetuned
- lora
- unsloth
- fable5
- claude
language:
- en
pipeline_tag: text-generation
library_name: transformers
---
# qwen3-8b-claude-agentic-fable5
**A Qwen3-8B model fine-tuned on Claude Fable-5 agent traces for agentic coding tasks.**
Fine-tuned by **DhruvalLabs** using LoRA on real coding agent trajectories from the
[Glint-Research/Fable-5-traces](https://huggingface.co/datasets/Glint-Research/Fable-5-traces) dataset.
---
## What is this model?
This model is fine-tuned to behave like an **agentic coding assistant** — it reasons step by step
inside `<think>` tags before taking any action, then calls the appropriate tool to complete the task.
Unlike a standard chat model that just replies with text, this model:
- **Thinks before acting** — every response includes a reasoning chain
- **Calls tools correctly** — uses `bash`, `read_file`, `write_file`, `edit_file`, `web_search` and more
- **Works multi-step** — plans and executes complex tasks autonomously
- **Follows the Fable-5 agent style** — trained on real Claude Fable-5 coding sessions
---
## Training Details
| | |
|---|---|
| **Base model** | `Qwen/Qwen3-8B` |
| **Dataset** | `Glint-Research/Fable-5-traces` |
| **Dataset size** | 4,665 rows |
| **Method** | QLoRA (LoRA fine-tuning on 4-bit quantized model) |
| **LoRA rank** | 16 |
| **LoRA alpha** | 32 |
| **Target modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| **Training steps** | 580 |
| **Batch size** | 2 × 8 grad accum = 16 effective |
| **Learning rate** | 2e-4 |
| **Sequence length** | 8192 |
| **GPU** | NVIDIA RTX 4000 Ada (20GB) |
| **Framework** | Unsloth + TRL |
| **Final loss** | ~0.27 |
---
## What it learned
The model was trained on real Fable-5 (Claude) coding agent sessions. Each training example contains:
- A coding task from a real user
- The agent's step-by-step reasoning (`<think>` block)
- The tool call the agent made (`bash`, `read_file`, `write_file`, etc.)
Tools present in training data:
| Tool | Count |
|---|---|
| bash | 1,544 |
| edit_file | 960 |
| text_response | 866 |
| read_file | 443 |
| write_file | 311 |
| web_search | 72 |
| + others | ~200 |
---
## How to use
### Basic inference
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"DhruvalLabs/qwen3-8b-claude-agentic-fable5",
torch_dtype=torch.bfloat16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("DhruvalLabs/qwen3-8b-claude-agentic-fable5")
messages = [
{
"role": "system",
"content": (
"You are an expert agentic coding assistant. "
"Before every action, reason carefully inside <think>...</think> tags. "
"Then call the appropriate tool to complete the task step by step."
)
},
{
"role": "user",
"content": "/think\nRead the file main.py and summarize what it does."
}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to("cuda")
outputs = model.generate(
input_ids=inputs,
max_new_tokens=500,
temperature=0.7,
do_sample=True,
)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
```
### With Unsloth (faster, less VRAM)
```python
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "DhruvalLabs/qwen3-8b-claude-agentic-fable5",
max_seq_length = 8192,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
```
### With vLLM (for serving as API)
```bash
python -m vllm.entrypoints.openai.api_server \
--model DhruvalLabs/qwen3-8b-claude-agentic-fable5 \
--port 8000 \
--max-model-len 8192
```
Then connect any OpenAI-compatible client to `http://localhost:8000/v1`.
---
## Example output
**Input:**
```
Check if Node.js is installed and what version it is.
```
**Output:**
```
<tool_call>
{"name": "bash", "arguments": {"command": "node --version 2>/dev/null || echo 'Node.js not installed'"}}
</tool_call>
```
---
## Tips for best results
- Always add `/think` at the start of your user message to trigger reasoning mode
- Use a system prompt that tells the model it's an agentic assistant
- Set `temperature=0.7` for a good balance of creativity and consistency
- Set `max_new_tokens` to at least 400 for complex tasks
---
## Dataset
Trained on [Glint-Research/Fable-5-traces](https://huggingface.co/datasets/Glint-Research/Fable-5-traces) —
a dataset of real Fable-5 (Claude) coding agent traces converted to Qwen3 chat format.
Data preprocessing and format conversion done by **DhruvalLabs**.
---
## License
This model inherits the **Apache 2.0** license from the base Qwen3-8B model.
Free to use for personal, research, and commercial purposes.
---
## Citation
If you use this model in your research or project, please cite:
```bibtex
@misc{dhruval2026qwen3fable5,
author = {DhruvalLabs},
title = {qwen3-8b-claude-agentic-fable5: Qwen3-8B Fine-tuned on Fable-5 Agent Traces},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/DhruvalLabs/qwen3-8b-claude-agentic-fable5}
}
```
---
*Made with ❤️ by DhruvalLabs*