if001 commited on
Commit
1778b45
1 Parent(s): ad7ccb1
Files changed (1) hide show
  1. README.md +80 -0
README.md CHANGED
@@ -1,3 +1,83 @@
1
  ---
2
  license: cc-by-4.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-4.0
3
+ language:
4
+ - ja
5
+ - en
6
+ pipeline_tag: text-generation
7
+ inference: false
8
+ tags:
9
+ - llama-2
10
  ---
11
+
12
+ 日本語でtrainingしたllama2をinstruction用のデータセットでsftしたものになります
13
+
14
+ base:
15
+ https://huggingface.co/if001/llama2_ja_small
16
+
17
+ trainingは以下のscript参照
18
+ https://github.com/Lightning-AI/lit-gpt/tree/main
19
+
20
+ ## use
21
+
22
+ ```python
23
+ from transformers import AutoTokenizer, AutoModelForCausalLM
24
+
25
+ tokenizer = AutoTokenizer.from_pretrained("if001/sentencepiece_ja", trust_remote_code=True)
26
+ model = AutoModelForCausalLM.from_pretrained("if001/llama2_ja_small")
27
+
28
+ import torch
29
+ from transformers import GenerationConfig
30
+
31
+ instruct="東京でおすすめの観光地を教えてください。。"
32
+ prompt=f"""以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。
33
+ ### 指示:
34
+ {instruct}
35
+
36
+ ### 出力:
37
+ """
38
+
39
+ inputs = tokenizer(prompt, return_tensors="pt")
40
+ input_ids = inputs["input_ids"]
41
+
42
+ generation_config = GenerationConfig(
43
+ temperature=0.8,
44
+ top_p=0.95,
45
+ top_k=50,
46
+ num_beams=1,
47
+ do_sample=True,
48
+ repetition_penalty=1.2,
49
+ pad_token_id= tokenizer.pad_token_id,
50
+ # pad_token_id=tokenizer.unk_token_id,
51
+ eos_token_id=tokenizer.eos_token_id
52
+ )
53
+ with torch.no_grad():
54
+ generation_output = model.generate(
55
+ input_ids=input_ids,
56
+ generation_config=generation_config,
57
+ return_dict_in_generate=True,
58
+ output_scores=True,
59
+ max_new_tokens=64,
60
+ )
61
+ s = generation_output.sequences[0]
62
+ output = tokenizer.decode(s)
63
+ print(output)
64
+ ```
65
+
66
+ 出力
67
+ ```
68
+ 以下は、タスクを説明する指示です。要求を適切に満たす応答を書きなさい。
69
+ ### 指示:
70
+ 東京でおすすめの観光地を教えてください。。
71
+
72
+ ### 出力:
73
+ - 東京で訪れる料理
74
+ - 美術館
75
+ - 博物館・新旧東の北京にある船浴場
76
+ - モニュッキングスの4つの空き地
77
+ - シュノーケリングチャイム、夜の奇抜な街
78
+ - ツアーなど、芸術/建築の6つ
79
+ ```
80
+
81
+ ## dataset
82
+ https://huggingface.co/datasets/kunishou/hh-rlhf-49k-ja
83
+ https://huggingface.co/datasets/kunishou/databricks-dolly-15k-ja