Open SupetZYK opened 11 months ago
from transformers import BertTokenizer, BartForConditionalGeneration, Text2TextGenerationPipeline tokenizer = BertTokenizer.from_pretrained("fnlp/bart-large-chinese") model = BartForConditionalGeneration.from_pretrained("fnlp/bart-large-chinese") text2text_generator = Text2TextGenerationPipeline(model, tokenizer) text2text_generator("北京是[MASK]的首都", max_length=50, do_sample=False) [{'generated_text': '北 京 是 中 华 人 民 共 和 国 的 首 都'}]
How to remove the blank between chinese characters?
Just replace the space in the outputs with nothing by .replace(' ', ''). Easy.
.replace(' ', '')
How to remove the blank between chinese characters?