Update README.md
Browse files
README.md
CHANGED
@@ -8,7 +8,9 @@ tags:
|
|
8 |
- trl
|
9 |
license: apache-2.0
|
10 |
language:
|
11 |
-
-
|
|
|
|
|
12 |
---
|
13 |
|
14 |
# Uploaded model
|
@@ -34,5 +36,58 @@ Training epoch:1
|
|
34 |
Authors
|
35 |
tsuchida rikuto
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
|
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
- trl
|
9 |
license: apache-2.0
|
10 |
language:
|
11 |
+
- ja
|
12 |
+
datasets:
|
13 |
+
- kinokokoro/ichikara-instruction-003
|
14 |
---
|
15 |
|
16 |
# Uploaded model
|
|
|
36 |
Authors
|
37 |
tsuchida rikuto
|
38 |
|
39 |
+
How to Use
|
40 |
+
To use this model, run the code below
|
41 |
+
```python
|
42 |
+
!pip install -U bitsandbytes
|
43 |
+
!pip install -U transformers
|
44 |
+
!pip install -U accelerate
|
45 |
+
!pip install -U datasets
|
46 |
|
47 |
+
!pip install ipywidgets --upgrade
|
48 |
|
49 |
+
from transformers import (
|
50 |
+
AutoModelForCausalLM,
|
51 |
+
AutoTokenizer,
|
52 |
+
BitsAndBytesConfig,
|
53 |
+
)
|
54 |
+
import torch
|
55 |
+
from tqdm import tqdm
|
56 |
+
import json
|
57 |
+
|
58 |
+
|
59 |
+
model_name = "trikudayodayodayo/llm-jp-3-13b-it-1209_lora"
|
60 |
+
|
61 |
+
bnb_config = BitsAndBytesConfig(
|
62 |
+
load_in_4bit=True,
|
63 |
+
bnb_4bit_quant_type="nf4",
|
64 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
65 |
+
bnb_4bit_use_double_quant=False,
|
66 |
+
)
|
67 |
+
|
68 |
+
HF_TOKEN="Type your HF_TOKEN"
|
69 |
+
|
70 |
+
model = AutoModelForCausalLM.from_pretrained(
|
71 |
+
model_name,
|
72 |
+
quantization_config=bnb_config,
|
73 |
+
device_map="auto",
|
74 |
+
token = HF_TOKEN
|
75 |
+
)
|
76 |
+
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True, token = HF_TOKEN)
|
78 |
+
|
79 |
+
input = "Type text here"
|
80 |
+
|
81 |
+
tokenized_input = tokenizer.encode(input, add_special_tokens=False, return_tensors="pt").to(model.device)
|
82 |
+
with torch.no_grad():
|
83 |
+
outputs = model.generate(
|
84 |
+
tokenized_input,
|
85 |
+
max_new_tokens=100,
|
86 |
+
do_sample=False,
|
87 |
+
repetition_penalty=1.2
|
88 |
+
)[0]
|
89 |
+
|
90 |
+
output = tokenizer.decode(outputs[tokenized_input.size(1):], skip_special_tokens=True)
|
91 |
+
|
92 |
+
print(output)
|
93 |
+
```
|