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.2.0.tar.gz (9.2 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.2.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fpf_chunking-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 195902c5840127604959b1a89665ba1ae20d4c7e2087e30837b34e3ed64714a3
MD5 29251e7ab9613bfd30cab0a0dacdcaca
BLAKE2b-256 e91e2ffbbbbdc9f5eebfdc4f4ee70cdeb45de8025f4394c1a8dbb3b3e73e49f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fpf_chunking-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ab99c04427dda7f63c83ef50a928be2fc948ffbb942d9f70714383743a78705
MD5 f9212f3ebadf5786669a074c2e1fc312
BLAKE2b-256 bf9eec083f84ec317646f9abefc233ecb5591e965b47405a360c857d1f396b5b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.0

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