Skip to main content

docparseai: Document Parsing, Chunking, and Embedding

docparseai is an open-source Python package designed for document processing tasks. It enables parsing, chunking, embedding, and efficient retrieval of document chunks using FAISS for vector similarity search. This package is ideal for applications such as document summarization, search engines, and semantic queries.

Installation

To install docparseai via PyPI:

pip install docparseai

Optional Dependency for Embeddings

If you need the embedding functionality for document chunking (which uses sentence-transformers for advanced embeddings), install the package with optional dependencies:

pip install docparseai[embedding]

This will install the sentence-transformers dependency needed for embedding-based models.


Modules

1. DocumentLoader

DocumentLoader parses various document formats such as PDF, DOCX, and TXT into clean text.

Usage:

from docparseai.document_loader import DocumentLoader

# Load a document
text = DocumentLoader.load("file.pdf")

2. TextSplitter

TextSplitter splits the loaded document text into manageable chunks. The chunking can be based on sentence or token boundaries with configurable chunk size and overlap.

Usage:

from docparseai.text_splitter import TextSplitter

# Split the document text into chunks
chunks = TextSplitter.split(text, chunk_size=500, overlap=50)

3. Embedder

Embedder generates dense vector embeddings for document chunks using SentenceTransformers. The default model is all-MiniLM-L6-v2, but you can provide your own model.

Usage (with optional dependency):

from docparseai.embedder import Embedder

# Generate embeddings for chunks
embedder = Embedder()  # By default, uses `all-MiniLM-L6-v2`
embeddings = embedder.embed(chunks)

4. FAISSStore

FAISSStore stores document chunk embeddings and allows fast similarity-based retrieval of top-k similar chunks for a given query.

Usage:

from docparseai.vectorstore.faiss_store import FAISSStore

# Create a store from embeddings
store = FAISSStore().from_embeddings(chunks, embeddings)

# Query the store for top-k similar chunks
top_k_results = store.query(query_embedding, top_k=5)

Full Workflow Example

from docparseai.document_loader import DocumentLoader
from docparseai.text_splitter import TextSplitter
from docparseai.embedder import Embedder
from docparseai.vectorstore.faiss_store import FAISSStore

# 1. Load document
text = DocumentLoader.load("file.pdf")

# 2. Split document into chunks
chunks = TextSplitter.split(text, chunk_size=500, overlap=50)

# 3. Generate embeddings for chunks
embedder = Embedder()
embeddings = embedder.embed(chunks)

# 4. Create FAISS store with embeddings
store = FAISSStore().from_embeddings(chunks, embeddings)

# 5. Query the store for similar chunks
query = "What is this document about?"
query_embedding = embedder.embed(query)[0]
top_k_results = store.query(query_embedding, top_k=5)

# Output results
for chunk, score in top_k_results:
    print(f"Chunk: {chunk} - Score: {score}")

Notes

  • Optional Embeddings: If you don’t need advanced embedding capabilities (e.g., for small or non-semantic tasks), you can run the package without installing sentence-transformers.
  • FAISS: The FAISS indexing method allows you to efficiently store and retrieve vector-based data for similarity queries.

Contributing

We welcome contributions! Feel free to submit issues or pull requests for bug fixes, enhancements, or new features.

To contribute:

  1. Fork the repository.
  2. Clone your fork: git clone https://github.com/your-username/docparseai.git
  3. Create a feature branch: git checkout -b feature-name
  4. Commit your changes: git commit -m "Add feature"
  5. Push to your fork: git push origin feature-name
  6. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Feedback / Issues

If you encounter any issues or have feedback, feel free to open an issue on GitHub or contact us directly.

Release files for docparseai 0.1.2

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

Source distribution (sdist)

Source distribution for docparseai 0.1.2
File Size Uploaded
docparseai-0.1.2.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for docparseai 0.1.2
File Interpreter ABI Platform
docparseai-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / docparseai-0.1.2.tar.gz

Download URL docparseai-0.1.2.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
231d6cdbb76f24fb08cd96f4de12b5313e7b00a38570448a5f9bc6d608b0313b
BLAKE2b-256 checksum
How to use checksums
af0aa4cad4df57e156d3ae2b20b7de1e5dc3d06c136ed510251076b20f4b2f9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / docparseai-0.1.2-py3-none-any.whl

Download URL docparseai-0.1.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c11af5fcfdb32b332fb91af192f12693af7a326ec291d55541e7b9316526059a
BLAKE2b-256 checksum
How to use checksums
f82b0d7450a062f2c2ab6bec46ea0b2e3c1e2838bb89a087dd2fcb82008a6045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release 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