Book a 15 Minute Consultations

If we can help in any way, please don't hesitate to set a time to meet or talk, or leave your details and we'll get back to you.

Looking for a job?

Apply here
Talk with Sales

UEI Project – Building an AI Teacher with a Robust RAG Pipeline

Overview

The UEI Project aims to develop an AI-powered educational assistant designed to function as an interactive AI teacher. The system leverages advanced Retrieval-Augmented Generation (RAG) techniques combined with state-of-the-art language models to deliver accurate, context-aware answers to user queries. It provides an interactive and scalable platform for users to upload files, generate insights, and engage in meaningful educational conversations.

This case study outlines the technical architecture, processes, and challenges involved in creating the UEI Project, ensuring seamless operation and scalability while maintaining data security and processing efficiency.

Problem Statement

Educational platforms today face several challenges that hinder effective learning:

  • Inefficient Document Handling : Many existing tools fail to process encoded text in PDFs and other file formats accurately, leading to incomplete or incorrect data extraction.
  • Behavioral Profiling : Building customer transaction patterns to detect deviations.
  • Scalability Issues: : Platforms struggle to efficiently handle large volumes of concurrent users, especially during file uploads and query submissions.
  • Unreliable AI Responses : Current systems often generate hallucinated or irrelevant responses, making it difficult to trust AI-generated content.
  • Security Gaps : Most educational tools lack secure communication channels, leading to data breaches or loss.
  • Lack of Multi-Language Support : Existing tools do not support a wide range of Indian and global languages, which is crucial for inclusive learning environments.

These pain points are amplified when handling documents with sensitive or encoded data, leading to incomplete information extraction and unreliable learning aids.

Solution

The UEI Project provides a cutting-edge solution by combining OCR techniques, vector-based document embeddings, secure backend infrastructure, and scalable processing to deliver a reliable, scalable, and secure AI educational assistant. Key features include:

File Handling and Document Upload -

  • File Storage : Users upload documents (PDFs) which are securely stored in AWS S3.
  • OCR Extraction : Tesseract OCR is employed to extract text from PDFs, especially those with encoded text, ensuring complete and accurate data extraction.
  • Metadata Storage : Querying and analyzing structured data.
  • Apache Spark : High-speed processing of big data workloads.
  • Apache Kafka : File metadata, such as filename, file type, and extraction results, are stored in a PostgreSQL database under the pdf_data table.

Embedding Creation -

  • JINA Embedding Model : Documents stored in S3 are processed using the JINA Embedding Model v3 to generate vector representations, which capture semantic meaning and are more efficient for document retrieval.
  • Vector Database : The resulting embeddings are stored in PGVector, an extension for PostgreSQL, with documents grouped into collections based on their source, allowing for efficient retrieval.

Query Processing and Answer Generation -

  • RAG Pipeline : Users submit queries via the API. The system retrieves relevant documents from the vector database using LangChain and PGVector.
  • Context Retrieval : Relevant documents are retrieved from the database to serve as context for the query.
  • Answer Generation : Using LLAMA3.3:70b LLM model, answers are generated based on the retrieved context. The system checks for hallucinated responses using detection algorithms to ensure accuracy.
  • Fallback Mechanism : The system queries in-house databases first, followed by RAG models, OLLAMA API, and OpenAI GPT as a last resort, ensuring multiple layers of query resolution.

Scalable Infrastructure -

  • Redis and Celery : Redis acts as a cache, storing intermediate data, and Celery enables parallel task processing to handle concurrent file uploads and query submissions efficiently.
  • Nginx & Gunicorn : Nginx handles proxy communication between the frontend and backend, while Gunicorn manages API traffic. SSL encryption through GoDaddy ensures secure connections.

Feature List

01
File Upload API

Securely stores uploaded documents in AWS S3 and logs relevant metadata into PostgreSQL.

02
OCR Extraction

Efficiently extracts encoded text from PDFs using Tesseract OCR.

03
Document Embedding Creation

Generates document embeddings with JINA, stored in PGVector for retrieval.

04
RAG API

Handles query processing, document retrieval, and contextual answer generation using LLMs.

05
Context Verification

Ensures the accuracy of AI-generated answers by detecting hallucinations and following fallback mechanisms.

06
Parallel Processing

Handles simultaneous user interactions through Celery and Redis task queuing.

07
Secure Communication

Ensures encrypted communication via SSL through Nginx.

08
Multi-Language OCR Support

Supports a wide range of Indian languages for OCR through Tesseract.

Tech and Solution Stack

Programming Language

Python Core logic and backend implementation.

Framework

FastAPI development for file handling and query processing.

Vector Database

PostgreSQL with PGVector - Storing document embeddings and metadata efficiently.

Embedding Model

JINA Embeddings v3 Generating vector representations of text documents.

File Storage

AWS S3 - Secure storage for uploaded documents.

OCR Library

Tesseract - Extracting text from documents, including encoded text.

LLMs

OLLAMA (Llama3.1:70b), OpenAI GPT - Context-aware response generation and fallback.

Proxy Management

Nginx and Gunicorn - Secure communication between frontend and backend.

Task Queue

Redis and Celery - Managing parallel task processing and task queuing.

Context Retrieval

LangChain and LangGraph - Document retrieval and context management.

Hosting

The UEI Project is hosted on DBMART, an efficient GPU-based server platform for low-cost AI model inference and processing. The backend communicates securely through Nginx and Gunicorn. SSL encryption via GoDaddy ensures secure interaction between the frontend and backend.

Team & Support

  • Development Team : A team of highly skilled engineers with expertise in Python, FastAPI, LangChain, LLMs, and AI model fine-tuning.
  • Infrastructure Support : Cloud engineers with deep knowledge of AWS, Nginx, PostgreSQL, Redis, and Celery for scalable backend operations.
  • AI Expertise : Dedicated AI experts focused on model training, RAG pipelines, and fine-tuning LLMs.
  • Technical Assistance : 24/7 monitoring, issue resolution, and performance optimization provided by the support team.

Maintenance

  • Regular Updates : Continuous monitoring, library upgrades, and API improvements to enhance performance and reliability.
  • Performance Monitoring : Real-time system performance tracking using Redis and Celery dashboards.
  • Scalability Enhancements : Additional resources provisioned based on growing user demand.
  • Security Audits : Routine database and SSL vulnerability assessments to ensure data protection.