Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
4tokenizer = AutoTokenizer.from_pretrained("line-corporation/japanese-large-lm-1.7b-instruction-sft", use_fast=False)
5model = AutoModelForCausalLM.from_pretrained("line-corporation/japanese-large-lm-1.7b-instruction-sft-8bit-1g-actorder_True")
6
7generator = pipeline("text-generation", model=model, tokenizer=tokenizer, device=0)
8
9input_text = """四国の県名を全て列挙してください。"""
10text = generator(
11 f"ユーザー: {input_text}\nシステム: ",
12 max_length = 256,
13 do_sample = True,
14 temperature = 0.7,
15 top_p = 0.9,
16 top_k = 0,
17 repetition_penalty = 1.1,
18 num_beams = 1,
19 pad_token_id = tokenizer.pad_token_id,
20 num_return_sequences = 1,
21)
22print(text) # [{'generated_text': 'ユーザー: 四国の県名を全て列挙してください。\nシステム: 高知県、徳島県、香川県、愛媛県'}]