AlHfac commited on
Commit
d4ecbd0
·
verified ·
1 Parent(s): c369292

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -3
README.md CHANGED
@@ -11,23 +11,73 @@ language:
11
  - en
12
  ---
13
 
14
- # How to Run thie Model
15
  基本的にhugging face modelとしてloadすればOK。
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  コード例
17
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  bnb_config = BitsAndBytesConfig(
19
  load_in_4bit=True,
20
  bnb_4bit_quant_type="nf4",
21
  bnb_4bit_compute_dtype=torch.bfloat16,
22
  bnb_4bit_use_double_quant=False,
23
  )
 
24
  model = AutoModelForCausalLM.from_pretrained(
25
- 'AlHfac/llm-jp-3-13b-it',
26
  quantization_config=bnb_config,
27
  device_map="auto",
28
  token = HF_TOKEN
29
  )
30
- tokenizer = AutoTokenizer.from_pretrained('AlHfac/llm-jp-3-13b-it', trust_remote_code=True, token = HF_TOKEN)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ```
32
 
33
  # Model Training Information
 
11
  - en
12
  ---
13
 
14
+ # How to Run this Model
15
  基本的にhugging face modelとしてloadすればOK。
16
+ ** elyza-tasks-100-TV_0.jsonl を事前に同じフォルダーに置いてください。 **
17
+
18
+
19
+ 環境準備
20
+
21
+ ```
22
+ !pip install -U bitsandbytes
23
+ !pip install -U transformers
24
+ !pip install -U accelerate
25
+ !pip install -U datasets
26
+ ```
27
+
28
+
29
+
30
  コード例
31
  ```
32
+ from transformers import (
33
+ AutoModelForCausalLM,
34
+ AutoTokenizer,
35
+ BitsAndBytesConfig,
36
+ )
37
+ import torch
38
+ from tqdm import tqdm
39
+ import json
40
+
41
+ HF_TOKEN = "hf_ddlNeFZWWURoIBcXhAlVIxAYErhqLntJjYn"
42
+ model_name = "AlHfac/llm-jp-3-13b-it"
43
+
44
+ # QLoRA config
45
  bnb_config = BitsAndBytesConfig(
46
  load_in_4bit=True,
47
  bnb_4bit_quant_type="nf4",
48
  bnb_4bit_compute_dtype=torch.bfloat16,
49
  bnb_4bit_use_double_quant=False,
50
  )
51
+ # Load model
52
  model = AutoModelForCausalLM.from_pretrained(
53
+ model_name,
54
  quantization_config=bnb_config,
55
  device_map="auto",
56
  token = HF_TOKEN
57
  )
58
+
59
+ # Load tokenizer
60
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True, token = HF_TOKEN)
61
+
62
+ # Evaluate
63
+ datasets = []
64
+ with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
65
+ item = ""
66
+ for line in f:
67
+ line = line.strip()
68
+ item += line
69
+ if item.endswith("}"):
70
+ datasets.append(json.loads(item))
71
+ item = ""
72
+
73
+ # Generate jsonl
74
+ import re
75
+ model_name = re.sub(".*/", "", model_name)
76
+ with open(f"./{model_name}-outputs.jsonl", 'w', encoding='utf-8') as f:
77
+ for result in results:
78
+ json.dump(result, f, ensure_ascii=False) # ensure_ascii=False for handling non-ASCII characters
79
+ f.write('\n')
80
+
81
  ```
82
 
83
  # Model Training Information