Instructions to use if001/llama2_ja_small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use if001/llama2_ja_small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="if001/llama2_ja_small")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("if001/llama2_ja_small") model = AutoModelForCausalLM.from_pretrained("if001/llama2_ja_small") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use if001/llama2_ja_small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "if001/llama2_ja_small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "if001/llama2_ja_small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/if001/llama2_ja_small
- SGLang
How to use if001/llama2_ja_small 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 "if001/llama2_ja_small" \ --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": "if001/llama2_ja_small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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" \ --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": "if001/llama2_ja_small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use if001/llama2_ja_small with Docker Model Runner:
docker model run hf.co/if001/llama2_ja_small
日本語でtrainingしたllama2
model size: 417.12M
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
prompt="あのイーハトーヴォのすきとおった風、"
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)
> あの イ ー ハ トー ヴォ の すき と おった 風 、 人の 声 とも 似 あ わぬ 歌 である 。 この 音楽 が われわれ を 最も 愛 し むる 時に その 音楽 は 「 われ 」 に 勝 るもの となった のである 。
dataset
英語と日本語のデータセットを使用
total tokens: 8.64B
wikipedia_ja: 844.65M
wikipedia_en: 3.80B
open-text-books: 60.17M
oscar: 3.85B
aozorabunko: 92.97M
https://huggingface.co/datasets/izumi-lab/wikipedia-ja-20230720 https://huggingface.co/datasets/izumi-lab/wikipedia-en-20230720 https://huggingface.co/datasets/izumi-lab/open-text-books https://huggingface.co/datasets/if001/aozorabunko-clean-sin https://huggingface.co/datasets/if001/oscar_2023_filtered
- Downloads last month
- 7
docker model run hf.co/if001/llama2_ja_small