Skip to content

Generated Knowledge

Generated Knowledge is a prompting technique where one first asks the LLM a question to generate facts, then uses the generated answer to answer a question correctly.

  • knownledge generation, the LLM is asked to generate a set of facts about the question.
  • knownledge integration, the LLM is asked a question augmented by the knowledge generated

This technique can be acheived by using runPrompt to execute an LLM request and use it in the final prompt.

Example

This example demanstrates this technique to generate a blog post.

script({
title: "blog using generated knowledge",
model: "openai:gpt-3.5-turbo",
description:
"Using Generated Knowledge technique. More at https://learnprompting.org/docs/intermediate/generated_knowledge",
tests: {
files: "src/rag/markdown.md",
keywords: ["markdown"],
},
})
// first prompt LLM to generate facts
const { text } = await runPrompt((_) => {
_.def("FILE", env.files)
_.$`Generate 5 facts about the content of FILE.`
})
// then use the facts to generate a blog
def("FACTS", text)
$`Use the above facts to write a one paragraph blog post`