Downloads · 30 days
21
3% of all-time downloads
benchang1110/Taiwan-tinyllama-v1.0-base
Taiwan-tinyllama-v1.0-base is a text generation model from benchang1110. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is a continue-pretrained version of Tinyllama tailored for traditional Chinese. The continue-pretraining dataset contains roughly 2B tokens.
Downloads · 30 days
21
3% of all-time downloads
All-time downloads
807
Public
Parameters
1.1B
8.8 GB on disk
Likes
1
Public
Click a slice to open those files.
.bin4.4 GB · 50%
From the Hugging Face model README
This is a continue-pretrained version of Tinyllama tailored for traditional Chinese. The continue-pretraining dataset contains roughly 2B tokens.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
def generate_response(input):
'''
simple test for the model
'''
# tokenzize the input
tokenized_input = tokenizer.encode_plus(input, return_tensors='pt').to(device)
# generate the response
outputs = model.generate(
input_ids=tokenized_input['input_ids'],
attention_mask=tokenized_input['attention_mask'],
pad_token_id=tokenizer.pad_token_id,
do_sample=False,
repetition_penalty=1.3,
max_length=500
)
# decode the response
return tokenizer.decode(outputs[0], skip_special_tokens=True)
if __name__ == '__main__':
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = AutoModelForCausalLM.from_pretrained("benchang1110/Taiwan-tinyllama-v1.0-base",device_map=device,torch_dtype=torch.bfloat16)
tokenizer = AutoTokenizer.from_pretrained("benchang1110/Taiwan-tinyllama-v1.0-base")
while(True):
text = input("input a simple prompt:")
print('System:', generate_response(text))
Using bfloat16, the VRAM required is around 3GB!!!