nvidia/OpenCodeReasoning
Viewer • Updated • 753k • 15.2k • 578
How to use alibidaran/LLAMA3-instructive_Python_reasoning with Transformers:
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("alibidaran/LLAMA3-instructive_Python_reasoning", device_map="auto")system_prompt="""
You are expert Python programmer. You task contians follwing instructions.
You should answer the user's questions about Python. Your thinking must be in the format <think>..</think>
The output format must contain only python codes with ```python syntax format.
You must use the the user input vairables in your code as code place holder.
"""
FastLanguageModel.for_inference(model)
messages = [
{'role':'system','content':system_prompt},
{"role": "user", "content":"How to write a Graph-based path finder algorithm?" },
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize = True,
add_generation_prompt = True, # Must add for generation
return_tensors = "pt",
).to("cuda")
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer, skip_prompt = True)
_ = model.generate(input_ids = inputs, streamer = text_streamer, max_new_tokens =2048,
use_cache = True, temperature = 0.5, min_p = 0.9)
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("alibidaran/LLAMA3-instructive_Python_reasoning", device_map="auto")