Skip to content
rithishcodespacePublic

About

Automated patent prior-art search engine using semantic similarity

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

158 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ PatentIQ β€” AI-Powered Patent Prior-Art Search & Confidence Analysis Engine

PatentIQ is an enterprise-grade, full-stack AI platform for automated patent prior-art retrieval, semantic claim analysis, metadata filtering, and RAG-driven novelty scoring.


πŸ“Œ Table of Contents


πŸ”¬ Overview

Patent prior-art searching traditionally requires laborious manual Boolean queries across massive patent databases. PatentIQ modernizes patent analysis by combining dense vector embeddings with metadata-filtered similarity retrieval and Retrieval-Augmented Generation (RAG).

It evaluates patent claims against prior art using local LLMs (qwen2.5:3b / llama3), calculates a heuristic Confidence Score across multiple dimensions (retrieval precision, vector similarity distance, section matching, and LLM certainty), and presents actionable technical insights through an interactive 3D command center interface.


πŸ”„ How the Project Works & System Flow

1. The Real-World Problem

Prior-art patent search has historically been a manual, costly bottleneck in intellectual property law. Patent attorneys typically spend 15 to 30 hours per invention constructing complex Boolean query matrices across fragmented databases. Because patent drafters deliberately use obscure technical synonyms to broaden claim scope (e.g., describing a pencil as an "elongated cylindrical writing instrument having an internal frangible marking core"), traditional keyword queries often miss critical prior art, exposing inventors to multi-million-dollar patent infringement lawsuits or novelty rejections under 35 U.S.C. Β§ 102.

2. End-to-End Execution Sequence

sequenceDiagram
    autonumber
    actor User as Inventor / IP Attorney
    participant UI as React 19 Client
    participant Server as Fastify API (Clean Arch)
    participant Ollama as Local Ollama (nomic-embed + Qwen)
    participant Pinecone as Pinecone Vector DB
    participant BM25 as Sparse BM25 Lexical Service
    participant RRF as Reciprocal Rank Fusion (RRF)
    participant Conf as Heuristic Confidence Engine
    participant Postgres as PostgreSQL (Prisma ORM)

    User->>UI: Submits invention disclosure & metadata filters
    UI->>Server: POST /api/rag/analyze { query, topK, filters }
    Server->>Server: Validate payload via Zod DTO schema
    
    par Multi-Stage Hybrid Retrieval
        Server->>Ollama: Generate 768-dim vector (nomic-embed-text)
        Ollama-->>Server: Dense float vector (~42ms)
        Server->>Pinecone: Query vector cosine similarity + metadata filters
        Pinecone-->>Server: Dense candidate patents
    and
        Server->>BM25: Query sparse keyword corpus
        BM25-->>Server: Sparse lexical candidates
    end

    Server->>RRF: Fuse dense & sparse ranks (k=60, w_dense=0.6, w_bm25=0.4)
    RRF-->>Server: Top-K deduplicated & fused prior-art candidates

    par Concurrent RAG AI Analysis
        Server->>Ollama: Novelty Analysis Prompt (Qwen 2.5 3B)
        Ollama-->>Server: 7-section structured novelty report JSON
    and
        Server->>Ollama: Section & Claim Overlap Prompt (Qwen 2.5 3B)
        Ollama-->>Server: Itemized claim overlap matrix JSON (Claims 1..N)
    end

    Server->>Conf: Compute Multi-Factor Confidence Score (Retrieval + Analysis)
    Conf-->>Server: Final Score (0–100) + Qualitative Badge (High/Moderate/Low)
    Server->>Postgres: Persist search query, candidate patents & RAG report
    Server-->>UI: Return combined prior-art matches, report & confidence telemetry
    UI-->>User: Render interactive 3D constellation cluster & analysis dashboard
Loading

