Overview
The question generation method combines structured data from the knowledge graph with unstructured data from input documents to generate candidate questions related to specific entities. This is useful for:- Conversational AI: Generating follow-up questions in multi-turn conversations
- Guided exploration: Creating question lists for investigators to dive deeper into datasets
- Content discovery: Surfacing important themes and topics for further investigation
- Interactive dashboards: Suggesting next questions based on user interests
Question generation uses the same context-building approach as local search, ensuring that generated questions are grounded in actual data from the knowledge graph.
How it works
Question generation follows a similar pipeline to local search:Context building
Given a list of prior user questions, the method:- Extracts entities: Identifies relevant entities from the knowledge graph using embeddings
- Builds context: Retrieves and prioritizes:
- Entities and their attributes
- Relationships between entities
- Entity covariates (claims, facts)
- Community reports
- Raw text chunks from source documents
- Fits context: Ensures all data fits within a single LLM prompt
Question generation
- Generates candidates: Uses the LLM to generate follow-up questions that:
- Represent the most important or urgent information in the data
- Relate to themes and content in the context
- Build on prior questions
- Are specific and actionable
Configuration
The question generation class accepts the following key parameters:Language model chat completion object for question generation
Context builder object for preparing context data from knowledge model objects. Uses the same context builder class as local search.
Prompt template for generating candidate questions. Default:
QUESTION_GEN_SYSTEM_PROMPTAdditional parameters (e.g., temperature, max_tokens) passed to the LLM call. Higher temperature often produces more diverse questions.
Additional parameters passed to the context builder when building context. Supports the same parameters as local search:
text_unit_prop: Proportion of context for text unitscommunity_prop: Proportion for community reportstop_k_mapped_entities: Number of top entities to includetop_k_relationships: Number of top relationships to includemax_context_tokens: Maximum tokens for context
Optional callback functions for custom event handlers
Usage
Basic question generation
Integration with local search
Conversational exploration loop
Custom prompt for specific domains
Best practices
Use higher temperature for diversity
Set
temperature to 0.7-0.9 to generate more diverse and creative questionsProvide rich context
Ensure the context builder has access to comprehensive entity and relationship data
Customize prompts for your domain
Tailor the system prompt to guide question generation for your specific use case
Track question history
Maintain a list of all prior questions to avoid repetition and ensure progression
Advanced techniques
Question ranking and filtering
Thematic question organization
Use cases
Research exploration
Guide researchers through datasets by suggesting relevant questions based on their inquiry path
Chatbot interfaces
Power conversational interfaces with contextually relevant follow-up questions
Data investigation
Help investigators discover hidden patterns by suggesting unexplored angles
Training data generation
Generate question-answer pairs for fine-tuning or evaluation datasets
Next steps
Local search
Learn about entity-based search that powers question generation
Conversation history
Manage multi-turn conversations
Example notebooks
See question generation in action
Custom prompts
Customize prompts for your domain