Views
No views yet
1from transformers import BertTokenizer, BartForConditionalGeneration, Text2TextGenerationPipeline
2tokenizer = BertTokenizer.from_pretrained('Ayaka/bart-base-cantonese')
3model = BartForConditionalGeneration.from_pretrained('Ayaka/bart-base-cantonese')
4text2text_generator = Text2TextGenerationPipeline(model, tokenizer)
5output = text2text_generator('聽日就要返香港,我激動到[MASK]唔着', max_length=50, do_sample=False)
6print(output[0]['generated_text'].replace(' ', ''))
7# output: 聽日就要返香港,我激動到瞓唔着BertTokenizer for the model vocabulary. DO NOT use the original BartTokenizer.1j7zs802