3. Pipeline Core Stages Breakdown

  1. Multi-Stage Hybrid Search: Pairs 768-dimensional dense vector embeddings (nomic-embed-text) with sparse lexical tokens (BM25), fused via Reciprocal Rank Fusion (RRF) ($k=60$, vector weight $0.6$, BM25 weight $0.4$) to combine conceptual understanding with exact patent-number/keyword precision.
  2. Concurrent Dual-Engine RAG: Single-pass retrieval triggers two parallel LLM executions via Promise.all using local Qwen 2.5 3B (NoveltyAnalysisService for patentability syntheses and OverlapAnalysisService for claim-by-claim overlap matrices) with strict anti-hallucination prompt constraints.
  3. Multi-Factor Heuristic Confidence Scoring: Mathematically evaluates retrieval precision, score decay distribution, metadata completeness, count penalties, and claim overlap density into a calibrated 0–100 score.
  4. Interactive 3D Constellation Visualizer: Renders prior-art relationships in an interactive Three.js 3D space where Euclidean distance reflects semantic similarity.
  5. Polyglot Persistence: Separates vector storage and similarity indexing (Pinecone) from transactional search history, session persistence, and audit logging (PostgreSQL via Prisma ORM).

✨ Key Features

  • πŸ” Semantic Prior-Art Search: Dense vector search powered by Pinecone and Ollama embeddings (nomic-embed-text).
  • 🎯 Granular Metadata Filtering: Filter prior-art queries by IPC classification codes, country/jurisdiction, publication date range, assignee/owner, and document sections (claims, abstract, description).
  • 🧠 RAG Novelty & Prior-Art Analysis: Automated AI evaluation of technical novelty, non-obviousness risks, overlapping claim elements, and technical differentiators using qwen2.5:3b.
  • πŸ“Š Heuristic Confidence Scoring Engine: Multi-metric scoring system evaluating retrieval precision/recall, vector distance, and LLM certainty mapped to qualitative confidence indicators.
  • πŸ’Ύ Search History & Persistence Layer: Atomic transaction storage via Prisma ORM and PostgreSQL to log user search sessions, retrieved patent metadata, and novelty reports.
  • ⚑ Dataset Pipelines & Benchmarking: Built-in CLI tooling for dataset cleaning, section extraction, vector embedding generation, Pinecone batch ingestion, and retrieval benchmarking (Precision@K, Recall@K, MRR, NDCG, Latency P95/P99).
  • 🎨 Modern Interactive UI: High-density command center built with React 19, Vite, Tailwind CSS v4, Framer Motion, and Three.js 3D visualizer in a cohesive Slate/Indigo theme.

πŸ—οΈ Architecture & Tech Stack

