我想要生成内容,但从一个大文件,而不是一个一行提示符。
我的文件包含60k个字符。
是否有像GPT-3这样的AI库可以接收大文件并生成类似的内容?
发布于 2022-08-31 23:45:53
您可以尝试微调GPT-2以满足您的需要。见这篇文章。或者,如果您不需要任何特别复杂或复杂的句子,而这些句子不太连贯,那么您可以使用markovify
和spacy
的马尔可夫链
import markovify
import spacy
FILE = "book.txt"
with open(FILE, "r") as file:
book = file.read()
nlp = spacy.load("en_core_web_sm")
doc = nlp(cleaned)
sentences = " ".join([sent.text for sent in doc.sents if len(sent.text) > 1])
generator = markovify.Text(sentences, state_size=3)
output = ""
for _ in range(100):
output += generator.make_sentence() + " "
print(output)
在运行此程序之前,请确保运行python -m spacy download en_core_web_sm
。
发布于 2022-09-01 15:25:34
https://stackoverflow.com/questions/73561722
复制相似问题