kunishou/databricks-dolly-15k-ja
Viewer • Updated • 15k • 1.2k • 89
How to use Kendamarron/Tokara-0.5B-Chat-dolly-jimba with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Kendamarron/Tokara-0.5B-Chat-dolly-jimba")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Kendamarron/Tokara-0.5B-Chat-dolly-jimba")
model = AutoModelForCausalLM.from_pretrained("Kendamarron/Tokara-0.5B-Chat-dolly-jimba", 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=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Kendamarron/Tokara-0.5B-Chat-dolly-jimba with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Kendamarron/Tokara-0.5B-Chat-dolly-jimba"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Kendamarron/Tokara-0.5B-Chat-dolly-jimba",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Kendamarron/Tokara-0.5B-Chat-dolly-jimba
How to use Kendamarron/Tokara-0.5B-Chat-dolly-jimba with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Kendamarron/Tokara-0.5B-Chat-dolly-jimba" \
--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": "Kendamarron/Tokara-0.5B-Chat-dolly-jimba",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "Kendamarron/Tokara-0.5B-Chat-dolly-jimba" \
--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": "Kendamarron/Tokara-0.5B-Chat-dolly-jimba",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Kendamarron/Tokara-0.5B-Chat-dolly-jimba with Docker Model Runner:
docker model run hf.co/Kendamarron/Tokara-0.5B-Chat-dolly-jimba
Qwen/Qwen1.5-0.5Bを日英データ5Bトークンで継続事前学習したTokara-0.5B-v0.1を日本語instructionデータセットでファインチューニングしたモデルです。
0.5Bというモデルサイズにしてはコミュニケーションが行えるモデルになっています。
学習データにマルチターンのデータセットを含めているため、複数ターンの会話も行えるはずです。
モデルサイズの問題なのか、repetition_penaltyを1.15~1.25くらいにしないと早めに繰り返しが始まります。
詳細はこちらをご覧ください。
jimba-oasst2-jaはoasst2のinstructionを起点にSwallow-MXを使って作成したマルチターン合成データセットです。
日本の在来馬であるトカラ馬から
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
device = "cuda"
model = AutoModelForCausalLM.from_pretrained(
'Kendamarron/Tokara-0.5B-Chat-v0.1',
torch_dtype=torch.bfloat16,
device_map=device,
)
tokenizer = AutoTokenizer.from_pretrained('Kendamarron/Tokara-0.5B-Chat-dolly-jimba')
messages = [
{"role": "system", "content": "あなたは誠実で優秀な日本人のアシスタントです。"},
{"role": "user", "content": "野菜は体にいいですか?"}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=256,
do_sample=True,
top_p=0.95,
top_k=40,
temperature=0.7,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id,
eos_token_id=tokenizer.eos_token_id,
no_repeat_ngram_size=2
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)