File size: 1,649 Bytes
08a2a40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
base_model: Qwen/Qwen3-4B-Thinking-2507
library_name: peft
pipeline_tag: text-generation
tags:
  - lora
  - peft
  - math
  - reasoning
  - qwen3
  - cse151b
---

# Qwen3-4B-Thinking-2507 — Math Reasoning LoRA

LoRA adapter for **`Qwen/Qwen3-4B-Thinking-2507`**, fine-tuned for a CSE 151B
math/statistics reasoning competition.

## Training
- **Method:** rejection-sampling fine-tuning (STaR). For each public training
  question, several reasoning traces were sampled from the base model; only
  traces whose extracted answer matched the gold answer were kept (1,205 traces
  from 624 questions). The adapter was trained on these with the prompt tokens
  masked, so loss is computed only on the reasoning + answer.
- **LoRA:** rank 32, α 64, dropout 0.05, targets all attention + MLP projections
  (q/k/v/o/gate/up/down).
- **Optim:** lr 1e-4, cosine schedule, 2 epochs, effective batch 16, bf16,
  gradient checkpointing.

## Usage
```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Thinking-2507", dtype="bfloat16")
model = PeftModel.from_pretrained(base, "Ekkoliu/qwen3-4b-thinking-2507-math-lora")
tok = AutoTokenizer.from_pretrained("Qwen/Qwen3-4B-Thinking-2507")
```

Or with vLLM (as used in the competition pipeline, with self-consistency voting):
```python
from vllm import LLM
from vllm.lora.request import LoRARequest
llm = LLM("Qwen/Qwen3-4B-Thinking-2507", enable_lora=True, max_lora_rank=32)
# pass lora_request=LoRARequest("adapter", 1, "<local_or_hub_path>") to llm.chat(...)
```

### Framework versions
- PEFT 0.19.1