Views
No views yet
<think>...</think> tags1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4# Load model
5base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-1.5B")
6model = PeftModel.from_pretrained(base_model, "OsamaBinLikhon/NextStep-Coder-MoE")
7tokenizer = AutoTokenizer.from_pretrained("OsamaBinLikhon/NextStep-Coder-MoE")
8
9# Generate
10prompt = "Write a Python function to check if a number is prime.\n<think>"
11inputs = tokenizer(prompt, return_tensors="pt")
12outputs = model.generate(**inputs, max_new_tokens=256)
13print(tokenizer.decode(outputs[0]))| Parameter | Value |
|---|---|
| Base Model | Qwen/Qwen2.5-Coder-1.5B |
| Method | LoRA (r=16, alpha=32) |
| Trainable Params | 18.4M (1.18%) |
| Precision | bf16 |
| Framework | Transformers + PEFT |
<think> tags to show reasoning:User: Write a binary search function.
Model: <think>
I need to implement binary search on a sorted array.
Key steps: find middle, compare, narrow search space.
Edge case: empty array returns -1.
</think>
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1<think> tag retention in conversation history