p1atdev/gsm8k-ja-slim
Viewer • Updated • 8.79k • 18 • 2
How to use p1atdev/llm-jp-3-3.7b-R26 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="p1atdev/llm-jp-3-3.7b-R26")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("p1atdev/llm-jp-3-3.7b-R26")
model = AutoModelForCausalLM.from_pretrained("p1atdev/llm-jp-3-3.7b-R26")
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]:]))How to use p1atdev/llm-jp-3-3.7b-R26 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "p1atdev/llm-jp-3-3.7b-R26"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "p1atdev/llm-jp-3-3.7b-R26",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/p1atdev/llm-jp-3-3.7b-R26
How to use p1atdev/llm-jp-3-3.7b-R26 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "p1atdev/llm-jp-3-3.7b-R26" \
--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": "p1atdev/llm-jp-3-3.7b-R26",
"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 "p1atdev/llm-jp-3-3.7b-R26" \
--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": "p1atdev/llm-jp-3-3.7b-R26",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use p1atdev/llm-jp-3-3.7b-R26 with Docker Model Runner:
docker model run hf.co/p1atdev/llm-jp-3-3.7b-R26
ポンコツです。
system prompt:
私はアシスタントチャットボットとしてユーザーの命令に従います。
<think>ここで慎重に考える</think><answer>答え</answer> のように、<think></think><answer></answer> の形式で思考過程とファイナルアンサーを回答します。
example:
import torch
from transformers import pipeline, AutoTokenizer
messages = [
{"role": "system"},
# # optional one-shot:
# {
# "role": "user",
# "content": """
#次の問題を解き、計算結果を数値のみで答えてください。
#10 * (23 + 45) - 67 = ?
#""".strip(),
# },
# {
# "role": "assistant",
# "content": """
#<think>
#与えられた式には括弧が含まれるため、先に括弧内の計算を行う必要があります。
#23 + 45 = 68 なので、等式は以下のように変形できます。
#10 * (23 + 45) - 67 = 10 * 68 - 67
#四則演算の優先順位に従い、掛け算を行ったのちに引き算を行います。
#10 * 68 - 67 = 680 - 67 = 613
#従って、計算結果は 613 です。数値のみを回答すべきなので、613 を回答します。
#</think>
#<answer>613</answer>
#""".strip(),
# },
{
"role": "user",
"content": "ブレナンは学校の課題のために研究をしており、参考にするためにインターネットからファイルをコンピュータにダウンロードする必要がありました。800個のファイルをダウンロードした後、役に立たないものを70%削除しました。さらに400個のファイルをダウンロードしましたが、再び3/5が関係ないことに気づきました。2回目にダウンロードした関係のないファイルを削除した後、彼は何個の価値のあるファイルを持っていましたか?",
},
]
pipe = pipeline(
"text-generation",
model="p1atdev/llm-jp-3-3.7b-R26",
torch_dtype=torch.bfloat16,
use_cache=True,
)
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
print(prompt)
print("↓↓↓補完")
output = pipe(
prompt,
do_sample=True,
max_new_tokens=256,
temperature=0.8,
repetition_penalty=1.0,
)[0]["generated_text"][len(prompt) :].strip()
print(output)
Base model
llm-jp/llm-jp-3-3.7b