Outline-Driven RAG & Web Research Prototype

Cobus Greyling
7 min readSep 19, 2024

--

Introduction

STORM = a writing system for the Synthesis of Topic Outlines through Retrieval and Multi-perspective Question Asking ~ Source

The research explores the process of writing Wikipedia-like articles from scratch, which necessitates a pre-writing stage before generating the final content. Simpler methods, such as Direct Prompting, often fall short in terms of planning capabilities. In contrast, the STORM approach conducts thorough research by employing perspective-driven questions in simulated conversations, allowing for the collection of more comprehensive insights on the topic.

STORM & Outline-Driven RAG

Discovering Diverse Perspectives

Simulating Conversations

Curating & Outlining

Question & Answer

LangChain Implementation

direct_gen_outline_prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You are a Wikipedia writer. Write an outline for a Wikipedia page about a user-provided topic. Be comprehensive and specific.",
),
("user", "{topic}"),
]
)
example_topic = "Impact of million-plus token context window language models on RAG"
gen_related_topics_prompt = ChatPromptTemplate.from_template(
"""I'm writing a Wikipedia page for a topic mentioned below. Please identify and recommend some Wikipedia pages on closely related subjects. I'm looking for examples that provide insights into interesting aspects commonly associated with this topic, or examples that help me understand the typical content and structure included in Wikipedia pages for similar topics.

Please list the as many subjects and urls as you can.

Topic of interest: {topic}
"""
)


class RelatedSubjects(BaseModel):
topics: List[str] = Field(
description="Comprehensive list of related subjects as background research.",
)


expand_chain = gen_related_topics_prompt | fast_llm.with_structured_output(
RelatedSubjects
)
gen_perspectives_prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"""You need to select a diverse (and distinct) group of Wikipedia editors who will work together to create a comprehensive article on the topic. Each of them represents a different perspective, role, or affiliation related to this topic.\
You can use other Wikipedia pages of related topics for inspiration. For each editor, add a description of what they will focus on.

Wiki page outlines of related topics for inspiration:
{examples}""",
),
("user", "Topic of interest: {topic}"),
]
)
gen_qn_prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"""You are an experienced Wikipedia writer and want to edit a specific page. \
Besides your identity as a Wikipedia writer, you have a specific focus when researching the topic. \
Now, you are chatting with an expert to get information. Ask good questions to get more useful information.

When you have no more questions to ask, say "Thank you so much for your help!" to end the conversation.\
Please only ask one question at a time and don't ask what you have asked before.\
Your questions should be related to the topic you want to write.
Be comprehensive and curious, gaining as much unique insight from the expert as possible.\

Stay true to your specific perspective:

{persona}""",
),
MessagesPlaceholder(variable_name="messages", optional=True),
]
)

--

--

Cobus Greyling
Cobus Greyling

Written by Cobus Greyling

I’m passionate about exploring the intersection of AI & language. www.cobusgreyling.com

No responses yet