<?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: Siddhartha Mani</title>
    <description>The latest articles on DEV Community by Siddhartha Mani (@siddhartha_mani_03).</description>
    <link>https://dev.to/siddhartha_mani_03</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3556772%2Ff4c12fb5-71ce-4935-b30c-f66476813d74.jpg</url>
      <title>DEV Community: Siddhartha Mani</title>
      <link>https://dev.to/siddhartha_mani_03</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siddhartha_mani_03"/>
    <language>en</language>
    <item>
      <title>If you are Information Developer or Technical Writer you can relate with this!! #ai #documentation</title>
      <dc:creator>Siddhartha Mani</dc:creator>
      <pubDate>Thu, 19 Feb 2026 13:58:58 +0000</pubDate>
      <link>https://dev.to/siddhartha_mani_03/if-you-are-information-developer-or-technical-writer-you-can-relate-with-this-ai-documentation-5e32</link>
      <guid>https://dev.to/siddhartha_mani_03/if-you-are-information-developer-or-technical-writer-you-can-relate-with-this-ai-documentation-5e32</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/siddhartha_mani_03" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3556772%2Ff4c12fb5-71ce-4935-b30c-f66476813d74.jpg" alt="siddhartha_mani_03"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/siddhartha_mani_03/writing-for-humans-is-no-longer-enough-writing-for-ai-is-now-part-of-the-job-14h9" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Writing for humans is no longer enough. Writing for AI is now part of the job&lt;/h2&gt;
      &lt;h3&gt;Siddhartha Mani ・ Feb 12&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#ai&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#documentation&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#testing&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#llm&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>ai</category>
      <category>documentation</category>
      <category>testing</category>
      <category>llm</category>
    </item>
    <item>
      <title>Writing for humans is no longer enough. Writing for AI is now part of the job</title>
      <dc:creator>Siddhartha Mani</dc:creator>
      <pubDate>Thu, 12 Feb 2026 16:33:58 +0000</pubDate>
      <link>https://dev.to/siddhartha_mani_03/writing-for-humans-is-no-longer-enough-writing-for-ai-is-now-part-of-the-job-14h9</link>
      <guid>https://dev.to/siddhartha_mani_03/writing-for-humans-is-no-longer-enough-writing-for-ai-is-now-part-of-the-job-14h9</guid>
      <description>&lt;p&gt;When my company integrated an AI assistant into our documentation platform, I was part of one of the early teams selected to test it. The goal was to see how well the AI could answer real user questions by using our existing documentation as the source of truth.&lt;br&gt;
What I did not expect was how much this exercise would change the way I think about technical writing.&lt;br&gt;
This was not just about AI accuracy. It was about how documentation itself behaves when consumed by large language models (LLMs).&lt;/p&gt;

&lt;p&gt;This article shares what that testing exposed and what it means for technical writers today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing approach: real questions, real results
&lt;/h2&gt;

&lt;p&gt;Testing started with questions that real Google Cloud users were already asking. Real support tickets, common search queries, and production environment questions were pulled directly using the QnA Analyzer tool.&lt;/p&gt;

&lt;p&gt;For each question, the team compared three outputs:&lt;/p&gt;

&lt;p&gt;• The AI assistant answer.&lt;/p&gt;

&lt;p&gt;• The documentation pages it retrieved.&lt;/p&gt;

&lt;p&gt;• The response that a subject matter expert or support engineer would give.&lt;/p&gt;

&lt;p&gt;The team tracked several quality signals, including answer correctness, follow-up prompts required, product information mixing, and missing prerequisites.&lt;/p&gt;

&lt;p&gt;When the AI assistant produced a weak or confusing answer, the first question was always whether the documentation was the cause, not the model. This framing changed the entire analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first surprise: the same question, different answers
&lt;/h2&gt;

&lt;p&gt;During testing, the assistant sometimes gave different answers to the same question. This happened even when nothing changed: the question was the same, the documentation was the same, and the same AI model was running. At first, this looked like a reliability problem.&lt;/p&gt;

&lt;p&gt;On closer inspection, the behavior revealed something fundamental about how Large Language Models (LLMs) work. LLMs are probabilistic, not deterministic. Unlike a calculator that always returns the same result, an LLM generates answers based on token probability and semantic similarity search, meaning it weighs available content and produces the most likely answer each time. Asking the same question twice is not guaranteed to produce identical output.&lt;/p&gt;

&lt;p&gt;The key factor is the quality of the content the AI model retrieves. When the content is clear and specific, the model has less room to vary and answers stay consistent. When the content is vague or incomplete, the model fills in the gaps, and those gaps introduce the variation that looks like unreliability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minimalist writing works for humans but not always for AI
&lt;/h2&gt;

