Act as an expert AI Systems Engineer specializing in LLM-powered web search agents. Analyze the provided GitHub repository focusing exclusively on the web search implementation and its unique search processing patterns.
Required Output:
Search Flow Overview (2-3 sentences)
Key Search Components
Search execution pattern
Query construction approach
Result processing mechanism
Context management method
Search Implementation Steps (numbered, brief)
Query formation
Search execution
Result processing
Context integration
Notable Search Features
Query refinement techniques
Result filtering methods
Context preservation strategies
Search iteration patterns
quote Prompts, and agentic behaver, cheking, tool, extra info like module/depencies, ect...
Search-Specific Dependencies
Guidelines:
Focus ONLY on web search functionality
Highlight search processing techniques
Explain context management between searches
Detail query refinement patterns
Describe result cleaning/filtering approaches
Note any search iteration or validation methods
as expert use clear defined techniqual and enginer word/term to be more precis when applicable for consise able for let reboducible/replicae code, if more compact but still clear, use pseudo python code.
Addiotnaly any other special/interesting/what make it special/not told powefull things.
Please analyze this repository's web search implementation.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
STORM employs a conversational search approach, iteratively querying search engines based on evolving user needs and different perspectives on the main topic. It refines queries through simulated conversations between a "Wikipedia writer" and a topic "expert," leveraging retrieved information to guide subsequent searches.
2. Key Search Components:
Search execution pattern: Primarily utilizes established search APIs (You.com, Bing, Brave, SearXNG, DuckDuckGo, Google, Azure AI Search) through configurable retriever modules. Supports both online search engine APIs and offline vector databases (Qdrant). Enables concurrent searches for efficiency.
Query construction approach: Constructs queries based on the main topic and dynamically generated sub-topics derived through simulated conversations and perspective-guided question asking. The outline generation module also contributes to query formulation.
Result processing mechanism: Retrieves top-k search results. Processes retrieved web pages, extracting text content and splitting it into smaller snippets using RecursiveCharacterTextSplitter while managing citations. Filters unreliable sources based on a Wikipedia-compliant blacklist. Stores processed results in a StormInformationTable for subsequent use.
Context management method: Maintains context through the StormInformationTable, storing retrieved information, associated queries, and perspectives. This table facilitates retrieval of relevant information during article generation based on section titles and sub-topics.
3. Search Implementation Steps:
Query formation: Initial query is the user-provided topic. Subsequent queries are generated by the question_asker_lm within the StormKnowledgeCurationModule, influenced by different perspectives and the conversation simulator. These queries are also informed by the dynamically generated outline.
Search execution: The Retriever class within StormKnowledgeCurationModule, using a configured rm (retrieval module), executes searches concurrently using specified search APIs or the offline vector database.
Result processing:WebPageHelper downloads and extracts text content from retrieved URLs. RecursiveCharacterTextSplitter splits the extracted text into snippets. is_valid_wikipedia_source filters unreliable sources. Results are stored in StormInformationTable, associating snippets with their source URLs.
Context integration: The StormInformationTable acts as the central context store. During article generation, the generate_article function retrieves relevant information from the table based on the section title being written, using it as the query.
4. Notable Search Features:
Query refinement techniques: Employs "perspective-guided question asking" and "simulated conversation" to dynamically refine search queries, ensuring diverse exploration of the topic.
Result filtering methods: Implements a blacklist of unreliable sources based on Wikipedia standards, improving the quality of retrieved information.
Context preservation strategies: Uses StormInformationTable to store and manage retrieved information, associating it with queries, perspectives, and source URLs. This allows for targeted retrieval of information during article generation.
Search iteration patterns: Iteratively refines queries based on retrieved information and simulated conversation turns, leading to a deeper exploration of the subject matter.
python
# Example of agentic behavior in knowledge_storm/storm_wiki/modules/knowledge_curation.py
# ... within StormKnowledgeCurationModule.research(...)
for perspective in perspectives:
# Simulate a conversation with the expert from the given perspective.
conversation = self.simulate_conversation(topic, perspective)
# ...
python
# Example of prompt in knowledge_storm/storm_wiki/modules/persona_generator.py
# Prompt to find related Wikipedia pages to a given topic.
FIND_RELATED_TOPIC_PROMPT = """\
Given the following topic, please provide a list of URLs of related Wikipedia pages.
Topic: {topic}
Related Wikipedia Pages:
"""
5. Search-Specific Dependencies:
httpx: For making HTTP requests to web pages and APIs.
trafilatura: For extracting main content from web pages.
langchain-text-splitters: For splitting long texts into smaller chunks.
wikipedia: For interacting with Wikipedia (though not directly related to web search in this context).
qdrant-client, langchain-qdrant: For interacting with the Qdrant vector database when using offline search.
Additional Notes:
STORM's unique strength lies in its dynamic query refinement process, utilizing simulated conversations and perspective shifting to explore the topic comprehensively. The filtering of unreliable sources enhances the trustworthiness of the generated content. The context management mechanism, through StormInformationTable, enables efficient retrieval of relevant information during article generation. The modular design allows for flexibility in choosing different search engines and language models.