run-llama/llama_index · error · ValueError
questions must be >= 1
Error message
questions must be >= 1
What it means
Raised by QuestionsAnsweredExtractor.__init__ when the questions parameter (number of questions the LLM should generate per node, default 5) is less than 1. Like the other metadata extractors, the count is validated eagerly in the constructor because it is interpolated into prompt_template.
Solutions
- Pass questions >= 1, e.g. QuestionsAnsweredExtractor() for the default of 5.
- Clamp config inputs: questions = max(1, cfg['questions']).
- If question metadata is unwanted, drop the extractor from the pipeline.
Example fix
# before extractor = QuestionsAnsweredExtractor(questions=cfg["questions"]) # 0 # after extractor = QuestionsAnsweredExtractor(questions=max(1, cfg["questions"]))
Defensive patterns
Strategy: validation
Validate before calling
num_questions = int(config.get("questions", 5))
if num_questions < 1:
raise ValueError(f"questions must be >= 1, got {num_questions}")
extractor = QuestionsAnsweredExtractor(questions=num_questions) Prevention
- Validate question counts (>= 1) before construction.
- Use Literal/Field(gt=0) constraints in pydantic config models.
- Centralize extractor-config validation so all extractors are checked uniformly.
When it happens
Trigger: Constructing QuestionsAnsweredExtractor(questions=0) from a misconfigured value — config file, environment variable, or computed expression that produces zero/negative.
Common situations: Shared config templates reused across extractors where questions defaulted to 0; dynamic question counts derived from document size; refactors that renamed the old questions_per_chunk parameter and lost the value.
Related errors
- num_keywords must be >= 1
- num_nodes must be >= 1
- All agents must have a description in a multi-agent workflow
- All agents must have a name in a multi-agent workflow
- At least one of requests_per_minute or tokens_per_minute…
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/c79b30dafd49bd82.
Report an issue: GitHub.
Appendix: source
Thrown at llama-index-core/llama_index/core/extractors/metadata_extractors.py:308
)
embedding_only: bool = Field(
default=True, description="Whether to use metadata for emebddings only."
)
def __init__(
self,
llm: Optional[LLM] = None,
# TODO: llm_predictor arg is deprecated
llm_predictor: Optional[LLM] = None,
questions: int = 5,
prompt_template: str = DEFAULT_QUESTION_GEN_TMPL,
embedding_only: bool = True,
num_workers: int = DEFAULT_NUM_WORKERS,
**kwargs: Any,
) -> None:
"""Init params."""
if questions < 1:
raise ValueError("questions must be >= 1")
super().__init__(
llm=llm or llm_predictor or Settings.llm,
questions=questions,
prompt_template=prompt_template,
embedding_only=embedding_only,
num_workers=num_workers,
**kwargs,
)
@classmethod
def class_name(cls) -> str:
return "QuestionsAnsweredExtractor"
async def _aextract_questions_from_node(self, node: BaseNode) -> Dict[str, str]:
"""Extract questions from a node and return it's metadata dict."""
if self.is_text_node_only and not isinstance(node, TextNode):
return {}View on GitHub (pinned to afd0fef371)