doc-knowledge-base

Ingest long-form documents into pgvector and answer questions with cited passages.

1|Updated Apr 9, 2026
One-click install
npx skills add https://github.com/AlexYedi/Empire_State_Events_Pipeline_Take_3 --skill doc-knowledge-base-alexyedi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: doc-knowledge-base
Source: https://github.com/AlexYedi/Empire_State_Events_Pipeline_Take_3/tree/main/.claude/skills/doc-knowledge-base
Command: npx skills add https://github.com/AlexYedi/Empire_State_Events_Pipeline_Take_3 --skill doc-knowledge-base-alexyedi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires boto3, sentence-transformers, ebooklib, beautifulsoup4, pymupdf, numpy, requests, huggingface-hub.

What problem does it solve? Long-form reference documents like books, whitepapers, and filings sit unread because searching them manually is slow. This Skill ingests epub and PDF files into a semantic vector index so you can ask natural-language questions over your library and get back cited passages with page or section locators. ## Core Features & Use Cases - Document Ingestion: Uploads raw epub/PDF originals to Cloudflare R2, extracts and cleans text (ligature repair, hyphenation fixes, front-matter filtering), chunks into ~400-token windows, embeds locally with BAAI/bge-small-en-v1.5, and indexes into Supabase pgvector. - Semantic Q&A with Citations: Embeds a question, runs the match_doc_chunks RPC, and returns top-k passages with document title, author, and section/page citations for grounded answers. - Retrieval Evaluation & A/B Testing: Ships recall@k acceptance gates, a 25-case validated eval set, a local cross-encoder reranker, and a 3-arm harness (dense, hybrid_rerank, contextual_hybrid_rerank) with an explicit ship rule. - Use Case: Ask "what does Inference Engineering say about KV cache sizing" and receive the relevant passages cited as "Chapter 3 Hardware > 3.1 GPU Architecture" or "p.79". ## Quick Start Ask the assistant to ingest a book from your knowledge library with /ingest-doc and then query it using /ask-library with your question.

Frequently Asked Questions about doc-knowledge-base

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a semantic search knowledge base from PDF and epub files?

Run the ingest script on each document: it dedups by sha256, uploads the original to R2, extracts text with ebooklib or pymupdf, chunks into ~400-token windows, embeds locally with bge-small-en-v1.5, and inserts into Supabase pgvector tables.

How do I answer questions over my document library with citations?

Use the ask_library script with your question and an optional k value. It embeds the query, calls the match_doc_chunks RPC, and prints the top passages with document title, author, and section or page locators for citation.

Does this RAG pipeline require paid embedding or LLM API calls?

No. Embeddings use the local BAAI/bge-small-en-v1.5 model and reranking uses a local bge-reranker-base cross-encoder on CPU, so ingest, query, and evaluation make zero metered API calls. Only the optional claim-extraction script uses the Gemini API.

How do I measure retrieval quality of a pgvector RAG index?

Run eval_retrieval.py for a recall@k acceptance gate against a gold-phrase eval set, or ab_harness.py to compare dense, hybrid rerank, and contextual hybrid arms with context recall, precision, latency, and an explicit ship rule.

Why do PDF extractions contain broken words like prefi ll?

PDF extractors split fi/fl/ff ligature glyphs, producing artifacts like prefi ll. The pipeline repairs these with a dictionary-guided ligature fix and de-hyphenation at extraction time, and the eval metrics normalize both sides so retrieval is measured fairly.

What are the limitations of PDF versus epub ingestion?

Epub is preferred because it yields semantic section-level locators and cleaner text. PDF is best-effort with page-based locators, can carry ligature artifacts, and front-matter pages like tables of contents may add retrieval noise.