update
Browse files
README.md
CHANGED
@@ -3,6 +3,76 @@ library_name: transformers
|
|
3 |
tags: []
|
4 |
---
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# Model Card for Model ID
|
7 |
|
8 |
<!-- Provide a quick summary of what the model is/does. -->
|
|
|
3 |
tags: []
|
4 |
---
|
5 |
|
6 |
+
## 以下は推論用コードです。
|
7 |
+
|
8 |
+
* 事前に以下をインストールしてください。
|
9 |
+
* pip install -q numpy==1.26.4
|
10 |
+
* pip install -q vllm==0.6.4
|
11 |
+
|
12 |
+
|
13 |
+
```python
|
14 |
+
|
15 |
+
from vllm import LLM, SamplingParams
|
16 |
+
|
17 |
+
import torch
|
18 |
+
import json
|
19 |
+
|
20 |
+
dir = "."
|
21 |
+
|
22 |
+
from datasets import load_dataset
|
23 |
+
|
24 |
+
data_files = {"test": dir + "/elyza-tasks-100-TV_0.jsonl"}
|
25 |
+
tasks = load_dataset("json", data_files=data_files, split="test")
|
26 |
+
|
27 |
+
id = "llm-jp-3-13b-it-bs4-ac10-step251-fp8"
|
28 |
+
|
29 |
+
from huggingface_hub import snapshot_download
|
30 |
+
model_id = snapshot_download(repo_id="jaked97/" + id)
|
31 |
+
|
32 |
+
prompts = [
|
33 |
+
f"""### instruction:
|
34 |
+
あなたは親切なAIアシスタントです。
|
35 |
+
### input:
|
36 |
+
{input}
|
37 |
+
### output:
|
38 |
+
""" for input in tasks["input"]]
|
39 |
+
|
40 |
+
llm = LLM(
|
41 |
+
model=model_id,
|
42 |
+
gpu_memory_utilization=0.95,
|
43 |
+
quantization="compressed-tensors",
|
44 |
+
trust_remote_code=True,
|
45 |
+
enforce_eager=True,
|
46 |
+
)
|
47 |
+
|
48 |
+
|
49 |
+
# 推論の実行
|
50 |
+
outputs = llm.generate(
|
51 |
+
prompts,
|
52 |
+
sampling_params = SamplingParams(
|
53 |
+
temperature=0,
|
54 |
+
max_tokens=512,
|
55 |
+
repetition_penalty=1.2,
|
56 |
+
skip_special_tokens=True,
|
57 |
+
seed=97,
|
58 |
+
),
|
59 |
+
)
|
60 |
+
|
61 |
+
|
62 |
+
# jsonlで保存
|
63 |
+
with open(dir + f"/{id}_max512-vllm.jsonl", 'w', encoding='utf-8') as f:
|
64 |
+
for i in range(len(outputs)):
|
65 |
+
result = {
|
66 |
+
"task_id" : tasks[i]["task_id"],
|
67 |
+
"input" : tasks[i]["input"],
|
68 |
+
"output" : outputs[i].outputs[0].text
|
69 |
+
}
|
70 |
+
json.dump(result, f, ensure_ascii=False)
|
71 |
+
f.write('\n')
|
72 |
+
```
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
# Model Card for Model ID
|
77 |
|
78 |
<!-- Provide a quick summary of what the model is/does. -->
|