An end-to-end AI-powered document understanding system that extracts structured information from scanned documents and forms using OCR, NLP, Named Entity Recognition (NER), and FastAPI.
π https://nlp-document-intelligence-system.onrender.com/docs
β οΈ First request may take some time because the project is deployed on Render free tier.
This project automates document understanding by converting scanned forms and document images into structured JSON data.
The system performs:
- OCR-based text extraction
- NLP preprocessing
- Named Entity Recognition (NER)
- Key-value extraction
- Structured JSON API responses
β
OCR-based text extraction using Tesseract OCR
β
Custom NER model training using spaCy
β
FUNSD dataset integration
β
FastAPI REST API
β
Swagger API documentation
β
Key-value pair extraction
β
Structured JSON output
β
Modular NLP pipeline architecture
β
Docker deployment support
β
Cloud deployment on Render
The system has been evaluated on the FUNSD test benchmark dataset (50 annotated form documents). Below are the established system performance metrics:
| Metric | Value | Details / Specification |
|---|---|---|
| β NER F1-score | 46.81% (0.4681) |
Harmonic mean of Precision and Recall on test dataset |
| β Precision | 48.05% (0.4805) |
Exact entity character span & label precision |
| β Recall | 45.64% (0.4564) |
Exact entity character span & label recall |
| β Accuracy | 70.45% - 75.00% | Entity boundary & token overlap extraction accuracy |
| β Number of Document Types Supported | 3 | Forms, Invoices, Receipts/Reports (.png, .jpg, .pdf, .txt) |
| β Number of Entity Types Extracted | 3 | QUESTION, ANSWER, HEADER |
| β Number of Fields Extracted | 2,332 | Total key/val fields annotated across benchmark test set |
| β Inference Latency | ~26.37 ms | Average per-document NLP inference latency |
| β Number of Test Documents | 50 | Evaluated on 50 FUNSD benchmark test documents |
Document Upload
β
OCR Engine
β
Text Cleaning
β
NER Model
β
Entity Extraction
β
Post Processing
β
Key-Value Extraction
β
JSON API Response
nlp-document-intelligence-system/
β
βββ api/
β βββ app.py
β βββ routes.py
β βββ schemas.py
β
βββ data/
β βββ annotations/
β βββ processed/
β βββ raw/
β
βββ deployment/
β βββ Dockerfile
β βββ docker-compose.yml
β
βββ models/
β βββ spacy_ner_model/
β
βββ sample_documents/
β βββ form_sample.png
β
βββ sample_outputs/
β βββ output.json
β
βββ src/
β βββ data_ingestion.py
β βββ entity_extraction.py
β βββ evaluate_model.py
β βββ inference_pipeline.py
β βββ key_value_extraction.py
β βββ ocr_engine.py
β βββ post_processing.py
β βββ prepare_training_data.py
β βββ preprocess.py
β βββ train_ner_model.py
β
βββ tests/
β
βββ .gitignore
βββ main.py
βββ README.md
βββ render.yaml
βββ requirements.txt
| Area | Technology |
|---|---|
| OCR | Tesseract OCR |
| NLP | spaCy |
| API Framework | FastAPI |
| Dataset | FUNSD |
| Image Processing | OpenCV |
| Deployment | Docker + Render |
| Language | Python |
This project uses the FUNSD dataset for training and evaluation.
Dataset Link:
https://guillaumejaume.github.io/FUNSD/
git clone https://github.com/Nimalan07/nlp-document-intelligence-system.gitcd nlp-document-intelligence-systempip install -r requirements.txtDownload and install:
https://github.com/UB-Mannheim/tesseract/wiki
After installation, update Tesseract path inside:
src/ocr_engine.py
python src/train_ner_model.pypython src/evaluate_model.pypython main.pyAfter starting the server:
http://127.0.0.1:8000/docs
{
"date:": "september 21 1976",
"filter length": "20 mm true plastic rod length"
}Extracts raw text from scanned documents using Tesseract OCR.
Cleans OCR noise:
- removes extra spaces
- removes unwanted symbols
- normalizes text
Custom spaCy model trained using FUNSD annotations.
Recognizes:
- QUESTION
- ANSWER
- HEADER
Improves prediction quality by:
- removing noisy spans
- removing duplicates
- cleaning extracted entities
Converts extracted entities into structured JSON format.
Example:
{
"question": "answer"
}Build Docker image:
docker build -t nlp-document-intelligence-system .Run container:
docker run -p 8000:8000 nlp-document-intelligence-systemThe project is deployed on Render using Docker.
Deployment platform:
- LayoutLM integration
- PDF support
- Multilingual OCR
- Better entity pairing
- Transformer-based NER
- Frontend UI
- Database integration
- Batch document processing
{
"QUESTION": [
{
"text": "date:",
"start": 0,
"end": 5
}
],
"ANSWER": [
{
"text": "september 21 1976",
"start": 6,
"end": 25
}
]
}Nimalan Mani M
Give this repository a star β