sapbot commited on
Commit
3c1f5f4
·
verified ·
1 Parent(s): a4ae03d
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ LocoOperator[[:space:]]4B[[:space:]]IQ3_M[[:space:]](2026)\[Romarchive\].gguf.gguf filter=lfs diff=lfs merge=lfs -text
37
+ LocoOperator[[:space:]]4B[[:space:]]Q4_0[[:space:]](2026)\[Romarchive\].gguf.gguf filter=lfs diff=lfs merge=lfs -text
38
+ LocoOperator[[:space:]]4B[[:space:]]TQ1_0[[:space:]](2026)\[Romarchive\].gguf.gguf filter=lfs diff=lfs merge=lfs -text
LocoOperator 4B IQ3_M (2026)[Romarchive].gguf.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61a5ea747047bc95abdda50ffc9770b4ae815cecc576f21b515b3eb63f96570d
3
+ size 1962894688
LocoOperator 4B Q4_0 (2026)[Romarchive].gguf.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc0486fa61d23083b67e601b109c755f52c878512925905e6626ccf205e9ec2b
3
+ size 2369545568
LocoOperator 4B TQ1_0 (2026)[Romarchive].gguf.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20d74a4df3bf25aabafd90325f7acf4fca43ef99e52cb1fc2be6f663c9381650
3
+ size 1092207968
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: gguf
3
+ pipeline_tag: text-generation
4
+ base_model:
5
+ - LocoreMind/LocoOperator-4B
6
+ ---
7
+ Quantized at [Romarchive](https://cows.info.gf)
8
+
9
+
10
+ <div align="center">
11
+ <img src="assets/loco_operator.png" width="55%" alt="LocoOperator" />
12
+ </div>
13
+
14
+ <br>
15
+
16
+ <div align="center">
17
+
18
+ [![MODEL](https://img.shields.io/badge/Model-FFB300?style=for-the-badge&logo=huggingface&logoColor=white)](https://huggingface.co/LocoreMind/LocoOperator-4B)
19
+ [![GGUF](https://img.shields.io/badge/GGUF-FF6F00?style=for-the-badge&logo=huggingface&logoColor=white)](https://huggingface.co/LocoreMind/LocoOperator-4B-GGUF)
20
+ [![Blog](https://img.shields.io/badge/Blog-4285F4?style=for-the-badge&logo=google-chrome&logoColor=white)](https://locoremind.com/blog/loco-operator)
21
+ [![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/LocoreMind/LocoOperator)
22
+ [![Colab](https://img.shields.io/badge/Colab-F9AB00?style=for-the-badge&logo=googlecolab&logoColor=white)](https://colab.research.google.com/github/LocoreMind/LocoOperator/blob/main/LocoOperator_4B.ipynb)
23
+
24
+ </div>
25
+
26
+ ## Introduction
27
+
28
+ **LocoOperator-4B** is a 4B-parameter tool-calling agent model trained via knowledge distillation from **Qwen3-Coder-Next** inference traces. It specializes in multi-turn codebase exploration — reading files, searching code, and navigating project structures within a Claude Code-style agent loop. Designed as a local sub agent, it runs via llama.cpp at zero API cost.
29
+
30
+ | | LocoOperator-4B |
31
+ |:--|:--|
32
+ | **Base Model** | [Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507) |
33
+ | **Teacher Model** | Qwen3-Coder-Next |
34
+ | **Training Method** | Full-parameter SFT (distillation) |
35
+ | **Training Data** | 170,356 multi-turn conversation samples |
36
+ | **Max Sequence Length** | 16,384 tokens |
37
+ | **Training Hardware** | 4x NVIDIA H200 141GB SXM5 |
38
+ | **Training Time** | ~25 hours |
39
+ | **Framework** | MS-SWIFT |
40
+
41
+ ## Key Features
42
+
43
+ - **Tool-Calling Agent**: Generates structured `<tool_call>` JSON for Read, Grep, Glob, Bash, Write, Edit, and Task (subagent delegation)
44
+ - **100% JSON Validity**: Every tool call is valid JSON with all required arguments — outperforming the teacher model (87.6%)
45
+ - **Local Deployment**: GGUF quantized, runs on Mac Studio via llama.cpp at zero API cost
46
+ - **Lightweight Explorer**: 4B parameters, optimized for fast codebase search and navigation
47
+ - **Multi-Turn**: Handles conversation depths of 3–33 messages with consistent tool-calling behavior
48
+
49
+ ## Performance
50
+
51
+ Evaluated on 65 multi-turn conversation samples from diverse open-source projects (scipy, fastapi, arrow, attrs, gevent, gunicorn, etc.), with labels generated by Qwen3-Coder-Next.
52
+
53
+ ### Core Metrics
54
+
55
+ | Metric | Score |
56
+ |:-------|:-----:|
57
+ | **Tool Call Presence Alignment** | **100%** (65/65) |
58
+ | **First Tool Type Match** | **65.6%** (40/61) |
59
+ | **JSON Validity** | **100%** (76/76) |
60
+ | **Argument Syntax Correctness** | **100%** (76/76) |
61
+
62
+ The model perfectly learned *when* to use tools vs. when to respond with text (100% presence alignment). Tool type mismatches are between semantically similar tools (e.g. Grep vs Read) — different but often valid strategies.
63
+
64
+ ### Tool Distribution Comparison
65
+
66
+ <div align="center">
67
+ <img src="assets/tool_distribution.png" width="80%" alt="Tool Distribution Comparison" />
68
+ </div>
69
+
70
+ ### JSON & Argument Syntax Correctness
71
+
72
+ | Model | JSON Valid | Argument Syntax Valid |
73
+ |:------|:---------:|:--------------------:|
74
+ | **LocoOperator-4B** | 76/76 (100%) | 76/76 (100%) |
75
+ | Qwen3-Coder-Next (teacher) | 89/89 (100%) | 78/89 (87.6%) |
76
+
77
+ > LocoOperator-4B achieves perfect structured output. The teacher model has 11 tool calls with missing required arguments (empty `arguments: {}`).
78
+
79
+ ## Quick Start
80
+
81
+ ```python
82
+ from transformers import AutoModelForCausalLM, AutoTokenizer
83
+
84
+ model_name = "LocoreMind/LocoOperator-4B"
85
+
86
+ # load the tokenizer and the model
87
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
88
+ model = AutoModelForCausalLM.from_pretrained(
89
+ model_name,
90
+ torch_dtype="auto",
91
+ device_map="auto"
92
+ )
93
+
94
+ # prepare the messages
95
+ messages = [
96
+ {
97
+ "role": "system",
98
+ "content": "You are a read-only codebase search specialist.\n\nCRITICAL CONSTRAINTS:\n1. STRICTLY READ-ONLY: You cannot create, edit, delete, move files, or run any state-changing commands. Use tools/bash ONLY for reading (e.g., ls, find, cat, grep).\n2. EFFICIENCY: Spawn multiple parallel tool calls for faster searching.\n3. OUTPUT RULES: \n - ALWAYS use absolute file paths.\n - STRICTLY NO EMOJIS in your response.\n - Output your final report directly. Do not use colons before tool calls.\n\nENV: Working directory is /Users/developer/workspace/code-analyzer (macOS, zsh)."
99
+ },
100
+ {
101
+ "role": "user",
102
+ "content": "Analyze the Black codebase at `/Users/developer/workspace/code-analyzer/projects/black`.\nFind and explain:\n1. How Black discovers config files.\n2. The exact search order for config files.\n3. Supported config file formats.\n4. Where this configuration discovery logic lives in the codebase.\n\nReturn a comprehensive answer with relevant code snippets and absolute file paths."
103
+ }
104
+ ]
105
+
106
+ # prepare the model input
107
+ text = tokenizer.apply_chat_template(
108
+ messages,
109
+ tokenize=False,
110
+ add_generation_prompt=True,
111
+ )
112
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
113
+
114
+ # conduct text completion
115
+ generated_ids = model.generate(
116
+ **model_inputs,
117
+ max_new_tokens=512,
118
+ )
119
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
120
+
121
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
122
+ print(content)
123
+ ```
124
+
125
+ ## Local Deployment
126
+
127
+ For GGUF quantized deployment with llama.cpp, hybrid proxy routing, and batch analysis pipelines, refer to our [GitHub repository](https://github.com/LocoreMind/LocoOperator).
128
+
129
+ ## Training Details
130
+
131
+ | Parameter | Value |
132
+ |:----------|:------|
133
+ | Base model | Qwen3-4B-Instruct-2507 |
134
+ | Teacher model | Qwen3-Coder-Next |
135
+ | Method | Full-parameter SFT |
136
+ | Training data | 170,356 samples |
137
+ | Hardware | 4x NVIDIA H200 141GB SXM5 |
138
+ | Parallelism | DDP (no DeepSpeed) |
139
+ | Precision | BF16 |
140
+ | Epochs | 1 |
141
+ | Batch size | 2/GPU, gradient accumulation 4 (effective batch 32) |
142
+ | Learning rate | 2e-5, warmup ratio 0.03 |
143
+ | Max sequence length | 16,384 tokens |
144
+ | Template | qwen3_nothinking |
145
+ | Framework | MS-SWIFT |
146
+ | Training time | ~25 hours |
147
+ | Checkpoint | Step 2524 |
148
+
149
+ ## Known Limitations
150
+
151
+ - First-tool-type match is 65.6% — the model sometimes picks a different (but not necessarily wrong) tool than the teacher
152
+ - Tends to under-generate parallel tool calls compared to the teacher (76 vs 89 total calls across 65 samples)
153
+ - Preference for Bash over Read may indicate the model defaults to shell commands where file reads would be more appropriate
154
+ - Evaluated on 65 samples only; larger-scale evaluation needed
155
+
156
+ ## License
157
+
158
+ MIT
159
+
160
+ ## Acknowledgments
161
+
162
+ - [Qwen Team](https://huggingface.co/Qwen) for the Qwen3-4B-Instruct-2507 base model
163
+ - [MS-SWIFT](https://github.com/modelscope/ms-swift) for the training framework
164
+ - [llama.cpp](https://github.com/ggerganov/llama.cpp) for efficient local inference
165
+ - [Anthropic](https://www.anthropic.com/) for the Claude Code agent loop design that inspired this work