<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tanisha Khakhrani</title>
    <description>The latest articles on DEV Community by Tanisha Khakhrani (@tanisha_050).</description>
    <link>https://dev.to/tanisha_050</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4131606%2F7abbbb20-c4b8-447e-a318-2c011498541d.jpg</url>
      <title>DEV Community: Tanisha Khakhrani</title>
      <link>https://dev.to/tanisha_050</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanisha_050"/>
    <language>en</language>
    <item>
      <title>From PDF to Knowledge Base: Building an AI-Powered Glossary Assistant for Intelligent Q&amp;A</title>
      <dc:creator>Tanisha Khakhrani</dc:creator>
      <pubDate>Wed, 14 Oct 2026 10:44:53 +0000</pubDate>
      <link>https://dev.to/addwebsolutionpvtltd/from-pdf-to-knowledge-base-building-an-ai-powered-glossary-assistant-for-intelligent-qa-3eob</link>
      <guid>https://dev.to/addwebsolutionpvtltd/from-pdf-to-knowledge-base-building-an-ai-powered-glossary-assistant-for-intelligent-qa-3eob</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;“The technology you use impresses no one. The experience you create with it is everything.” - Sean Gerety&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why is a Knowledge Base useful for PDF-based AI applications?&lt;/li&gt;
&lt;li&gt;How are PDFs converted into searchable knowledge?&lt;/li&gt;
&lt;li&gt;How does semantic search improve document Q&amp;amp;A?&lt;/li&gt;
&lt;li&gt;Why is an AI assistant needed on top of the Knowledge Base?&lt;/li&gt;
&lt;li&gt;How does the glossary handle terminology-based questions?&lt;/li&gt;
&lt;li&gt;How do the Knowledge Base, glossary, retrieval system, and LLM work together?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Table of Content(Index)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Introduction
1.1 From PDF to Knowledge
1.2 Problems with Traditional PDF Search
1.3 Intelligent Document Interaction&lt;/li&gt;
&lt;li&gt;Knowledge Base for PDFs
2.1 What is a Knowledge Base?
2.2 Building a Knowledge Base
2.3 Benefits of a Document-Based Knowledge Base&lt;/li&gt;
&lt;li&gt;AI-Powered Q&amp;amp;A Assistant
3.1 Why an AI Assistant is Needed
3.2 Natural Language Q&amp;amp;A
3.3 Conversation and Ambiguity Handling&lt;/li&gt;
&lt;li&gt;Building the Knowledge Base
4.1 Text Extraction and Structure Detection
4.2 Chunking
4.3 Embeddings and FAISS
4.4 Semantic Retrieval and Sources&lt;/li&gt;
&lt;li&gt;Role of the Glossary
5.1 What is a Glossary?
5.2 Automatic Glossary Extraction
5.3 Glossary vs Knowledge Base&lt;/li&gt;
&lt;li&gt;Putting Everything Together
6.1 LLM and Context
6.2 End-to-End Workflow
6.3 User Interface&lt;/li&gt;
&lt;li&gt;FAQs&lt;/li&gt;
&lt;li&gt;Interesting Facts&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1.1 From PDF to Knowledge&lt;/strong&gt;&lt;br&gt;
PDFs are mainly designed for storing and displaying documents. They are convenient for humans, but their content is not automatically organized in a form that an AI system can efficiently search.&lt;/p&gt;

&lt;p&gt;A Knowledge Base (KB) transforms document content into a structured and searchable representation that an AI application can retrieve when answering questions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F03rbrz5xg0l517tamp0y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F03rbrz5xg0l517tamp0y.png" alt=" " width="430" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The goal is therefore not simply to store PDFs, but to transform their content into usable knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.2 Problems with Traditional PDF Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Traditional PDF search has several limitations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keyword Mismatch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keyword-based search mainly looks for matching words. A search for:&lt;br&gt;
"repair ruptured plumbing"&lt;/p&gt;

