Skip to main content

llama-index-readers-section-anything

A LlamaIndex reader for Section Anything: it finds the sections of a PDF (every heading, its level, its pages and its exact text) and returns one Document per section, with the heading path in the metadata and parent/child links between sections. The default mode runs locally with rules only, calls no model and costs nothing.

Install

pip install llama-index-readers-section-anything
# latest from GitHub:
pip install "git+https://github.com/Omniwot/section-anything#subdirectory=packages/llama-index-readers-section-anything"

Python 3.11+. Depends on section-anything and llama-index-core only.

Example

from llama_index.core import SimpleDirectoryReader
from llama_index.readers.section_anything import SectionAnythingReader

reader = SectionAnythingReader()  # mode="free": rules only, no model, $0
docs = reader.load_data("paper.pdf")
# or for a folder: SimpleDirectoryReader("papers/", file_extractor={".pdf": reader}).load_data()

doc = docs[2]
print(doc.text[:59])                 # '### 1.1 Scope\n\nSectioning splits a long document into parts'
print(doc.metadata["heading_path"])  # '1 Introduction > 1.1 Scope'
print(doc.metadata["page_start"], doc.metadata["page_end"])  # 1 1

Sections vary in length; VectorStoreIndex.from_documents(docs) splits long ones with its node parser and keeps the metadata on every node.

Options

SectionAnythingReader(mode="free", *, include_heading=True, relationships=True, **opts), then load_data(file, extra_info=None, fs=None) (also lazy_load_data and aload_data).

  • mode: free (bookmarks, table of contents and typography rules; nothing leaves the machine), quick (a small model reviews candidate heading lines, about $0.07 per 1,000 pages), standard (a model reads every line) or local:<ollama model>. Over the per-document cost cap (default $0.50) a run is downgraded (standard → quick → free) or refused.
  • include_heading: start each Document with its heading as a Markdown line (## 1 Introduction). With False, sections with no text of their own (a heading directly followed by a subheading) are skipped.
  • relationships: set PARENT (the enclosing section), CHILD, PREVIOUS and NEXT between the Documents. Ids are <file path>_part_<n>, the format SimpleDirectoryReader(filename_as_id=True) uses, so the links survive it. A node parser starts fresh links between its own nodes; these are for using the sections as nodes directly.
  • **opts go to section_anything.section: api_key, base_url, model, max_usd, prices, over_budget, max_pages, extract_timeout, progress, settings. Anything not given falls back to the SECTIONANY_* environment variables; see the library README. Keys are never logged or put in metadata.
  • fs: an fsspec filesystem (as SimpleDirectoryReader passes for remote files); the file is copied to a temporary local file first.

Text and metadata

A Document's text is the section's own text, from its heading to the next heading, reflowed into paragraphs with running headers and footers removed (the same text as section-anything --body). Text before the first heading is a Document of its own (flag front_matter).

Metadata is flat (str, int, float or None), so it works with every vector store. extra_info is merged over it.

Key Meaning
file_path, file_name the PDF
section_index position in the document's section list (0-based)
title, number, level heading text, numbering as printed ("3.1" or ""), 1 = top level
heading_path headings from the outermost section down to this one, joined with " > "
page_start, page_end 1-based pages
start, end character range in the library's extracted text
flags comma-separated, for example doc_title, front_matter, generated_title
document_title the document's title, if found
mode, model, document_cost_usd how the document was sectioned (after any downgrade) and what the whole document cost

Embeddings see only heading_path and document_title; the LLM also sees file_name, page_start and page_end (for citations). The other keys are excluded from both (excluded_embed_metadata_keys, excluded_llm_metadata_keys) but stay available for filters.

Licence

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for llama-index-readers-section-anything 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-readers-section-anything 0.1.0
File Size Uploaded Provenance Actions
llama_index_readers_section_anything-0.1.0.tar.gz 17.0 kB With provenance Details for llama_index_readers_section_anything-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-readers-section-anything 0.1.0
File Interpreter ABI Platform Actions
llama_index_readers_section_anything-0.1.0-py3-none-any.whl Python 3 none any Details for llama_index_readers_section_anything-0.1.0-py3-none-any.whl

Total release size: 30.5 kB

Release files / llama_index_readers_section_anything-0.1.0.tar.gz

Download URL llama_index_readers_section_anything-0.1.0.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6ada0fe109ff5c63c32d18e82d1ed93191a13a5ff97ee1942fac637840bcab1b
BLAKE2b-256 checksum
How to use checksums
dbdf6bde196b916caa94c5ba691f7ec4c901e918f334003aa67c82e3c6afdbdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / llama_index_readers_section_anything-0.1.0-py3-none-any.whl

Download URL llama_index_readers_section_anything-0.1.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7dafb4c8bf549476e4ca57e45c17f3af33b78924a958b4a39a8ff72dc918509c
BLAKE2b-256 checksum
How to use checksums
73ebf2dc526433898e2fb2ff2f4bd06fa49eead7ef22ed7b31b966ad77685fc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for llama-index-readers-section-anything 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llama_index_readers_section_anything-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page