This repository is a learning project for Devscale AI-Enabled Python Batch IV. It demonstrates a simple OCR and embeddings workflow using Python, Mistral OCR, and ChromaDB.
- Reads
employee-handbook.pdf - Sends the PDF to Mistral OCR
- Saves each OCR page as Markdown in
ocr-output/ - Stores OCR text in a local ChromaDB collection
- Runs a semantic query against the stored document text
- Python 3.13+
- Mistral AI OCR
- ChromaDB
- python-dotenv
- uv
.
├── app/
│ ├── main.py # Query OCR text from ChromaDB
│ ├── ocr.py # Run OCR and store page text embeddings
│ └── utils.py # Shared Mistral and Chroma clients
├── chroma_db/ # Local ChromaDB persistence
├── ocr-output/ # OCR Markdown output per page
├── employee-handbook.pdf
├── pyproject.toml
└── uv.lock
Install dependencies:
uv syncCreate a .env file:
MISTRALAI_API_KEY=your_mistral_api_keyRun OCR and save the output into ChromaDB:
uv run python -m app.ocrQuery the embedded OCR content:
uv run python -m app.mainThe current sample query asks:
What is the paternity leave policy
You can edit app/main.py to try different questions.
This project is intended to help learners understand:
- How OCR turns PDF documents into machine-readable text
- How document text can be split and stored for retrieval
- How embeddings make semantic search possible
- How a local vector database can support document question answering