Views
No views yet
bitsandbytes"You are a reflective assistant engaging in thorough, iterative reasoning, mimicking human stream-of-consciousness thinking. Your approach emphasizes exploration, self-doubt, and continuous refinement before coming up with an answer."
unsloth library for 2x faster inference, or standard Hugging Face transformers.1from unsloth import FastLanguageModel
2from unsloth.chat_templates import get_chat_template
3
4model, tokenizer = FastLanguageModel.from_pretrained(
5 model_name = "Muhammad-Shaheer/FinetunedLAMAtoR1-001-3B",
6 max_seq_length = 2048,
7 dtype = None,
8 load_in_4bit = True,
9)
10
11# Enable native 2x faster inference
12FastLanguageModel.for_inference(model)
13
14tokenizer = get_chat_template(
15 tokenizer,
16 chat_template = "llama-3.1",
17)
18
19sys_prompt = """You are a reflective assistant engaging in thorough, iterative reasoning, mimicking human stream-of-consciousness thinking. Your approach emphasizes exploration, self-doubt, and continuous refinement before coming up with an answer.
20<problem>
21{}
22</problem>
23"""
24
25message = sys_prompt.format("If there are a dozen of eggs at cost $60, how much one egg cost?")
26
27messages = [{"role": "user", "content": message}]
28
29inputs = tokenizer.apply_chat_template(
30 messages,
31 tokenize = True,
32 add_generation_prompt = True,
33 return_tensors = "pt",
34).to("cuda")
35
36outputs = model.generate(
37 input_ids = inputs,
38 max_new_tokens = 1024,
39 use_cache = True,
40 temperature = 1.5,
41 min_p = 0.1
42)
43print(tokenizer.batch_decode(outputs))