bertin-project/alpaca-spanish
Viewer • Updated • 51.9k • 897 • 36
How to use marianbasti/Llama-2-13b-alpaca-spanish-LoRA with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="marianbasti/Llama-2-13b-alpaca-spanish-LoRA") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("marianbasti/Llama-2-13b-alpaca-spanish-LoRA", device_map="auto")How to use marianbasti/Llama-2-13b-alpaca-spanish-LoRA with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "marianbasti/Llama-2-13b-alpaca-spanish-LoRA"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "marianbasti/Llama-2-13b-alpaca-spanish-LoRA",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/marianbasti/Llama-2-13b-alpaca-spanish-LoRA
How to use marianbasti/Llama-2-13b-alpaca-spanish-LoRA with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "marianbasti/Llama-2-13b-alpaca-spanish-LoRA" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "marianbasti/Llama-2-13b-alpaca-spanish-LoRA",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "marianbasti/Llama-2-13b-alpaca-spanish-LoRA" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "marianbasti/Llama-2-13b-alpaca-spanish-LoRA",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use marianbasti/Llama-2-13b-alpaca-spanish-LoRA with Docker Model Runner:
docker model run hf.co/marianbasti/Llama-2-13b-alpaca-spanish-LoRA
This is a LoRA for Llama 2 13B trained on a translated alpaca dataset on an attempt to improve spanish performance of the Llama-2 foundation model with a conversational focus.
Base model used was The Bloke's Llama-2-13B-fp16 trained in 4bit precision with an added padding token.
The original Llama 2 model does not have a padding token, this came to be restrictive when training. To address this, I added a padding token to the tokenizer associated with the model.
from transformers import LlamaTokenizer, LlamaForCausalLM
model_name = 'TheBloke/Llama-2-13B-fp16'
model = LlamaForCausalLM.from_pretrained(model_name).half()
tokenizer = LlamaTokenizer.from_pretrained(model_name)
# Add padding token
tokenizer.add_tokens(['<PAD>'])
tokenizer.pad_token = '<PAD>'
# Resizing the model
model.resize_token_embeddings(len(tokenizer))
padded_model_name = 'Llama-2-13B-fp16-padded'
# Save
tokenizer.save_pretrained(padded_model_name)
model.save_pretrained(padded_model_name)
| Training parameteres | |
|---|---|
| LoRA scale | 2 |
| Epochs | 0.75 |
| Learning Rate | 2e-5 |
| Warmup Steps | 100 |
| Loss | 1.07 |