Instructions to use richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning") model = AutoModelForCausalLM.from_pretrained("richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning
- SGLang
How to use richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning with Docker Model Runner:
docker model run hf.co/richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning
Llama-3.1-8B-Instruct-Post-Reasoning
Llama-3.1-8B-Instruct after supervised Post-Reason tuning, from the paper Post-Reasoning: Improving the Performance of Non-Thinking Models at Negligible Cost (code: https://github.com/richmondsin/Post-Reasoning).
Post-Reasoning asks an instruction-tuned model to state the final answer first and to justify it after the answer. The answer can be read (and generation stopped) at the end-of-answer marker, so no reasoning tokens come before it. Post-Reason tuning trains the model on post-answer justifications only: the loss is masked on the prompt and on the answer.
- Base model: meta-llama/Llama-3.1-8B-Instruct
- Training data: NuminaMath problems with self-distilled post-answer justifications (local data file
post_reflective_data/<model>_numina_v4.json) - Method: LoRA (r 16, lora_alpha 32, dropout 0.05), learning rate 2e-5, 3 epochs, cosine schedule, then merged into the base weights (bf16)
- Local checkpoint name:
Llama-31-8B-Instruct-numina-Reflection-Merged-v4
Usage (vLLM)
from vllm import LLM, SamplingParams
llm = LLM(model="richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning")
prompt = "What is 10 + 2? State the final answer immediately and justify your answer."
out = llm.chat([{"role": "user", "content": prompt}], SamplingParams(temperature=0, max_tokens=512))
print(out[0].outputs[0].text) # "Answer: 12. Explanation: ..."
To read only the answer, stop generation at the end-of-answer marker (for example stop=["Explanation"]).
The evaluation prompts and scripts are in the GitHub repository.
Citation
@article{sin2026postreasoning,
title = {Post-Reasoning: Improving the Performance of Non-Thinking Models at Negligible Cost},
author = {Sin, Richmond Jing Xuan and Bhardwaj, Rishabh and Poria, Soujanya},
journal = {arXiv preprint arXiv:2605.06165},
year = {2026}
}
The use of this model follows the license of the base model (llama3.1).
- Downloads last month
- 292
Model tree for richmondsin/Llama-3.1-8B-Instruct-Post-Reasoning
Base model
meta-llama/Llama-3.1-8B