AI-Powered Document Classification and Similarity Search

Megan Duncan
shareFacebook iconTwitter iconLinkedin icon

Over the past few years, we've seen an increasing number of clients approaching us with the same fundamental challenge: they're drowning in unstructured documents and struggling to extract meaningful insights from them. Whether it's insurance companies with thousands of claim files, law firms with decades of case documents, or healthcare organisations with extensive patient records, the problem is consistent - valuable knowledge is trapped in PDFs that are impossible to navigate efficiently.

Traditionally, our approach involved keyword-based indexing systems, often built with tools like Elasticsearch. We'd extract text, build searchable indexes around key terms, and implement filtering based on predefined categories. While this worked for basic retrieval, it had significant limitations: documents could only be found if users knew exact terms to search for, manual categorisation risked misclassifying documents, and keyword matching couldn't understand meaning or context. A claim involving "vehicle damage" might be missed if someone searched for "car accident," and documents with similar intent but different terminology would never be connected.

The emergence of large language models and vector databases has fundamentally changed this landscape. By combining Claude's language models for classification and analysis with OpenAI's embeddings API for vector search using sqlite-vec, we can now build systems that understand meaning rather than just matching words. Documents can be classified automatically based on semantic content, and similarity search can discover connections that would never emerge through traditional keyword approaches - turning static repositories into intelligent, discoverable knowledge bases.

The Approach #

Document Processing Pipeline.png

1. Document Processing Pipeline #

Text Extraction and Preprocessing #

The first challenge is converting unstructured PDFs into machine-readable text while preserving semantic meaning. Our pipeline uses the pdf-text-extract library to handle various PDF document formats and extract readable text content.

Content Processing #

The extracted PDF text is processed by combining multiple pages into a single continuous text block. This approach preserves the document's narrative flow while creating a format suitable for AI analysis. The raw text is stored directly in the SQLite database alongside other case study metadata for subsequent AI processing.

2. Classification System #

We use Claude for document analysis because it has a longer context window, so can handle much larger documents without needing to chunk them down. While it is the right tool for the first step of classification, it doesn’t have a dedicated embedding API, so we used OpenAI for the second part of the classification.

AI-Powered Analysis with Claude Sonnet 4-5 #

The system uses Claude to analyse document content and extract structured information, including:

  • Group Classification: Primary categories like "Insurance", "Banking", "Investment", "Credit"
  • Service Identification: Specific service types such as "Motor Insurance", "Home Loan", "Credit Card"
  • Content Analysis: Document summaries, key points extraction, and sentiment analysis
  • Outcome Extraction: Identifies case outcomes from existing case study data

Embedding Generation with OpenAI's embedding API #

Each processed document is converted into high-dimensional vectors using OpenAI's text-embedding-3-small model. The embedding input combines Claude's structured outputs (summary, group, service, key points, and outcome) into a single text string that gets converted into 1536-dimensional vectors capturing semantic meaning.

The system uses the generated embeddings to find similar cases through:

  • Mathematical similarity matching using cosine similarity calculations across the entire document corpus
  • Semantic understanding that goes beyond keyword matching to find conceptually similar cases

This approach leverages Claude's language understanding to create consistent, structured data that OpenAI then converts into searchable vector representations for scalable similarity matching.

3. Vector Database Implementation #

SQLite-Vec Integration #

We chose sqlite-vec for its simplicity and performance characteristics:

  • Fast similarity search using vector indexing
  • SQL-compatible interface for complex queries
  • Lightweight deployment requirements
  • Excellent performance for moderate-scale datasets

Similarity Search Algorithm #

The vector database enables sophisticated queries:

  • Find documents with similar semantic content - Match documents based on meaning rather than keywords
  • Discover thematically related materials - Surface documents with similar topics or themes

Technical Implementation #

To prove out this theory, we decided to stand up a proof-of-concept application using modern, accessible technologies that could demonstrate the practical viability of semantic document classification and similarity search.

Technology Stack #

  • Frontend: Next.js 16 with React 19 and TypeScript for a responsive web interface
  • PDF Processing: pdf-text-extract library for converting documents to machine-readable text
  • AI Integration: -- Claude Sonnet 4-5 for document classification, analysis, and summary generation -- OpenAI Embeddings API (text-embedding-3-small) for generating 1536-dimensional vector embeddings of document content
  • Vector Database: sqlite-vec (v0.1.7-alpha.2) with SQLite for efficient similarity search

Architecture Approach #

