Instructions to use modrill/Qwen3-4B-Base-ThinkCode-A-NH025 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use modrill/Qwen3-4B-Base-ThinkCode-A-NH025 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Base") model = PeftModel.from_pretrained(base_model, "modrill/Qwen3-4B-Base-ThinkCode-A-NH025") - Transformers
How to use modrill/Qwen3-4B-Base-ThinkCode-A-NH025 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="modrill/Qwen3-4B-Base-ThinkCode-A-NH025")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("modrill/Qwen3-4B-Base-ThinkCode-A-NH025", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use modrill/Qwen3-4B-Base-ThinkCode-A-NH025 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "modrill/Qwen3-4B-Base-ThinkCode-A-NH025" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modrill/Qwen3-4B-Base-ThinkCode-A-NH025", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/modrill/Qwen3-4B-Base-ThinkCode-A-NH025
- SGLang
How to use modrill/Qwen3-4B-Base-ThinkCode-A-NH025 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/Qwen3-4B-Base-ThinkCode-A-NH025" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modrill/Qwen3-4B-Base-ThinkCode-A-NH025", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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/Qwen3-4B-Base-ThinkCode-A-NH025" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modrill/Qwen3-4B-Base-ThinkCode-A-NH025", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use modrill/Qwen3-4B-Base-ThinkCode-A-NH025 with Docker Model Runner:
docker model run hf.co/modrill/Qwen3-4B-Base-ThinkCode-A-NH025
File size: 4,991 Bytes
aedefab | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | ---
license: apache-2.0
library_name: peft
pipeline_tag: text-generation
base_model: Qwen/Qwen3-4B-Base
base_model_relation: adapter
tags:
- peft
- lora
- transformers
- safetensors
- qwen3
- code
- text-generation
model-index:
- name: Qwen3-4B-Base-ThinkCode-A-NH025 PEFT Adapter
results:
- task:
type: text-generation
name: Code Generation
dataset:
name: EvalScope Full1055 corrected (development-only)
type: evalscope-full1055-corrected-development
metrics:
- type: pass@1
name: resolved aggregate code_only pass@1 (3 seeds)
value: 25.09
---
# Qwen3-4B-Base-ThinkCode-A-NH025 — PEFT Adapter
This repository contains a **PEFT LoRA adapter only**. It does not contain the
Qwen3 base-model weights and cannot be loaded as a standalone causal language
model.
The required base is
[`Qwen/Qwen3-4B-Base`](https://huggingface.co/Qwen/Qwen3-4B-Base) at the fixed
revision `906bfd4b4dc7f14ee4320094d8b41684abff8539`.
## Adapter construction
`A-NH025` is the Phase A no-head arm. Starting from the completed source LoRA,
every selected transformer-body LoRA `B` tensor is multiplied by `0.25` in
FP32, while the `lm_head` LoRA `B` tensor is multiplied by `0`, making its
effective head/shared-embedding delta exactly zero. LoRA `A` tensors are
unchanged. With `lora_alpha=128` and `r=64`, PEFT applies the intended body
delta without a language-model-head delta across the 253 declared modules.
The effective-zero `lm_head` adapter is omitted from the release state and
target list; this is exactly equivalent to its validated zero delta and avoids
packaging any base-layer tensor. `MODULE_SCALE_MANIFEST.json` retains the
explicit zero-head contract and records every logical module, source tensor
key, physical base weight, and scale. This release is from the completed Phase
A delta-scaling line; it is **not** the later failed NEXTGEN route and does not
include subsequent protocol-repair experiments.
## Loading with PEFT
Use recent `transformers` and `peft` versions. Load the fixed base first, then
attach this adapter:
```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_id = "Qwen/Qwen3-4B-Base"
base_revision = "906bfd4b4dc7f14ee4320094d8b41684abff8539"
adapter_id = "modrill/Qwen3-4B-Base-ThinkCode-A-NH025"
tokenizer = AutoTokenizer.from_pretrained(base_id, revision=base_revision)
base = AutoModelForCausalLM.from_pretrained(
base_id,
revision=base_revision,
torch_dtype="auto",
device_map="auto",
)
model = PeftModel.from_pretrained(base, adapter_id)
messages = [{"role": "user", "content": "Write a Python function that checks whether a number is prime."}]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
eos_ids = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|im_end|>"),
]
outputs = model.generate(**inputs, max_new_tokens=2048, eos_token_id=eos_ids)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))
```
The base tokenizer's chat template supports `enable_thinking`. Disable it for
direct code generation matching the concise screening style, or enable it when
explicit reasoning is desired. Pass both `<|endoftext|>` and `<|im_end|>` as
EOS IDs. Keep the combined prompt and generated sequence within **32K tokens**,
the fixed base model configuration limit, unless a separate long-context
extension is validated.
## Development evaluation
Across three preregistered seeds on the corrected EvalScope Full1055
development suite, the resolved `code_only` aggregate was
**794/3165 = 25.09%**. Relative to the fixed BASE, the estimated change was
approximately **+0.98 percentage points**, with an approximate 95% confidence
interval of **[+0.095, +1.833] percentage points**. The Holm-adjusted
**p-value was 0.489**.
These results are development-only, not a held-out formal claim. In the
original bidirectional scoring for `seed=3407`, some outcomes flipped between
PASS and TLE because of the execution environment. Those cases were resolved
by fixed single-CPU serial rejudgment, which does not eliminate all scorer,
timing, or environment uncertainty.
## Limitations
- This adapter requires the exact base model and should not be loaded alone.
- The evidence is development-only and includes scorer-environment uncertainty.
- Generated code can be incorrect, insecure, or non-compiling; sandbox and
test it independently.
- No production safety, security, or suitability certification is implied.
## License
The fixed base card and included license identify Apache-2.0. This adapter
preserves that license text and metadata. Users should independently verify the
upstream Qwen3 license, notices, training-data terms, and applicability to their
use case.
|