模型:
vennify/t5-base-grammar-correction
该模型生成一篇经过修订的文本版本,目的是减少语法错误。它使用一个名为 JFLEG 的数据集经过 Happy Transformer 的训练得到。这里有一个关于如何训练类似模型的 full article 。
pip install happytransformer
from happytransformer import HappyTextToText, TTSettings happy_tt = HappyTextToText("T5", "vennify/t5-base-grammar-correction") args = TTSettings(num_beams=5, min_length=1) # Add the prefix "grammar: " before each input result = happy_tt.generate_text("grammar: This sentences has has bads grammar.", args=args) print(result.text) # This sentence has bad grammar.