Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model = AutoModelForCausalLM.from_pretrained(
5 "suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit",
6 load_in_4bit = True,
7 device_map="auto"
8)
9
10tokenizer = AutoTokenizer.from_pretrained("suayptalha/DeepSeek-R1-Distill-Llama-3B-4bit")
11
12SYSTEM_PROMPT = """Respond in the following format:
13<reasoning>
14You should reason between these tags.
15</reasoning>
16
17Answer goes here...
18
19Always use <reasoning> </reasoning> tags even if they are not necessary.
20"""
21
22messages = [
23 {"role": "system", "content": SYSTEM_PROMPT},
24 {"role": "user", "content": "Continue the fibonnaci sequence: 1, 1, 2, 3, 5, 8,"},
25]
26inputs = tokenizer.apply_chat_template(
27 messages,
28 tokenize = True,
29 add_generation_prompt = True,
30 return_tensors = "pt",
31).to("cuda")
32output = model.generate(input_ids=inputs, max_new_tokens=256, use_cache=True, temperature=0.7)
33decoded_output = tokenizer.decode(output[0], skip_special_tokens=False)
34print(decoded_output)<reasoning>
To continue the Fibonacci sequence, we need to recall the pattern of adding the previous two numbers to get the next number.
</reasoning>
The next numbers in the sequence would be: 13, 21, 34, 55, 89, 144Respond in the following format:
<reasoning>
You should reason between these tags.
</reasoning>
Answer goes here...
Always use <reasoning> </reasoning> tags even if they are not necessary.