&lt;p&gt;may not return content describing:&lt;br&gt;
"fixing a leaking pipe"&lt;/p&gt;

&lt;p&gt;even though the two expressions have a similar meaning.&lt;/p&gt;

&lt;p&gt;Semantic search addresses this by representing text as embeddings and comparing their meaning. Sentence Transformers, for example, supports embeddings and semantic search across text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Poor Machine Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PDFs are designed around visual layouts. During extraction, issues can occur with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multicolumn text&lt;/li&gt;
&lt;li&gt;Headers and footers&lt;/li&gt;
&lt;li&gt;Reading order&lt;/li&gt;
&lt;li&gt;Tables&lt;/li&gt;
&lt;li&gt;Text inside images&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PDF extraction tools such as pdfplumber provide text and layout-related extraction capabilities, but the quality still depends on how the original PDF was created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Information Spread Across Multiple Files&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Important information may be distributed across several PDFs. Users have to search each document separately and combine the results themselves.&lt;/p&gt;

&lt;p&gt;A Knowledge Base brings these documents into a single searchable layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scanned Documents&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scanned PDFs may contain images instead of machine-readable text. Such documents require OCR before their content can be processed as text. pdfplumber's documentation also notes that it works best with machine-generated PDFs rather than scanned documents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.3 Intelligent Document Interaction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of manually searching through hundreds of pages, users can ask questions directly.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What are the termination liabilities in Section 4?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The system retrieves relevant information and provides it to an LLM for answer generation.&lt;/p&gt;

&lt;p&gt;A typical RAG-style document workflow is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF → Extract → Chunk → Embeddings → Vector Search → Context → LLM → Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The key idea is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instead of searching only for exact words, search for meaning and context.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Knowledge Base for PDFs
&lt;/h2&gt;

&lt;p&gt;The Knowledge Base is the foundation of the assistant. Before the AI can answer questions, information from PDFs must be extracted, organized, indexed, and made searchable.&lt;/p&gt;

&lt;p&gt;Instead of treating a PDF as one large file, the system divides its content into smaller meaningful units called chunks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.1 What is a Knowledge Base?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;Knowledge Base&lt;/strong&gt; is a centralized collection of information that an application can retrieve and use to answer questions.&lt;/p&gt;

&lt;p&gt;In this project:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF → Text → Chunks → Embeddings → FAISS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each chunk represents a small piece of document knowledge. Its embedding allows the system to find it when a user's question is semantically related.&lt;/p&gt;

&lt;p&gt;In simple terms:&lt;br&gt;
&lt;strong&gt;A PDF is the source of information.&lt;br&gt;
A Knowledge Base is the searchable representation of that information.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.2 Building a Knowledge Base&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose the system receives several PDFs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learning.pdf&lt;/li&gt;
&lt;li&gt;Constructors.pdf&lt;/li&gt;
&lt;li&gt;Encapsulation.pdf&lt;/li&gt;
&lt;li&gt;Inheritance.pdf&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of searching each document independently, the project processes them through the same pipeline:&lt;br&gt;
&lt;strong&gt;PDFs → Text Extraction → Structure Detection → Chunking → Embeddings → FAISS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The chunks and their metadata are combined:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;all_chunks.extend(get_chunks)&lt;br&gt;
all_metadata.extend(get_metadata)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Embeddings are then generated for the combined collection:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;chunk_embeddings = embedding_chunks(all_chunks)&lt;br&gt;
stored_chunk_embeddings = store_embeddings(chunk_embeddings)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The result is a single searchable knowledge layer containing information from multiple PDFs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.3 Benefits of a Document-Based Knowledge Base&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Centralized Knowledge&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Multiple PDFs can be processed into one searchable system.&lt;br&gt;
Multiple PDFs → Processing → Unified Knowledge Base&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Faster Retrieval&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of processing an entire document for every question, the system searches indexed chunks and retrieves only the most relevant content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Semantic Understanding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Embeddings allow the system to retrieve related content even when the question and document use different wording. Semantic search works by embedding the query and corpus into a shared vector space and finding nearby representations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Context Preservation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each chunk can retain metadata such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PDF filename&lt;/li&gt;
&lt;li&gt;Page number&lt;/li&gt;
&lt;li&gt;Heading&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;strong&gt;Inheritance.pdf → Page 4 → Types of Inheritance → Relevant Chunk&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Reusable AI Foundation&lt;/strong&gt;&lt;br&gt;
Once created, the Knowledge Base can support:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Question answering&lt;/li&gt;
&lt;li&gt;Document assistants&lt;/li&gt;
&lt;li&gt;Summarization&lt;/li&gt;
&lt;li&gt;Information extraction&lt;/li&gt;
&lt;li&gt;Intelligent search&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. AI-Powered Q&amp;amp;A Assistant
&lt;/h2&gt;

