The Information Gap in Indian Elections

Every election cycle in India, voters face a critical information deficit. While candidates present manifestos and campaign promises, detailed personal financial disclosures and criminal records, often buried in lengthy official documents, remain largely inaccessible to the average citizen. This opacity hinders informed decision-making, as voters lack easy access to the information that could shape their choices.

Introducing the Candidate Compliance Agent

To address this, the Candidate Compliance Agent has been developed. This AI-powered system allows anyone to query the affidavits of Tamil Nadu election candidates using plain English or Tamil. Users can ask direct questions about a candidate's assets, declared income, educational background, and any criminal records. The agent then retrieves and synthesizes answers directly from the official candidate affidavit documents.

A live demo is available at: https://affidavit-rag-frontend.vercel.app.

Navigating Complex Data: The Technical Hurdles

Building this system presented significant technical challenges, primarily stemming from the nature of the source data. The affidavits were not provided as clean, structured datasets. Instead, the raw materials consisted of:

  • Scanned PDFs: Each document, often around 6MB, was a scanned image rather than machine-readable text.
  • Multilingual Content: The text within the PDFs was a mix of Tamil and English, requiring robust natural language processing capabilities for both languages.
  • Obfuscated Text: The text was frequently overlaid with stamp paper backgrounds and notary seals, making optical character recognition (OCR) more difficult and prone to errors.
  • Inconsistent Formatting: There was no standardized template for affidavits across different candidates or constituencies, leading to variations in layout, section ordering, and data presentation.

System Architecture and Implementation

The Candidate Compliance Agent employs a Retrieval-Augmented Generation (RAG) architecture to overcome these data complexities. The system can be broken down into several key components:

Data Ingestion and Preprocessing

The process begins with ingesting the scanned PDF documents. Advanced OCR tools are used to extract text from the images. Given the presence of stamp papers and seals, specialized OCR techniques are employed to improve accuracy. Following OCR, the extracted text undergoes significant cleaning. This involves removing noise, identifying and separating Tamil and English text segments, and attempting to normalize formatting inconsistencies. Regular expressions and custom parsing logic are crucial at this stage to handle the varied document structures.

Diagram illustrating the data ingestion pipeline for scanned, multilingual election affidavits.

Document Chunking and Embedding

Once the text is cleaned, it is divided into manageable chunks. This is a critical step for effective retrieval. The size and overlap of these chunks are carefully tuned to ensure that relevant context is preserved without creating overly large segments that dilute specific information. Each chunk is then converted into a numerical vector embedding using a multilingual sentence transformer model. This allows the system to understand the semantic meaning of the text and compare it to user queries.

Vector Database and Retrieval

These embeddings are stored in a specialized vector database. When a user submits a query in English or Tamil, the query itself is also embedded into a vector. The system then performs a similarity search within the vector database to find the most relevant text chunks that semantically match the query. This retrieval mechanism is the core of the RAG system, ensuring that the AI's responses are grounded in the actual affidavit data.

Large Language Model (LLM) for Generation

The retrieved text chunks, which serve as the context, are then passed to a Large Language Model (LLM). The LLM's task is to synthesize this contextual information and generate a coherent, natural-language answer to the user's original query. By grounding the LLM's response in specific, retrieved document segments, the system significantly reduces the risk of hallucination and ensures factual accuracy, directly addressing the reliability concerns often associated with AI-generated content.

Frontend and User Experience

The user interface is built using React and deployed on Vercel, providing a responsive and accessible web application. This frontend allows users to input their questions in either English or Tamil and receive the answers generated by the backend AI agent. The focus is on simplicity and ease of use, enabling individuals with no technical background to access this vital information.

Implications and Future Directions

The Candidate Compliance Agent represents a significant step towards greater transparency in the electoral process. By democratizing access to candidate information, it empowers voters to make more informed decisions. The technical approach, particularly the handling of noisy, multilingual, scanned documents through RAG, offers a blueprint for similar applications in other domains dealing with unstructured or semi-structured data.

Future work could involve expanding the system to cover affidavits from other Indian states, incorporating additional document types, or developing more sophisticated methods for handling complex legal jargon and financial terms. The core challenge remains making complex, official information digestible and actionable for the public.