garystafford/fine-tune-nvidia-blackwell
Viewer • Updated • 307 • 114 • 1
How to use garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell", dtype="auto")How to use garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell
How to use garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell" \
--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": "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell",
"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 "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell" \
--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": "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell with Docker Model Runner:
docker model run hf.co/garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell
This model is a fine-tuned version of meta-llama/Llama-3.2-3B-Instruct. It has been trained using TRL. It was trained with Rank-Stabilized LoRA (rsLoRA), a variation of Low-Rank Adaptation (LoRA) and a supervised fine-tuning method within the Parameter-Efficient Fine-Tuning (PEFT) framework.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
device = "cuda:0" if torch.cuda.is_available() else "cpu"
HF_TOKEN = "<YOUR_HF_TOKEN_GOES_HERE>"
base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
peft_model_id = "garystafford/Llama-3.2-3B-Instruct-lora-nvidia-blackwell"
base_model = AutoModelForCausalLM.from_pretrained(base_model_id, token=HF_TOKEN)
model = PeftModel.from_pretrained(base_model, peft_model_id).to(device)
tokenizer = AutoTokenizer.from_pretrained(base_model_id, token=HF_TOKEN)
test_prompt = [
{
"role": "user",
"content": "Describe the NVIDIA Blackwell architecture.",
}
]
inputs = tokenizer.apply_chat_template(
test_prompt,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
).to(device)
output = model.generate(
input_ids=inputs,
max_new_tokens=128,
temperature=0.1,
pad_token_id=tokenizer.pad_token_id,
).to(device)
output = tokenizer.decode(output[0], skip_special_tokens=True)
output = output.split('assistant\n\n')[1].strip()
print(output)
This model was trained with SFT.
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}
Base model
meta-llama/Llama-3.2-3B-Instruct