Upload folder using huggingface_hub
Browse files- README.md +52 -51
- config.json +1 -1
- generation_config.json +1 -1
- model.safetensors +1 -1
- tokenizer.json +0 -0
README.md
CHANGED
@@ -1,51 +1,52 @@
|
|
1 |
-
---
|
2 |
-
library_name: transformers
|
3 |
-
license: apache-2.0
|
4 |
-
datasets:
|
5 |
-
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
import
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
1 |
+
---
|
2 |
+
library_name: transformers
|
3 |
+
license: apache-2.0
|
4 |
+
datasets:
|
5 |
+
- benchang1110/pretrainedtw
|
6 |
+
- HuggingFaceTB/cosmopedia-100k
|
7 |
+
language:
|
8 |
+
- zh
|
9 |
+
widget:
|
10 |
+
- text: '在很久以前,這座島上'
|
11 |
+
example_title: Example1
|
12 |
+
|
13 |
+
---
|
14 |
+
|
15 |
+
# Model Card for Model ID
|
16 |
+
|
17 |
+
This is a continue-pretrained version of [Tinyllama](TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T) tailored for traditional Chinese. The continue-pretraining dataset contains roughly 2B tokens.
|
18 |
+
|
19 |
+
# Usage
|
20 |
+
```python
|
21 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
22 |
+
import torch
|
23 |
+
|
24 |
+
def generate_response(input):
|
25 |
+
'''
|
26 |
+
simple test for the model
|
27 |
+
'''
|
28 |
+
# tokenzize the input
|
29 |
+
tokenized_input = tokenizer.encode_plus(input, return_tensors='pt').to(device)
|
30 |
+
|
31 |
+
# generate the response
|
32 |
+
outputs = model.generate(
|
33 |
+
input_ids=tokenized_input['input_ids'],
|
34 |
+
attention_mask=tokenized_input['attention_mask'],
|
35 |
+
pad_token_id=tokenizer.pad_token_id,
|
36 |
+
do_sample=False,
|
37 |
+
repetition_penalty=1.3,
|
38 |
+
max_length=500
|
39 |
+
)
|
40 |
+
|
41 |
+
# decode the response
|
42 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
43 |
+
|
44 |
+
if __name__ == '__main__':
|
45 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
46 |
+
model = AutoModelForCausalLM.from_pretrained("DavidLanz/Taiwan-tinyllama-v1.0-chat",device_map=device,torch_dtype=torch.bfloat16)
|
47 |
+
tokenizer = AutoTokenizer.from_pretrained("DavidLanz/Taiwan-tinyllama-v1.0-chat")
|
48 |
+
while(True):
|
49 |
+
text = input("input a simple prompt:")
|
50 |
+
print('System:', generate_response(text))
|
51 |
+
```
|
52 |
+
Using bfloat16, the VRAM required is around 3GB!!!
|
config.json
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
"rope_theta": 10000.0,
|
24 |
"tie_word_embeddings": false,
|
25 |
"torch_dtype": "float16",
|
26 |
-
"transformers_version": "4.
|
27 |
"use_cache": true,
|
28 |
"vocab_size": 32000
|
29 |
}
|
|
|
23 |
"rope_theta": 10000.0,
|
24 |
"tie_word_embeddings": false,
|
25 |
"torch_dtype": "float16",
|
26 |
+
"transformers_version": "4.44.2",
|
27 |
"use_cache": true,
|
28 |
"vocab_size": 32000
|
29 |
}
|
generation_config.json
CHANGED
@@ -3,5 +3,5 @@
|
|
3 |
"eos_token_id": 2,
|
4 |
"max_length": 2048,
|
5 |
"pad_token_id": 0,
|
6 |
-
"transformers_version": "4.
|
7 |
}
|
|
|
3 |
"eos_token_id": 2,
|
4 |
"max_length": 2048,
|
5 |
"pad_token_id": 0,
|
6 |
+
"transformers_version": "4.44.2"
|
7 |
}
|
model.safetensors
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 2200119664
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:13874894c02bd920b5b31e1b4ce044aed98f3c0d3fa27ba9db3f5fe83e71ff02
|
3 |
size 2200119664
|
tokenizer.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|