thesugar commited on
Commit
0ec310f
1 Parent(s): 9f1ce8e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -1
README.md CHANGED
@@ -6,9 +6,11 @@ tags:
6
  - unsloth
7
  - llama
8
  - trl
9
- license: apache-2.0
10
  language:
11
  - en
 
 
12
  ---
13
 
14
  # Uploaded model
@@ -20,3 +22,88 @@ language:
20
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  - unsloth
7
  - llama
8
  - trl
9
+ license: cc
10
  language:
11
  - en
12
+ datasets:
13
+ - weblab-GENIAC/aya-ja-nemotron-dpo-masked
14
  ---
15
 
16
  # Uploaded model
 
22
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
23
 
24
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
25
+
26
+ # HOW TO INFERENCE for competition evaluators
27
+
28
+ Google Colab L4 で実行
29
+
30
+ ```ipynb
31
+ !pip install unsloth
32
+ !pip uninstall unsloth -y && pip install --upgrade --no-cache-dir --no-deps git+https://github.com/unslothai/unsloth.git
33
+
34
+ HF_TOKEN = # WRITE YOUR HF_TOKEN
35
+ ELYZA_TASKS_100_TV_JSONL_PATH = # WRITE
36
+ # Output for elyza-tasks-100-tv is saved as "output.jsonl"
37
+
38
+
39
+ from huggingface_hub import login
40
+ login(HF_TOKEN)
41
+
42
+ from unsloth import FastLanguageModel
43
+ import torch
44
+
45
+ max_seq_length = 2048
46
+ dtype = torch.bfloat16
47
+ load_in_4bit = True
48
+ model, tokenizer = FastLanguageModel.from_pretrained(
49
+ model_name = "thesugar/llm-jp-3-13b-it_lora-DPO-12-16",
50
+ max_seq_length = max_seq_length,
51
+ dtype = dtype,
52
+ load_in_4bit = load_in_4bit,
53
+ token = HF_TOKEN,
54
+ )
55
+
56
+ import json
57
+ datasets = []
58
+ with open(ELYZA_TASKS_100_TV_JSONL_PATH, "r") as f:
59
+ item = ""
60
+ for line in f:
61
+ line = line.strip()
62
+ item += line
63
+ if item.endswith("}"):
64
+ datasets.append(json.loads(item))
65
+ item = ""
66
+
67
+ from tqdm import tqdm
68
+
69
+ FastLanguageModel.for_inference(model)
70
+
71
+ results = []
72
+ for dt in tqdm(datasets):
73
+ input = dt["input"]
74
+
75
+ prompt = f"""### 指示\n{input}\n### 回答\n"""
76
+
77
+ inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
78
+
79
+ outputs = model.generate(**inputs, max_new_tokens = 2048, use_cache = True, do_sample=False, repetition_penalty=1.2)
80
+ prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
81
+
82
+ results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
83
+
84
+ with open("output.jsonl", "w") as f:
85
+ for r in results:
86
+ f.write(json.dumps(r, ensure_ascii=False) + "\n")
87
+ ```
88
+
89
+ # Development steps
90
+ - `llm-jp/llm-jp-3-13b` を量子化
91
+ - インストラクションチューニング
92
+ - `ichikara-instruction` データセットの `ichikara-instruction-003-001-1.json` の全データを使用
93
+ - direct policy optimization
94
+ - `weblab-GENIAC/aya-ja-nemotron-dpo-masked` からランダムに選択した 100 レコードを使用
95
+
96
+ # Used datasets and their licenses
97
+ ## ichikara-instruction: LLMのための日本語インストラクションデータ
98
+ - [LLMのための日本語インストラクションデータ 公開ページ – LIAT-AIP homepage](https://liat-aip.sakura.ne.jp/wp/llm%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%A9%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3%E3%83%87%E3%83%BC%E3%82%BF%E4%BD%9C%E6%88%90/)
99
+
100
+ 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)
101
+ CC-BY-NC-SA
102
+
103
+ ## weblab-GENIAC/aya-ja-nemotron-dpo-masked
104
+ - [creator](https://huggingface.co/weblab-GENIAC)
105
+ - [repository](https://huggingface.co/datasets/weblab-GENIAC/aya-ja-nemotron-dpo-masked)
106
+
107
+ weblab-GENIAC
108
+ weblab-GENIAC/aya-ja-nemotron-dpo-masked
109
+ Apache License 2.0