llamas
Collection
llama models in openvino format, converted using optimum • 2 items • Updated
How to use TheAverageDetective/Llama-3.2-1B-Instruct-openvino with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="TheAverageDetective/Llama-3.2-1B-Instruct-openvino")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("TheAverageDetective/Llama-3.2-1B-Instruct-openvino")
model = AutoModelForCausalLM.from_pretrained("TheAverageDetective/Llama-3.2-1B-Instruct-openvino")
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 TheAverageDetective/Llama-3.2-1B-Instruct-openvino with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "TheAverageDetective/Llama-3.2-1B-Instruct-openvino"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "TheAverageDetective/Llama-3.2-1B-Instruct-openvino",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/TheAverageDetective/Llama-3.2-1B-Instruct-openvino
How to use TheAverageDetective/Llama-3.2-1B-Instruct-openvino with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "TheAverageDetective/Llama-3.2-1B-Instruct-openvino" \
--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": "TheAverageDetective/Llama-3.2-1B-Instruct-openvino",
"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 "TheAverageDetective/Llama-3.2-1B-Instruct-openvino" \
--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": "TheAverageDetective/Llama-3.2-1B-Instruct-openvino",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use TheAverageDetective/Llama-3.2-1B-Instruct-openvino with Docker Model Runner:
docker model run hf.co/TheAverageDetective/Llama-3.2-1B-Instruct-openvino
This model was converted to OpenVINO from meta-llama/Llama-3.2-1B-Instruct using optimum-intel
via the export space.
Install packages:
pip install optimum[openvino] transformers torch
Sample code:
from optimum.intel import OVModelForCausalLM
from transformers import AutoTokenizer
model_id = "TheAverageDetective/Llama-3.2-1B-Instruct-openvino"
model = OVModelForCausalLM.from_pretrained(model_id, device="GPU")
tokenizer = AutoTokenizer.from_pretrained(model_id)
prompt = "Explain the theory of relativity in simple terms."
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(input_text, return_tensors="pt")
output_ids = model.generate(**inputs, max_new_tokens=150)
result = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0]
print("\n", result)
Base model
meta-llama/Llama-3.2-1B-Instruct