The proof-of-concept follows a straightforward data pipeline: documents are uploaded and processed through PDF text extraction, content is cleaned and sent to OpenAI for classification and embedding generation, then stored in SQLite with vector extensions for fast similarity search. This architecture prioritises simplicity and deployability while maintaining the core functionality needed to validate the semantic search approach.

Implementation Benefits #

By choosing lightweight, familiar technologies like SQLite and standard web frameworks, we created a system that can be deployed anywhere without complex infrastructure requirements, making it easy to demonstrate and iterate on the core concept with real document collections.

Use Cases #

We've brainstormed some use cases where we thought this approach would be particularly useful, especially for organisations dealing with large volumes of similar documents that need to be categorised and matched against historical patterns.

  • Insurance Claims: Auto-categorise and route claims, match to historical cases for outcome prediction, identify fraud patterns and optimise adjuster assignments
  • Digital Collections: Automatically categorise and tag historical documents, photographs, and artifacts based on content analysis. Help researchers find related materials across different collections and institutions
  • Healthcare: Classify medical records, match patient conditions to similar cases, optimise specialist routing and discover treatment efficacy patterns
  • Credit Assessment: Compare loan applications to similar profiles for more accurate risk scoring
  • Customer Support: Categorise tickets, match to resolved cases for faster solutions, improve agent routing and reduce escalation times

Each application uses AI classification and vector similarity search to transform manual document processing into intelligent, automated workflows.

Results & Benefits #

Benefits for businesses #

Faster Decision Making #

Instead of spending hours searching through filing cabinets or digital folders, hoping to find the right precedent, staff can now find similar cases in seconds. An insurance adjuster dealing with a complex motor vehicle claim immediately sees how 20 similar cases were resolved, their settlement amounts, and processing times - turning guesswork into data-driven decisions.

Improved Consistency Across Teams #

Different team members no longer categorise the same type of case differently based on their personal judgment. The AI applies the same logical analysis every time, meaning a new hire and a 20-year veteran will get the same classification results. This consistency improves service quality and reduces customer complaints about inconsistent treatment.

Hidden Patterns Become Visible #

The system reveals connections that humans would never spot. For example, it might discover that certain types of health insurance claims submitted during winter months have different approval patterns, or that customer complaints mentioning specific phrases tend to escalate more often. These insights help businesses proactively address issues before they become problems.

Cost Savings Through Automation #

Manual document review and categorisation that previously took days now happens automatically. Staff time is freed up for higher-value work like customer service, complex case analysis, or business development.

Technical Advantages Over Traditional Systems #

Smarter Search Than Keyword Matching #

Traditional systems like Elasticsearch require users to guess the exact words used in documents. Our approach understands meaning, searching for "car accident" will find documents about "vehicle collisions," "motor incidents," or "automotive damage", even if those exact words weren't used. This eliminates the frustration of knowing relevant information exists but being unable to find it. ####More Portable Than Proprietary Index-Only Approaches A common pain point with traditional search engines is the effort required to build and tune indexes that are tightly coupled to a specific platform. To reduce that lock-in, we separate AI classification from vectorisation and persist classification outputs (such as categories, entities, summaries, and key points) as reusable metadata, for example in JSON sidecar files alongside the source documents. If we later move to a different vector store, we can usually re-vectorise from this enriched data without re-running full document classification.

Self-Improving Organisation #

Unlike traditional filing systems that require constant manual updates to keyword lists and categories, this AI-powered approach automatically adapts to new document types and terminology. When new regulations create new claim types or industry language evolves, the system learns and adjusts without requiring technical maintenance.

Scalable Without Linear Cost Increase #

Processing 1,000 documents takes roughly the same effort as processing 100,000, so the system doesn't slow down or require proportionally more staff as volume grows. Traditional manual classification would require hiring more people; this approach handles growth automatically.

This semantic understanding fundamentally solves the biggest problem with traditional document management: valuable information getting lost simply because someone didn't use the "right" search terms or file it in the expected category. AI Powered documents.png This project demonstrates that AI-powered document classification and similarity search are practical solutions using accessible technologies today. By combining Claude’s language models with OpenAI's embeddings API and sqlite-vec, organisations can transform manual document categorisation into intelligent, automated systems that reveal hidden patterns and accelerate decision-making. This approach is particularly valuable for insurance claims processing, collections management, medical diagnosis support, and customer service optimisation, anywhere finding the right precedent or similar case significantly impacts outcomes. If your organisation is struggling with unstructured data trapped in documents and traditional search methods aren't delivering the insights you need, Abletech can help. We specialise in building practical AI solutions that turn your document collections from static repositories into intelligent, searchable knowledge bases that drive better decision-making across your organisation.