vutuka/aya_african_alpaca
Viewer • Updated • 571k • 59 • 4
How to use vutuka/Llama-3.1-8B-african-aya with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="vutuka/Llama-3.1-8B-african-aya") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("vutuka/Llama-3.1-8B-african-aya", device_map="auto")How to use vutuka/Llama-3.1-8B-african-aya with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="vutuka/Llama-3.1-8B-african-aya", filename="llama-3.1-8B-african-aya.F16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
How to use vutuka/Llama-3.1-8B-african-aya with llama.cpp:
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M # Run inference directly in the terminal: llama cli -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M # Run inference directly in the terminal: llama cli -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf vutuka/Llama-3.1-8B-african-aya:Q4_K_M
docker model run hf.co/vutuka/Llama-3.1-8B-african-aya:Q4_K_M
How to use vutuka/Llama-3.1-8B-african-aya with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "vutuka/Llama-3.1-8B-african-aya"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "vutuka/Llama-3.1-8B-african-aya",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/vutuka/Llama-3.1-8B-african-aya:Q4_K_M
How to use vutuka/Llama-3.1-8B-african-aya with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "vutuka/Llama-3.1-8B-african-aya" \
--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": "vutuka/Llama-3.1-8B-african-aya",
"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 "vutuka/Llama-3.1-8B-african-aya" \
--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": "vutuka/Llama-3.1-8B-african-aya",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use vutuka/Llama-3.1-8B-african-aya with Ollama:
ollama run hf.co/vutuka/Llama-3.1-8B-african-aya:Q4_K_M
How to use vutuka/Llama-3.1-8B-african-aya with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for vutuka/Llama-3.1-8B-african-aya to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for vutuka/Llama-3.1-8B-african-aya to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for vutuka/Llama-3.1-8B-african-aya to start chatting
How to use vutuka/Llama-3.1-8B-african-aya with Docker Model Runner:
docker model run hf.co/vutuka/Llama-3.1-8B-african-aya:Q4_K_M
How to use vutuka/Llama-3.1-8B-african-aya with Lemonade:
# Download Lemonade from https://lemonade-server.ai/ lemonade pull vutuka/Llama-3.1-8B-african-aya:Q4_K_M
lemonade run user.Llama-3.1-8B-african-aya-Q4_K_M
lemonade list
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
%%capture
# Installs Unsloth, Xformers (Flash Attention) and all other packages!
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
!pip install --no-deps "xformers<0.0.27" "trl<0.9.0" peft accelerate bitsandbytes
max_seq_length = 4096
dtype = None
load_in_4bit = True # Use 4bit quantization to reduce memory usage.
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
## Load the Quantize model
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "vutuka/Llama-3.1-8B-african-aya",
max_seq_length = max_seq_length,
dtype = dtype,
load_in_4bit = load_in_4bit,
)
FastLanguageModel.for_inference(model)
def llama_african_aya(input: str = "", instruction: str = ""):
inputs = tokenizer(
[
alpaca_prompt.format(
instruction,
input,
"",
)
], return_tensors = "pt").to("cuda")
text_streamer = TextStreamer(tokenizer)
# _ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 800)
# Generate the response
output = model.generate(**inputs, max_new_tokens=1024)
# Decode the generated response
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
# Extract the response part if needed (assuming the response starts after "### Response:")
response_start = generated_text.find("### Response:") + len("### Response:")
response = generated_text[response_start:].strip()
# Format the response in Markdown
# markdown_response = f"{response}"
# Render the markdown response
# display(Markdown(markdown_response))
return response
llama_african_aya(
instruction="",
input="Àwọn ajínigbé méjì ni wọ́n mú ní Supare Akoko, ṣàlàyé ìtàn náà."
)
CMAKE_ARGS="-DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS" \
pip install llama-cpp-python
from huggingface_hub import hf_hub_download
from llama_cpp import Llama
## Download the GGUF model
model_name = "vutuka/Llama-3.1-8B-african-aya"
model_file = "llama-3.1-8B-african-aya.Q8_0.gguf"
model_path = hf_hub_download(model_name, filename=model_file)
## Instantiate model from downloaded file
llm = Llama(
model_path=model_path,
n_ctx=4096,
n_gpu_layers=-1,
n_batch=512,
verbose=False,
)
## Run inference
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
prompt = alpaca_prompt.format(
"",
"Àwọn ajínigbé méjì ni wọ́n mú ní Supare Akoko, ṣàlàyé ìtàn náà.",
"",
)
res = llm(prompt) # Res is a dictionary
## Unpack and the generated text from the LLM response dictionary and print it
print(res["choices"][0]["text"])
# res is short for result
4-bit
5-bit
8-bit
16-bit