yahma/alpaca-cleaned
Viewer • Updated • 51.8k • 23.3k • 888
How to use dhlak/llama-3.1-8b-alpaca-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("unsloth/Llama-3.1-8B")
model = PeftModel.from_pretrained(base_model, "dhlak/llama-3.1-8b-alpaca-lora")How to use dhlak/llama-3.1-8b-alpaca-lora with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="dhlak/llama-3.1-8b-alpaca-lora")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("dhlak/llama-3.1-8b-alpaca-lora", device_map="auto")How to use dhlak/llama-3.1-8b-alpaca-lora with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "dhlak/llama-3.1-8b-alpaca-lora"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "dhlak/llama-3.1-8b-alpaca-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/dhlak/llama-3.1-8b-alpaca-lora
How to use dhlak/llama-3.1-8b-alpaca-lora with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "dhlak/llama-3.1-8b-alpaca-lora" \
--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": "dhlak/llama-3.1-8b-alpaca-lora",
"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 "dhlak/llama-3.1-8b-alpaca-lora" \
--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": "dhlak/llama-3.1-8b-alpaca-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use dhlak/llama-3.1-8b-alpaca-lora with Docker Model Runner:
docker model run hf.co/dhlak/llama-3.1-8b-alpaca-lora
A LoRA adapter for Llama-3.1-8B fine-tuned on the Alpaca Cleaned dataset for instruction following.
| Parameter | Value |
|---|---|
| r (rank) | 16 |
| alpha | 16 |
| dropout | 0 |
| target_modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Parameter | Value |
|---|---|
| Dataset | yahma/alpaca-cleaned |
| Training Samples | 51,760 |
| Training Steps | 809 |
| Final Loss | 1.20 |
| Training Time | ~1.7 hours |
| Precision | bf16 |
| Peak GPU Memory | 37.6 GB |
Evaluated on IFEval (Instruction Following Evaluation):
| Metric | Score |
|---|---|
| Prompt-level Strict Accuracy | 22.4% |
| Prompt-level Loose Accuracy | 22.4% |
| Instruction-level Strict Accuracy | 36.7% |
| Instruction-level Loose Accuracy | 36.7% |
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"unsloth/Llama-3.1-8B",
torch_dtype="auto",
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("unsloth/Llama-3.1-8B")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "YOUR_USERNAME/YOUR_MODEL_NAME")
# Generate
messages = [{"role": "user", "content": "Explain quantum computing in simple terms."}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="YOUR_USERNAME/YOUR_MODEL_NAME",
max_seq_length=2048,
load_in_4bit=True, # or False for full precision
)
FastLanguageModel.for_inference(model)
# Generate
messages = [{"role": "user", "content": "Explain quantum computing in simple terms."}]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))