&lt;p&gt;The Knowledge Base solves the problem of storing and retrieving information, but users still need a simple way to interact with it.&lt;br&gt;
Users should not need to understand embeddings, vector indexes, or similarity calculations. They should simply be able to ask a question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.1 Why an AI Assistant is Needed&lt;/strong&gt;&lt;br&gt;
Manual document search requires users to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the correct document.&lt;/li&gt;
&lt;li&gt;Open it.&lt;/li&gt;
&lt;li&gt;Search for keywords.&lt;/li&gt;
&lt;li&gt;Read surrounding content.&lt;/li&gt;
&lt;li&gt;Compare information across documents.&lt;/li&gt;
&lt;li&gt;Form the answer themselves.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This becomes inefficient as documents become larger or more numerous.&lt;br&gt;
Instead of manually searching:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"What is encapsulation and why is it useful?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;the user can ask the assistant directly. The assistant handles the retrieval process in the background.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Any sufficiently advanced technology is indistinguishable from magic.” - Arthur C. Clarke&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;3.2 Natural Language Q&amp;amp;A&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The user can ask questions in normal language.&lt;br&gt;
For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User:&lt;/strong&gt; What is inheritance in Python?&lt;/p&gt;

&lt;p&gt;The question is converted into an embedding and used to retrieve relevant document chunks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question → Relevant Context → LLM → Natural-Language Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The retrieved context is then passed to the LLM.&lt;/p&gt;

&lt;p&gt;This creates an important separation:&lt;br&gt;
&lt;strong&gt;Retrieval finds the knowledge.&lt;br&gt;
Generation explains the knowledge.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sentence Transformers supports embedding generation and semantic search, making this type of retrieval possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.3 Conversation and Ambiguity Handling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A useful assistant should understand follow-up questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User:&lt;/strong&gt; What is inheritance?&lt;br&gt;
&lt;strong&gt;Assistant:&lt;/strong&gt; Inheritance allows one class to derive properties and behavior from another.&lt;br&gt;
&lt;strong&gt;User:&lt;/strong&gt; Explain it with an example.&lt;/p&gt;

&lt;p&gt;The second question depends on the first. The assistant therefore uses conversation history:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current Question + Previous Conversation → LLM → Context-Aware Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The assistant should also avoid guessing when a question is ambiguous.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;strong&gt;What is inheritance?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If multiple contexts are available:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Python inheritance&lt;/li&gt;
&lt;li&gt;Java inheritance&lt;/li&gt;
&lt;li&gt;C++ inheritance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;the assistant can ask the user to clarify instead of selecting one without sufficient evidence.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Knowledge is power. Information is liberating.” - Kofi Annan&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  4. Building the Knowledge Base
&lt;/h2&gt;

&lt;p&gt;The Knowledge Base converts raw PDF content into searchable vector representations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF → Text Extraction → Structure Detection → Chunking → Embeddings → FAISS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.1 Text Extraction and Structure Detection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first step is to extract text from each PDF page.&lt;br&gt;
The project uses &lt;strong&gt;pdfplumber:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;with pdfplumber.open(pdf_path) as pdf:&lt;/strong&gt;&lt;br&gt;
for page in pdf.pages:&lt;br&gt;
page_text = page.extract_text()&lt;/p&gt;

