Skip to main content

Ingestion pipeline for the koji-db database: parsing, chunking, and multi-vector embeddings

Project description

koji-ingest

Ingestion pipeline for Kōji — document parsing, chunking, multi-vector embeddings, and VLM enrichment.

koji-ingest transforms raw documents (PDF, DOCX, PPTX, audio, images, and more) into ColBERT-style multi-vector embeddings ready for storage and semantic search in Kōji.

Installation

The distribution is published to PyPI as koji-ingest; the import module is koji_ingest.

# Core ingestion (parsing, chunking, embeddings)
pip install koji-ingest

# With document parsing support (Docling, PDF)
pip install "koji-ingest[document]"

# With LibreOffice-based rendering (DOCX/PPTX page images)
pip install "koji-ingest[rendering]"

# With MLX VLM enrichment engine (Apple Silicon)
pip install "koji-ingest[enrichment]"

# With Kōji storage integration (PyArrow)
pip install "koji-ingest[koji]"

# With the ColNomic multi-vector engine (colpali-engine + torch + transformers)
pip install "koji-ingest[colnomic]"

# Linux + NVIDIA only: enable 4bit/8bit quantization (bitsandbytes)
pip install "koji-ingest[colnomic,cuda]"

Embedding-engine install matrix

Platform Install Supported quantization
Apple Silicon (MPS) pip install "koji-ingest[colnomic]" fp16, bf16, fp32
CPU-only pip install "koji-ingest[colnomic]" fp16, bf16, fp32
Linux + NVIDIA CUDA pip install "koji-ingest[colnomic,cuda]" fp16, bf16, fp32, 4bit, 8bit

bitsandbytes is CUDA-only, so the [cuda] extra is a no-op on macOS — requesting quantization="4bit" on a non-CUDA device raises a clear error at config-validation time rather than at model load.

Features

Multi-Vector Embeddings

koji-ingest generates ColBERT-style multi-vector embeddings where each document is represented by a set of per-token vectors, enabling MaxSim late-interaction scoring:

from koji_ingest import MultiVectorEmbedding
import numpy as np

data = np.random.randn(10, 128).astype(np.float32)
emb = MultiVectorEmbedding(num_tokens=10, dim=128, data=data)

blob = emb.to_blob()          # serialize for Lance storage
recovered = MultiVectorEmbedding.from_blob(blob)

Document Parsing and Chunking

Parse and chunk documents in a variety of formats via Docling:

from koji_ingest import parse, chunk, IngestConfig

config = IngestConfig()
parsed = parse("report.pdf", config=config)
chunks = chunk(parsed, config=config)

Supported formats include PDF, DOCX, PPTX, Markdown, HTML, images, and audio files.

DenseTextEngine (Lightweight Embedding)

For text-only workloads without vision, use DenseTextEngine backed by mlx-embeddings:

from koji_ingest import DenseTextEngine

engine = DenseTextEngine()
embedding = engine.embed("The quick brown fox")

Gemma 4 E4B VLM Enrichment (Apple Silicon)

Augment parsed documents with VLM-generated descriptions, code analysis, formula interpretations, and document summaries using the Gemma 4 E4B model via mlx-vlm:

from koji_ingest.enrichment import GemmaEnrichmentEngine

engine = GemmaEnrichmentEngine()
enriched = await engine.enrich(parsed_content)
# enriched.figures now contain model-generated captions
# enriched.summary contains a document-level summary

GPU / Metal Memory Management

Release cached GPU or Metal memory between batch operations to prevent OOM errors:

from koji_ingest.gpu import release_gpu_memory

for batch in large_corpus:
    process(batch)
    release_gpu_memory()   # returns allocations to OS after each batch

LibreOffice Page Renderer

Convert DOCX and PPTX slides to page images for visual ingestion:

from koji_ingest.parser import parse

# Renders pages via LibreOffice headless, returns per-page images in ParsedContent
result = parse("slides.pptx", config=config)

Audio Chunking

Ingest long-form audio with automatic chunking:

from koji_ingest import IngestConfig, AudioConfig

config = IngestConfig(audio=AudioConfig(chunk_duration_secs=30))
result = parse("interview.mp3", config=config)

Full Ingestion Pipeline

from koji_ingest import Ingester, IngestConfig

ingester = Ingester(config=IngestConfig())
result = await ingester.ingest("document.pdf")

print(result.chunks)       # List[TextChunk]
print(result.embeddings)   # List[MultiVectorEmbedding]

License

Apache-2.0

Project details


Download files

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

Source Distribution

koji_ingest-0.4.0.tar.gz (501.3 kB view details)

Uploaded Source

Built Distribution

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

koji_ingest-0.4.0-py3-none-any.whl (131.8 kB view details)

Uploaded Python 3

File details

Details for the file koji_ingest-0.4.0.tar.gz.

File metadata

  • Download URL: koji_ingest-0.4.0.tar.gz
  • Upload date:
  • Size: 501.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for koji_ingest-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e038531abacb60cfbcf79b7866487e8d75f9c3843ea19db9c23670f0ad5d8aca
MD5 7e3873b4a2b36aa493302067fc949056
BLAKE2b-256 23a4fb8125e5c83301a57764a3f011a3724b1bb110e0e57b0d6ddffa52e29cf1

See more details on using hashes here.

Provenance

The following attestation bundles were made for koji_ingest-0.4.0.tar.gz:

Publisher: koji-ingest-release.yml on tkr-projects/tkr-koji

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file koji_ingest-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: koji_ingest-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 131.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for koji_ingest-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a81a63c15543c23d919369612d9b7121e5ed331e647a5a98892b64968f524b53
MD5 8c2a94c84e4d43a7b9afd15f173f1e62
BLAKE2b-256 5896be455782f17cb23e83f36c33f19eeb03674b21e62c1854e36d62565d8839

See more details on using hashes here.

Provenance

The following attestation bundles were made for koji_ingest-0.4.0-py3-none-any.whl:

Publisher: koji-ingest-release.yml on tkr-projects/tkr-koji

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page