Skip to content

API Reference parrot.knowledge.pageindex.optimizer_eval

github-actions[bot] edited this page Dec 2, 2026 · 2 revisions

parrot.knowledge.pageindex.optimizer_eval

View source

Evaluation harness for the PageIndex tree optimizer (FEAT-846 M6). Numbers only, never node titles.

Usage::

python -m parrot.knowledge.pageindex.optimizer_eval <pdf|dir>... [--llm provider:model] [--out DIR]

Each PDF is imported into a temporary storage directory with optimize_on_import=False (layout structure, no summaries), then optimized with optimize(apply=True). The report holds counts, token statistics and the PDF file stem only, so a report over a non-redistributable PDF can be quoted.

Attribute DEFAULT_OUT

Class EvalReport

Corpus evaluation report.

Fields:

Field Type Default Description
created_at str
settings EvalSettings
results list[TreeMetrics]
suggested_target_leaf_tokens Optional[int]

Class EvalSettings

Optimizer settings under evaluation.

Fields:

Field Type Default Description
target_leaf_tokens int
min_leaf_tokens int
llm Optional[str] None

Alias OptimizerSettings

Re-exported from parrot.knowledge.pageindex.optimizer.OptimizerSettings.

Alias PageIndexToolkit

Re-exported from parrot.knowledge.pageindex.PageIndexToolkit.

Class TreeMetrics

Metrics for one evaluated PDF: numbers and the file-stem label only, never a node title.

Fields:

Field Type Default Description
label str
pages Optional[int]
nodes_before int
nodes_after int
leaves_before int
leaves_after int
leaf_tokens_p50 int
leaf_tokens_p90 int
leaf_tokens_max int
leaves_over_target_before int
leaves_over_target_after int
key_items int
summary_words_mean float
llm_calls int
seconds float
llm_heading_splits int

Function evaluate_corpus

Writes optimizer_eval-<ts>.json; suggested target = p75 of post-layout leaf tokens rounded to 100.

evaluate_corpus(pdfs: list[Path], *, settings: EvalSettings, out_dir: Path = DEFAULT_OUT) -> EvalReport

Parameter Type Default Description
pdfs list[Path]
settings EvalSettings
out_dir Path DEFAULT_OUT

Returns: EvalReport

Function evaluate_pdf

Import pdf into storage_dir (optimize_on_import=False), then optimize(apply=True); measure.

evaluate_pdf(pdf: Path, *, settings: EvalSettings, storage_dir: Path) -> TreeMetrics

Parameter Type Default Description
pdf Path
settings EvalSettings
storage_dir Path

Returns: TreeMetrics

Attribute logger

Function main

python -m parrot.knowledge.pageindex.optimizer_eval <pdf|dir>...

main(argv: Optional[list[str]] = None) -> int

Parameter Type Default Description
argv Optional[list[str]] None

Returns: int

Alias owned_tokens

Re-exported from parrot.knowledge.pageindex.optimizer.owned_tokens.

Alias structure_to_list

Re-exported from parrot.knowledge.pageindex.utils.structure_to_list.

Function suggest_target

p75 of the layout-built leaf tokens of all trees, rounded to 100; None with fewer than three trees.

suggest_target(results: Sequence[TreeMetrics]) -> Optional[int]

Parameter Type Default Description
results Sequence[TreeMetrics]

Returns: Optional[int]

Function tuned_target

Suggestion inside [2min_leaf_tokens, 2target_leaf_tokens], else None.

tuned_target(report: EvalReport, current: OptimizerSettings) -> Optional[int]

Parameter Type Default Description
report EvalReport
current OptimizerSettings

Returns: Optional[int]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally