DavidLanz commited on
Commit
2ec7df8
·
verified ·
1 Parent(s): 0caa7ac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -52
README.md CHANGED
@@ -1,52 +1,53 @@
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!!!
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ datasets:
5
+ - DavidLanz/TaiwanChat
6
+ - benchang1110/pretrainedtw
7
+ - HuggingFaceTB/cosmopedia-100k
8
+ language:
9
+ - zh
10
+ widget:
11
+ - text: '在很久以前,這座島上'
12
+ example_title: Example1
13
+
14
+ ---
15
+
16
+ # Model Card for Model ID
17
+
18
+ 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.
19
+
20
+ # Usage
21
+ ```python
22
+ from transformers import AutoModelForCausalLM, AutoTokenizer
23
+ import torch
24
+
25
+ def generate_response(input):
26
+ '''
27
+ simple test for the model
28
+ '''
29
+ # tokenzize the input
30
+ tokenized_input = tokenizer.encode_plus(input, return_tensors='pt').to(device)
31
+
32
+ # generate the response
33
+ outputs = model.generate(
34
+ input_ids=tokenized_input['input_ids'],
35
+ attention_mask=tokenized_input['attention_mask'],
36
+ pad_token_id=tokenizer.pad_token_id,
37
+ do_sample=False,
38
+ repetition_penalty=1.3,
39
+ max_length=500
40
+ )
41
+
42
+ # decode the response
43
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
44
+
45
+ if __name__ == '__main__':
46
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
47
+ model = AutoModelForCausalLM.from_pretrained("DavidLanz/Taiwan-tinyllama-v1.0-chat",device_map=device,torch_dtype=torch.bfloat16)
48
+ tokenizer = AutoTokenizer.from_pretrained("DavidLanz/Taiwan-tinyllama-v1.0-chat")
49
+ while(True):
50
+ text = input("input a simple prompt:")
51
+ print('System:', generate_response(text))
52
+ ```
53
+ Using bfloat16, the VRAM required is around 3GB!!!