Views
No views yet
int_1, var_1) to potentially improve generalization.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "FearandDreams/Qwen2.5-1.5B-Instruct-CodeGen-Renamed"
4model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6
7# Example: Solving a competitive programming problem
8problem = """You are a helpful and harmless assistant. You should think step-by-step before responding to the instruction below.
9
10Please use python programming language only.
11
12You must use ```python for just the final solution code block with the following format:
13```python
14# Your code here
15(put ``` there, I can't directly use ``` here for readme)
16{question}
17
18Input: "" (keep empty, put the question to problem)
19
20Output: .........."""
21
22messages = [
23 {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
24 {"role": "user", "content": problem}
25]
26
27text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
28inputs = tokenizer([text], return_tensors="pt").to(model.device)
29
30outputs = model.generate(**inputs, max_new_tokens=2048, temperature=0.2, top_p=0.95)
31response = tokenizer.decode(outputs[0], skip_special_tokens=True)
32print(response)<think> section with step-by-step reasoningint_1, var_1)1@misc{qwen2.5-1.5b-codegen-renamed,
2 author = {FearandDreams},
3 title = {Qwen2.5-1.5B-Instruct Fine-tuned on Competitive Programming (Obfuscated Variables)},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/FearandDreams/Qwen2.5-1.5B-Instruct-CodeGen-Renamed}},
7}