How qwenlm/qwen3-coder works
1. This repository is a model-centric monorepo for Qwen3-Coder: it contains the model README, demo apps, training scripts, and a large evaluation harness rather than a single product service. The main architectural split is between model development, model consumption, and benchmark/evaluation infrastructure.
2. The root README is effectively the public entrypoint. It describes the model family, supported context length, chat/FIM usage patterns, and external distribution channels. The repo itself does not host model weights; it hosts the code, prompts, and evaluation assets needed to use and measure the models.
3. The demo/ and assets/ areas are lightweight presentation layers. demo/chatbot and demo/artifacts suggest small runnable examples with static frontend assets plus a Python app/config bundle, while assets/qwen3-coder-next-demo stores demo media used in the README. These are isolated from the training/evaluation pipelines.
4. The examples/ directory is a usage cookbook for inference patterns: normal chat completion, streaming, fill-in-the-middle, and repo-level code completion. These scripts are thin integration examples and sit at the boundary between the tokenizer/model API and the consumer application.
5. finetuning/sft is the supervised fine-tuning pipeline. It includes data preparation, binary data conversion, model download/merge utilities, LoRA support, and training entrypoints. The important flow here is: raw code/execution data → preprocessing/binarization → training → optional adapter merge → released weights or adapters.
6. finetuning/dpo is a separate preference-optimization pipeline. Its configuration files, DeepSpeed zero configs, shell scripts, and train.py indicate a distributed training path for alignment after SFT. This subsystem is narrower than SFT: it consumes prepared preference data and produces a better-aligned checkpoint.
7. The largest architectural block is qwencoder-eval/, which contains multiple benchmark families and orchestration code. It is organized by evaluation mode (base, instruct, reasoning, tool_calling_eval) and by benchmark suite, so it acts as an umbrella over many semi-independent evaluation subsystems.
8. qwencoder-eval/base and qwencoder-eval/instruct hold many benchmark adapters and their output artifacts. Common benchmark families include BigCodeBench, EvalPlus, CruxEval, FIM-Bench, MultiPL-E, Aider, Bird/Spider, CodeArena, PlotCraft, LiveCodeBench, and others. Each family typically includes prompt generation, inference runners, execution/evaluation code, and stored results, so the repo preserves both code and benchmark outputs.
9. The evaluation harnesses are intentionally multi-language and sandboxed. There are Python runners for most benchmarks, a Go-based core in instruct/eval-dev-quality, plus language-specific evaluators and “safe_subprocess” sandboxes to control untrusted code execution. This is a key architectural boundary: model-generated code is executed only inside constrained runners with separate evaluation logic per language/task type.
10. qwencoder-eval/instruct/eval-dev-quality is its own substantial product-like subsystem. It has Go modules for CLI, evaluation, reporting, language abstraction, model/provider abstraction, and tooling. The data flow is: repository tasks and test fixtures → model/provider invocation → task execution and scoring → CSV/Markdown report generation. It also stores historical report snapshots under docs/reports/.
11. That Go-based evaluation system is layered by concern: language/ models language-specific behavior, model/ describes model capabilities and prompt parsing, provider/ wraps external/local inference backends, evaluate/ runs tasks and computes metrics, tools/ installs or configures external utilities, and util/ contains execution and I/O helpers. This makes it a clean architecture diagram candidate with explicit domain, provider, and reporting boundaries.
12. External inference backends are a material part of the architecture. Across the eval suites and BFCL/Tau-Bench, the repo integrates with OpenAI-compatible APIs, Anthropic, OpenRouter, Ollama, vLLM, Symflower, and model-specific handlers. These are not just optional adapters; they determine how prompts are sent, how tool calls are parsed, and whether evaluation runs locally or against hosted APIs.
13. qwencoder-eval/tool_calling_eval focuses on tool/function-calling benchmarks. It vendors the Berkeley Function Calling Leaderboard and TAU-Bench, including model handlers, parsers, task definitions, and datasets for multi-turn and tool-using scenarios. This subsystem is centered on structured output validation rather than pure code generation.
14. The repo also commits benchmark corpora, cached outputs, and result tables alongside the code. That means the architecture includes an artifact layer: datasets in data/ and testdata/, generated generations/results in results/, and summarized CSV/JSON reports in docs/reports/, outptus/, and other output directories. For diagramming, treat these as persistent evaluation artifacts flowing from the runners.
15. In short, the repository is organized as: model usage examples and demos at the edge; SFT/DPO pipelines for model improvement; and a large, benchmark-heavy evaluation platform with isolated task runners, sandboxed execution, and provider adapters. The strongest architectural boundaries are between data preparation, model invocation, code execution, and report aggregation.
Main entry points: instruct/README.md Eval hub · train.py SFT · README.md README · main.go Dev quality
Components 21
Entry & usage
Public docs, demos, and consumer examples
- README · Public overview and usage entrypoint for Qwen3-Coder.
README.md - Chatbot · Runnable chat demo wrapper.
demo/chatbot/app.py - Artifacts · Small presentation app with static assets and config.
demo/artifacts/app.py - Examples · Thin scripts showing chat, streaming, FIM, and repo-level completion patterns.
examples/Qwen2.5-Coder.py
Training
Supervised and preference optimization pipelines
- SFT · Supervised fine-tuning pipeline for code execution data and adapters.
finetuning/sft/train.py - Data prep · Prepares, binarizes, and decontaminates training data.
finetuning/sft/prepare_code_execution_data.py - LoRA merge · Downloads models and merges adapters after fine-tuning.
finetuning/sft/merge_adapter.py - DPO · Distributed preference-optimization stage after SFT.
finetuning/dpo/train.py
Evaluation
Benchmark harnesses, runners, and stored results
- Eval hub · Top-level evaluation workspace spanning multiple benchmark families and modes.
qwencoder-eval/instruct/README.md - Dev quality · Go-based quality evaluation system with CLI, language, model, provider, and reporting layers.
qwencoder-eval/instruct/eval-dev-quality/cmd/eval-dev-quality/main.go - Base evals · Base-generation benchmark adapters and stored outputs.
qwencoder-eval/base/readme.md - Instruct evals · Instruction-following benchmark adapters and outputs.
qwencoder-eval/instruct/evaluate.sh - Reasoning · Reasoning-oriented LiveCodeBench CoT evaluation flow.
qwencoder-eval/reasoning/livecode_bench_cot/README.md - Languages · Language-specific execution, coverage, and test semantics for eval tasks.
qwencoder-eval/instruct/eval-dev-quality/language/language.go - Reports · CSV/Markdown report generation and stored historical reports.
qwencoder-eval/instruct/eval-dev-quality/evaluate/report/markdown.go - Base suites · Core code-generation suites such as BigCodeBench, EvalPlus, CruxEval, FIM-Bench, and MultiPL-E.
qwencoder-eval/base/benchmarks/bigcodebench/generate.py - Instruct suites · Instruction benchmarks such as Aider, Bird/Spider, CodeArena, PlotCraft, LiveCodeBench, and MultiPL-E chat.
qwencoder-eval/instruct/aider/benchmark/benchmark.py
Tool calling
Structured-function-calling evaluation stacks
- Tool calling · Function-calling and agentic benchmark harnesses.
qwencoder-eval/tool_calling_eval/README.md - Providers · API and local inference backends used by evaluation harnesses.
qwencoder-eval/instruct/eval-dev-quality/provider/provider.go - BFCL · Berkeley Function Calling Leaderboard adapters, parsers, and model handlers.
qwencoder-eval/tool_calling_eval/berkeley-function-call-leaderboard/bfcl_eval/__main__.py - TAU-Bench · Tool-using airline and retail environments with agents and model utilities.
qwencoder-eval/tool_calling_eval/tau-bench/tau_bench/run.py
Connections 23
- README → Chatbot: introduces · The root README points users to runnable demos.
- README → Examples: documents · README describes chat, streaming, and FIM usage patterns.
- README → SFT: describes · The repository frames SFT as a core model-improvement path.
- README → Eval hub: orients · The README is the entrypoint for the evaluation-heavy monorepo.
- Chatbot → Artifacts: shares UI layer · Both demos are lightweight presentation surfaces.
- Examples → SFT: consumes model · Examples exercise the model interface at inference time.
- Data prep → SFT: feeds · Prepared and binarized data flows into training.
- SFT → LoRA merge: produces · Training can emit adapters that are later merged.
- DPO → SFT: refines · DPO consumes a prior SFT checkpoint.
- Eval hub → Base evals: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Eval hub → Instruct evals: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Eval hub → Reasoning: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Eval hub → Tool calling: organizes · Evaluation is split into base, instruct, reasoning, and tool-calling modes.
- Base evals → Base suites: contains · Base evaluation aggregates multiple code-generation suites.
- Instruct evals → Instruct suites: contains · Instruct evaluation aggregates many task-specific suites.
- Reasoning → Instruct suites: reuses runner · Reasoning evaluation reuses the code-generation runner pattern with CoT flows.
- Tool calling → BFCL: vendors · BFCL is one of the main tool-calling benchmarks.
- Tool calling → TAU-Bench: vendors · TAU-Bench provides multi-turn tool-using environments.
- Dev quality → Providers: adapts · The Go evaluator wraps local and remote inference providers.
- Dev quality → Languages: abstracts · Language-specific execution behavior is isolated in its own layer.
- Dev quality → Reports: emits · Evaluation results are summarized into CSV and Markdown reports.
- Providers → Reports: drives runs · Backend choice determines how prompts are executed and recorded.
- Languages → Dev quality: constrains execution · Execution and scoring depend on language-specific semantics and sandboxes.