How to use from
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 "if001/llama2_ja_small_instruct" \
    --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": "if001/llama2_ja_small_instruct",
		"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 "if001/llama2_ja_small_instruct" \
        --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": "if001/llama2_ja_small_instruct",
		"messages": [
			{
				"role": "user",
				"content": "What is the capital of France?"
			}
		]
	}'
Quick Links

日本語でtrainingしたllama2をinstruction用のデータセットでsftしたものになります

base: https://huggingface.co/if001/llama2_ja_small

trainingは以下のscript参照 https://github.com/Lightning-AI/lit-gpt/tree/main

use

from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("if001/sentencepiece_ja", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("if001/llama2_ja_small")

import torch
from transformers import GenerationConfig

instruct="東京でおすすめの観光地を教えてください。。"
prompt=f"""以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。
### 指示:
{instruct}

### 出力:
"""

inputs = tokenizer(prompt, return_tensors="pt")
input_ids = inputs["input_ids"]

generation_config = GenerationConfig(
    temperature=0.8,
    top_p=0.95,
    top_k=50,
    num_beams=1,
    do_sample=True,
    repetition_penalty=1.2,
    pad_token_id= tokenizer.pad_token_id,
    # pad_token_id=tokenizer.unk_token_id,
    eos_token_id=tokenizer.eos_token_id
)
with torch.no_grad():
  generation_output = model.generate(
            input_ids=input_ids,
            generation_config=generation_config,
            return_dict_in_generate=True,
            output_scores=True,
            max_new_tokens=64,
        )
  s = generation_output.sequences[0]
  output = tokenizer.decode(s)
  print(output)

出力

以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。
### 指示:
東京でおすすめの観光地を教えてください。。

### 出力:
- 東京で訪れる料理
- 美術館
- 博物館・新旧東の北京にある船浴場
- モニュッキングスの4つの空き地
- シュノーケリングチャイム、夜の奇抜な街
- ツアーなど、芸術/建築の6つ

dataset

https://huggingface.co/datasets/kunishou/hh-rlhf-49k-ja https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja

Downloads last month
24
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train if001/llama2_ja_small_instruct