Skip to main content

Document parsing, chunking, embedding, and vector retrieval made easy.

Project description

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.embeddings.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.embeddings.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.

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

docparseai-0.1.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

docparseai-0.1.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file docparseai-0.1.1.tar.gz.

File metadata

  • Download URL: docparseai-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for docparseai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9aa0925bcc4bd476e61608059f7b404293437e9b70d0071e52d238473bd6d8d8
MD5 283268551bdb518e71bf7ff6abe09eaa
BLAKE2b-256 58d7ba216eae2538bcec638dc25218c1492e9f02116b21fa93acb4d841621b3d

See more details on using hashes here.

File details

Details for the file docparseai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: docparseai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for docparseai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fc903e4eb716b43744e0cbe69d0398afd1780248f377a16643243cf1a8723b9
MD5 e6557f36d394e2b135f9fde22721f0e5
BLAKE2b-256 f312a729d193520237f1fb680ffb5d73387834f292c85289d8a4ecd7f862d9f3

See more details on using hashes here.

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