File size: 1,800 Bytes
ff7df9d
 
 
4aedd0c
 
 
ff7df9d
 
4aedd0c
 
3219ff7
 
289a41e
 
 
 
3219ff7
 
97f96f4
3219ff7
20de96f
3219ff7
f8bcaea
4aedd0c
3219ff7
 
046be6d
3219ff7
 
 
 
 
 
 
 
 
4aedd0c
 
 
 
3219ff7
 
 
 
 
 
 
 
 
 
 
4aedd0c
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
---
base_model:
- deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
datasets:
- open-r1/codeforces-cots
license: mit
tags:
- code
pipeline_tag: text-generation
library_name: transformers
---

# Paper Page

[**Pruning the Unsurprising: Efficient Code Reasoning via First-Token Surprisal.**](https://arxiv.org/abs/2508.05988)

# LogicCoder-7B

**LogicCoder-7B** is a 7B-parameter language model fine-tuned for code generation tasks. It is based on the DeepSeek-R1-Distill-Qwen-7B model and trained on a Python subset of the open-r1/codeforces-cots dataset.

This model was fine-tuned on pruned CoTs examples derived via our **ASAP** method(**A**nchor-guided, **S**urpris**a**l-polished **P**runing), focusing on highly compressed yet semantically informative reasoning traces.

GitHub Repository: [https://github.com/Zengwh02/ASAP](https://github.com/Zengwh02/ASAP)

# 🧠 Reasoning Mode

We recommend **explicitly activating reasoning mode by inserting ```<think>``` in the prompt**.

# 🔧 Usage

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("azzzacs/LogicCoder-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("azzzacs/LogicCoder-7B", device_map="auto", trust_remote_code=True).eval()

message = [{"role": "user", "content": "Please write a Python quick sort algorithm.
"}]
prompt = tokenizer.apply_chat_template(message, add_generation_prompt=True, tokenize=False) + "<|Assistant|><think>
"

model_inputs = tokenizer([prompt], return_tensors="pt").to(model.device)

outputs = model.generate(
    model_inputs.input_ids,
    max_new_tokens=4096,
    do_sample=False,
    eos_token_id=tokenizer.eos_token_id
)

print(tokenizer.decode(outputs[0][len(model_inputs.input_ids[0]):], skip_special_tokens=False))
```