Views
No views yet
t5-chinese-couplet evaluate couplet test data:| prefix | input_text | target_text | pred |
|---|---|---|---|
| 对联: | 春回大地,对对黄莺鸣暖树 | 日照神州,群群紫燕衔新泥 | 福至人间,家家紫燕舞和风 |

pip install -U textgen1from textgen import T5Model
2model = T5Model("t5", "shibing624/t5-chinese-couplet")
3r = model.predict(["对联:丹枫江冷人初去"])
4print(r) # ['白石矶寒客不归']pip install transformers 1from transformers import T5ForConditionalGeneration, T5Tokenizer
2
3tokenizer = T5Tokenizer.from_pretrained("shibing624/t5-chinese-couplet")
4model = T5ForConditionalGeneration.from_pretrained("shibing624/t5-chinese-couplet")
5
6
7def batch_generate(input_texts, max_length=64):
8 features = tokenizer(input_texts, return_tensors='pt')
9 outputs = model.generate(input_ids=features['input_ids'],
10 attention_mask=features['attention_mask'],
11 max_length=max_length)
12 return tokenizer.batch_decode(outputs, skip_special_tokens=True)
13
14
15r = batch_generate(["对联:丹枫江冷人初去"])
16print(r)['白石矶寒客不归']t5-chinese-couplet
├── config.json
├── model_args.json
├── pytorch_model.bin
├── special_tokens_map.json
├── tokenizer_config.json
├── spiece.model
└── vocab.txt1head -n 1 couplet_files/couplet/train/in.txt
2晚 风 摇 树 树 还 挺
3
4head -n 1 couplet_files/couplet/train/out.txt
5晨 露 润 花 花 更 红 1@software{textgen,
2 author = {Xu Ming},
3 title = {textgen: Implementation of Text Generation models},
4 year = {2022},
5 url = {https://github.com/shibing624/textgen},
6}