Skip to main content

fpf-chunking

FPF-guided (holon / bounded-context) semantic document chunking: parses a document's structure, uses an LLM to validate which structural boundaries make good chunk boundaries, and assembles the result into token-bounded chunks — without ever exceeding the LLM's context window on a single oversized structural unit.

Install

pip install fpf-chunking

Usage

From a file:

from anthropic import Anthropic
from fpf_chunking import MarkdownLoader, chunk_document

doc = MarkdownLoader().load("path/to/doc.md")
chunks = chunk_document(
    doc,
    anthropic_client=Anthropic(api_key="..."),
    anthropic_model="claude-sonnet-4-5-20250929",
    max_chunk_tokens=400,
)

From content already in memory (e.g. fetched over the network by your own wrapper — no filesystem path required):

from fpf_chunking import Document, chunk_document

doc = Document(doc_id="my-doc", text=buffer_from_network)
chunks = chunk_document(doc, anthropic_client=..., anthropic_model=..., max_chunk_tokens=400)

Then embed however you like:

from openai import OpenAI
from fpf_chunking import embed

embedded = embed(chunks, client=OpenAI(api_key="..."), model="text-embedding-3-small")

See the module docstrings for the full API: parse_holons, extract_candidate_boundaries, split_oversized_holons, assemble_chunks, FPFBoundaryValidator, fixed_size_chunks (naive baseline), and semantic_chunks (embedding-similarity baseline) are all exported for callers who want the individual pipeline stages instead of the composed chunk_document.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fpf_chunking-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fpf_chunking-0.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file fpf_chunking-0.1.0.tar.gz.

File metadata

  • Download URL: fpf_chunking-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fpf_chunking-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e9683abaf96a8c063ac45ef61f62bcdbad6c7f655c9accceb602bfde43ad8c3
MD5 056fe1ed424d287e4325fc333c8a5527
BLAKE2b-256 b03e8d0421440553d754ff707a9b26f0406b6e08974782d7f289579bbb89be94

See more details on using hashes here.

File details

Details for the file fpf_chunking-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fpf_chunking-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fpf_chunking-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93221eadadf6bf6ec8fd9cfa402f105c3aac7ff7a4178a8cdae5f81425741973
MD5 dcb3ff3f90827697dbe69066a0b0a7cd
BLAKE2b-256 51f37d29c6cc37e24d059f7fe35497029fe049f64f90061a8e49388b0f537e72

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

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