&lt;p&gt;The extracted text is stored along with page information:&lt;br&gt;
&lt;strong&gt;page_text_list.append(page_text)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;pdfplumber supports page-level text extraction and can also work with layout-related information such as character positions and font attributes.&lt;/p&gt;

&lt;p&gt;The basic transformation is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF → Machine-Readable Text&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure Detection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Extracted text alone may lose useful document structure. Headings provide additional context.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chapter 2&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inheritance allows one class to...&lt;br&gt;
The project uses font-size information to identify headings.&lt;/p&gt;

&lt;p&gt;It calculates the median body font size:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;body_font_size = np.median(all_sizes)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and defines a threshold:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;heading_threshold = body_font_size + 1&lt;/strong&gt;.5&lt;/p&gt;

&lt;p&gt;A sufficiently large and relatively short line can then be treated as a heading.&lt;/p&gt;

&lt;p&gt;The resulting chunk can retain:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Heading: Inheritance&lt;br&gt;
Text: Inheritance allows one class...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This makes the retrieved information more meaningful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.2 Chunking&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Large documents should not be treated as one giant block of text. The content is divided into smaller &lt;strong&gt;chunks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project uses:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;max_chunk_size = 1000&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;overlap = 200&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The overlap helps preserve context between neighboring chunks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chunk 1 → 1000 characters&lt;br&gt;
200-character overlap&lt;br&gt;
Chunk 2 → 1000 characters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project also associates headings and metadata with chunks, providing additional context during retrieval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.3 Embeddings and FAISS&lt;/strong&gt;&lt;br&gt;
After chunking, each chunk is converted into a numerical representation called an embedding.&lt;/p&gt;

