Skip to main content
Question generation takes a list of user queries and generates candidate follow-up questions, enabling conversational exploration and deeper investigation of your dataset.

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:
  1. Extracts entities: Identifies relevant entities from the knowledge graph using embeddings
  2. Builds context: Retrieves and prioritizes:
    • Entities and their attributes
    • Relationships between entities
    • Entity covariates (claims, facts)
    • Community reports
    • Raw text chunks from source documents
  3. Fits context: Ensures all data fits within a single LLM prompt

Question generation

  1. 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:
model
LLMCompletion
required
Language model chat completion object for question generation
context_builder
LocalContextBuilder
required
Context builder object for preparing context data from knowledge model objects. Uses the same context builder class as local search.
system_prompt
str
Prompt template for generating candidate questions. Default: QUESTION_GEN_SYSTEM_PROMPT
llm_params
dict
Additional parameters (e.g., temperature, max_tokens) passed to the LLM call. Higher temperature often produces more diverse questions.
context_builder_params
dict
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 units
  • community_prop: Proportion for community reports
  • top_k_mapped_entities: Number of top entities to include
  • top_k_relationships: Number of top relationships to include
  • max_context_tokens: Maximum tokens for context
callbacks
list[QueryCallbacks]
Optional callback functions for custom event handlers

Usage

Basic question generation

Conversational exploration loop

Custom prompt for specific domains

Best practices

1

Use higher temperature for diversity

Set temperature to 0.7-0.9 to generate more diverse and creative questions
2

Provide rich context

Ensure the context builder has access to comprehensive entity and relationship data
3

Customize prompts for your domain

Tailor the system prompt to guide question generation for your specific use case
4

Track question history

Maintain a list of all prior questions to avoid repetition and ensure progression
5

Filter and rank generated questions

Post-process questions to remove duplicates or low-quality candidates

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