【发布时间】:2022-12-09 18:24:05
【问题描述】:
EluetherAPI 基于 PILE 数据集发布了很多 GPT 模型,等同于原始的 GPT 模型。由于它们是在更大的数据集上训练的,我们可以在同一个模型上执行多个 NLP 任务,而无需重新训练模型,只需很少的提示或使用少样本学习提供一些上下文。
我正在努力实现同样的目标。但问题是返回文本有时太大或太短。这是我的示例代码:
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B', device=0)
prompt= """[Original]: The diplomatic spat came days after France cut the number of visas it issues for citizens of Algeria and other North African countries.
[Paraphrase]: """
result = generator(prompt, do_sample=True, min_length=10, max_new_tokens=50, top_p=0.9, temperature=1)
结果给了我这个:
France has been forced to temporarily remove two of its citizens who are on a tourist visa from Algeria and Morocco, which have had a long and acrimonious history over the past decade.
[Original]: The two visa holders, who
如您所见,它给我的结果包括输入文本,我删除了输入文本,它工作正常但最后它仍然显示 [Original]: 提示,如何删除它并给出完全相同的结果?
我尝试了多次,甚至提供了上下文,但有时效果很好,有时却不行。我什至尝试使用数据进行少量学习:
"""[Original]: Algeria recalled its ambassador to Paris on Saturday and closed its airspace to French military planes a day later after the French president made comments about the northern Africa country.
[Paraphrase]: Last Saturday, the Algerian government recalled its ambassador and stopped accepting French military airplanes in its airspace. It happened one day after the French president made comments about Algeria.
###
[Original]: President Macron was quoted as saying the former French colony was ruled by a "political-military system" with an official history that was based not on truth, but on hatred of France.
[Paraphrase]: Emmanuel Macron said that the former colony was lying and angry at France. He also said that the country was ruled by a "political-military system".
###
[Original]: The diplomatic spat came days after France cut the number of visas it issues for citizens of Algeria and other North African countries.
[Paraphrase]: Diplomatic issues started appearing when France decided to stop granting visas to Algerian people and other North African people.
###
[Original]: After a war lasting 20 years, following the decision taken first by President Trump and then by President Biden to withdraw American troops, Kabul, the capital of Afghanistan, fell within a few hours to the Taliban, without resistance.
[Paraphrase]:""
我想知道有什么方法可以传递 end_sequence 以便它在之后停止生成,还有参数 top_p 和 temperature 以获得良好的结果?
【问题讨论】:
标签: python nlp gpt gpt-3 text-generation