&lt;p&gt;The project uses:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SentenceTransformer("all-MiniLM-L6-v2")&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;embeddings = model.encode(chunks)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sentence Transformers creates fixed-size vector representations that can be used for semantic search and similarity comparison.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Python inheritance" → [0.12, -0.34, 0.81, ...]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The exact numbers are not meaningful to humans. They allow text to be compared mathematically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question Embedding → Compare Similarity → Document Chunk Embeddings → Relevant Chunks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FAISS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once embeddings are generated, they need to be stored for efficient search.&lt;br&gt;
The project uses FAISS:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dimension = embeddings.shape[1]&lt;br&gt;
index = faiss.IndexFlatL2(dimension)&lt;br&gt;
index.add(&lt;/strong&gt;&lt;br&gt;
np.array(embeddings).astype("float32")&lt;br&gt;
&lt;strong&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;IndexFlatL2 performs nearest-neighbor search using L2 distance.&lt;br&gt;
The simplified flow is:&lt;br&gt;
&lt;strong&gt;Document Chunks → Embeddings → FAISS → Vector Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FAISS provides indexing and efficient similarity-search functionality for vector data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.4 Semantic Retrieval and Sources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user asks a question, the question is converted into an embedding using the same model.&lt;/p&gt;

&lt;p&gt;The system then searches FAISS:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Question → Question Embedding → FAISS Search → Relevant Chunks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project retrieves the top &lt;strong&gt;3 relevant chunks:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;distances, indices = index.search(&lt;/strong&gt;&lt;br&gt;
question_embedding,&lt;br&gt;
k=3&lt;br&gt;
&lt;strong&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These chunks become the context for the LLM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Metadata&lt;/strong&gt;&lt;br&gt;
Each chunk also retains information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File name&lt;/li&gt;
&lt;li&gt;Page number&lt;/li&gt;
&lt;li&gt;Heading&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance.pdf&lt;br&gt;
Page 4&lt;br&gt;
Heading: Types of Inheritance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This allows users to verify the answer and return to the original document.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Role of the Glossary
&lt;/h2&gt;

&lt;p&gt;Technical documents often contain specialized terminology. Even when the system retrieves the correct information, users may not understand the terms being used. This is where the glossary becomes important.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Our industry does not respect tradition. It only respects innovation.” - Satya Nadella&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;5.1 What is a Glossary?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;glossary&lt;/strong&gt; is a collection of important terms and their definitions.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encapsulation&lt;/strong&gt;&lt;br&gt;
→ The practice of bundling data and methods within a class.&lt;br&gt;
&lt;strong&gt;Inheritance&lt;/strong&gt;&lt;br&gt;
→ A mechanism through which one class derives properties and behavior from another.&lt;br&gt;
&lt;strong&gt;Polymorphism&lt;/strong&gt;&lt;br&gt;
→ The ability of different objects to respond to the same interface in different ways.&lt;/p&gt;

&lt;p&gt;The glossary provides quick access to definitions without requiring users to search through the complete document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.2 Automatic Glossary Extraction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of manually creating the glossary, the project uses an LLM to identify important terminology from the extracted document content.&lt;/p&gt;

&lt;p&gt;The system can identify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Key terms&lt;/li&gt;
&lt;li&gt;Abbreviations&lt;/li&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;li&gt;Concepts&lt;/li&gt;
&lt;li&gt;Tools&lt;/li&gt;
&lt;li&gt;Definitions
The expected structure is a dictionary:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;br&gt;
"inheritance": "A mechanism through which one class derives properties and behavior from another.",&lt;br&gt;
"encapsulation": "A technique of bundling data and methods within a class."&lt;br&gt;
&lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The terms are normalized:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;return {&lt;/strong&gt;&lt;br&gt;
str(k).lower().strip(): str(v).strip()&lt;br&gt;
for k, v in glossary_dict.items()&lt;br&gt;
&lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This makes lookup more consistent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.3 Glossary vs Knowledge Base&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The glossary and Knowledge Base have different responsibilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1genlmn9v53740uf6qua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1genlmn9v53740uf6qua.png" alt=" " width="439" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;**Glossary Question&lt;/p&gt;

&lt;p&gt;"What is inheritance?"&lt;/p&gt;

&lt;p&gt;Question → Glossary Lookup → Definition&lt;/p&gt;

&lt;p&gt;Knowledge Base Question&lt;/p&gt;

&lt;p&gt;"How is inheritance used in this application?"&lt;/p&gt;

&lt;p&gt;Question → Embedding → FAISS Search → Relevant Chunks → LLM → Answer**&lt;/p&gt;

&lt;p&gt;The glossary is therefore &lt;strong&gt;not a replacement for the Knowledge Base.&lt;/strong&gt; It is an additional layer designed to make terminology-focused questions faster and clearer.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Putting Everything Together
&lt;/h2&gt;

&lt;p&gt;The final assistant combines the Knowledge Base, glossary, retrieval system, conversation history, and LLM into one workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.1 LLM and Context&lt;/strong&gt;&lt;br&gt;
The LLM is responsible for generating the final natural-language response.&lt;/p&gt;

&lt;p&gt;The basic process is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question → Relevant Context → LLM → Natural-Language Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The important distinction is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The vector index retrieves.&lt;br&gt;
The LLM explains.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The retrieved context helps ground the generated answer in information from the uploaded documents.&lt;/p&gt;

&lt;p&gt;For follow-up questions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current Question + Previous Conversation → LLM → Context-Aware Answer&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“The advance of technology is based on making it fit in so that you don't really even think about it.” - Bill Gates&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;6.2 End-to-End Workflow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The complete system can be divided into two stages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 1: Knowledge Base Creation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF → Text Extraction → Structure Detection → Chunking → Embeddings → FAISS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The glossary is generated alongside the Knowledge Base:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF Text → Important Terms → Glossary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 2: Question Answering&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a definition-based question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question → Glossary Lookup → Definition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a broader question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question → Embedding → FAISS Search → Relevant Chunks → LLM → Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a follow-up question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current Question + Previous Conversation → LLM → Context-Aware Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The overall experience is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upload PDF → Ask Question → Get Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.3 User Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project uses Streamlit to provide the user interface.&lt;br&gt;
The user can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Upload PDF documents.&lt;/li&gt;
&lt;li&gt;Process the documents.&lt;/li&gt;
&lt;li&gt;Ask questions.&lt;/li&gt;
&lt;li&gt;View generated answers.&lt;/li&gt;
&lt;li&gt;Continue the conversation.&lt;/li&gt;
&lt;li&gt;View relevant sources.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From the user's perspective:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upload PDF → Ask Question → Get Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Behind the scenes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF → Extraction → Chunking → Embeddings → FAISS → Retrieval → LLM → Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The complexity remains in the backend while the user experience remains simple.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. What is a PDF Knowledge Base?&lt;/strong&gt;&lt;br&gt;
A PDF Knowledge Base converts information from PDFs into searchable chunks. These chunks are represented as embeddings and stored in a vector index such as FAISS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Why not simply search the PDF?&lt;/strong&gt;&lt;br&gt;
Traditional search relies heavily on matching words. Semantic search can retrieve related information even when different wording is used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. What is the role of FAISS?&lt;/strong&gt;&lt;br&gt;
FAISS stores vector representations and performs similarity search to retrieve relevant chunks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Why is a glossary needed?&lt;/strong&gt;&lt;br&gt;
The Knowledge Base handles broader questions, while the glossary provides quick answers to terminology-based questions such as "What is encapsulation?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Can the assistant answer follow-up questions?&lt;/strong&gt;&lt;br&gt;
Yes. Conversation history allows the assistant to interpret questions based on previous messages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. What happens when a question is ambiguous?&lt;/strong&gt;&lt;br&gt;
The assistant can identify multiple relevant contexts and ask the user to clarify instead of making an unsupported assumption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interesting Facts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Semantic search focuses on meaning rather than only exact keywords -&lt;a href="https://www.sbert.net/examples/sentence_transformer/applications/semantic-search/README.html" rel="noopener noreferrer"&gt;Semantic Search Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The entire PDF does not need to be sent to the LLM. Relevant chunks are retrieved first - &lt;a href="https://www.sbert.net/" rel="noopener noreferrer"&gt;Sentence Transformers Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;This project uses 1,000-character chunks with 200-character overlap - &lt;a href="https://faiss.ai/" rel="noopener noreferrer"&gt;FAISS Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The glossary and Knowledge Base serve different purposes.&lt;/li&gt;
&lt;li&gt;Source metadata can connect retrieved content back to its original PDF, page, and heading - &lt;a href="https://github.com/jsvine/pdfplumber/blob/stable/README.md" rel="noopener noreferrer"&gt;pdfplumber Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The same Knowledge Base can support multiple AI applications beyond Q&amp;amp;A.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;“We are stuck with technology when what we really want is just stuff that works.” - Douglas Adams&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The project demonstrates how static PDF documents can be transformed into an interactive source of knowledge.&lt;/p&gt;

&lt;p&gt;By combining PDF extraction, structure detection, chunking, embeddings, FAISS-based retrieval, glossary lookup, conversation history, source tracking, and an LLM, users can interact with documents using natural language instead of manually searching through files.&lt;/p&gt;

&lt;p&gt;The key idea is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Knowledge Base retrieves the right information, the glossary explains important terminology, and the AI assistant turns that information into a conversational answer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The result is a document assistant that combines semantic search, contextual understanding, and glossary-based definitions into one simple question-answering experience.sea&lt;/p&gt;

&lt;p&gt;About the Author: &lt;em&gt;Tanisha is an AI Engineer at &lt;a href="https://www.addwebsolution.com/" rel="noopener noreferrer"&gt;AddWeb Solution&lt;/a&gt;, working on AI/ML solutions, intelligent document processing, and AI-powered applications.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>vertexai</category>
      <category>rag</category>
      <category>knowledgebase</category>
    </item>
  </channel>
</rss>
