Semantic Document Processing Library
281
Kallia is a semantic document processing library that converts documents into intelligent semantic chunks. The library specializes in extracting meaningful content segments from documents while preserving context and semantic relationships.
pip install kallia
git clone https://github.com/kallia-project/kallia.git
cd kallia
pip install -e .
kallia/
โโโ kallia/
โ โโโ core/ # Core API service
โ โ โโโ kallia_core/ # Main library modules
โ โ โ โโโ main.py # FastAPI application
โ โ โ โโโ documents.py # Document processing
โ โ โ โโโ chunker.py # Semantic chunking
โ โ โ โโโ memories.py # Memory management
โ โ โ โโโ models.py # Data models
โ โ โ โโโ ...
โ โ โโโ requirements.txt # Core dependencies
โ โ โโโ Dockerfile # Core service container
โ โ โโโ docker-compose.yml # Core service orchestration
โ โโโ playground/ # Interactive chat interface
โ โโโ kallia_playground/ # Playground modules
โ โ โโโ main.py # Chainlit application
โ โ โโโ qa.py # Q&A functionality
โ โ โโโ ...
โ โโโ requirements.txt # Playground dependencies
โ โโโ Dockerfile # Playground container
โ โโโ docker-compose.yml # Playground orchestration
โโโ tests/ # Test suite
โโโ assets/ # Sample documents
โโโ pyproject.toml # Project configuration
Start the FastAPI service:
cd kallia/core
pip install -r requirements.txt
uvicorn kallia_core.main:app --reload
The API will be available at http://localhost:8000
Process Documents
POST /documents
Request body:
{
"url": "path/to/document.pdf",
"page_number": 1,
"temperature": 0.7,
"max_tokens": 4000
}
Create Memories
POST /memories
Request body:
{
"messages": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "Hi there!" }
],
"temperature": 0.7,
"max_tokens": 4000
}
Start the Chainlit chat interface:
cd kallia/playground
pip install -r requirements.txt
chainlit run kallia_playground/main.py
The playground will be available at http://localhost:8000
Core Service
cd kallia/core
docker-compose up -d
Playground
cd kallia/playground
docker-compose up -d
from kallia_core.documents import Documents
from kallia_core.chunker import Chunker
from kallia_core.memories import Memories
# Convert document to markdown
markdown_content = Documents.to_markdown(
source="document.pdf",
page_number=1,
temperature=0.7,
max_tokens=4000
)
# Create semantic chunks
chunks = Chunker.create(
text=markdown_content,
temperature=0.7,
max_tokens=4000
)
# Generate memories from conversation
messages = [
{"role": "user", "content": "What is this document about?"},
{"role": "assistant", "content": "This document discusses..."}
]
memories = Memories.create(messages)
# Process a document
curl -X POST "http://localhost:8000/documents" \
-H "Content-Type: application/json" \
-d '{
"url": "https://raw.githubusercontent.com/kallia-project/kallia/refs/tags/v0.1.5/assets/pdf/01.pdf",
"page_number": 1,
"temperature": 0.7,
"max_tokens": 4000
}'
# Create memories
curl -X POST "http://localhost:8000/memories" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hi there!"}
],
"temperature": 0.7,
"max_tokens": 4000
}'
Kallia has been extensively benchmarked against other popular document processing libraries using a comprehensive RAG (Retrieval-Augmented Generation) evaluation framework. The benchmark evaluates the quality of document chunking and retrieval performance across 100 test questions.

| System | Mean Score | Perfect Score Rate | Ranking |
|---|---|---|---|
| Kallia | 4.600 | 81.0% | ๐ฅ 1st |
| LlamaIndex | 4.300 | 71.0% | ๐ฅ 2nd |
| PyMuPDF | 4.060 | 65.0% | ๐ฅ 3rd |
| Unstructured | 3.950 | 63.0% | 4th |
The benchmark results demonstrate Kallia's superior performance in document processing and retrieval tasks, making it the optimal choice for applications requiring high-quality document understanding and semantic chunking.
For detailed benchmark results and visualizations, see the benchmark/ directory.
Run the test suite:
python -m pytest tests/
Available tests:
test_pdf_to_markdown.py - Document conversion teststest_markdown_to_chunks.py - Chunking functionality teststest_histories_to_memories.py - Memory creation testsCreate a .env file based on the provided .env.example template in each directory:
Core Service:
cd kallia/core
cp .env.example .env
# Edit .env with your configuration
Playground:
cd kallia/playground
cp .env.example .env
# Edit .env with your configuration
Currently supported:
The architecture is designed to be extensible for additional formats.
This project is licensed under the Apache License 2.0 - see the LICENSEโ file for details.
CK - [email protected]โ
Built with โค๏ธ for intelligent document processing
Content type
Image
Digest
sha256:cedca7b3fโฆ
Size
4 GB
Last updated
12 months ago
docker pull overheatsystem/kallia:0.1.6