Views
No views yet
Meta-Llama-3-8B-Instruct designed to enforce Chain-of-Thought (CoT) reasoning before providing a final answer. By utilizing specialized <thinking> tags, the model pauses to break down logic puzzles, coding problems, and tricky phrasing (like riddles and state-tracking) before generating its response.<thinking> tag. If you do not prompt the model correctly, it may bypass the reasoning phase and act like a standard Llama 3 model.1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "eelixir/llama3-8b-thinking-v2"
4model = AutoModelForCausalLM.from_pretrained(model_name)
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6
7test_question = "A farmer has 17 sheep. All but 9 run away. How many sheep are left?"
8
9# Note the intentional inclusion of <thinking>\n at the end to "prime" the reasoning!
10prompt = f"<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{test_question}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n<thinking>\n"
11
12inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
13outputs = model.generate(**inputs, max_new_tokens=1024, use_cache=True)
14
15print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])