Skip to content

Nimalan07/nlp-document-intelligence-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NLP-Based Document Intelligence System

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.


🌐 Live Demo

πŸ”— https://nlp-document-intelligence-system.onrender.com/docs

⚠️ First request may take some time because the project is deployed on Render free tier.


🧠 Project Overview

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

πŸ”₯ Features

βœ… 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


πŸ—οΈ Project Architecture

Document Upload
       ↓
OCR Engine
       ↓
Text Cleaning
       ↓
NER Model
       ↓
Entity Extraction
       ↓
Post Processing
       ↓
Key-Value Extraction
       ↓
JSON API Response

πŸ“‚ Project Structure

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

βš™οΈ Tech Stack

Area Technology
OCR Tesseract OCR
NLP spaCy
API Framework FastAPI
Dataset FUNSD
Image Processing OpenCV
Deployment Docker + Render
Language Python

πŸ“¦ Dataset

This project uses the FUNSD dataset for training and evaluation.

Dataset Link:

https://guillaumejaume.github.io/FUNSD/


πŸš€ Installation

1️⃣ Clone Repository

git clone https://github.com/Nimalan07/nlp-document-intelligence-system.git
cd nlp-document-intelligence-system

2️⃣ Install Dependencies

pip install -r requirements.txt

3️⃣ Install Tesseract OCR

Download and install:

https://github.com/UB-Mannheim/tesseract/wiki

After installation, update Tesseract path inside:

src/ocr_engine.py

4️⃣ Train Model

python src/train_ner_model.py

5️⃣ Run Application

python main.py

πŸ“˜ API Documentation

After starting the server:

http://127.0.0.1:8000/docs

πŸ“€ Example API Response

{
    "date:": "september 21 1976",
    "filter length": "20 mm true plastic rod length"
}

🧠 NLP Pipeline

OCR Engine

Extracts raw text from scanned documents using Tesseract OCR.


Text Preprocessing

Cleans OCR noise:

  • removes extra spaces
  • removes unwanted symbols
  • normalizes text

Named Entity Recognition (NER)

Custom spaCy model trained using FUNSD annotations.

Recognizes:

  • QUESTION
  • ANSWER
  • HEADER

Post Processing

Improves prediction quality by:

  • removing noisy spans
  • removing duplicates
  • cleaning extracted entities

Key-Value Extraction

Converts extracted entities into structured JSON format.

Example:

{
    "question": "answer"
}

🐳 Docker Support

Build Docker image:

docker build -t nlp-document-intelligence-system .

Run container:

docker run -p 8000:8000 nlp-document-intelligence-system

☁️ Deployment

The project is deployed on Render using Docker.

Deployment platform:

https://render.com/


🎯 Future Improvements

  • LayoutLM integration
  • PDF support
  • Multilingual OCR
  • Better entity pairing
  • Transformer-based NER
  • Frontend UI
  • Database integration
  • Batch document processing

πŸ“Έ Sample Output

{
    "QUESTION": [
        {
            "text": "date:",
            "start": 0,
            "end": 5
        }
    ],
    "ANSWER": [
        {
            "text": "september 21 1976",
            "start": 6,
            "end": 25
        }
    ]
}

πŸ‘¨β€πŸ’» Author

Nimalan Mani M


⭐ If you found this project useful

Give this repository a star ⭐

About

AI-powered document intelligence system using OCR, NLP, Named Entity Recognition, and FastAPI for structured information extraction from scanned documents.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors