Instructions to use lightblue/suzume-llama-3-8B-multilingual with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lightblue/suzume-llama-3-8B-multilingual with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lightblue/suzume-llama-3-8B-multilingual") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lightblue/suzume-llama-3-8B-multilingual") model = AutoModelForCausalLM.from_pretrained("lightblue/suzume-llama-3-8B-multilingual", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lightblue/suzume-llama-3-8B-multilingual with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lightblue/suzume-llama-3-8B-multilingual" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightblue/suzume-llama-3-8B-multilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lightblue/suzume-llama-3-8B-multilingual
- SGLang
How to use lightblue/suzume-llama-3-8B-multilingual with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "lightblue/suzume-llama-3-8B-multilingual" \ --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": "lightblue/suzume-llama-3-8B-multilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "lightblue/suzume-llama-3-8B-multilingual" \ --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": "lightblue/suzume-llama-3-8B-multilingual", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lightblue/suzume-llama-3-8B-multilingual with Docker Model Runner:
docker model run hf.co/lightblue/suzume-llama-3-8B-multilingual
How to add multilinguality to llama 3 tokenizer?
I am a newbie in the LLM field.
I'm trying to add Korean language to llama 3 tokenizer,
I have no idea where the problem is in the code.
I would really appreciate it if you could tell me what's wrong with the code.
I added the token as below, but tokenize gives me the same result.
I'm currently using a dataset of about 10G.
I used this article by huggingface as a reference.
https://huggingface.co/learn/nlp-course/chapter6/2
from transformers import AutoTokenizer, AutoModelForCausalLM
from datasets import load_dataset
base_model = "meta-llama/Meta-Llama-3-8B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(base_model)
ds = load_dataset("richard-park/sapie-dataset-for-tokenizer", cache_dir="./cache")
def get_training_corpus():
return (
ds["train"][i : i + 1000]["text"]
for i in range(0, len(ds["train"]), 1000)
)
training_corpus = get_training_corpus()
new_tokenizer = tokenizer.train_new_from_iterator(training_corpus, 12_000)
new_tokens = set(new_tokenizer.vocab) - set(tokenizer.vocab)
print("new vocab size: ", len(new_tokens))
sample_text = ["์์ฆ ๋ ์จ๊ฐ ๋๋ฌด ์ค๋ฝ๊ฐ๋ฝํด์ ์์ง๋ ๊ฒจ์ธ์ท์ ๋ชป์น์ ์ด์.." ,
"๋ง์๋ ๋ฐฅ์ ๋์
จ์ต๋๊น? ๋ง์ด ๊ถ๊ธํ๋ค์",
"๋๋ฒ์๋ถํฐ ํ๊ธ์ฌ ํ๋ก๊น์ง ์ํ๋ ํ๋ก๋ฅผ ์ฐพ๋ ๊ฐ์ฅ ๋น ๋ฅธ ๋ฐฉ๋ฒ - ์๋ฉด ๊ฒ์, ์์ฒญ ํ๋ก, ์ ์ฌ ํ๋ก, AI ์ถ์ฒ, ํ๋ก ๋ฐ ๋ฒ๋ น ๊ฒ์." ,
"๋ณธ ๋ฐ๋ช
์ ๊ธ์ํ์ ๋ค์ ๋ถ๋ถ์ ์์นญ์์ผ ํน์ ๋ฌด๋ฌ๋ชจ์์ ํ์ฑํ๋ ๊ฑด์ถ์ฉ ๊ธ์์ฌ ์ฅ์ํ์ผ๋ก ์ด๋ฃจ์ด์ง ๊ฒ์ ํน์ง์ด ์๋ค.",
"๊ณจ๋ค๊ณต์ฆ์ ์ ์๊ธฐ๋๊ฑฐ์์? ๊ทธ๋ฆฌ๊ณ ์น๋ฃํ๋ ค๋ฉด ์ด๋ป๊ฒํด์ผํ์ฃ ?",
]
tokenizer.add_tokens(list(new_tokens))
base_tokenizer = AutoTokenizer.from_pretrained(base_model)
for text in sample_text:
print("old: ", [base_tokenizer.decode([id]) for id in base_tokenizer.encode(text)])
print("new: ", [tokenizer.decode([id]) for id in tokenizer.encode(text)])
print("-"*100)