This model is a fine-tuned version of Meta's Llama 3.2 3B (Base) that has been specially trained to generate high-quality thought processes before producing answers. The model underwent 4 rounds of specialized fine-tuning using a thought-chain ranking approach.
(Weekend project, just a few hundred steps of training)
-
Initial Generation: For each training sample, the model generates multiple thought chains by prefixing different thought tokens: <thought>{char}</thought> for each character in [a-zA-Z0-9]. Each thought chain is allowed up to 128 tokens.
-
Answer Generation: Following each thought chain, the model generates a complete answer with up to 2048 tokens.
-
Ranking & Selection: An external LLM ranking system evaluates the quality of answers without seeing the thought processes, creating a ranking of the most effective thought patterns.
-
Final Training: The model is then trained on the highest-ranked thought-answer pairs, learning to generate the most effective thought patterns autonomously.
This model is designed for tasks that benefit from explicit reasoning chains, including but not limited to:
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("ericflo/Llama-3.2-3B-COT")
4tokenizer = AutoTokenizer.from_pretrained("ericflo/Llama-3.2-3B-COT")
5
6# Example usage
7prompt = "Solve this math problem: 2x + 3 = 7"
8input_ids = tokenizer.apply_chat_template(
9 [{"role": "user", "content": prompt}],
10 return_tensors="pt"
11)
12
13# Generate response with thought chain
14output = model.generate(
15 input_ids,
16 temperature=1.0,
17)
18
19response = tokenizer.decode(output[0])
1@misc{thought-ranked-llama,
2 title={Thought-Ranked Llama 3.2: Fine-tuning Language Models with Ranked Thought Chains},
3 author={[Eric Florenzano]},
4 year={2024},
5 howpublished={\url{https://huggingface.co/ericflo/Llama-3.2-3B-COT}}
6}