Text Generation
Transformers
Safetensors
Japanese
llama
grpo
trl
conversational
text-generation-inference
Instructions to use p1atdev/llm-jp-3-3.7b-R26 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use p1atdev/llm-jp-3-3.7b-R26 with vLLM:
Install from pip and serve model
# 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?" } ] }'Use Docker
docker model run hf.co/p1atdev/llm-jp-3-3.7b-R26
- SGLang
How to use p1atdev/llm-jp-3-3.7b-R26 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 "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?" } ] }'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 "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 Model Runner
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
metadata
license: apache-2.0
datasets:
- p1atdev/gsm8k-ja-slim
- SyntheticVeryEasyMath5k
- SyntheticWhichIsGreater5k
language:
- ja
base_model:
- llm-jp/llm-jp-3-3.7b
tags:
- grpo
- trl
library_name: transformers
ポンコツです。
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)