&lt;p&gt;Minimalist documentation (short pages, fewer words, fewer explanations) works well for experienced human readers who fill in context from prior knowledge. LLMs cannot do this. They need intent and scope to be written down.&lt;/p&gt;

&lt;p&gt;A minimalist page that opens directly with a task list gives the model almost nothing to use when deciding whether that page is relevant to a given query. Adding a short description of one to three sentences, covering the product, the scenario, and the user goal, gives the model a reliable signal to retrieve the right page. Without that context, the model guesses and produces unreliable responses.&lt;/p&gt;

&lt;p&gt;The principle is straightforward: when documentation leaves less to interpretation, the model varies less in its answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple cross-references can hurt AI retrieval
&lt;/h2&gt;

&lt;p&gt;Too many cross-references created a different kind of documentation problem. When pages are heavily linked to other topics, the AI assistant did not always stay focused on the main page. Instead, it sometimes pulled steps from linked pages, combined partial instructions from multiple locations, and lost the workflow context that the user actually needed. The result was answers that were fragmented and hard to follow.&lt;/p&gt;

&lt;p&gt;To address this issue, the approach was adjusted to treat cross-references as a last resort rather than a default. Primary workflows were kept self-contained so the model could find everything it needed on a single page. Circular linking patterns, where page A links to page B which links back to page A, were removed because they created retrieval loops with no clear resolution.&lt;/p&gt;

&lt;h2&gt;
  
  
  A real example: "How do I back up my instance?"
&lt;/h2&gt;

&lt;p&gt;Users rarely specify which Google Cloud product or service they are using when they ask a question. The documentation needs to carry that context so the AI assistant can match the question to the right product. The question "How do I back up my instance?" is a good example of why this matters.&lt;/p&gt;

&lt;p&gt;Multiple Google Cloud services use the word "instance" to mean different things. Several of these services use the concept of an “instance” but refer to different resources. Each service had its own backup process, its own console, and its own steps. However, the documentation pages for each service opened directly with steps and UI labels, with no introduction stating which service the page belonged to.&lt;/p&gt;

&lt;p&gt;When the AI assistant received the question from users, it retrieved pages from multiple services and combined their steps into a single answer. The response looked complete and confident. It was not. A user following those steps would be mixing actions from different products and different consoles, which would either fail or cause unintended changes.&lt;/p&gt;

&lt;p&gt;The root cause was not the model hallucination. The documentation pages looked identical to the model because they all used the same term and none of them declared their scope upfront.&lt;/p&gt;

&lt;p&gt;The fix was straightforward. Each page introduction was updated to open with a clear statement, for example: "This topic describes how to back up an instance in Google Cloud Databases." That one sentence gave the model the signal it needed to retrieve the correct page for the correct service. After the update, the assistant stopped blending workflows and returned accurate, product-specific answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The experiment results
&lt;/h2&gt;

&lt;p&gt;The team ran a targeted experiment on a selected set of pages. The changes included adding concise descriptions at the beginning of each page, introducing short summaries for topics and subtopics, enhancing step-level descriptions for clarity, and reducing unnecessary cross references to keep key workflows self-contained.&lt;/p&gt;

&lt;p&gt;The results were measurable. AI answers became more accurate, search relevance improved, mixed-product responses decreased, and trust in AI-generated answers increased.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical guidance
&lt;/h2&gt;

&lt;p&gt;Apply these practices to make documentation more effective for AI retrieval:&lt;/p&gt;

&lt;p&gt;Add a concise description (one to three sentences) to every topic that states the product, scope, and scenario. &lt;br&gt;
State the product scope early in the page, particularly when similar products share terminology. &lt;br&gt;
Write preconditions and constraints explicitly rather than assuming the reader knows the context. &lt;br&gt;
Disambiguate common terms that appear across products by adding a brief clarifying phrase. &lt;br&gt;
Keep key workflows self-contained and limit cross-references to cases where they are necessary. &lt;br&gt;
Treat topic introductions as retrieval anchors that help the model decide when a page is relevant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;LLMs don't replace technical writers. They amplify the quality of the documentation we create. When documentation is clear, scoped, and intentional, AI becomes a powerful assistant. When it isn't, AI simply reflects the confusion already present in the content.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>documentation</category>
      <category>testing</category>
      <category>llm</category>
    </item>
    <item>
      <title>MCP server for Style Guide</title>
      <dc:creator>Siddhartha Mani</dc:creator>
      <pubDate>Mon, 22 Dec 2025 18:38:31 +0000</pubDate>
      <link>https://dev.to/siddhartha_mani_03/-1iio</link>
      <guid>https://dev.to/siddhartha_mani_03/-1iio</guid>
      <description>&lt;p&gt;

&lt;/p&gt;
&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m" class="crayons-story__hidden-navigation-link"&gt;How I Built an MCP Server to Create My Own AI Writing Style Guide Expert&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/siddhartha_mani_03" class="crayons-avatar  crayons-avatar--l  "&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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3556772%2Ff4c12fb5-71ce-4935-b30c-f66476813d74.jpg" alt="siddhartha_mani_03 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/siddhartha_mani_03" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Siddhartha Mani
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Siddhartha Mani
                
              
              &lt;div id="story-author-preview-content-3103822" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/siddhartha_mani_03" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3556772%2Ff4c12fb5-71ce-4935-b30c-f66476813d74.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Siddhartha Mani&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Dec 22 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m" id="article-link-3103822"&gt;
          How I Built an MCP Server to Create My Own AI Writing Style Guide Expert
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mcp"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mcp&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/documentation"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;documentation&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/vscode"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;vscode&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt; reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            10 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;




</description>
      <category>mcp</category>
      <category>documentation</category>
      <category>ai</category>
      <category>vscode</category>
    </item>
    <item>
      <title>How I Built an MCP Server to Create My Own AI Writing Style Guide Expert</title>
      <dc:creator>Siddhartha Mani</dc:creator>
      <pubDate>Mon, 22 Dec 2025 18:10:14 +0000</pubDate>
      <link>https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m</link>
      <guid>https://dev.to/siddhartha_mani_03/how-i-built-an-mcp-server-to-create-my-own-ai-writing-style-guide-expert-297m</guid>
      <description>&lt;p&gt;As a technical writer, my life revolves around corporate &lt;strong&gt;Writing Style Guides&lt;/strong&gt;. The &lt;strong&gt;Writing Style Guide&lt;/strong&gt; is my bible for me, every company I work for, my writing pattern follows their Writing Style Guide. For technical writers, the &lt;strong&gt;Writing Style Guide&lt;/strong&gt; plays the most important role in documenting any Technical Content, APIs or CLIs. But today I want to be honest: the writing style guide in general is always a massive PDF. Writers spend a lot of time figuring out what to use and when to use it. For example: Should I write “can’t” or “cannot”? Do I need a comma before “and”? How should IP addresses be formatted? Is the term “Slave” still approved for documentation?&lt;/p&gt;

&lt;p&gt;Constantly searching through a 400+ page PDF breaks my flow. I explain code, I write conceptual docs, I write API docs, I don't want to play "Ctrl+F" detective every 10 minutes.&lt;/p&gt;

&lt;p&gt;So, I built a solution.&lt;/p&gt;

&lt;p&gt;I created a custom &lt;strong&gt;MCP (Model Context Protocol) server&lt;/strong&gt; that reads my corporate Writing Style Guide and answers my questions instantly—right inside &lt;strong&gt;Claude Desktop&lt;/strong&gt; and &lt;strong&gt;VS Code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Yes, you heard right! Writing Style Guide MCP Server.&lt;/p&gt;

&lt;p&gt;Here is how I did it, and how you can too.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is MCP?
&lt;/h2&gt;

&lt;p&gt;Think of &lt;strong&gt;MCP&lt;/strong&gt; as a universal Universal Serial Bus (USB) port for AI models. Just like we can use USB in our laptop as plug‑and‑play, MCP serves the same role for AI models.&lt;br&gt;
Classically, if you wanted to connect Claude Desktop to your database, you would write a specific integration. If you wanted to connect it to VS Code, you would write another.&lt;/p&gt;

&lt;p&gt;MCP changes that. You build a "Server" (like my Writing Style Guide tool) once, and any "Client" (Claude, VS Code, Zed Editor) can plug into it and use it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Architecture:
&lt;/h2&gt;

&lt;p&gt;The implementation uses RAG (Retrieval-Augmented Generation), an AI framework that connects large language models (LLMs) to external data sources. RAG retrieves specific information from these sources before generating answers. In this case, the external data source is the &lt;code&gt;writing-style-documentation.pdf&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;The architecture includes four components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;Source file&lt;/code&gt;: The &lt;code&gt;writing-style-documentation.pdf&lt;/code&gt; file contains the style guide content.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Processor&lt;/code&gt;: Python scripts split the PDF into small, readable chunks for efficient processing.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Vector store&lt;/code&gt;: FAISS indexes and retrieves relevant content. For example, when you ask about punctuation, the vector store finds the exact page that discusses commas.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Large language model&lt;/code&gt;: The Groq API with the Llama 3 model generates responses based on the retrieved content.&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  Step-by-Step Implementation
&lt;/h2&gt;

&lt;p&gt;Complete the following steps to create an MCP server for the writing style guide.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic understanding of Python.&lt;/li&gt;
&lt;li&gt;Basic knowledge of Agentic AI.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Step 1: Set up the project
&lt;/h3&gt;

&lt;p&gt;1 Create a new &lt;code&gt;MCP-Styleguide&lt;/code&gt; folder in your local system for the   Python workspace.&lt;br&gt;
2 Open your editor, navigate to the &lt;code&gt;MCP-Styleguide&lt;/code&gt; directory in the terminal and run the following command to create a new environment named &lt;code&gt;.venv&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 -m venv .venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 Create a new &lt;code&gt;requirements.txt&lt;/code&gt; file with following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mcp
langchain
langchain-community
langchain-groq
sentence-transformers
langchain-huggingface
pypdf
faiss-cpu
python-dotenv
uvicorn 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4 Install the packages by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key libraries:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;mcp&lt;/code&gt;: Enables communication with Claude and VS Code&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;langchain&lt;/code&gt;: Manages PDF processing and AI logic&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;langchain-community&lt;/code&gt;: Provides community integrations for LangChain&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;langchain-groq&lt;/code&gt;: Integrates Groq API with LangChain&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;sentence-transformers&lt;/code&gt;: Creates text embeddings for semantic search&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;langchain-huggingface&lt;/code&gt;: Integrates Hugging Face models with LangChain&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;pypdf&lt;/code&gt;: Extracts text from PDF files&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;faiss-cpu&lt;/code&gt;: Performs vector similarity search.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;python-dotenv&lt;/code&gt;: Loads environment variables from &lt;code&gt;.env&lt;/code&gt; files&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;uvicorn&lt;/code&gt;: Runs ASGI web applications

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5 Create a new &lt;code&gt;.env&lt;/code&gt; environment file with your groq API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GROQ_API_KEY=gsk_OSV6lH3Mkelmsker45dlknWL......
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Set up the RAG engine
&lt;/h3&gt;

&lt;p&gt;Complete the following steps to create the RAG engine that processes and queries the Writing Style Guide.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Create the RAG engine file
&lt;/h4&gt;

&lt;p&gt;Create a new &lt;code&gt;rag.py&lt;/code&gt; file in the &lt;code&gt;MCP-Styleguide&lt;/code&gt; folder.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Import required libraries
&lt;/h4&gt;

&lt;p&gt;Add the following import statements to the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;typing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Optional&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.document_loaders&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PyPDFLoader&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_text_splitters&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RecursiveCharacterTextSplitter&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.vectorstores&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_community.embeddings&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HuggingFaceEmbeddings&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ChatOpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.chains&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RetrievalQA&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.prompts&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PromptTemplate&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Imports the necessary libraries for PDF processing, embeddings, vector storage, and language model integration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key libraries&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;os&lt;/code&gt;: Provides file path operations&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;typing&lt;/code&gt;: Supplies type hints for function parameters and return values&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PyPDFLoader&lt;/code&gt;: Loads and extracts content from PDF files&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RecursiveCharacterTextSplitter&lt;/code&gt;: Divides documents into smaller chunks&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FAISS&lt;/code&gt;: Creates and manages the vector database for similarity search&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;HuggingFaceEmbeddings&lt;/code&gt;: Generates text embeddings using HuggingFace models&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ChatOpenAI&lt;/code&gt;: Provides the interface to language models&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RetrievalQA&lt;/code&gt;: Creates question-answering chains with retrieval&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PromptTemplate&lt;/code&gt;: Formats prompts with variables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;load_dotenv&lt;/code&gt;: Loads environment variables from &lt;code&gt;.env&lt;/code&gt; files&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Load environment variables
&lt;/h4&gt;

&lt;p&gt;Add the following code to load environment variables from the &lt;code&gt;.env&lt;/code&gt; file in the &lt;code&gt;MCP-Styleguide&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;BASE_DIR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abspath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__file__&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BASE_DIR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.env&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Configures the base directory and loads environment variables required for API authentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;os.path.abspath(__file__)&lt;/code&gt;: Gets the absolute path of the current script file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;os.path.dirname()&lt;/code&gt;: Extracts the directory path from the absolute file path&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;BASE_DIR&lt;/code&gt;: Stores the directory path where the script is located&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;load_dotenv()&lt;/code&gt;: Reads environment variables from the &lt;code&gt;.env&lt;/code&gt; file in the base directory&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. Define global variables and configuration
&lt;/h4&gt;

&lt;p&gt;Add the following code to define the global variables, file path, and prompt template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;qa_chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;span class="n"&gt;vector_store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

&lt;span class="n"&gt;PDF_PATH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BASE_DIR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;writing-style-documentation.pdf&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;PROMPT_TEMPLATE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;You are an MCP server designed to answer questions about the Writing Style Guide.

You have access to the full Writing Style Guide PDF content. Use only this content to answer. Do not use external knowledge.

**When answering, follow these guidelines:**
- If the question is about a specific rule, term, or example, locate it in the guide.
- If multiple sections are relevant, synthesize the information.
- If the guide does not contain the answer, state that and suggest consulting the full guide.
- Provide examples from the guide when helpful.
- Cite the relevant section or page number when possible.
- Keep answers clear, concise, and professional.

**User Question:**
{question}

**Relevant Context from Writing Style Guide:**
{context}

**Answer:**
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Defines the configuration elements that control how the RAG engine operates and responds to queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;qa_chain = None&lt;/code&gt;: Initializes the global variable that will store the question-answering chain instance&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;vector_store = None&lt;/code&gt;: Initializes the global variable that will store the vector database instance&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PDF_PATH&lt;/code&gt;: Constructs the full file path to the Writing Style Guide PDF by combining the base directory with the filename&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PROMPT_TEMPLATE&lt;/code&gt;: Defines the template that structures responses from the MCP server with the following characteristics:

&lt;ul&gt;
&lt;li&gt;Instructs the model to use only content from the Writing Style Guide&lt;/li&gt;
&lt;li&gt;Provides guidelines for answering different types of questions&lt;/li&gt;
&lt;li&gt;Includes placeholders &lt;code&gt;{question}&lt;/code&gt; and &lt;code&gt;{context}&lt;/code&gt; that will be replaced with actual user queries and retrieved content&lt;/li&gt;
&lt;li&gt;Ensures responses are clear, concise, and professional&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Template variables&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;{question}&lt;/code&gt;: Replaced with the user's question at runtime&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;{context}&lt;/code&gt;: Replaced with relevant content retrieved from the Writing Style Guide&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  5.  Function declaration and PDF validation
&lt;/h4&gt;

&lt;p&gt;Add the &lt;code&gt;initialize_rag()&lt;/code&gt; function to set up the RAG pipeline. This function loads the PDF, creates embeddings, and initializes the question-answering chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize_rag&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Initializes the RAG pipeline: loads PDF, creates embeddings, builds index.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;qa_chain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vector_store&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PDF_PATH&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;FileNotFoundError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PDF file not found at &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PDF_PATH&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;. Please upload &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ibm-style-documentation.pdf&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Declares the function and validates that the PDF file exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;global qa_chain, vector_store&lt;/code&gt;: Declares global variables to store the retrieval chain and vector store&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;os.path.exists(PDF_PATH)&lt;/code&gt;: Checks whether the PDF file exists at the specified path&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FileNotFoundError&lt;/code&gt;: Raised when the PDF file is not found&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  6.  Load the PDF document
&lt;/h4&gt;

&lt;p&gt;Add the following code to load the PDF document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Loading PDF from &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;PDF_PATH&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PyPDFLoader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PDF_PATH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;documents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Loads the Writing Style Guide PDF and extracts its content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;PyPDFLoader(PDF_PATH)&lt;/code&gt;: Creates a PDF loader instance for the specified file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;loader.load()&lt;/code&gt;: Extracts all pages from the PDF and returns them as document objects&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  7.  Split the document into chunks
&lt;/h4&gt;

&lt;p&gt;Add the following code to split the document into chunks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Splitting &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; pages...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;text_splitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RecursiveCharacterTextSplitter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;chunk_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;chunk_overlap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;add_start_index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;splits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text_splitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Divides the PDF content into smaller, manageable chunks for efficient processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;chunk_size=1000&lt;/code&gt;: Sets the maximum size of each text chunk to 1000 characters&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chunk_overlap=200&lt;/code&gt;: Creates a 200-character overlap between consecutive chunks to preserve context across boundaries&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;add_start_index=True&lt;/code&gt;: Tracks the starting position of each chunk in the original document for reference&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RecursiveCharacterTextSplitter&lt;/code&gt;: A text splitter that recursively divides documents at natural boundaries&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;split_documents(documents)&lt;/code&gt;: Applies the splitting logic to all loaded documents&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  8. Create embeddings and vector store
&lt;/h4&gt;

&lt;p&gt;Add the following code to generate text embeddings and store them in a vector database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Creating embeddings and vector store (using HuggingFace embeddings)...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;HuggingFaceEmbeddings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all-MiniLM-L6-v2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;vector_store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FAISS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;splits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Generates text embeddings and stores them in a vector database for similarity search.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")&lt;/code&gt;: Uses a lightweight HuggingFace model to convert text into numerical vectors&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FAISS.from_documents(splits, embeddings)&lt;/code&gt;: Creates a FAISS vector store that indexes all document chunks with their embeddings for fast retrieval&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  9. Configure the language model
&lt;/h4&gt;

&lt;p&gt;Add the following code to configure the Groq for generating responses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Setting up QA chain with Groq (via ChatOpenAI)...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GROQ_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
         &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GROQ_API_KEY environment variable not found.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChatOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llama-3.3-70b-versatile&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
        &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GROQ_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://api.groq.com/openai/v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Sets up the Groq-hosted language model for generating responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;model_name="llama-3.3-70b-versatile"&lt;/code&gt;: Specifies the Llama 3.3 70B model for high-quality responses&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;temperature=0&lt;/code&gt;: Sets deterministic output by eliminating randomness in responses&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;api_key=os.environ["GROQ_API_KEY"]&lt;/code&gt;: Retrieves the API key from environment variables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;base_url="https://api.groq.com/openai/v1"&lt;/code&gt;: Configures the Groq API endpoint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Environment variable validation ensures the API key is set before proceeding&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ChatOpenAI&lt;/code&gt;: A LangChain wrapper that provides a consistent interface to the language model&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  10.  Initialize the QA chain
&lt;/h4&gt;

&lt;p&gt;Add the following code to initialize the question-answering chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;PROMPT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PromptTemplate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PROMPT_TEMPLATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input_variables&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;context&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;question&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;qa_chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RetrievalQA&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_chain_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;chain_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;stuff&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;retriever&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;vector_store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_retriever&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;search_kwargs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;k&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt;
        &lt;span class="n"&gt;return_source_documents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;chain_type_kwargs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prompt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;PROMPT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RAG initialization complete.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Creates the question-answering chain that combines retrieval and generation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;PromptTemplate&lt;/code&gt;: Formats the prompt using the predefined template with context and question variables&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RetrievalQA.from_chain_type()&lt;/code&gt;: Creates a QA chain with the following configuration:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;llm=llm&lt;/code&gt;: Uses the configured language model&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chain_type="stuff"&lt;/code&gt;: Uses the "stuff" method, which includes all retrieved documents in a single prompt&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;retriever=vector_store.as_retriever(search_kwargs={"k": 5})&lt;/code&gt;: Configures the retriever to fetch the top 5 most relevant chunks&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;return_source_documents=True&lt;/code&gt;: Includes source documents in the response for citation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chain_type_kwargs={"prompt": PROMPT}&lt;/code&gt;: Applies the custom prompt template&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  11.  Function declaration and initialization check
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;: Ensure that the &lt;code&gt;GROQ_API_KEY&lt;/code&gt; environment variable is set in your &lt;code&gt;.env&lt;/code&gt; file before running this function.&lt;/p&gt;

&lt;p&gt;Add the &lt;code&gt;query_style_guide()&lt;/code&gt; function to handle user queries and the test code to verify the implementation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;query_style_guide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Queries the Writing Style Guide using the initialized RAG chain.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;global&lt;/span&gt; &lt;span class="n"&gt;qa_chain&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;qa_chain&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;initialize_rag&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Error initializing RAG engine: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Declares the query function and ensures the RAG chain is initialized before processing questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;question: str&lt;/code&gt;: The user's question about the Writing Style Guide&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-&amp;gt; str&lt;/code&gt;: Returns the answer as a string&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;global qa_chain&lt;/code&gt;: Accesses the global QA chain variable&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if qa_chain is None&lt;/code&gt;: Checks whether the RAG chain has been initialized&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;initialize_rag()&lt;/code&gt;: Initializes the RAG pipeline if not already set up&lt;/li&gt;
&lt;li&gt;Error handling catches initialization failures and returns a descriptive error message&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  12. Process the query
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;qa_chain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;query&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;result&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Error processing query: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Sends the question to the RAG chain and retrieves the answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;qa_chain.invoke({"query": question})&lt;/code&gt;: Passes the user's question to the retrieval and generation pipeline&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;result["result"]&lt;/code&gt;: Extracts the generated answer from the response dictionary&lt;/li&gt;
&lt;li&gt;Error handling catches query processing failures and returns a descriptive error message&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Return value&lt;/strong&gt;: The function returns either the generated answer or an error message if the query fails.&lt;/p&gt;

&lt;h4&gt;
  
  
  13. Test the implementation
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Test run
&lt;/span&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;query_style_guide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What are the rules for using contractions?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: Tests the query function when the script runs directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key elements&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;if __name__ == "__main__"&lt;/code&gt;: Ensures the test code runs only when the script executes directly, not when imported as a module&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;query_style_guide("What are the rules for using contractions?")&lt;/code&gt;: Tests the function with a sample question about contraction usage&lt;/li&gt;
&lt;li&gt;Error handling catches and displays any exceptions that occur during testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Expected behavior&lt;/strong&gt;: When you run the script, it should initialize the RAG pipeline and return the Writing Style Guide's rules for using contractions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: The Server
&lt;/h3&gt;

&lt;p&gt;This is the "Face" of the application. using the &lt;code&gt;FastMCP&lt;/code&gt; library, it effectively says: &lt;em&gt;"Hey Claude, I have a tool called &lt;code&gt;ask_writing_style_guide&lt;/code&gt;. You can send me text, and I'll send you an answer."&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;mcp.server.fastmcp&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastMCP&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;rag&lt;/span&gt;

&lt;span class="n"&gt;mcp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastMCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Writing Style Guide Expert&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@mcp.tool&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ask_writing_style_guide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query_style_guide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it! Less than 30 lines of code for the server itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Connecting It to Claude Desktop
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In Claude Desktop, go to &lt;strong&gt;Settings&lt;/strong&gt; → &lt;strong&gt;Developer&lt;/strong&gt; → &lt;strong&gt;Edit Config&lt;/strong&gt;￼￼￼￼&lt;/li&gt;
&lt;li&gt; Add your MCP Server entry&lt;/li&gt;
&lt;li&gt;Save and Restart Claude Desktop
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"writing-style-guide"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/Users/siddhartha/Documents/thepath/MCP/venv/bin/python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"/Users/siddhartha/Documents/thepath/MCP/server.py"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
 ￼￼&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Connecting It to My Workflow
&lt;/h3&gt;

&lt;p&gt;This is where the magic happens. I don't use a terminal to query this. I use the tools I am already working in.&lt;/p&gt;

&lt;h4&gt;
  
  
  Claude Desktop
&lt;/h4&gt;

&lt;p&gt;I added a simple config to my Claude Desktop settings. Now, when I chat with Claude, I can say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Can I use word &lt;strong&gt;&lt;em&gt;Slave&lt;/em&gt;&lt;/strong&gt; in my documentation?, check the writing style rules and inform."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude &lt;strong&gt;automatically&lt;/strong&gt; calls my tool, reads the rule from the PDF: &lt;em&gt;“No, you cannot use "slave" in your documentation according to the Writing Style Guide”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I never had to leave my editor.&lt;/p&gt;

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

&lt;p&gt;Building an MCP server sounds intimidating, but it’s mostly glue code. The ability to give your AI assistants custom knowledge whether it's a style guide, your internal API docs, or your project manifest is a superpower.&lt;/p&gt;

&lt;p&gt;Give it a try. Your &lt;code&gt;Ctrl+F&lt;/code&gt; keys will thank you :)&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>documentation</category>
      <category>ai</category>
      <category>vscode</category>
    </item>
    <item>
      <title>The Era of CPU, GPU, TPU and LPU</title>
      <dc:creator>Siddhartha Mani</dc:creator>
      <pubDate>Thu, 30 Oct 2025 15:16:01 +0000</pubDate>
      <link>https://dev.to/siddhartha_mani_03/the-era-of-cpu-gpu-tpu-and-lpu-1d4j</link>
      <guid>https://dev.to/siddhartha_mani_03/the-era-of-cpu-gpu-tpu-and-lpu-1d4j</guid>
      <description>&lt;p&gt;It is 2025, and we have officially entered the age of artificial intelligence. After years of research and development, humans have created AI systems that can help find information faster, automate repetitive tasks, accelerate medical research, and make learning technology more accessible to everyone.&lt;/p&gt;

&lt;p&gt;Although we are now in the AI era, the full potential of AI and its impact on the world remain uncertain. Industry analysts anticipate that robots may soon walk the streets, science‑fiction‑style vehicles may appear, and futuristic devices that do not yet exist could become a reality.&lt;/p&gt;

&lt;p&gt;When discussing AI, the focus is often on software—the algorithms and models. Equally important is the hardware, the “brain” of AI, which includes the chips that perform the processing behind the scenes. Software intelligence depends entirely on hardware intelligence.&lt;/p&gt;

&lt;p&gt;This article highlights the primary types of chips that drive AI: CPU, GPU, TPU, and LPU. Whether the reader is a developer, a technology enthusiast, or simply curious about the future, understanding these chips is essential because they are shaping the technology of tomorrow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chip Comparison: CPU, GPU, TPU, LPU
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Feature&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;CPU&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;GPU&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;TPU&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;LPU&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Full Name&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Central Processing Unit&lt;/td&gt;
&lt;td&gt;Graphics Processing Unit&lt;/td&gt;
&lt;td&gt;Tensor Processing Unit&lt;/td&gt;
&lt;td&gt;Language Processing Unit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Primary Function&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;General-purpose computing&lt;/td&gt;
&lt;td&gt;Parallel processing and graphics&lt;/td&gt;
&lt;td&gt;AI/ML acceleration&lt;/td&gt;
&lt;td&gt;Language model inference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Architecture&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Few complex cores (2–64)&lt;/td&gt;
&lt;td&gt;Thousands of simple cores&lt;/td&gt;
&lt;td&gt;Matrix multiplication units&lt;/td&gt;
&lt;td&gt;Deterministic execution core&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Processing Style&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Sequential tasks&lt;/td&gt;
&lt;td&gt;Massively parallel&lt;/td&gt;
&lt;td&gt;Matrix operations&lt;/td&gt;
&lt;td&gt;Sequential token processing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For AI Training&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Poor&lt;/td&gt;
&lt;td&gt;Excellent (Industry standard)&lt;/td&gt;
&lt;td&gt;Good (Google ecosystem)&lt;/td&gt;
&lt;td&gt;Not designed for&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For AI Inference&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Basic models only&lt;/td&gt;
&lt;td&gt;Excellent and versatile&lt;/td&gt;
&lt;td&gt;Excellent and efficient&lt;/td&gt;
&lt;td&gt;Revolutionary for LLMs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Power Consumption&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Moderate (15–250W)&lt;/td&gt;
&lt;td&gt;Very high (250–700W+)&lt;/td&gt;
&lt;td&gt;High but efficient&lt;/td&gt;
&lt;td&gt;Highly efficient&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost (Data Center)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;$500 – $10,000+&lt;/td&gt;
&lt;td&gt;$10,000 – $40,000+&lt;/td&gt;
&lt;td&gt;Cloud service only&lt;/td&gt;
&lt;td&gt;Inference API service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key Strength&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Versatility and quick decisions&lt;/td&gt;
&lt;td&gt;Massive parallel throughput&lt;/td&gt;
&lt;td&gt;AI inference efficiency&lt;/td&gt;
&lt;td&gt;Ultra-low latency for text&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key Weakness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Poor parallel performance&lt;/td&gt;
&lt;td&gt;High power and cost&lt;/td&gt;
&lt;td&gt;Limited flexibility&lt;/td&gt;
&lt;td&gt;Hyper-specialized&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Memory Approach&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hierarchical cache&lt;/td&gt;
&lt;td&gt;GDDR/HBM memory&lt;/td&gt;
&lt;td&gt;On-chip memory&lt;/td&gt;
&lt;td&gt;Massive single-thread bandwidth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Programming&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;C++, Python, Java&lt;/td&gt;
&lt;td&gt;CUDA, OpenCL&lt;/td&gt;
&lt;td&gt;TensorFlow&lt;/td&gt;
&lt;td&gt;Groq API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Leading Examples&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Intel Core, AMD Ryzen, Apple M-series&lt;/td&gt;
&lt;td&gt;NVIDIA A100/H100, RTX series&lt;/td&gt;
&lt;td&gt;Google TPU v4/v5&lt;/td&gt;
&lt;td&gt;GroqChip LPU-1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Use Case Example&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Running operating system, web browser&lt;/td&gt;
&lt;td&gt;Training AI models, gaming&lt;/td&gt;
&lt;td&gt;Google Search, Translate&lt;/td&gt;
&lt;td&gt;AI chatbots, text generation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Which Chip is For You?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Everyday User:&lt;/strong&gt; You have a CPU (and often a small built-in GPU) in your laptop and phone. It's perfect for web browsing, emails, and documents. You don't need to think about the rest!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gamer or Video Editor:&lt;/strong&gt; You need a powerful GPU (like from NVIDIA or AMD) in your computer. It will render your games and videos beautifully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Company Training a New AI Model:&lt;/strong&gt; You will buy or rent thousands of GPUs (like NVIDIA's H100). They are the most versatile for the heavy lifting of training.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Company Running a Chatbot Service (like ChatGPT):&lt;/strong&gt; You have two great choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use GPUs (versatile and powerful).&lt;/li&gt;
&lt;li&gt;Use LPUs (if your main goal is raw, unbeatable speed and responsiveness for text generation).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Large-Scale Company like Google:&lt;/strong&gt; Running its services requires using their own TPUs by the millions to power search, photos, and translate because it's hyper-efficient for their specific, massive-scale needs.&lt;/p&gt;

&lt;p&gt;If you do not understand the terms in the table above, do not worry. In my next blog, I will explain each term so that you can understand the technical details. Until then, happy reading.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>gpu</category>
      <category>cpu</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
