1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3tokenizer = AutoTokenizer.from_pretrained("llm-jp/llm-jp-3-7.2b-instruct3")
4model = AutoModelForCausalLM.from_pretrained("llm-jp/llm-jp-3-7.2b-instruct3", device_map="auto", torch_dtype=torch.bfloat16)
5chat = [
6 {"role": "system", "content": "以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。"},
7 {"role": "user", "content": "自然言語処理とは何か"},
8]
9tokenized_input = tokenizer.apply_chat_template(chat, add_generation_prompt=True, tokenize=True, return_tensors="pt").to(model.device)
10with torch.no_grad():
11 output = model.generate(
12 tokenized_input,
13 max_new_tokens=100,
14 do_sample=True,
15 top_p=0.95,
16 temperature=0.7,
17 repetition_penalty=1.05,
18 )[0]
19print(tokenizer.decode(output))
The tokenizer of this model is based on
huggingface/tokenizers Unigram byte-fallback model.
The vocabulary entries were converted from
llm-jp-tokenizer v3.0.
Please refer to
README.md of
llm-jp-tokenizer for details on the vocabulary construction procedure (the pure SentencePiece training does not reproduce our vocabulary).
The models have been pre-trained using a blend of the following datasets.
We have fine-tuned the pre-trained checkpoint with supervised fine-tuning and further aligned it with Direct Preference Optimization.
Detailed evaluation results are reported in this
blog.
The models released here are in the early stages of our research and development and have not been tuned to ensure outputs align with human intent and safety considerations.
Hirokazu Kiyomaru and Takashi Kodama.