thesugar commited on
Commit
f3fc763
·
verified ·
1 Parent(s): 7ca3c0a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +90 -2
README.md CHANGED
@@ -6,17 +6,105 @@ tags:
6
  - unsloth
7
  - llama
8
  - trl
9
- license: apache-2.0
10
  language:
11
  - en
 
 
12
  ---
13
 
14
  # Uploaded model
15
 
16
  - **Developed by:** thesugar
17
- - **License:** apache-2.0
18
  - **Finetuned from model :** llm-jp/llm-jp-3-13b
19
 
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
17
 
18
  - **Developed by:** thesugar
19
+ - **License:** CC-BY-NC-SA
20
  - **Finetuned from model :** llm-jp/llm-jp-3-13b
21
 
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
+ model.eval()
71
+
72
+ results = []
73
+ for dt in tqdm(datasets):
74
+ input = dt["input"]
75
+
76
+ prompt = f"""### 指示\n{input}\n### 回答\n"""
77
+
78
+ inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
79
+
80
+ outputs = model.generate(**inputs, max_new_tokens = 2048, use_cache = True, do_sample=False, repetition_penalty=1.2)
81
+ prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
82
+
83
+ results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
84
+
85
+ with open("output.jsonl", "w") as f:
86
+ for r in results:
87
+ f.write(json.dumps(r, ensure_ascii=False) + "\n")
88
+ ```
89
+
90
+ # Development steps
91
+ - `llm-jp/llm-jp-3-13b` を量子化
92
+ - インストラクションチューニング
93
+ - `ichikara-instruction` データセットの `ichikara-instruction-003-001-1.json`, `ichikara-instruction-003-002-1.json` の全データを使用
94
+ - direct policy optimization
95
+ - `weblab-GENIAC/aya-ja-nemotron-dpo-masked` からランダムに選択した 100 レコードを使用
96
+
97
+ # Used datasets and their licenses
98
+ ## ichikara-instruction: LLMのための日本語インストラクションデータ
99
+ - [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/)
100
+
101
+ 関根聡, 安藤まや, 後藤美知子, 鈴木久美, 河原大輔, 井之上直也, 乾健太郎. ichikara-instruction: LLMのための日本語インストラクションデータの構築. 言語処理学会第30回年次大会(2024)
102
+ CC-BY-NC-SA
103
+
104
+ ## weblab-GENIAC/aya-ja-nemotron-dpo-masked
105
+ - [creator](https://huggingface.co/weblab-GENIAC)
106
+ - [repository](https://huggingface.co/datasets/weblab-GENIAC/aya-ja-nemotron-dpo-masked)
107
+
108
+ weblab-GENIAC
109
+ weblab-GENIAC/aya-ja-nemotron-dpo-masked
110
+ Apache License 2.0