vicgalle/alpaca-gpt4
Viewer • Updated • 52k • 4.35k • 324
How to use mostafaamiri/persian_llama_7B_merged with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mostafaamiri/persian_llama_7B_merged") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("mostafaamiri/persian_llama_7B_merged")
model = AutoModelForCausalLM.from_pretrained("mostafaamiri/persian_llama_7B_merged")How to use mostafaamiri/persian_llama_7B_merged with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "mostafaamiri/persian_llama_7B_merged"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mostafaamiri/persian_llama_7B_merged",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/mostafaamiri/persian_llama_7B_merged
How to use mostafaamiri/persian_llama_7B_merged with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "mostafaamiri/persian_llama_7B_merged" \
--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": "mostafaamiri/persian_llama_7B_merged",
"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 "mostafaamiri/persian_llama_7B_merged" \
--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": "mostafaamiri/persian_llama_7B_merged",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use mostafaamiri/persian_llama_7B_merged with Docker Model Runner:
docker model run hf.co/mostafaamiri/persian_llama_7B_merged
This model is Llama2-7B fine-tuned model which trained on farsi-wiki(approximately 180 milion token) and translated ALPACA dataset. We extend tokenizer by 19954 new token with BPE algorithm running on persian dataset.
Use this code to run model on you input:
from transformers import AutoTokenizer, LlamaModelForCausalLM
model = LlamaModelForCausalLM.from_pretrained("mostafaamiri/persian_llama_7B_merged")
tokenizer = AutoTokenizer.from_pretrained(""mostafaamiri/persian_llama_7B_merged"")
instruction = "برای رفتن به کوهنوردی چه وسایلی را با خود ببرم؟"
prompt = [
"""Below is an instruction that describes a task.
Write a response that appropriately completes the request.\n\n
### Instruction:\n\n{instruction}\n\n\n### Response:\n\n\n"""
]
model.to("cuda")
generated_ids = model.generate(**tokenizer(prompt, return_tensors='pt').to("cuda"))
print(tokenizer.batch_decode(generated_ids)[0])