CoolFace
Modelpublic

LocoreMind/LocoOperator-4B

sourceHugging Facemitupdated 7mo agoView on Hugging Face
278likes175downloads
Model Card

<div align="center"> <img src="assets/loco_operator.png" width="55%" alt="LocoOperator" /> </div>

<br>

<div align="center">

![MODEL](https://huggingface.co/LocoreMind/LocoOperator-4B) ![GGUF](https://huggingface.co/LocoreMind/LocoOperator-4B-GGUF) ![Blog](https://locoremind.com/blog/loco-operator) ![GitHub](https://github.com/LocoreMind/LocoOperator) ![Colab](https://colab.research.google.com/github/LocoreMind/LocoOperator/blob/main/LocoOperator_4B.ipynb)

</div>

Introduction

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.

LocoOperator-4B
Base ModelQwen3-4B-Instruct-2507
Teacher ModelQwen3-Coder-Next
Training MethodFull-parameter SFT (distillation)
Training Data170,356 multi-turn conversation samples
Max Sequence Length16,384 tokens
Training Hardware4x NVIDIA H200 141GB SXM5
Training Time~25 hours
FrameworkMS-SWIFT

Key Features

  • Tool-Calling Agent: Generates structured <tool_call> JSON for Read, Grep, Glob, Bash, Write, Edit, and Task (subagent delegation)
  • 100% JSON Validity: Every tool call is valid JSON with all required arguments — outperforming the teacher model (87.6%)
  • Local Deployment: GGUF quantized, runs on Mac Studio via llama.cpp at zero API cost
  • Lightweight Explorer: 4B parameters, optimized for fast codebase search and navigation
  • Multi-Turn: Handles conversation depths of 3–33 messages with consistent tool-calling behavior

Performance

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.

Core Metrics

MetricScore
Tool Call Presence Alignment100% (65/65)
First Tool Type Match65.6% (40/61)
JSON Validity100% (76/76)
Argument Syntax Correctness100% (76/76)

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.

Tool Distribution Comparison

<div align="center"> <img src="assets/tool_distribution.png" width="80%" alt="Tool Distribution Comparison" /> </div>

JSON & Argument Syntax Correctness

ModelJSON ValidArgument Syntax Valid
LocoOperator-4B76/76 (100%)76/76 (100%)
Qwen3-Coder-Next (teacher)89/89 (100%)78/89 (87.6%)
LocoOperator-4B achieves perfect structured output. The teacher model has 11 tool calls with missing required arguments (empty arguments: {}).

Quick Start

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "LocoreMind/LocoOperator-4B"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)

# prepare the messages
messages = [
    {
        "role": "system",
        "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)."
    },
    {
        "role": "user",
        "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."
    }
]

# prepare the model input
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

# conduct text completion
generated_ids = model.generate(
    **model_inputs,
    max_new_tokens=512,
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()

content = tokenizer.decode(output_ids, skip_special_tokens=True)
print(content)

Local Deployment

For GGUF quantized deployment with llama.cpp, hybrid proxy routing, and batch analysis pipelines, refer to our GitHub repository.

Training Details

ParameterValue
Base modelQwen3-4B-Instruct-2507
Teacher modelQwen3-Coder-Next
MethodFull-parameter SFT
Training data170,356 samples
Hardware4x NVIDIA H200 141GB SXM5
ParallelismDDP (no DeepSpeed)
PrecisionBF16
Epochs1
Batch size2/GPU, gradient accumulation 4 (effective batch 32)
Learning rate2e-5, warmup ratio 0.03
Max sequence length16,384 tokens
Templateqwen3_nothinking
FrameworkMS-SWIFT
Training time~25 hours
CheckpointStep 2524

Known Limitations

  • First-tool-type match is 65.6% — the model sometimes picks a different (but not necessarily wrong) tool than the teacher
  • Tends to under-generate parallel tool calls compared to the teacher (76 vs 89 total calls across 65 samples)
  • Preference for Bash over Read may indicate the model defaults to shell commands where file reads would be more appropriate
  • Evaluated on 65 samples only; larger-scale evaluation needed

License

MIT

Acknowledgments

  • Qwen Team for the Qwen3-4B-Instruct-2507 base model
  • MS-SWIFT for the training framework
  • llama.cpp for efficient local inference
  • Anthropic for the Claude Code agent loop design that inspired this work