Veri-Graph
Collection
12 items • Updated
How to use doupari/Llama-3.1-8B-Instruct-question with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B-Instruct")
model = PeftModel.from_pretrained(base_model, "doupari/Llama-3.1-8B-Instruct-question")How to use doupari/Llama-3.1-8B-Instruct-question with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="doupari/Llama-3.1-8B-Instruct-question")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("doupari/Llama-3.1-8B-Instruct-question", device_map="auto")How to use doupari/Llama-3.1-8B-Instruct-question with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "doupari/Llama-3.1-8B-Instruct-question"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "doupari/Llama-3.1-8B-Instruct-question",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/doupari/Llama-3.1-8B-Instruct-question
How to use doupari/Llama-3.1-8B-Instruct-question with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "doupari/Llama-3.1-8B-Instruct-question" \
--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": "doupari/Llama-3.1-8B-Instruct-question",
"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 "doupari/Llama-3.1-8B-Instruct-question" \
--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": "doupari/Llama-3.1-8B-Instruct-question",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use doupari/Llama-3.1-8B-Instruct-question with Docker Model Runner:
docker model run hf.co/doupari/Llama-3.1-8B-Instruct-question
This repository contains a LoRA adapter fine-tuned from meta-llama/Llama-3.1-8B-Instruct.
The uploaded adapter was selected from:
checkpoint-2802802.0eval_loss0.0648028627038002Evaluation loss history from training:
| Step | Epoch | Eval loss |
|---|---|---|
| 140 | 1.0 | 0.072911650 |
| 280 | 2.0 | 0.064802863 |
| 420 | 3.0 | 0.077800997 |
| 560 | 4.0 | 0.091106474 |
| 700 | 5.0 | 0.114740528 |
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model = "meta-llama/Llama-3.1-8B-Instruct"
adapter_id = "YOUR_USERNAME/YOUR_REPO_NAME"
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
model = AutoModelForCausalLM.from_pretrained(
base_model,
device_map="auto",
torch_dtype="auto",
)
model = PeftModel.from_pretrained(model, adapter_id)
messages = [{"role": "user", "content": "Your question here"}]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Base model
meta-llama/Llama-3.1-8B