Update README.md
Browse files
README.md
CHANGED
@@ -23,6 +23,23 @@ This llama model was trained 2x faster with [Unsloth](https://github.com/unsloth
|
|
23 |
|
24 |
|
25 |
# Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
```python
|
28 |
# ベースとなるモデルと学習したLoRAのアダプタ(Hugging FaceのIDを指定)。
|
@@ -57,8 +74,7 @@ with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
|
|
57 |
datasets.append(json.loads(item))
|
58 |
item = ""
|
59 |
|
60 |
-
#
|
61 |
-
|
62 |
# 推論するためにモデルのモードを変更
|
63 |
FastLanguageModel.for_inference(model)
|
64 |
|
@@ -66,7 +82,7 @@ results = []
|
|
66 |
for dt in tqdm(datasets):
|
67 |
input = dt["input"]
|
68 |
|
69 |
-
prompt = f"""### 指示\n{input}\n
|
70 |
|
71 |
inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
|
72 |
|
|
|
23 |
|
24 |
|
25 |
# Usage
|
26 |
+
```python
|
27 |
+
# 必要なライブラリのインストール
|
28 |
+
!pip install unsloth
|
29 |
+
!pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
|
30 |
+
!pip install -U torch
|
31 |
+
!pip install -U peft
|
32 |
+
```
|
33 |
+
|
34 |
+
```python
|
35 |
+
# 必要なライブラリを読み込み
|
36 |
+
from unsloth import FastLanguageModel
|
37 |
+
from peft import PeftModel
|
38 |
+
import torch
|
39 |
+
import json
|
40 |
+
from tqdm import tqdm
|
41 |
+
import re
|
42 |
+
```
|
43 |
|
44 |
```python
|
45 |
# ベースとなるモデルと学習したLoRAのアダプタ(Hugging FaceのIDを指定)。
|
|
|
74 |
datasets.append(json.loads(item))
|
75 |
item = ""
|
76 |
|
77 |
+
# モデルを用いてタスクの推論
|
|
|
78 |
# 推論するためにモデルのモードを変更
|
79 |
FastLanguageModel.for_inference(model)
|
80 |
|
|
|
82 |
for dt in tqdm(datasets):
|
83 |
input = dt["input"]
|
84 |
|
85 |
+
prompt = f"""### 指示\n{input}\n### 回答\n"""
|
86 |
|
87 |
inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
|
88 |
|