Mxode/Meow-Instruct-12k
Viewer • Updated • 12.3k • 17 • 2
How to use Mxode/Meow-bloom-346m-v0.1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Mxode/Meow-bloom-346m-v0.1", device_map="auto") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Mxode/Meow-bloom-346m-v0.1")
model = AutoModelForCausalLM.from_pretrained("Mxode/Meow-bloom-346m-v0.1", device_map="auto")How to use Mxode/Meow-bloom-346m-v0.1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Mxode/Meow-bloom-346m-v0.1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Mxode/Meow-bloom-346m-v0.1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Mxode/Meow-bloom-346m-v0.1
How to use Mxode/Meow-bloom-346m-v0.1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Mxode/Meow-bloom-346m-v0.1" \
--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": "Mxode/Meow-bloom-346m-v0.1",
"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 "Mxode/Meow-bloom-346m-v0.1" \
--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": "Mxode/Meow-bloom-346m-v0.1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Mxode/Meow-bloom-346m-v0.1 with Docker Model Runner:
docker model run hf.co/Mxode/Meow-bloom-346m-v0.1
一只会说话的可爱猫猫,基座模型是 Langboat/bloom-389m-zh,在 Mxode/Meow-Instruct-12k 数据集上微调得到。
请注意,这个模型训练的时候使用了类似 chatml 的格式,想要实现好的对话效果需要按照如下格式组织 prompt,直接 generate 可能得不到想要的效果。其中 system_prompt 建议保持为 你是一只会说话的猫猫,聪明又可爱,来自喵星球。你的名字是“咪咪”。 不变。
<s><s>system
{system_prompt}</s>
<s>user
{text}</s>
<s>assistant\n
可以通过如下方式试用:
import torch
from transformers import BloomTokenizerFast, BloomForCausalLM
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model_name_or_path = 'Mxode/Meow-bloom-346m-v0.1'
tokenizer = BloomTokenizerFast.from_pretrained(model_name_or_path)
model = BloomForCausalLM.from_pretrained(model_name_or_path)
model.to(device).eval()
def generate_prompt(text: str) -> str:
system_prompt = '你是一只会说话的猫猫,聪明又可爱,来自喵星球。你的名字是“咪咪”。'
return f'<s><s>system\n{system_prompt}</s>\n<s>user\n{text}</s>\n<s>assistant\n'
text = '你觉得如果有一天猫咪统治地球会是什么样子?会有哪些新的法律或者规定出台?'
prompt = generate_prompt(text)
inputs = tokenizer.encode(prompt, return_tensors='pt').to(device)
response = model.generate(inputs, max_new_tokens=400)
outputs = tokenizer.batch_decode(response)
outputs = outputs[0].replace(text, '').strip().strip('</s>')
print(f'Meow: {outputs}')