Flexan commited on
Commit
b357013
·
verified ·
1 Parent(s): cb63bcc

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ 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-4B.f16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ LocoOperator-4B.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
38
+ LocoOperator-4B.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
39
+ LocoOperator-4B.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
LocoOperator-4B.Q2_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18fbe3deb8ff557dd6f998d4070a884bc261944fa1a70c94819ba256e29db0df
3
+ size 1669498272
LocoOperator-4B.Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8769347274179f9ef5f848f0f488e1047d3cfeb073bdd3c82911973377e28cfa
3
+ size 2497279392
LocoOperator-4B.Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:139746bf0bca169a683214c651a2516517678712b106dcf48f0175ab0b5c05a8
3
+ size 4280403872
LocoOperator-4B.f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:548c8d5c47701628c31228656ac7989a11a4c8023f98ffef37a42a7eca690062
3
+ size 8051283872
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: mit
4
+ base_model: LocoreMind/LocoOperator-4B
5
+ tags:
6
+ - code
7
+ - agent
8
+ - tool-calling
9
+ - distillation
10
+ - qwen3
11
+ - gguf
12
+ - llama-cpp
13
+ language:
14
+ - en
15
+ pipeline_tag: text-generation
16
+ ---
17
+
18
+ # GGUF Files for LocoOperator-4B
19
+
20
+ These are the GGUF files for [LocoreMind/LocoOperator-4B](https://huggingface.co/LocoreMind/LocoOperator-4B).
21
+
22
+ > [!NOTE]
23
+ > **Note:** this model has only been quantized to **Q2_K**, **Q4_K_M**, and **Q8_0**. Other quantizations may become available later.
24
+
25
+ ## Downloads
26
+
27
+ | GGUF Link | Quantization | Description |
28
+ | ---- | ----- | ----------- |
29
+ | [Download](https://huggingface.co/Flexan/LocoreMind-LocoOperator-4B-GGUF/resolve/main/LocoOperator-4B.Q2_K.gguf) | Q2_K | Lowest quality |
30
+ | [Download](https://huggingface.co/Flexan/LocoreMind-LocoOperator-4B-GGUF/resolve/main/LocoOperator-4B.Q4_K_M.gguf) | Q4_K_M | **Recommended:** Perfect mix of speed and performance |
31
+ | [Download](https://huggingface.co/Flexan/LocoreMind-LocoOperator-4B-GGUF/resolve/main/LocoOperator-4B.Q8_0.gguf) | Q8_0 | Best quality |
32
+ | [Download](https://huggingface.co/Flexan/LocoreMind-LocoOperator-4B-GGUF/resolve/main/LocoOperator-4B.f16.gguf) | f16 | Full precision, don't bother; use a quant |
33
+
34
+ ## Note from Flexan
35
+
36
+ I provide GGUFs and quantizations of publicly available models that do not have a GGUF equivalent available yet.
37
+ This process is not yet automated and I download, convert, quantize, and upload them **by hand**, usually for models **I deem interesting and wish to try out**.
38
+
39
+ If there are some quants missing that you'd like me to add, you may request one in the community tab.
40
+ If you want to request a public model to be converted, you can also request that in the community tab.
41
+ If you have questions regarding the model, please refer to the original model repo.
42
+
43
+ # Model Card for LocoOperator-4B
44
+
45
+ <div align="center">
46
+ <img src="assets/loco_operator.png" width="55%" alt="LocoOperator" />
47
+ </div>
48
+
49
+ <br>
50
+
51
+ <div align="center">
52
+
53
+ [![MODEL](https://img.shields.io/badge/Model-FFB300?style=for-the-badge&logo=huggingface&logoColor=white)](https://huggingface.co/LocoreMind/LocoOperator-4B)
54
+ [![Blog](https://img.shields.io/badge/Blog-4285F4?style=for-the-badge&logo=google-chrome&logoColor=white)](https://locoremind.com/blog/loco-operator)
55
+ [![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/LocoreMind/LocoOperator)
56
+ [![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)
57
+
58
+ </div>
59
+
60
+ ## Introduction
61
+
62
+ **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.
63
+
64
+ | | LocoOperator-4B |
65
+ |:--|:--|
66
+ | **Base Model** | [Qwen3-4B-Instruct-2507](https://huggingface.co/Qwen/Qwen3-4B-Instruct-2507) |
67
+ | **Teacher Model** | Qwen3-Coder-Next |
68
+ | **Training Method** | Full-parameter SFT (distillation) |
69
+ | **Training Data** | 170,356 multi-turn conversation samples |
70
+ | **Max Sequence Length** | 16,384 tokens |
71
+ | **Training Hardware** | 4x NVIDIA H200 141GB SXM5 |
72
+ | **Training Time** | ~25 hours |
73
+ | **Framework** | MS-SWIFT |
74
+
75
+ ## Key Features
76
+
77
+ - **Tool-Calling Agent**: Generates structured `<tool_call>` JSON for Read, Grep, Glob, Bash, Write, Edit, and Task (subagent delegation)
78
+ - **100% JSON Validity**: Every tool call is valid JSON with all required arguments — outperforming the teacher model (87.6%)
79
+ - **Local Deployment**: GGUF quantized, runs on Mac Studio via llama.cpp at zero API cost
80
+ - **Lightweight Explorer**: 4B parameters, optimized for fast codebase search and navigation
81
+ - **Multi-Turn**: Handles conversation depths of 3–33 messages with consistent tool-calling behavior
82
+
83
+ ## Performance
84
+
85
+ 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.
86
+
87
+ ### Core Metrics
88
+
89
+ | Metric | Score |
90
+ |:-------|:-----:|
91
+ | **Tool Call Presence Alignment** | **100%** (65/65) |
92
+ | **First Tool Type Match** | **65.6%** (40/61) |
93
+ | **JSON Validity** | **100%** (76/76) |
94
+ | **Argument Syntax Correctness** | **100%** (76/76) |
95
+
96
+ 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.
97
+
98
+ ### Tool Distribution Comparison
99
+
100
+ <div align="center">
101
+ <img src="assets/tool_distribution.png" width="80%" alt="Tool Distribution Comparison" />
102
+ </div>
103
+
104
+ ### JSON & Argument Syntax Correctness
105
+
106
+ | Model | JSON Valid | Argument Syntax Valid |
107
+ |:------|:---------:|:--------------------:|
108
+ | **LocoOperator-4B** | 76/76 (100%) | 76/76 (100%) |
109
+ | Qwen3-Coder-Next (teacher) | 89/89 (100%) | 78/89 (87.6%) |
110
+
111
+ > LocoOperator-4B achieves perfect structured output. The teacher model has 11 tool calls with missing required arguments (empty `arguments: {}`).
112
+
113
+ ## Quick Start
114
+
115
+ ```python
116
+ from transformers import AutoModelForCausalLM, AutoTokenizer
117
+
118
+ model_name = "LocoreMind/LocoOperator-4B"
119
+
120
+ # load the tokenizer and the model
121
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
122
+ model = AutoModelForCausalLM.from_pretrained(
123
+ model_name,
124
+ torch_dtype="auto",
125
+ device_map="auto"
126
+ )
127
+
128
+ # prepare the messages
129
+ messages = [
130
+ {
131
+ "role": "system",
132
+ "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)."
133
+ },
134
+ {
135
+ "role": "user",
136
+ "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."
137
+ }
138
+ ]
139
+
140
+ # prepare the model input
141
+ text = tokenizer.apply_chat_template(
142
+ messages,
143
+ tokenize=False,
144
+ add_generation_prompt=True,
145
+ )
146
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
147
+
148
+ # conduct text completion
149
+ generated_ids = model.generate(
150
+ **model_inputs,
151
+ max_new_tokens=512,
152
+ )
153
+ output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
154
+
155
+ content = tokenizer.decode(output_ids, skip_special_tokens=True)
156
+ print(content)
157
+ ```
158
+
159
+ ## Local Deployment
160
+
161
+ For GGUF quantized deployment with llama.cpp, hybrid proxy routing, and batch analysis pipelines, refer to our [GitHub repository](https://github.com/LocoreMind/LocoOperator).
162
+
163
+ ## Training Details
164
+
165
+ | Parameter | Value |
166
+ |:----------|:------|
167
+ | Base model | Qwen3-4B-Instruct-2507 |
168
+ | Teacher model | Qwen3-Coder-Next |
169
+ | Method | Full-parameter SFT |
170
+ | Training data | 170,356 samples |
171
+ | Hardware | 4x NVIDIA H200 141GB SXM5 |
172
+ | Parallelism | DDP (no DeepSpeed) |
173
+ | Precision | BF16 |
174
+ | Epochs | 1 |
175
+ | Batch size | 2/GPU, gradient accumulation 4 (effective batch 32) |
176
+ | Learning rate | 2e-5, warmup ratio 0.03 |
177
+ | Max sequence length | 16,384 tokens |
178
+ | Template | qwen3_nothinking |
179
+ | Framework | MS-SWIFT |
180
+ | Training time | ~25 hours |
181
+ | Checkpoint | Step 2524 |
182
+
183
+ ## Known Limitations
184
+
185
+ - First-tool-type match is 65.6% — the model sometimes picks a different (but not necessarily wrong) tool than the teacher
186
+ - Tends to under-generate parallel tool calls compared to the teacher (76 vs 89 total calls across 65 samples)
187
+ - Preference for Bash over Read may indicate the model defaults to shell commands where file reads would be more appropriate
188
+ - Evaluated on 65 samples only; larger-scale evaluation needed
189
+
190
+ ## License
191
+
192
+ MIT
193
+
194
+ ## Acknowledgments
195
+
196
+ - [Qwen Team](https://huggingface.co/Qwen) for the Qwen3-4B-Instruct-2507 base model
197
+ - [MS-SWIFT](https://github.com/modelscope/ms-swift) for the training framework
198
+ - [llama.cpp](https://github.com/ggerganov/llama.cpp) for efficient local inference
199
+ - [Anthropic](https://www.anthropic.com/) for the Claude Code agent loop design that inspired this work