Text Generation
Transformers
Safetensors
qwen3
code
reasoning
lora-merged
livecodebench
conversational
text-generation-inference
Instructions to use modrill/code-think-q4b-20260908 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use modrill/code-think-q4b-20260908 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="modrill/code-think-q4b-20260908") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("modrill/code-think-q4b-20260908") model = AutoModelForCausalLM.from_pretrained("modrill/code-think-q4b-20260908", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use modrill/code-think-q4b-20260908 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "modrill/code-think-q4b-20260908" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modrill/code-think-q4b-20260908", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/modrill/code-think-q4b-20260908
- SGLang
How to use modrill/code-think-q4b-20260908 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "modrill/code-think-q4b-20260908" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modrill/code-think-q4b-20260908", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "modrill/code-think-q4b-20260908" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modrill/code-think-q4b-20260908", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use modrill/code-think-q4b-20260908 with Docker Model Runner:
docker model run hf.co/modrill/code-think-q4b-20260908
|
Download README.md from modrill/code-think-q4b-20260908: direct link, hf CLI and curl.
- Browser
- Download file 5.65 kB
-
https://huggingface.co/modrill/code-think-q4b-20260908/resolve/main/README.md
- Command line
-
hf download hf://modrill/code-think-q4b-20260908/README.md
-
curl -L -o README.md https://huggingface.co/modrill/code-think-q4b-20260908/resolve/main/README.md
5.65 kB
| license: apache-2.0 | |
| base_model: Qwen/Qwen3-4B-Base | |
| tags: | |
| - code | |
| - reasoning | |
| - lora-merged | |
| - livecodebench | |
| pipeline_tag: text-generation | |
| library_name: transformers | |
| # code-think-q4b-20260908 | |
| Research checkpoint: **Qwen/Qwen3-4B-Base** (`906bfd4b4dc7f14ee4320094d8b41684abff8539`) after V4 LoRA SFT on a **Mix Distillation** payload, then merged to full weights. | |
| This is a **research checkpoint, not a product**. Single-seed diagnostic numbers only. Do not treat DEV256 as a leaderboard claim. | |
| License: **Apache-2.0**, inherited from [Qwen/Qwen3-4B-Base](https://huggingface.co/Qwen/Qwen3-4B-Base) (verified from the local base `README.md` / `LICENSE`). | |
| ## Base, teacher, and data | |
| | | | | |
| |---|---| | |
| | Student | `Qwen/Qwen3-4B-Base` revision `906bfd4b4dc7f14ee4320094d8b41684abff8539` | | |
| | Recipe | Mix Distillation **Mix-Large** (Li et al., 2025, ["Small Models Struggle to Learn from Strong Reasoners"](https://arxiv.org/abs/2502.12143), arXiv:2502.12143): **0.2** traces from `Qwen/Qwen3-30B-A3B-Thinking-2507` : **0.8** traces from `Qwen/Qwen3-4B-Thinking-2507`, one teacher trace per problem | | |
| | Problems | **4155** unique problems (`source_1ep_rows`); physical 2-epoch concat = **8310** rows | | |
| | Mix split | **831** (30B) : **3324** (4B) rows in the 1-epoch mix (`n30`/`n4`) | | |
| | Dose | **32,424,225** assistant tokens / epoch; endpoint **64,848,450** assistant tokens (2 epochs) | | |
| | Train seed | **42** | | |
| ## Recipe | |
| - LoRA **r64 / α128**, dropout 0.0, seven projections: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` | |
| - Embeddings / `lm_head` frozen except **two-sided trainable B-rows** for special tokens **151643** (`<|endoftext|>`), **151667** (`<think>`), **151668** (`</think>`). Qwen3-4B-Base embeddings were tied; training **untied** them. Token ids from `adapter/TOKEN_ROWS_META.json`. | |
| - Assistant supervised tail: `<|endoftext|>` (**151643**) | |
| - LR **1e-4**, AdamW (β 0.9/0.95), **cosine** over assistant-token dose, **warmup 6%** (3,890,907 / 64,848,450 tokens), weight decay **0.1** (LoRA; row WD 0) | |
| - **bf16** activations, fp32 trainable masters, no packing, no truncation, context 32768 | |
| - **2 epochs**, physical concat of the 1-epoch mix (same order). Endpoint-only score; no checkpoint picking. | |
| Merged weights in this repo are the 2-epoch endpoint (`step-000920`, 64,848,450 assistant tokens). The LoRA adapter and B-row file are under `adapter/`. | |
| ## Evaluation (DEV256) | |
| 256-problem LiveCodeBench-derived **dev** split. Seed **3407**, **think** mode, **no `<think>` prefill**, max generation ~32k (model context 32768), sandbox-verified **pass@1**. Temperature 0.6, top-p 0.95, top-k 20. | |
| **Cap** = generations that hit the 32k length limit without closing `</think>`. | |
| | Model | pass@1 | Cap | Notes | | |
| |---|---:|---:|---| | |
| | **code-think-q4b-20260908** | **73/256** | **136** | this repo; seed 3407 | | |
| | Qwen3-4B-Base (same contract, think) | 63/256 | 6 | bare base, seed 3407 | | |
| | Qwen3-4B-Base 5-seed band | 55.2 ± 4.9 | — | seeds {3407→61, 12345→52, 20260903→49, 777→55, 2024→59}; sample SD 4.92 | | |
| Single seed. These are research checkpoints, not product scores. | |
| ### Why Mix (sibling V4 controls) | |
| Pure strong-teacher traces **hurt** this 4B student; a same-size teacher and the 0.2:0.8 mix did not: | |
| | Sibling (same student / recipe family) | pass@1 | Cap | | |
| |---|---:|---:| | |
| | V4 Q4B-THINK (100% 30B-A3B-Thinking traces) | 60/256 | 150 | | |
| | V4 Q4B-THINK-T4BDATA (100% 4B-Thinking traces) | 72/256 | 106 | | |
| | **This Mix 0.2 : 0.8** | **73/256** | **136** | | |
| That pattern matches Li et al. 2025 (arXiv:2502.12143): small students often learn worse from much stronger reasoners than from a mixed or same-size teacher. | |
| ## Usage | |
| Merged full weights; no PEFT required at inference. Think mode: pass `enable_thinking=True` and **do not** prefill `<think>`. | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| repo = "modrill/code-think-q4b-20260908" | |
| tokenizer = AutoTokenizer.from_pretrained(repo) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| repo, torch_dtype="bfloat16", device_map="auto" | |
| ) | |
| system = ( | |
| "You are an expert Python programmer. You will be given a question " | |
| "(problem specification) and will generate a correct Python program that " | |
| "matches the specification and passes all tests. You will NOT return " | |
| "anything except for the program." | |
| ) | |
| messages = [ | |
| {"role": "system", "content": system}, | |
| {"role": "user", "content": problem_statement}, | |
| ] | |
| prompt = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True, | |
| enable_thinking=True, # think mode; no <think> prefill | |
| ) | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| output = model.generate( | |
| **inputs, | |
| max_new_tokens=32768, | |
| do_sample=True, | |
| temperature=0.6, | |
| top_p=0.95, | |
| top_k=20, | |
| ) | |
| print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)) | |
| ``` | |
| Stop ids used in the official eval: `151643` (`<|endoftext|>`), `151645` (`<|im_end|>`). | |
| ## Repo layout | |
| - Root: merged HF weights (`config.json`, `model.safetensors`, tokenizer, `generation_config.json`, `chat_template.jinja`) plus the merge record `OFFICIAL_MERGE_RECEIPT.json` | |
| - `adapter/`: LoRA (`adapter_config.json`, `adapter_model.safetensors`), two-sided B-rows (`token_rows_both_sides.safetensors`), `TOKEN_ROWS_META.json`, checkpoint `MANIFEST.json` | |
| - `provenance/`: train `RUN_IDENTITY.json`, `TRAINING_CONFIG.json`, `POLICY.json`; DEV256 `COMPLETE.json`; mix builder and MQ0 near-dup report | |
| - `MANIFEST.sha256`: sha256 of every uploaded file | |
| Optimizer / resume states are **not** included. | |