laion/Anh
Preview • Updated • 28 • 9
How to use laion/anh-bloomz-7b1-mt-cross-lingual with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="laion/anh-bloomz-7b1-mt-cross-lingual") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("laion/anh-bloomz-7b1-mt-cross-lingual")
model = AutoModelForCausalLM.from_pretrained("laion/anh-bloomz-7b1-mt-cross-lingual")How to use laion/anh-bloomz-7b1-mt-cross-lingual with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "laion/anh-bloomz-7b1-mt-cross-lingual"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "laion/anh-bloomz-7b1-mt-cross-lingual",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/laion/anh-bloomz-7b1-mt-cross-lingual
How to use laion/anh-bloomz-7b1-mt-cross-lingual with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "laion/anh-bloomz-7b1-mt-cross-lingual" \
--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": "laion/anh-bloomz-7b1-mt-cross-lingual",
"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 "laion/anh-bloomz-7b1-mt-cross-lingual" \
--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": "laion/anh-bloomz-7b1-mt-cross-lingual",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use laion/anh-bloomz-7b1-mt-cross-lingual with Docker Model Runner:
docker model run hf.co/laion/anh-bloomz-7b1-mt-cross-lingual
This model is bloomz-7b1-mt model finetuned on instruct dataset cross_lingual.jsonl from laion/Anh.
anh-bloomz-7b1-mt-cross-lingual model can be loaded and used via the following code:
import re
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "laion/anh-bloomz-7b1-mt-cross-lingual"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
whitespace_tokens_map = {'\n': '<n>', ' ': '<w>'}
text = "User: Apakah kita akan bisa menyembuhkan penyakit kanker? Jawab dalam bahasa China.\n"
for k, v in whitespace_tokens_map.items():
text = text.replace(k, v)
inputs = tokenizer(text, return_tensors="pt")
tokens = model.generate(**inputs, max_new_tokens=200, do_sample=True, top_k=40, top_p=0.9, temperature=0.2,
repetition_penalty=1.2,num_return_sequences=1)
output = tokenizer.decode(tokens[0], skip_special_tokens=True)
for v in whitespace_tokens_map.values():
output = re.sub(rf"{v}\s+(\S+)", rf"{v}\1", output)
for k, v in whitespace_tokens_map.items():
output = output.replace(v, k)