gpt4 book ai didi

python - 如何仅从单词生成有意义的句子?

转载 作者:行者123 更新时间:2023-12-02 02:30:50 25 4
gpt4 key购买 nike

我想从单词列表中生成一个句子。我已经尝试过 n-gram 模型,但它只从已经存在的句子生成文本,即我们输入一个句子,它根据 n 的值输出下一个生成的单词。哪种模型有助于仅根据单词列表生成有意义的句子,应该使用哪个数据集来训练模型?

最佳答案

您可以使用 GPT-J。它是一个免费的 GPT 模型,其性能可与 GPT-3 相媲美。该模型接受您提供的输入,并尝试完成它。

我如何使用 GPT-J 从一组关键字生成句子:

输入:

Make a sentence with the following words: earth, dirt, alligator
Sentence: While the alligator is a species which mainly lives in the water, the earth is not uncommon territory and they like to dig through the dirt.

Make a sentence with the following words: shape, lantern, hair
Sentence:

输出:

Make a sentence with the following words: earth, dirt, alligator
Sentence: While the alligator is a species which mainly lives in the water, the earth is not uncommon territory and they like to dig through the dirt.

Make a sentence with the following words: shape, lantern, hair
Sentence: The hair is so thick on the lantern that it is almost like a shape.

如何针对特定用例进行调整?

在输入中给出一个你想要的例子(例子关键词+句子)可以帮助GPT理解想要输出的结构。明确地向 GPT 解释输入中期望的任务是什么(造句...)可以帮助它理解我的经验中的任务。

您可以通过将例句更改为类似以下内容来更改输出句子的复杂性:An alligator likes dig dirt out of the earth.

如何使用?

Git 存储库:https://github.com/kingoflolz/mesh-transformer-jax

如repo中所示,您可以使用模型的web demo进行测试,也可以使用Colab实现。

网络演示:https://6b.eleuther.ai/

Colab 笔记本:http://colab.research.google.com/github/kingoflolz/mesh-transformer-jax/blob/master/colab_demo.ipynb

我不建议尝试在本地运行它。

关于python - 如何仅从单词生成有意义的句子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65062141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com