223b
/

Safetensors
223b commited on
Commit
969b33e
·
verified ·
1 Parent(s): b172d88

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -16
README.md CHANGED
@@ -1,22 +1,66 @@
1
  ---
2
- base_model: llm-jp/llm-jp-3-13b
3
- tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - llama
8
- - trl
9
- license: apache-2.0
10
- language:
11
- - en
12
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- # Uploaded model
15
 
16
- - **Developed by:** 223b
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)
 
 
 
 
 
 
1
  ---
2
+ license: llama3.1
3
+ datasets:
4
+ - DeL-TaiseiOzaki/Tengentoppa-sft-v1.0
5
+ - kinokokoro/ichikara-instruction-003
6
+ base_model:
7
+ - llm-jp/llm-jp-3-13b-instruct
 
 
 
 
8
  ---
9
+ ---
10
+
11
+ # Inference
12
+ ```python
13
+ from unsloth import FastLanguageModel
14
+ from peft import PeftModel
15
+ import torch
16
+ import json
17
+ from tqdm import tqdm
18
+ import re
19
+
20
+ model_id = "llm-jp/llm-jp-3-13b"
21
+ adapter_id = ""
22
+ HF_TOKEN = "" # use your token
23
+
24
+ dtype = None
25
+ load_in_4bit = True # 今回は13Bモデルを扱うためTrue
26
+
27
+ model, tokenizer = FastLanguageModel.from_pretrained(
28
+ model_name=model_id,
29
+ dtype=dtype,
30
+ load_in_4bit=load_in_4bit,
31
+ trust_remote_code=True,
32
+ )
33
+
34
+ model = PeftModel.from_pretrained(model, adapter_id, token = HF_TOKEN)
35
+
36
+ datasets = []
37
+ with open("./elyza-tasks-100-TV_0.jsonl", "r") as f:
38
+ item = ""
39
+ for line in f:
40
+ line = line.strip()
41
+ item += line
42
+ if item.endswith("}"):
43
+ datasets.append(json.loads(item))
44
+ item = ""
45
+
46
+ FastLanguageModel.for_inference(model)
47
+
48
+ results = []
49
+ for dt in tqdm(datasets):
50
+ input = dt["input"]
51
+
52
+ prompt = f"""### 指示\n{input}\n### 回答\n"""
53
 
54
+ inputs = tokenizer([prompt], return_tensors = "pt").to(model.device)
55
 
56
+ outputs = model.generate(**inputs, max_new_tokens = 512, use_cache = True, do_sample=False, repetition_penalty=1.2)
57
+ prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).split('\n### 回答')[-1]
 
58
 
59
+ results.append({"task_id": dt["task_id"], "input": input, "output": prediction})
60
 
61
+ json_file_id = re.sub(".*/", "", adapter_id)
62
+ with open(f"/content/{json_file_id}_output.jsonl", 'w', encoding='utf-8') as f:
63
+ for result in results:
64
+ json.dump(result, f, ensure_ascii=False)
65
+ f.write('\n')
66
+ ```