Vision-language OCR and multimodal document QA for images and PDFs.
2
stars
23
commits
Python
primary language
Mar 27, 2026
updated
Vision-language OCR and multimodal document QA for images and PDFs.
Vlense helps you do two things well:
It is designed for workflows where plain OCR is not enough and the model needs to reason over full document pages, scans, tables, forms, and mixed visual layouts.
colpali-engineInstall the package:
uv add vlense
Or install from source in this repository:
uv sync
PDF rendering uses pdf2image, so Poppler must be available on your system.
import asyncio
import os
from vlense import Vlense
async def main():
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
vlense = Vlense()
result = await vlense.ocr(
file_path=["./invoice.png", "./report.pdf"],
model="gpt-5-mini",
format="markdown",
)
print(result["invoice.png"].content)
if __name__ == "__main__":
asyncio.run(main())
import asyncio
import os
from vlense import Vlense
async def main():
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
vlense = Vlense()
await vlense.index(
data_dir="./handbook.pdf",
collection_name="company-docs",
index_dir="./.vlense",
retrieval="hybrid",
retriever_model="vidore/colSmol-500M",
)
answer = await vlense.ask(
query="What are the eligibility requirements?",
collection_name="company-docs",
index_dir="./.vlense",
model="gpt-5-mini",
top_k=3,
)
print(answer)
if __name__ == "__main__":
asyncio.run(main())
Vlense.ask() returns a grounded answer based on the retrieved page images, with cited page references.
For OpenAI-compatible gateways, set OPENAI_BASE_URL or pass base_url= directly to Vlense.ocr() and Vlense.ask().
Vlense uses colpali-engine for page-image retrieval and defaults to vidore/colSmol-500M.
For PDFs with a usable text layer, Vlense also supports:
retrieval="bm25" for lexical text retrieval with page-grounded answer synthesisretrieval="hybrid" to combine BM25 text retrieval with ColPali page-image retrievalThis gives you:
The repository includes a runnable example for PDF question answering:
uv run python examples/pdf_qa.py ./document.pdf \
--collection my-docs \
--question "What does the report say about pricing?" \
--vision-model gpt-5-mini
Vlense.ocr()Runs OCR over one or more images or PDFs and returns generated content in Markdown, HTML, or JSON.
Key options:
file_path: single path or list of pathsmodel: OpenAI-compatible vision-capable model nameformat: markdown, html, or jsonjson_schema: optional Pydantic schema for structured extractionoutput_dir: optional directory for persisted outputsapi_key: optional API key overridebase_url: optional OpenAI-compatible base URL overrideVlense.index()Builds a local multimodal retrieval collection from PDFs or images.
Key options:
data_dir: file path, list of paths, or directorycollection_name: logical name for the collectionindex_dir: storage root for page renders and embeddingsretrieval: colpali, bm25, or hybridretriever_model: colpali-engine checkpoint nameVlense.ask()Searches an indexed collection, retrieves the most relevant pages, and asks a vision model to answer using those pages as evidence.
Key options:
query: user questioncollection_name: existing indexed collectionmodel: answer model such as gpt-5-minitop_k: number of retrieved pages to ground the answerretrieval: optional override for colpali, bm25, or hybridapi_key: optional API key overridebase_url: optional OpenAI-compatible base URL overrideGitHub Actions runs CI on pushes and pull requests. Tagged releases publish to PyPI and create a GitHub Release.
Repository setup:
PYPI_API_TOKENRelease flow:
git tag v0.2.5
git push origin v0.2.5
This repository uses uv, not pip.
Useful commands:
uv sync
uv run python -m unittest vlense.tests.test_vlense
uv build
Issues and pull requests are welcome.
MIT
23 commits
Python
100.0%
Vision-language OCR and multimodal document QA for images and PDFs.
2
stars
23
commits
Python
primary language
Mar 27, 2026
updated
Vision-language OCR and multimodal document QA for images and PDFs.
Vlense helps you do two things well:
It is designed for workflows where plain OCR is not enough and the model needs to reason over full document pages, scans, tables, forms, and mixed visual layouts.
colpali-engineInstall the package:
uv add vlense
Or install from source in this repository:
uv sync
PDF rendering uses pdf2image, so Poppler must be available on your system.
import asyncio
import os
from vlense import Vlense
async def main():
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
vlense = Vlense()
result = await vlense.ocr(
file_path=["./invoice.png", "./report.pdf"],
model="gpt-5-mini",
format="markdown",
)
print(result["invoice.png"].content)
if __name__ == "__main__":
asyncio.run(main())
import asyncio
import os
from vlense import Vlense
async def main():
os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"
vlense = Vlense()
await vlense.index(
data_dir="./handbook.pdf",
collection_name="company-docs",
index_dir="./.vlense",
retrieval="hybrid",
retriever_model="vidore/colSmol-500M",
)
answer = await vlense.ask(
query="What are the eligibility requirements?",
collection_name="company-docs",
index_dir="./.vlense",
model="gpt-5-mini",
top_k=3,
)
print(answer)
if __name__ == "__main__":
asyncio.run(main())
Vlense.ask() returns a grounded answer based on the retrieved page images, with cited page references.
For OpenAI-compatible gateways, set OPENAI_BASE_URL or pass base_url= directly to Vlense.ocr() and Vlense.ask().
Vlense uses colpali-engine for page-image retrieval and defaults to vidore/colSmol-500M.
For PDFs with a usable text layer, Vlense also supports:
retrieval="bm25" for lexical text retrieval with page-grounded answer synthesisretrieval="hybrid" to combine BM25 text retrieval with ColPali page-image retrievalThis gives you:
The repository includes a runnable example for PDF question answering:
uv run python examples/pdf_qa.py ./document.pdf \
--collection my-docs \
--question "What does the report say about pricing?" \
--vision-model gpt-5-mini
Vlense.ocr()Runs OCR over one or more images or PDFs and returns generated content in Markdown, HTML, or JSON.
Key options:
file_path: single path or list of pathsmodel: OpenAI-compatible vision-capable model nameformat: markdown, html, or jsonjson_schema: optional Pydantic schema for structured extractionoutput_dir: optional directory for persisted outputsapi_key: optional API key overridebase_url: optional OpenAI-compatible base URL overrideVlense.index()Builds a local multimodal retrieval collection from PDFs or images.
Key options:
data_dir: file path, list of paths, or directorycollection_name: logical name for the collectionindex_dir: storage root for page renders and embeddingsretrieval: colpali, bm25, or hybridretriever_model: colpali-engine checkpoint nameVlense.ask()Searches an indexed collection, retrieves the most relevant pages, and asks a vision model to answer using those pages as evidence.
Key options:
query: user questioncollection_name: existing indexed collectionmodel: answer model such as gpt-5-minitop_k: number of retrieved pages to ground the answerretrieval: optional override for colpali, bm25, or hybridapi_key: optional API key overridebase_url: optional OpenAI-compatible base URL overrideGitHub Actions runs CI on pushes and pull requests. Tagged releases publish to PyPI and create a GitHub Release.
Repository setup:
PYPI_API_TOKENRelease flow:
git tag v0.2.5
git push origin v0.2.5
This repository uses uv, not pip.
Useful commands:
uv sync
uv run python -m unittest vlense.tests.test_vlense
uv build
Issues and pull requests are welcome.
MIT
23 commits
Python
100.0%