初始化项目,由ModelHub XC社区提供模型

Model: dmaheshwar22/qwen-1.5b-coder-grpo-scratch-step200
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-05-08 18:33:37 +08:00
commit c1d8c5704b
12 changed files with 151984 additions and 0 deletions

36
.gitattributes vendored Normal file
View File

@@ -0,0 +1,36 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

165
README.md Normal file
View File

@@ -0,0 +1,165 @@
---
license: apache-2.0
base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
language:
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- code
- python
- reinforcement-learning
- grpo
- rlvr
- verifiable-rewards
datasets:
- evalplus/mbppplus
- evalplus/humanevalplus
---
# Qwen-2.5-Coder-1.5B — GRPO from base, 200 steps
GRPO-trained variant of `Qwen/Qwen2.5-Coder-1.5B-Instruct`, optimized with
**verifiable rewards from sandboxed test execution** — same family of
techniques behind DeepSeek-R1 and Kimi-K1.5, scaled down to a 1.5B model
that fits on a single 24 GB GPU.
> **Honest framing:** this is a **pipeline-validation run**, not the
> headline checkpoint. Trained from base (no SFT warm-start), 200 steps,
> single A100. Pass@1 on HumanEval+ is essentially tied with the SFT
> baseline — see [Results](#results) for numbers. The headline run
> (SFT-warmstarted, 500+ steps) is forthcoming as a separate model.
## Training setup
| | |
|---|---|
| Base model | `Qwen/Qwen2.5-Coder-1.5B-Instruct` |
| RL algorithm | GRPO (group-relative policy optimization) |
| RL framework | [verl](https://github.com/volcengine/verl) v0.7.0 |
| Rollout engine | vLLM |
| Group size (samples per prompt) | 8 |
| Train batch | 32 prompts × 8 rollouts = 256 candidates per step |
| Learning rate | 1e-6 |
| KL coefficient (loss-side) | 0.04, low-variance KL |
| KL coefficient (reward-side) | 0.001 |
| Temperature (rollout) | 1.0 |
| Total steps | 200 |
| Hardware | 1× A100 80 GB (FSDP with CPU offload) |
| Warm-start | None — trained from base instruct model |
| Training data | 319 MBPP-train prompts (MBPP+ contamination removed) |
### Reward function
Each rollout is scored by a composite reward executed in a sandboxed
Docker container running pytest:
- **Test-pass rate** (primary signal) — fraction of hidden tests passing
- **Lint reward** — `ruff` clean code bonus
- **Length penalty** — anti-verbosity
- **Compile-error penalty** — hard penalty for non-runnable code
All numeric rewards are bounded in `[0, ~1.1]` to keep GRPO group-relative
advantages well-scaled.
## Results
Greedy decoding, n=5 samples, temperature=0.2, evaluated with
[evalplus](https://github.com/evalplus/evalplus):
| Setup | HumanEval+ pass@1 | HumanEval+ pass@5 |
|---|---|---|
| Qwen-2.5-Coder-1.5B base | 0.627 | — |
| + SFT (3 epochs LoRA on rejection-sampled MBPP) | 0.638 | — |
| **+ GRPO from base, 200 steps (this model)** | **0.6415** | **0.6890** |
| + SFT + Coordinator retry (max 3 rounds) | 0.677 | — |
| Best-of-8 @ T=0.7 (oracle ceiling) | 0.783 | — |
**Reading the numbers honestly:**
- +1.4 pts over base, +0.4 pts over SFT — the SFT delta is within noise
(no paired bootstrap significance at p<0.05 on 164 problems).
- Pass@5 = 0.689 implies the policy *can* solve ~69% of HumanEval+; the
4.7-pt gap to pass@1 says it picks the wrong sample at temp=0.2 about
5% of the time. There's headroom this is not a converged policy.
- Most likely cause of the modest lift: trained from base instead of
SFT-warmstarted, and stopped at step 200. The
[WEEK4_GUIDE](https://github.com/Devesh-Maheshwari/verifiable-rl-coder/blob/main/docs/WEEK4_GUIDE.md)
projection of 0.680.75 assumes both SFT warm-start and 5001000 steps.
## Intended use
- **Research and education** concrete reference for end-to-end GRPO with
verifiable rewards on a small open coder. Reward function, sandbox, and
training config are all open-source in the
[companion repo](https://github.com/Devesh-Maheshwari/verifiable-rl-coder).
- **NOT for production inference** at 0.64 pass@1 it is no stronger than
the SFT baseline; use the headline run (forthcoming) for that.
## How to use
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "dmaheshwar22/qwen-1.5b-coder-grpo-scratch-step200"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="bfloat16", device_map="auto")
prompt = "Write a Python function `is_prime(n: int) -> bool` that returns True iff n is prime."
messages = [{"role": "user", "content": prompt}]
inputs = tok.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
out = model.generate(inputs, max_new_tokens=256, temperature=0.2, do_sample=True)
print(tok.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
```
Or with vLLM for batched evaluation:
```python
from vllm import LLM, SamplingParams
llm = LLM(model="dmaheshwar22/qwen-1.5b-coder-grpo-scratch-step200",
gpu_memory_utilization=0.5, dtype="bfloat16")
out = llm.generate(["def is_prime(n):"],
SamplingParams(max_tokens=256, temperature=0.2))
print(out[0].outputs[0].text)
```
## Limitations
- **Coding-only.** Trained on MBPP-style Python tasks; do not expect
general-purpose chat or reasoning quality outside coding.
- **Output format.** Despite the in-training markdown-fence stripping fix,
the policy occasionally still wraps code in ```` ``` ````. Strip fences
in any downstream evaluator.
- **Sandbox required for reward replay.** Reproducing the training reward
signal requires running pytest in a Docker container with the project's
resource limits — see the companion repo's `sandbox/runner.py`.
- **Not safety-tuned.** Inherits all behaviors of the base instruct model.
## Reproduction
Full training config, reward function, and sandbox runner are in the
companion repo:
- Repo: <https://github.com/Devesh-Maheshwari/verifiable-rl-coder>
- Training config: `configs/grpo_qwen1_5b.yaml`
- Reward fn: `src/verifiable_rl_coder/training/grpo_reward.py`
- Sandbox: `src/verifiable_rl_coder/sandbox/runner.py`
- CHTC submit scripts: `chtc/train_grpo.{sub,sh}`, `chtc/submit_train_grpo.sh`
## Citation
```bibtex
@misc{verifiable-rl-coder-2026,
author = {Maheshwari, Devesh},
title = {Verifiable-RL Coder: GRPO-trained Qwen-2.5-Coder with sandboxed verifiable rewards},
year = {2026},
howpublished = {\url{https://github.com/Devesh-Maheshwari/verifiable-rl-coder}}
}
```
## Acknowledgments
- [Qwen team](https://huggingface.co/Qwen) for the strong open-weights coder base.
- [verl](https://github.com/volcengine/verl) for the production-grade GRPO trainer.
- [evalplus](https://github.com/evalplus/evalplus) for the hardened HumanEval+/MBPP+ benchmarks.
- Trained on UW-Madison Center for High Throughput Computing (CHTC) resources.

24
added_tokens.json Normal file
View File

@@ -0,0 +1,24 @@
{
"</tool_call>": 151658,
"<tool_call>": 151657,
"<|box_end|>": 151649,
"<|box_start|>": 151648,
"<|endoftext|>": 151643,
"<|file_sep|>": 151664,
"<|fim_middle|>": 151660,
"<|fim_pad|>": 151662,
"<|fim_prefix|>": 151659,
"<|fim_suffix|>": 151661,
"<|im_end|>": 151645,
"<|im_start|>": 151644,
"<|image_pad|>": 151655,
"<|object_ref_end|>": 151647,
"<|object_ref_start|>": 151646,
"<|quad_end|>": 151651,
"<|quad_start|>": 151650,
"<|repo_name|>": 151663,
"<|video_pad|>": 151656,
"<|vision_end|>": 151653,
"<|vision_pad|>": 151654,
"<|vision_start|>": 151652
}

54
chat_template.jinja Normal file
View File

@@ -0,0 +1,54 @@
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0]['role'] == 'system' %}
{{- messages[0]['content'] }}
{%- else %}
{{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
{%- endif %}
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
{%- else %}
{%- if messages[0]['role'] == 'system' %}
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
{%- else %}
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- for message in messages %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{{- '<|im_start|>' + message.role }}
{%- if message.content %}
{{- '\n' + message.content }}
{%- endif %}
{%- for tool_call in message.tool_calls %}
{%- if tool_call.function is defined %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '\n<tool_call>\n{"name": "' }}
{{- tool_call.name }}
{{- '", "arguments": ' }}
{{- tool_call.arguments | tojson }}
{{- '}\n</tool_call>' }}
{%- endfor %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
{{- '<|im_start|>user' }}
{%- endif %}
{{- '\n<tool_response>\n' }}
{{- message.content }}
{{- '\n</tool_response>' }}
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- endif %}

58
config.json Normal file
View File

@@ -0,0 +1,58 @@
{
"architectures": [
"Qwen2ForCausalLM"
],
"attention_dropout": 0.0,
"dtype": "bfloat16",
"eos_token_id": 151645,
"hidden_act": "silu",
"hidden_size": 1536,
"initializer_range": 0.02,
"intermediate_size": 8960,
"layer_types": [
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention"
],
"max_position_embeddings": 32768,
"max_window_layers": 28,
"model_type": "qwen2",
"num_attention_heads": 12,
"num_hidden_layers": 28,
"num_key_value_heads": 2,
"pad_token_id": 151643,
"rms_norm_eps": 1e-06,
"rope_scaling": null,
"rope_theta": 1000000.0,
"sliding_window": null,
"tie_word_embeddings": true,
"transformers_version": "4.57.3",
"use_cache": true,
"use_sliding_window": false,
"vocab_size": 151936
}

14
generation_config.json Normal file
View File

@@ -0,0 +1,14 @@
{
"bos_token_id": 151643,
"do_sample": true,
"eos_token_id": [
151645,
151643
],
"pad_token_id": 151643,
"repetition_penalty": 1.1,
"temperature": 0.7,
"top_k": 20,
"top_p": 0.8,
"transformers_version": "4.57.3"
}

151388
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d27b46a2b9d3560247993ac3d3ef72a287d8bd3ef656b9c87c5cac00455de612
size 3554214752

31
special_tokens_map.json Normal file
View File

@@ -0,0 +1,31 @@
{
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"eos_token": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
size 11421896

207
tokenizer_config.json Normal file
View File

@@ -0,0 +1,207 @@
{
"add_bos_token": false,
"add_prefix_space": false,
"added_tokens_decoder": {
"151643": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151644": {
"content": "<|im_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151645": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151646": {
"content": "<|object_ref_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151647": {
"content": "<|object_ref_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151648": {
"content": "<|box_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151649": {
"content": "<|box_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151650": {
"content": "<|quad_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151651": {
"content": "<|quad_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151652": {
"content": "<|vision_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151653": {
"content": "<|vision_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151654": {
"content": "<|vision_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151655": {
"content": "<|image_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151656": {
"content": "<|video_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151657": {
"content": "<tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151658": {
"content": "</tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151659": {
"content": "<|fim_prefix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151660": {
"content": "<|fim_middle|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151661": {
"content": "<|fim_suffix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151662": {
"content": "<|fim_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151663": {
"content": "<|repo_name|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151664": {
"content": "<|file_sep|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
}
},
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": {},
"model_max_length": 2048,
"pad_token": "<|endoftext|>",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}

1
vocab.json Normal file

File diff suppressed because one or more lines are too long