BAAI/Infinity-Instruct
Viewer • Updated • 21.9M • 5.38k • 753
How to use MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere")
model = AutoModelForCausalLM.from_pretrained("MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere", 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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere
How to use MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere" \
--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": "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere" \
--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": "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere",
max_seq_length=2048,
)How to use MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere with Docker Model Runner:
docker model run hf.co/MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere
This model uses the "0625" version, but there will be a fine-tuned model trained with the "7M" version as well.
Check my full repo on github for better undestanding: https://github.com/Mateorovere/FineTuning-LLM-Llama3.2-3b
But with the proper dependencies you can run the model with the following code:
from unsloth.chat_templates import get_chat_template
from unsloth import FastLanguageModel
# Get the chat template
tokenizer = get_chat_template(
tokenizer,
chat_template="llama-3.1",
)
model = "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere"
# Enable native 2x faster inference
FastLanguageModel.for_inference(model)
# Define the input message
messages = [
{"role": "user", "content": "Continue the Fibonacci sequence: 1, 1, 2, 3, 5, 8,"},
]
# Prepare the inputs
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True, # Must add for generation
return_tensors="pt",
).to("cuda")
# Generate the output
outputs = model.generate(
input_ids=inputs,
max_new_tokens=64,
use_cache=True,
temperature=1.5,
min_p=0.1,
)
# Decode the outputs
result = tokenizer.batch_decode(outputs)
print(result)
To get the generation token by token:
from unsloth.chat_templates import get_chat_template
from unsloth import FastLanguageModel
from transformers import TextStreamer
model = "MateoRov/Llama3.2-3b-SFF-Infinity-MateoRovere"
# Enable native 2x faster inference
FastLanguageModel.for_inference(model)
# Get the chat template
tokenizer = get_chat_template(
tokenizer,
chat_template="llama-3.1",
)
# Define the input message
messages = [
{"role": "user", "content": "Continue the Fibonacci sequence: 1, 1, 2, 3, 5, 8,"},
]
# Prepare the inputs
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True, # Must add for generation
return_tensors="pt",
).to("cuda")
# Initialize the text streamer
text_streamer = TextStreamer(tokenizer, skip_prompt=True)
# Generate the output token by token
_ = model.generate(
input_ids=inputs,
streamer=text_streamer,
max_new_tokens=128,
use_cache=True,
temperature=1.5,
min_p=0.1,
)