PatentIQ follows Clean Architecture with strict Dependency Injection (DI) and modular separation of transport, domain, and infrastructure layers.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    React 19 Client                      β”‚
β”‚        (Vite + TailwindCSS + Framer Motion + 3D)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ REST API (/api/v1/*)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Fastify Server                       β”‚
β”‚    (Dependency Injection Container + Zod Validation)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                   β”‚                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Pinecone DB    β”‚ β”‚  PostgreSQL DB  β”‚ β”‚   Ollama LLM   β”‚
β”‚ (Vector Search) β”‚ β”‚ (Prisma ORM)    β”‚ β”‚ (Embed & RAG)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Backend (apps/server)

  • Runtime: Node.js & TypeScript
  • Web Framework: Fastify v5 (with CORS, Helmet, Rate Limit, Swagger OpenAPI, Multipart)
  • Database & ORM: PostgreSQL & Prisma ORM v7
  • Vector Database: Pinecone Database SDK (dimension: 768, metric: cosine)
  • LLM & Embeddings: Ollama (nomic-embed-text, qwen2.5:3b / llama3)
  • Validation: Zod schema validation & DTO typing
  • Testing: Vitest & Supertest

Frontend (apps/client)

  • Framework: React 19 & TypeScript
  • Build Tool: Vite v8
  • Styling: Tailwind CSS v4
  • Animations & 3D: Framer Motion & Three.js / React Three Fiber
  • Icons & UI: Lucide React

πŸŽ“ Technical Interview Guide & Core Concepts

πŸ’‘ Master Guide Available: For the complete 720-line deep dive with 26 technical questions, mathematical proofs, STAR behavioral scenarios, and code references, explore the dedicated PROJECT_EXPLANATION_AND_INTERVIEW_GUIDE.md.

πŸŽ™οΈ The 30-Second Elevator Pitch

"PatentIQ is an enterprise AI platform for automated prior-art patent search and novelty scoring. Traditional patent search takes 15 to 30 hours of manual Boolean queries across fragmented databases and often fails when different terminology is used. PatentIQ solves this by combining hybrid semantic searchβ€”pairing dense Pinecone vector embeddings with sparse BM25 lexical search via Reciprocal Rank Fusionβ€”with a local, privacy-preserving RAG pipeline powered by Ollama and Qwen 2.5 3B. It automatically maps claim overlaps, computes a multi-factor mathematical Confidence Score, and visualizes patent clusters in an interactive Three.js 3D space, cutting patentability analysis time from hours to seconds."


🧠 Top 10 Technical Interview Questions & Answers

1. Why did you choose Fastify over Express or NestJS?
  • Throughput & Efficiency: Fastify is up to 2x faster than Express due to its compiled JSON serialization (fast-json-stringify) and radix-tree routing (find-my-way), minimizing server overhead during high-throughput AI orchestration.
  • Encapsulated Plugin Architecture: Fastify's lifecycle hooks provide clean dependency scoping, making it straightforward to build our custom Dependency Injection container (di.plugin.ts) without the heavyweight boilerplate of NestJS.
  • Built-in Schema Validation: Native integration with Zod schemas enables strict DTO validation and auto-generated Swagger documentation.
2. Why use local Ollama models instead of the OpenAI / Anthropic cloud API?
  • Trade Secret Protection & Pre-Grant Privacy: Unfiled patent ideas are proprietary trade secrets. Sending unpublished invention claims to public cloud AI APIs risks breaching non-disclosure agreements and forfeiting patent rights through public disclosure.
  • Zero Cloud Inference Costs: Patent analysis involves processing dense technical documentation across multiple candidates. Local execution on nomic-embed-text and qwen2.5:3b eliminates per-token API costs.
  • Deterministic Offline Availability: Protects the platform from external cloud rate limits, network outages, and pricing tier changes.
3. Why Hybrid Search (Dense + BM25) instead of pure vector search?
  • The Exact Keyword Vocabulary Problem: Pure dense embeddings excel at fuzzy semantic concepts (e.g. connecting "drone" with "unmanned aerial vehicle"), but frequently fail on exact patent numbers (e.g. US10948372B2), chemical formulas, or specific trademarked part names.
  • Reciprocal Rank Fusion (RRF): Running BM25 alongside Pinecone dense vectors and fusing them via RRF ($k=60$, vector weight $0.6$, BM25 weight $0.4$) ensures that candidates scoring high across both systems rise to the top without needing to normalize disparate score scales.
4. How do you prevent LLM hallucinations when evaluating technical patent claims?
  • Strict Context Grounding: Prompts explicitly designate the LLM as an objective patent examiner and instruct it to reason only from the provided patent metadata.
  • Prohibition of Fabricated Identifiers: The model is strictly forbidden from inventing patent numbers, filing dates, or non-existent claim numbers.
  • Explicit Extraction Constraints: For claim overlap analysis, the prompt forces the model to cite specific claim numbers (e.g., "Claim 3") and quote the exact technical rationale.
  • Fallback Sanitization: Regex parsers sanitize markdown fences (json ... ) and validate payload schemas with deterministic fallbacks if the model returns malformed JSON.
5. How is the multi-factor Confidence Score mathematically calculated?

Instead of relying solely on raw vector similarity, PatentIQ computes a holistic 0–100 score:

  • Retrieval Confidence ($C_{\text{ret}}$): $$C_{\text{ret}} = \Big[ (S_{\text{top}} \times 40) + (S_{\text{avg}} \times 30) + (D_{\text{score}} \times 15) + (M_{\text{meta}} \times 15) \Big] \times M_{\text{count}}$$ (Evaluating top similarity, average similarity, score decay distribution, metadata completeness, and candidate count ratio).
  • Analysis Confidence ($C_{\text{ana}}$): Weighted composite of Retrieval Confidence (50%), Analysis Completeness (30%), and Claim Overlap Density (20%).
  • Overall Confidence: $0.40 \times C_{\text{ret}} + 0.60 \times C_{\text{ana}}$, mapped to qualitative tiers (Very High, High, Moderate, Low, Very Low).
6. Why use both PostgreSQL (Prisma) and Pinecone (Polyglot Persistence)?
  • Specialized Workloads: Pinecone handles high-throughput Approximate Nearest Neighbor (ANN) cosine distance queries over 768-dimensional float vectors with serverless scaling.
  • Relational ACID Integrity: PostgreSQL handles structured search sessions, user profiles, audit timestamps, and one-to-many relationships between search queries, retrieved patents, and novelty analysis reports via Prisma ORM.
  • Resource Isolation: Vector search computations in Pinecone never compete with PostgreSQL transactional operations for memory or CPU.
7. How do you handle 50-page patent specifications within LLM context windows?
  • Domain-Aware Section Extraction: During dataset ingestion (extractPatentSections.ts), we isolate the highest-density legal sections: the Title, Abstract, and Independent Claims (which define the actual legal boundaries of protection).
  • Chunking with Sliding Windows: Detailed descriptions are chunked into 512-token segments with 50-token overlap, tagged with metadata (patentId, section, ipc), ensuring only the most relevant sections enter the RAG prompt context.
8. How do you measure retrieval quality (Precision@K, Recall@K, MRR, NDCG)?

Through the automated benchmarking suite (POST /api/search/benchmark):

  • Precision@K: Proportion of retrieved patents in the top-K that are relevant.
  • Recall@K: Proportion of all known relevant patents found in the top-K.
  • MRR (Mean Reciprocal Rank): Reciprocal rank ($\frac{1}{\text{rank}}$) of the first relevant patent found.
  • NDCG@K: Ranking quality metric that penalizes placing relevant patents at lower ranks using logarithmic discounting.
9. How does the Dependency Injection (DI) system work in Fastify?

In src/plugins/di.plugin.ts, we register a Fastify plugin that instantiates providers, repositories, services, and controllers in topological dependency order. The assembled container is decorated onto the Fastify instance as fastify.diContainer. This eliminates global state, enables clean unit testing with mocked providers, and enforces separation of concerns.

10. How would you scale this architecture to 100M patents and 5,000 QPS?
  1. Vector Sharding: Horizontally partition the Pinecone index across pod replicas for distributed read throughput.
  2. Query Caching: Deploy a Redis cache layer (ENABLE_QUERY_CACHE=true) with a 300s TTL for popular query embeddings.
  3. High-Throughput LLM Serving: Transition from single-node Ollama to a distributed vLLM cluster with PagedAttention and continuous batching behind an internal load balancer.
  4. Stateless Fastify Pods: Deploy Fastify as autoscaling stateless pods in Kubernetes (EKS/GKE) with horizontal pod autoscaling (HPA).
  5. Database Read Replicas: Direct search history and analytics reads to PostgreSQL read replicas.

⚑ Quick-Recall Metrics & Specs

Parameter Value / Metric Description
Embedding Model nomic-embed-text 768 float dimensions, Cosine distance metric
Generative Model qwen2.5:3b Local Ollama inference for RAG novelty analysis
RRF Parameters $k=60$, $w_v=0.6$, $w_b=0.4$ Reciprocal Rank Fusion constants (dense + BM25)
Retrieval Latency $< 200\text{ ms}$ Combined embedding generation + Pinecone query
RAG Inference Latency $< 2,000\text{ ms}$ Concurrent novelty and claim overlap analysis
Confidence Formula $0.4 \times C_{\text{ret}} + 0.6 \times C_{\text{ana}}$ Composite multi-factor confidence scoring

πŸ“ Project Structure

PatentIQ/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ client/                  # React 19 Frontend SPA
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ components/      # UI components (ResultCard, ConfidenceDashboard, 3D Canvas)
β”‚   β”‚   β”‚   β”œβ”€β”€ pages/           # Search, Results, History, HowItWorks, Docs
β”‚   β”‚   β”‚   β”œβ”€β”€ services/        # REST API service client integrations
β”‚   β”‚   β”‚   └── types/           # TypeScript type definitions
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── server/                  # Fastify Backend API Server
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ common/          # Middleware, DTO schemas, custom error classes
β”‚       β”‚   β”œβ”€β”€ config/          # Environment variables & service configs
β”‚       β”‚   β”œβ”€β”€ modules/         # Clean Architecture feature modules
β”‚       β”‚   β”‚   β”œβ”€β”€ admin/       # System metrics & admin management
β”‚       β”‚   β”‚   β”œβ”€β”€ analytics/   # Usage & performance telemetry
β”‚       β”‚   β”‚   β”œβ”€β”€ auth/        # JWT Authentication & user authorization
β”‚       β”‚   β”‚   β”œβ”€β”€ confidence/  # Confidence scoring heuristic module
β”‚       β”‚   β”‚   β”œβ”€β”€ embeddings/  # Vector embedding generation & batching
β”‚       β”‚   β”‚   β”œβ”€β”€ history/     # Search & RAG analysis persistence
β”‚       β”‚   β”‚   β”œβ”€β”€ patents/     # Patent ingestion & dataset processing
β”‚       β”‚   β”‚   β”œβ”€β”€ rag/         # RAG novelty analysis & candidate ranking
β”‚       β”‚   β”‚   β”œβ”€β”€ reports/     # Report generation & exports
β”‚       β”‚   β”‚   β”œβ”€β”€ search/      # Pinecone semantic search & filtering
β”‚       β”‚   β”‚   β”œβ”€β”€ uploads/     # PDF document parsing & extraction
β”‚       β”‚   β”‚   └── users/       # User profile management
β”‚       β”‚   β”œβ”€β”€ plugins/         # Fastify core plugins & DI container
β”‚       β”‚   β”œβ”€β”€ providers/       # Vector DB & LLM provider implementations
β”‚       β”‚   └── app.ts           # Fastify application factory
β”‚       β”œβ”€β”€ tests/               # Unit & integration test suites
β”‚       └── package.json
β”‚
β”œβ”€β”€ docs/                        # Deep-dive architecture & API technical guides
└── README.md

πŸ“š Documentation Index

Detailed technical specifications and architectural guides are available in the docs/ directory:

Document Description
πŸŽ“ Interview & System Guide End-to-end workflows, system design, math formulas & 26 technical interview Q&A
πŸ›οΈ System Architecture Clean Architecture, Dependency Injection container, and request lifecycle
πŸ”Œ REST API Specifications Request/response DTO schemas, endpoints, and OpenAPI specs
πŸ” Semantic Search Pipeline Vector embedding generation, Pinecone index querying, and metadata filters
πŸ€– RAG Novelty Pipeline 7-section structured prompts, claim overlap matrix, and anti-hallucination rules
πŸ“Š Benchmarking & Metrics Precision@K, Recall@K, MRR, NDCG calculation, and latency percentiles
βš™οΈ Configuration Reference Detailed breakdown of environment variables and service credentials
πŸš€ Deployment Guide Local environment setup, database migrations, and operational guidelines
πŸ“ Project Structure Taxonomy Directory taxonomy, module relationships, and contribution standards

πŸš€ Getting Started

Prerequisites

Ensure you have the following installed on your system:

  • Node.js: v20+
  • npm (or pnpm)
  • PostgreSQL: v15+
  • Ollama: Running locally with required models:
    ollama pull nomic-embed-text
    ollama pull qwen2.5:3b
  • Pinecone Account: API Key and an index configured (dimension: 768, metric: cosine)

Environment Setup

  1. Copy .env.example inside apps/server/ to .env:
cp apps/server/.env.example apps/server/.env
  1. Configure environment variables in apps/server/.env:
NODE_ENV=development
PORT=4000
HOST=0.0.0.0

# Database Connection
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/patent_iq?schema=public"

# JWT Authentication
JWT_SECRET="patentiq_super_secret_jwt_key_2026"

# Pinecone Vector DB
PINECONE_API_KEY="your-pinecone-api-key"
PINECONE_INDEX_NAME="patent-embeddings"

# Ollama Local LLM & Embedding Models
OLLAMA_BASE_URL="http://localhost:11434"
OLLAMA_EMBEDDING_MODEL="nomic-embed-text"
OLLAMA_LLM_MODEL="qwen2.5:3b"

# File Storage & Search Defaults
STORAGE_TYPE="local"
STORAGE_PATH="./storage/uploads"
DEFAULT_TOP_K=10
BENCHMARK_ITERATIONS=5
ENABLE_QUERY_CACHE=false
CACHE_TTL_SECONDS=300

Installation

Install workspace dependencies from the project root:

npm install

Database & Vector Store Setup

Run Prisma migrations to initialize PostgreSQL database schemas:

cd apps/server
npx prisma migrate dev --name init
npx prisma generate

Running the Applications

Start the Fastify backend server and React frontend client:

# Start Backend API Server (Runs on http://localhost:4000)
cd apps/server
npm run dev

# Start Frontend UI Client (Runs on http://localhost:5173)
cd apps/client
npm run dev

πŸ› οΈ CLI Scripts & Dataset Tools

PatentIQ includes built-in CLI scripts in apps/server to process, embed, and benchmark patent datasets:

cd apps/server
Script Command Purpose & Description
npm run clean-dataset Cleans raw CSV/JSON patent datasets and normalizes metadata schemas
npm run extract-sections Extracts claims, abstracts, descriptions, and metadata into structured JSON
npm run generate-embeddings Generates 768-dim vector embeddings for extracted sections via Ollama
npm run upload-pinecone Batch uploads processed vector embeddings and metadata to Pinecone
npm run semantic-search Executes interactive CLI test queries against the Pinecone vector index
npm run benchmark-search Measures Precision@K, Recall@K, MRR, NDCG, and latency metrics

πŸ“– API Documentation & Endpoints

Interactive OpenAPI / Swagger documentation is available when the server is running at: πŸ‘‰ http://localhost:4000/documentation

Summary of REST API Endpoints

πŸ” Semantic Search & RAG

  • POST /api/v1/search: Vector similarity search with optional metadata filters (IPC, country, date, assignee).
  • POST /api/v1/search/benchmark: Execute multi-query benchmarking and return IR quality metrics.
  • POST /api/v1/search/prior-art: Execute prior art evaluation over query.
  • POST /api/v1/rag/analyze: Perform 7-section RAG novelty analysis & section/claim overlap breakdown.
  • POST /api/v1/rag/rank: Hybrid candidate reranking over retrieved prior-art candidates.

πŸ”‘ Authentication (/api/v1/auth)

  • POST /register: Register a new user account.
  • POST /login: Authenticate and receive JWT access/refresh tokens.
  • POST /refresh: Refresh expired access tokens.
  • POST /logout: Invalidate user session tokens.

πŸ’Ύ History & Persistence (/api/v1/history)

  • GET /: Retrieve paginated search history sessions for user.
  • GET /:id: Fetch detailed search session, prior art matches, and RAG reports.
  • DELETE /:id: Delete search session entry.

πŸ“„ Patents & Uploads (/api/v1/patents, /api/v1/uploads)

  • POST /api/v1/patents: Ingest new patent record into relational database.
  • GET /api/v1/patents: List ingested patents with metadata pagination.
  • GET /api/v1/patents/:id: Retrieve detailed patent by ID.
  • POST /api/v1/uploads: Upload and parse patent PDF documents for instant prior-art analysis.

⚑ Vector Embeddings & System Metrics (/api/v1/embeddings, /api/v1/admin, /api/v1/analytics)

  • POST /api/v1/embeddings/generate: Generate vector embedding for input text.
  • POST /api/v1/embeddings/batch: Batch vector embedding generation.
  • GET /api/v1/admin/status: System operational status and index stats.
  • POST /api/v1/admin/clear-cache: Purge active query response cache.
  • GET /api/v1/analytics/overview: Usage statistics, query performance, and retrieval latency metrics.

🩺 Health Checks

  • GET /health: Overall server health and operational status.
  • GET /health/postgres: PostgreSQL database connectivity status.
  • GET /health/pinecone: Pinecone vector store API status.
  • GET /health/ollama: Ollama local LLM service status.

πŸ“Š Benchmarking & Evaluation

PatentIQ features an evaluation module designed to measure retrieval efficiency and execution latency:

  • Precision@K & Recall@K: Evaluates top-K document relevance against ground-truth benchmarks.
  • MRR (Mean Reciprocal Rank): Evaluates the rank placement of the first relevant patent result.
  • NDCG (Normalized Discounted Cumulative Gain): Measures ranked retrieval effectiveness.
  • System Latency Instrumentation: Benchmarks execution time breakdown across embedding generation, vector similarity search, and database persistence (P95 / P99 latency percentiles).

πŸ§ͺ Testing

Run backend unit and integration test suites using Vitest:

cd apps/server

# Run all unit tests
npm run test:unit

# Run integration tests
npm run test:integration

# Run full test coverage report
npm run test:coverage

πŸ“„ License

This project is licensed under the ISC License.

PatentIQ

Automated patent prior-art search engine using semantic similarity S

About

Automated patent prior-art search engine using semantic similarity

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages