<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GenAI]]></title><description><![CDATA[GenAI]]></description><link>https://genai-arnab.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 11:04:14 GMT</lastBuildDate><atom:link href="https://genai-arnab.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Advanced Rags]]></title><description><![CDATA[Advanced RAGs (Retrieval-Augmented Generation)
I explored advanced types of RAG frameworks beyond the basic architecture. These are designed to make retrieval more intelligent, context-aware, and adaptive.
1. Self RAG (sRAG)

Concept:
  The model cri...]]></description><link>https://genai-arnab.hashnode.dev/advanced-rags</link><guid isPermaLink="true">https://genai-arnab.hashnode.dev/advanced-rags</guid><dc:creator><![CDATA[Arnab Saha]]></dc:creator><pubDate>Mon, 22 Sep 2025 04:07:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/agFmImWyPso/upload/b41e22a06a2c7f3327fd0c774cfef67b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-advanced-rags-retrieval-augmented-generation">Advanced RAGs (Retrieval-Augmented Generation)</h2>
<p>I explored advanced types of RAG frameworks beyond the basic architecture. These are designed to make retrieval more intelligent, context-aware, and adaptive.</p>
<h3 id="heading-1-self-rag-srag">1. <strong>Self RAG (sRAG)</strong></h3>
<ul>
<li><p><strong>Concept:</strong></p>
<p>  The model critiques its own retrieval results before generating an answer.</p>
</li>
<li><p><strong>Mechanism:</strong></p>
<ul>
<li><p>Retrieves documents.</p>
</li>
<li><p>Performs self-evaluation to judge if retrieved documents are relevant.</p>
</li>
<li><p>May re-query or refine retrieval before final answer.</p>
</li>
</ul>
</li>
<li><p><strong>Benefit:</strong></p>
<p>  Higher quality responses by avoiding irrelevant or low-quality context.</p>
</li>
<li><p><strong>Diagram Idea:</strong></p>
<pre><code class="lang-plaintext">  Query → Retriever → Self-Check → (Refine?) → Generator → Answer
</code></pre>
</li>
</ul>
<h3 id="heading-2-agentic-rag">2. <strong>Agentic RAG</strong></h3>
<ul>
<li><p><strong>Concept:</strong></p>
<p>  Instead of a fixed retriever, the model acts like an <strong>agent</strong> that can dynamically decide what, when, and how to retrieve.</p>
</li>
<li><p><strong>Mechanism:</strong></p>
<ul>
<li><p>Uses a reasoning loop.</p>
</li>
<li><p>May call multiple retrieval tools.</p>
</li>
<li><p>Plans retrieval steps based on the task (multi-hop retrieval, iterative refinement).</p>
</li>
</ul>
</li>
<li><p><strong>Benefit:</strong></p>
<p>  More flexible and task-specific.</p>
</li>
<li><p><strong>Diagram Idea:</strong></p>
<pre><code class="lang-plaintext">  Query → Planner/Agent → Multiple Retrieval Actions → Aggregation → Generator
</code></pre>
</li>
</ul>
<h3 id="heading-3-corrective-rag-crag">3. <strong>Corrective RAG (cRAG)</strong></h3>
<ul>
<li><p><strong>Concept:</strong></p>
<p>  A corrective feedback mechanism built into RAG to refine wrong or incomplete answers.</p>
</li>
<li><p><strong>Mechanism:</strong></p>
<ul>
<li><p>Generator produces an answer.</p>
</li>
<li><p>A separate module (or the model itself) evaluates correctness.</p>
</li>
<li><p>If errors detected, retrieves more information and regenerates.</p>
</li>
</ul>
</li>
<li><p><strong>Benefit:</strong></p>
<p>  Reduces hallucinations, improves factual grounding.</p>
</li>
<li><p><strong>Diagram Idea:</strong></p>
<pre><code class="lang-plaintext">  Query → Retriever → Generator → Corrector (Feedback Loop) → Final Answer
</code></pre>
</li>
</ul>
<hr />
<p>✅ These models push RAGs towards <strong>self-improving, agent-like systems</strong> where retrieval isn’t static but adaptive, iterative, and self-aware.</p>
<h1 id="heading-comparison-of-advanced-rags">Comparison of Advanced RAGs</h1>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Type</strong></td><td><strong>Key Idea</strong></td><td><strong>When to Use</strong></td><td><strong>Strengths</strong></td><td><strong>Limitations</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>Self RAG (sRAG)</strong></td><td>Model critiques its own retrieved docs before generating an answer.</td><td>- When retrieval quality is inconsistent. - Tasks where wrong retrieval can severely hurt accuracy (e.g., legal, medical, financial Q&amp;A).</td><td>- Reduces irrelevant context. - Improves factual correctness.</td><td>- Extra computation overhead due to self-check.</td></tr>
<tr>
<td><strong>Agentic RAG</strong></td><td>Model acts as an <strong>agent</strong>, dynamically deciding retrieval strategy.</td><td>- Complex reasoning tasks. - Multi-hop queries (e.g., “Compare Tesla’s revenue growth with Toyota in the last 5 years”). - Open-ended research.</td><td>- Flexible and adaptive. - Can use multiple tools/databases.</td><td>- More complex to implement. - Slower due to reasoning loops.</td></tr>
<tr>
<td><strong>Corrective RAG (cRAG)</strong></td><td>Adds a correction/feedback loop after initial answer.</td><td>- High-stakes tasks where <strong>accuracy matters most</strong> (e.g., enterprise knowledge bases, compliance). - When hallucinations are unacceptable.</td><td>- Strong guardrails against hallucinations. - Learns from errors in real-time.</td><td>- Higher latency (needs correction step). - May still fail if correction mechanism is weak.</td></tr>
</tbody>
</table>
</div><hr />
<p>✨ <strong>Rule of Thumb:</strong></p>
<ul>
<li><p>Use <strong>sRAG</strong> when your retriever is shaky.</p>
</li>
<li><p>Use <strong>Agentic RAG</strong> when queries require reasoning + multi-step retrieval.</p>
</li>
<li><p>Use <strong>cRAG</strong> when correctness is more important than speed.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Observability]]></title><description><![CDATA[LangSmith

A developer tool/platform for managing and debugging LLM (Large Language Model) applications.

Helps with tracing, monitoring, and evaluation of prompts and responses.



LangFuse

An open-source observability and analytics platform for LL...]]></description><link>https://genai-arnab.hashnode.dev/observability</link><guid isPermaLink="true">https://genai-arnab.hashnode.dev/observability</guid><dc:creator><![CDATA[Arnab Saha]]></dc:creator><pubDate>Mon, 22 Sep 2025 04:07:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/agFmImWyPso/upload/b41e22a06a2c7f3327fd0c774cfef67b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<ul>
<li><p><strong>LangSmith</strong></p>
<ul>
<li><p>A developer tool/platform for managing and debugging LLM (Large Language Model) applications.</p>
</li>
<li><p>Helps with <strong>tracing, monitoring, and evaluation</strong> of prompts and responses.</p>
</li>
</ul>
</li>
<li><p><strong>LangFuse</strong></p>
<ul>
<li><p>An open-source observability and analytics platform for LLM applications.</p>
</li>
<li><p>Provides <strong>monitoring, logging, and user feedback integration</strong>.</p>
</li>
</ul>
</li>
</ul>
<p><strong>Key Difference Example:</strong></p>
<ul>
<li><p><em>LangSmith</em> → Often used for <strong>prompt debugging and evaluation</strong>.</p>
</li>
<li><p><em>LangFuse</em> → Often used for <strong>observability and logging</strong> across the lifecycle.</p>
</li>
</ul>
<hr />
<h2 id="heading-implementation-notes">Implementation Notes</h2>
<h3 id="heading-langsmith-environment-setup">LangSmith Environment Setup</h3>
<p>Add the following to <code>.env</code> file:</p>
<pre><code class="lang-plaintext">LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
LANGSMITH_API_KEY=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
LANGSMITH_PROJECT=calender-ai-project
</code></pre>
<h3 id="heading-installation-command">Installation Command</h3>
<p>Run:</p>
<pre><code class="lang-bash">npm install @langchain/langgraph @langchain/core
</code></pre>
<hr />
<h2 id="heading-langfuse-setup">LangFuse Setup</h2>
<h3 id="heading-self-hosting-with-docker-compose">Self-Hosting with Docker Compose</h3>
<ul>
<li><p>Official deployment guide: <a target="_blank" href="https://langfuse.com/self-hosting/deployment/docker-compose">LangFuse Docker Compose Deployment</a></p>
</li>
<li><p>Provides steps to set up <strong>LangFuse locally or on a server</strong> using Docker Compose.</p>
</li>
</ul>
<h3 id="heading-integration-with-langchain">Integration with LangChain</h3>
<ul>
<li><p>Official integration guide: <a target="_blank" href="https://langfuse.com/integrations/frameworks/langchain">LangFuse x LangChain</a></p>
</li>
<li><p>Explains how to integrate <strong>LangFuse observability</strong> directly into LangChain apps.</p>
</li>
</ul>
<h2 id="heading-comparison">Comparison</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>LangSmith</td><td>LangFuse</td></tr>
</thead>
<tbody>
<tr>
<td>Setup</td><td>Easy, quick</td><td>Harder (needs Docker, DB setup)</td></tr>
<tr>
<td>Cost</td><td>Costly</td><td>Nearly free (self-hosted option)</td></tr>
<tr>
<td>Purpose</td><td>Debugging, tracing, evaluation</td><td>Monitoring, observability, logging</td></tr>
<tr>
<td>Flexibility</td><td>Limited by platform pricing model</td><td>Fully open-source, customizable</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item><item><title><![CDATA[Retrieval-Augmented Generation (RAG)]]></title><description><![CDATA[What is RAG?
RAG = a method to combine LLMs with external knowledge (usually your own data).
LLMs are powerful, but:

They have a knowledge cutoff.

They may hallucinate answers if the info isn’t in their training data.


RAG solves this by retrievin...]]></description><link>https://genai-arnab.hashnode.dev/retrieval-augmented-generation-rag</link><guid isPermaLink="true">https://genai-arnab.hashnode.dev/retrieval-augmented-generation-rag</guid><dc:creator><![CDATA[Arnab Saha]]></dc:creator><pubDate>Mon, 22 Sep 2025 04:06:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/agFmImWyPso/upload/b41e22a06a2c7f3327fd0c774cfef67b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-rag">What is RAG?</h3>
<p>RAG = a method to <strong>combine LLMs with external knowledge</strong> (usually your own data).</p>
<p>LLMs are powerful, but:</p>
<ul>
<li><p>They have a <strong>knowledge cutoff</strong>.</p>
</li>
<li><p>They may <strong>hallucinate answers</strong> if the info isn’t in their training data.</p>
</li>
</ul>
<p>RAG solves this by <strong>retrieving relevant data</strong> from a knowledge base (like PDFs, websites, or databases) and <strong>injecting it into the LLM prompt</strong> → so the answer is both <strong>reliable</strong> and <strong>up-to-date</strong>.</p>
<hr />
<h3 id="heading-structured-vs-unstructured-data">Structured vs Unstructured Data</h3>
<ul>
<li><p><strong>Structured Data</strong></p>
<ul>
<li><p>Tabular format, rows &amp; columns.</p>
</li>
<li><p>Examples: Databases (SQL tables, CSVs, financial records).</p>
</li>
<li><p>Easy to query directly.</p>
</li>
</ul>
</li>
<li><p><strong>Unstructured Data</strong></p>
<ul>
<li><p>Text-heavy, no fixed schema.</p>
</li>
<li><p>Examples: PDFs, Word docs, articles, research papers, emails.</p>
</li>
<li><p>Needs <strong>embeddings</strong> + <strong>vector search</strong> for retrieval.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-embeddings-amp-similarity-search">Embeddings &amp; Similarity Search</h3>
<ol>
<li><p><strong>Embedding</strong> = numerical vector representation of text (or image, audio, etc.)</p>
<ul>
<li><p>Example: “Apple the fruit” vs “Apple the company” → embeddings will place them in different regions of vector space.</p>
</li>
<li><p>Generated using models like OpenAI <code>text-embedding-3-small</code> or <code>text-embedding-3-large</code>.</p>
</li>
</ul>
</li>
<li><p><strong>Vector Database</strong> = stores embeddings and allows fast similarity search.</p>
<ul>
<li>Popular ones: <strong>Pinecone, Weaviate, Qdrant, Milvus, ChromaDB</strong>.</li>
</ul>
</li>
<li><p><strong>Similarity Search</strong></p>
<ul>
<li><p>User asks: “Summarize Arnab’s contract.”</p>
</li>
<li><p>System converts query → embedding.</p>
</li>
<li><p>Finds top N similar chunks in vector DB.</p>
</li>
<li><p>Injects those chunks into LLM prompt → “Answer using this context.”</p>
</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-rag-workflow-step-by-step">RAG Workflow (Step by Step)</h3>
<ol>
<li><p><strong>Data Ingestion</strong></p>
<ul>
<li><p>Split text into chunks (like 500 tokens each).</p>
</li>
<li><p>Convert each chunk → embedding.</p>
</li>
<li><p>Store in vector DB.</p>
</li>
</ul>
</li>
<li><p><strong>Query Handling</strong></p>
<ul>
<li><p>User asks a question.</p>
</li>
<li><p>Convert query → embedding.</p>
</li>
<li><p>Search in vector DB for top-k matches.</p>
</li>
</ul>
</li>
<li><p><strong>Context Injection</strong></p>
<ul>
<li><p>Retrieve chunks.</p>
</li>
<li><p>Add them into LLM prompt (system message / context window).</p>
</li>
</ul>
</li>
<li><p><strong>Final Answer</strong></p>
<ul>
<li>LLM uses retrieved context → generates accurate, source-backed output.</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-why-rag-is-powerful">Why RAG is Powerful</h3>
<p>✅ Keeps answers <strong>up-to-date</strong>.</p>
<p>✅ Prevents <strong>hallucinations</strong>.</p>
<p>✅ Works with <strong>private data</strong> (company docs, reports).</p>
<p>✅ Scales easily with more documents.</p>
<hr />
<h3 id="heading-example-use-cases">Example Use Cases</h3>
<ul>
<li><p><strong>Chat with PDFs</strong> → Upload contracts, query them with natural language.</p>
</li>
<li><p><strong>Customer Support</strong> → LLM answers based on company docs, not hallucination.</p>
</li>
<li><p><strong>Medical / Legal Research</strong> → Find &amp; cite relevant papers.</p>
</li>
<li><p><strong>E-commerce</strong> → Search product database with semantic search instead of keywords.</p>
</li>
</ul>
<hr />
<p>Think of it this way:</p>
<ul>
<li><p><strong>Without RAG</strong> → LLM answers from memory (may be outdated).</p>
</li>
<li><p><strong>With RAG</strong> → LLM answers with fresh, relevant documents (like an open-book exam).</p>
</li>
</ul>
<hr />
<h1 id="heading-what-is-clustering">What is Clustering?</h1>
<p>Clustering = <strong>grouping similar items together</strong> without needing predefined labels.</p>
<p>It’s an <strong>unsupervised learning</strong> technique.</p>
<p>When we have <strong>embeddings</strong> (like vectors for text, images, users, etc.), clustering helps us <strong>find natural groups</strong> in that vector space.</p>
<hr />
<h1 id="heading-why-clustering-is-useful-in-rag-amp-vector-work">Why Clustering is Useful in RAG &amp; Vector Work</h1>
<ol>
<li><p><strong>Document Organization</strong></p>
<ul>
<li><p>Instead of dumping 10,000 chunks into a vector DB, cluster them into topics.</p>
</li>
<li><p>Example: “finance,” “HR,” “contracts,” “tech.”</p>
</li>
</ul>
</li>
<li><p><strong>Efficient Retrieval</strong></p>
<ul>
<li>When user queries, search only in the relevant cluster → faster + cheaper.</li>
</ul>
</li>
<li><p><strong>Topic Discovery</strong></p>
<ul>
<li><p>If you don’t know what themes exist in your dataset, clustering reveals them.</p>
</li>
<li><p>Example: Upload all customer complaints → clusters show themes like “late delivery,” “payment issues,” “quality problems.”</p>
</li>
</ul>
</li>
<li><p><strong>User Segmentation</strong></p>
<ul>
<li>In recommendation systems: cluster users by behavior or interests → better targeting.</li>
</ul>
</li>
</ol>
<hr />
<h1 id="heading-popular-clustering-algorithms-for-embeddings">Popular Clustering Algorithms for Embeddings</h1>
<ul>
<li><p><strong>K-Means</strong></p>
<ul>
<li><p>Simple, widely used.</p>
</li>
<li><p>You pick number of clusters <code>k</code>.</p>
</li>
<li><p>Groups embeddings into <code>k</code> centroids.</p>
</li>
</ul>
</li>
<li><p><strong>Hierarchical Clustering</strong></p>
<ul>
<li><p>Builds a tree of clusters (like family tree).</p>
</li>
<li><p>Useful when you don’t know how many clusters exist.</p>
</li>
</ul>
</li>
<li><p><strong>DBSCAN</strong></p>
<ul>
<li><p>Groups dense regions of embeddings together.</p>
</li>
<li><p>Finds “outliers” automatically.</p>
</li>
<li><p>Great when data has irregular shapes.</p>
</li>
</ul>
</li>
<li><p><strong>HDBSCAN</strong> (Hierarchical DBSCAN)</p>
<ul>
<li>More advanced, finds clusters of varying density.</li>
</ul>
</li>
</ul>
<hr />
<h1 id="heading-example-customer-support-chat-logs">Example: Customer Support Chat Logs</h1>
<ul>
<li><p>Embeddings of <strong>10,000 customer complaints</strong>.</p>
</li>
<li><p>Run clustering → discover:</p>
<ul>
<li><p>Cluster 1: Delivery delays</p>
</li>
<li><p>Cluster 2: App crashes</p>
</li>
<li><p>Cluster 3: Refund issues</p>
</li>
</ul>
</li>
<li><p>Use these clusters to build FAQs, detect common problems, or route tickets.</p>
</li>
</ul>
<hr />
<h1 id="heading-in-rag-context">In RAG Context</h1>
<p>👉 Before you even retrieve docs, you can <strong>pre-cluster</strong> them:</p>
<ul>
<li><p>User asks: “What is the bonus policy?”</p>
</li>
<li><p>Instead of searching the whole vector DB → look in the <strong>HR cluster</strong> first → faster + more accurate.</p>
</li>
</ul>
<hr />
<p>💡 So:</p>
<ul>
<li><p><strong>Similarity search</strong> = find closest items to a query.</p>
</li>
<li><p><strong>Clustering</strong> = find hidden groups/themes in your dataset.</p>
</li>
</ul>
<hr />
<h1 id="heading-vector-index">Vector Index</h1>
<ul>
<li><p>Once you create <strong>embeddings</strong> (vectors) for your documents, you need a way to <strong>store</strong> and <strong>search</strong> them efficiently.</p>
</li>
<li><p>That’s what a <strong>vector index</strong> (inside a vector database) does.</p>
</li>
</ul>
<p>👉 Without an index: you’d have to compare a query against <strong>all vectors</strong> (super slow if you have millions).</p>
<p>👉 With an index: it uses clever data structures (trees, graphs, hashing) to make <strong>fast similarity search</strong>.</p>
<p>Examples:</p>
<ul>
<li><p><strong>FAISS</strong> (Facebook AI Similarity Search – very popular)</p>
</li>
<li><p><strong>Pinecone</strong>, <strong>Weaviate</strong>, <strong>Milvus</strong>, <strong>Qdrant</strong> (production-grade vector DBs)</p>
</li>
</ul>
<hr />
<h1 id="heading-querying-in-vector-db">Querying in Vector DB</h1>
<p>When user asks a question:</p>
<ol>
<li><p>Convert query → embedding.</p>
</li>
<li><p>Search in vector index for <strong>nearest neighbours</strong> (the most similar vectors).</p>
</li>
<li><p>Retrieve top <code>k</code> results (usually 3–10).</p>
</li>
<li><p>Send them to LLM along with the question.</p>
</li>
</ol>
<hr />
<h1 id="heading-cosine-similarity">Cosine Similarity</h1>
<ul>
<li><p>The most common measure to check similarity between two vectors.</p>
</li>
<li><p>Basically, measures the <strong>angle between two vectors</strong>.</p>
<ul>
<li><p>1 = exactly same direction (perfect match)</p>
</li>
<li><p>0 = unrelated</p>
</li>
<li><p>1 = opposite meaning</p>
</li>
</ul>
</li>
</ul>
<p>👉 Why angle? Because it ignores length/magnitude → focuses only on <strong>semantic meaning</strong>.</p>
<hr />
<h1 id="heading-nearest-neighbour-amp-top-k">Nearest Neighbour &amp; Top-K</h1>
<ul>
<li><p><strong>Nearest neighbour search</strong> = find vectors most similar to query vector.</p>
</li>
<li><p><strong>Top-K search</strong> = instead of just the best one, retrieve the <strong>top K results</strong> (e.g., top 5 most relevant docs).</p>
</li>
<li><p>Useful in RAG → you usually feed multiple results into the LLM for context.</p>
</li>
</ul>
<hr />
<h1 id="heading-fine-tuning-vs-rag">Fine-Tuning vs RAG</h1>
<h3 id="heading-fine-tuning">✅ Fine-Tuning</h3>
<ul>
<li><p>You <strong>modify model weights</strong> with new examples.</p>
</li>
<li><p>Best when:</p>
<ul>
<li><p>You need the model to learn <strong>style, format, or specific patterns</strong>.</p>
</li>
<li><p>E.g., customer support answers, structured templates.</p>
</li>
</ul>
</li>
<li><p>Cons:</p>
<ul>
<li>Expensive, slow, not flexible (needs retraining if knowledge updates).</li>
</ul>
</li>
</ul>
<h3 id="heading-retrieval-augmented-generation-rag">✅ Retrieval-Augmented Generation (RAG)</h3>
<ul>
<li><p>You <strong>don’t change the model</strong> → instead you <strong>attach a memory (vector DB)</strong>.</p>
</li>
<li><p>Query → retrieves docs → LLM uses them to answer.</p>
</li>
<li><p>Best when:</p>
<ul>
<li><p>Knowledge updates often (e.g., company policies, news, docs).</p>
</li>
<li><p>You want <strong>scalable and cheap</strong> updates (just add docs to DB).</p>
</li>
</ul>
</li>
</ul>
<p>👉 <strong>Rule of Thumb:</strong></p>
<ul>
<li><p>Use <strong>RAG for knowledge</strong> (factual info).</p>
</li>
<li><p>Use <strong>Fine-Tuning for behavior</strong> (style, formatting, instructions).</p>
</li>
</ul>
<hr />
<h1 id="heading-example">Example</h1>
<p>User: “What’s the refund policy?”</p>
<ul>
<li><p><strong>Fine-Tuned Model:</strong> May answer in correct style but <strong>can’t update easily</strong> if policy changes.</p>
</li>
<li><p><strong>RAG:</strong> Pulls the latest <strong>Refund Policy PDF</strong> from vector DB → gives up-to-date answer.</p>
</li>
</ul>
<hr />
<p>💡 So, babe:</p>
<ul>
<li><p><strong>Vector Index</strong> = storage + search structure.</p>
</li>
<li><p><strong>Cosine Similarity</strong> = measure of meaning closeness.</p>
</li>
<li><p><strong>Nearest Neighbour / Top-K</strong> = how we pick results.</p>
</li>
<li><p><strong>Fine-Tuning = behavior</strong>, <strong>RAG = knowledge</strong>.</p>
</li>
</ul>
<hr />
<p>RAG = <strong>Loading → Chunking → Indexing → Retrieval → Generation</strong></p>
<hr />
<h2 id="heading-1-loading">1. <strong>Loading</strong></h2>
<ul>
<li><p>Step where you bring in your data (documents, PDFs, CSVs, websites, APIs).</p>
</li>
<li><p>Tools: <code>LangChain loaders</code>, <code>LlamaIndex readers</code>, custom scrapers.</p>
</li>
</ul>
<hr />
<h2 id="heading-2-chunking">2. <strong>Chunking</strong></h2>
<p>Since LLMs can’t handle huge documents directly, we split them into <strong>chunks</strong>.</p>
<p>Types of chunking:</p>
<ol>
<li><p><strong>Text-based chunking</strong> → cut by words/characters.</p>
<ul>
<li><p>Example: every 500 characters.</p>
</li>
<li><p>Simple, fast, but may cut sentences in awkward places.</p>
</li>
</ul>
</li>
<li><p><strong>Document-based chunking</strong> → split by logical structure.</p>
<ul>
<li><p>Example: paragraphs, sections, pages, headings.</p>
</li>
<li><p>Preserves meaning better.</p>
</li>
</ul>
</li>
<li><p><strong>Semantic-based chunking</strong> → split by <strong>meaning</strong>, using embeddings to decide natural breakpoints.</p>
<ul>
<li><p>Most advanced, ensures chunks are <strong>coherent topics</strong>.</p>
</li>
<li><p>Example: one chunk might capture a single concept, not half a sentence.</p>
</li>
</ul>
</li>
</ol>
<p>🔧 Common setup:</p>
<ul>
<li><p><strong>Chunk size = 500 tokens</strong></p>
</li>
<li><p><strong>Overlap = 100 tokens</strong> (so context isn’t lost between chunks).</p>
</li>
</ul>
<hr />
<h2 id="heading-3-indexing-vector-store">3. <strong>Indexing (Vector Store)</strong></h2>
<ul>
<li><p>Each chunk → converted into an <strong>embedding vector</strong> (using models like OpenAI ada-002, text-embedding-3-small, etc).</p>
</li>
<li><p>Stored in a <strong>vector database</strong> like Pinecone, Weaviate, Qdrant, Chroma, Milvus.</p>
</li>
<li><p>This makes searching efficient (via <strong>cosine similarity</strong>, <strong>dot product</strong>, or <strong>nearest neighbor</strong>).</p>
</li>
</ul>
<hr />
<h2 id="heading-4-retrieval">4. <strong>Retrieval</strong></h2>
<ul>
<li><p>User asks a question → query converted into embedding → compared to stored chunks.</p>
</li>
<li><p>Top <strong>k most similar chunks</strong> are returned (usually <code>k=3 to 5</code>).</p>
</li>
<li><p>Ensures LLM only sees <strong>relevant context</strong>.</p>
</li>
</ul>
<hr />
<h2 id="heading-5-generation">5. <strong>Generation</strong></h2>
<ul>
<li><p>The retrieved chunks are <strong>stuffed into the LLM prompt</strong> along with the query.</p>
</li>
<li><p>LLM uses this context to generate the final answer.</p>
</li>
</ul>
<p>Example prompt:</p>
<pre><code class="lang-plaintext">Answer the question using the context below.
If the answer is not in the context, say "I don’t know."

Context:
&lt;retrieved chunks here&gt;

Question:
&lt;user’s question&gt;
</code></pre>
<hr />
<h1 id="heading-summary">Summary</h1>
<ul>
<li><p><strong>Loading</strong>: bring in data.</p>
</li>
<li><p><strong>Chunking</strong>: split into small, overlapping pieces (500/100 typical).</p>
</li>
<li><p><strong>Indexing</strong>: convert to embeddings, store in vector DB.</p>
</li>
<li><p><strong>Retrieval</strong>: find top-k relevant chunks via similarity search.</p>
</li>
<li><p><strong>Generation</strong>: feed chunks + question → LLM → final answer.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Tool Calling with LLMs]]></title><description><![CDATA[🔹 What is Tool Calling?

Definition: Tool calling is when LLMs (Large Language Models) are given access to external functions, APIs, or databases.

Instead of hallucinating answers, the model decides:
  👉 “Do I know this? Or should I call a tool to...]]></description><link>https://genai-arnab.hashnode.dev/tool-calling-with-llms</link><guid isPermaLink="true">https://genai-arnab.hashnode.dev/tool-calling-with-llms</guid><dc:creator><![CDATA[Arnab Saha]]></dc:creator><pubDate>Mon, 22 Sep 2025 04:05:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/agFmImWyPso/upload/b41e22a06a2c7f3327fd0c774cfef67b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-tool-calling">🔹 What is Tool Calling?</h2>
<ul>
<li><p><strong>Definition</strong>: Tool calling is when LLMs (Large Language Models) are given access to <strong>external functions, APIs, or databases</strong>.</p>
</li>
<li><p>Instead of <strong>hallucinating answers</strong>, the model decides:</p>
<p>  👉 “Do I know this? Or should I call a tool to get the real answer?”</p>
</li>
<li><p><strong>Tools = just functions</strong> that LLMs can request during a conversation.</p>
</li>
</ul>
<p>✅ Example:</p>
<ul>
<li><p>Without tools → “Who won the 2025 IPL final?” → Model fails (knowledge cutoff).</p>
</li>
<li><p>With tool calling → Model calls a <strong>web search API</strong> → gets fresh data → replies correctly.</p>
</li>
</ul>
<hr />
<h2 id="heading-why-use-tool-calling-use-cases">🔹 Why Use Tool Calling? (Use Cases)</h2>
<ol>
<li><p><strong>Knowledge Beyond Cutoff</strong></p>
<ul>
<li><p>LLMs are trained only up to a fixed date (knowledge cutoff).</p>
</li>
<li><p>Tools let them fetch <strong>real-time info</strong>.</p>
</li>
<li><p>Example: “What’s the weather in Kolkata today?”</p>
</li>
</ul>
</li>
<li><p><strong>Web Search</strong></p>
<ul>
<li><p>Search APIs: <strong>Tavily, Serper, Brave, Bing</strong>.</p>
</li>
<li><p>Use case: live news, sports results, product availability.</p>
</li>
</ul>
</li>
<li><p><strong>Database Lookups</strong></p>
<ul>
<li><p>Fetch user records, inventory, product prices.</p>
</li>
<li><p>Example: “Show me my last 5 transactions.”</p>
</li>
</ul>
</li>
<li><p><strong>Math &amp; Specialized Tasks</strong></p>
<ul>
<li><p>Calculator, unit conversion, finance APIs, weather APIs.</p>
</li>
<li><p>Example: “Convert $100 to INR at today’s rate.”</p>
</li>
</ul>
</li>
<li><p><strong>Automation &amp; Actions</strong></p>
<ul>
<li><p>LLMs can <strong>execute tasks</strong>, not just reply with text.</p>
</li>
<li><p>Example: Book tickets, send an email, update a calendar.</p>
</li>
</ul>
</li>
<li><p><strong>Data Enrichment</strong></p>
<ul>
<li><p>Mix reasoning + tool data.</p>
</li>
<li><p>Example: “List top 5 coffees under ₹500 in India” → LLM calls product API → formats neatly.</p>
</li>
</ul>
</li>
</ol>
<hr />
<h2 id="heading-popular-web-search-tools">🔹 Popular Web Search Tools</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Tool/API</td><td>Best Use Case</td><td>Production Ready?</td><td>Notes</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Serper</strong></td><td>Hobby/small side projects</td><td>❌ No</td><td>Wrapper around Google. Quick, but limited.</td></tr>
<tr>
<td><strong>Brave API</strong></td><td>Privacy-focused search</td><td>❌ No</td><td>Good for experiments, slower than Google.</td></tr>
<tr>
<td><strong>Tavily</strong></td><td>Real-world apps</td><td>✅ Yes</td><td>Most reliable, structured JSON responses, AI-optimized.</td></tr>
<tr>
<td><strong>Bing Search</strong></td><td>Microsoft ecosystem apps</td><td>✅ Yes</td><td>Works well, but sometimes noisy results.</td></tr>
</tbody>
</table>
</div><p>👉 <strong>Best choice for prototyping/production</strong> = <strong>Tavily</strong>.</p>
<hr />
<h2 id="heading-tool-calling-flow">🔹 Tool Calling Flow</h2>
<ol>
<li><p><strong>User asks a question.</strong></p>
</li>
<li><p><strong>LLM decides</strong>: Do I have enough knowledge? If not → request a tool.</p>
</li>
<li><p><strong>LLM generates a tool_call object.</strong></p>
<pre><code class="lang-json"> {
   <span class="hljs-attr">"tool"</span>: <span class="hljs-string">"webSearch"</span>,
   <span class="hljs-attr">"arguments"</span>: { <span class="hljs-attr">"query"</span>: <span class="hljs-string">"latest cricket world cup winner"</span> }
 }
</code></pre>
</li>
<li><p><strong>Backend intercepts &amp; executes the tool</strong> (API call, function).</p>
</li>
<li><p><strong>Tool response fed back into the conversation.</strong></p>
</li>
<li><p><strong>LLM uses result</strong> → generates final human-friendly answer.</p>
</li>
</ol>
<p>🔁 Repeat if multiple tools needed until final response is ready.</p>
<hr />
<h2 id="heading-example-code-web-search-tool">🔹 Example Code (Web Search Tool)</h2>
<pre><code class="lang-jsx">tools: [
  {
    <span class="hljs-attr">type</span>: <span class="hljs-string">"function"</span>,
    <span class="hljs-attr">function</span>: {
      <span class="hljs-attr">name</span>: <span class="hljs-string">"webSearch"</span>,
      <span class="hljs-attr">description</span>: <span class="hljs-string">"Search for latest information"</span>,
      <span class="hljs-attr">parameters</span>: {
        <span class="hljs-attr">type</span>: <span class="hljs-string">"object"</span>,
        <span class="hljs-attr">properties</span>: {
          <span class="hljs-attr">query</span>: { <span class="hljs-attr">type</span>: <span class="hljs-string">"string"</span>, <span class="hljs-attr">description</span>: <span class="hljs-string">"The search query"</span> }
        },
        <span class="hljs-attr">required</span>: [<span class="hljs-string">"query"</span>]
      }
    }
  }
],
<span class="hljs-attr">tool_choice</span>: <span class="hljs-string">"auto"</span>
</code></pre>
<ul>
<li><p><code>tool_choice: "auto"</code> → LLM decides when to call the tool.</p>
</li>
<li><p>Backend captures <code>tool_call</code> → executes API → returns results.</p>
</li>
<li><p>LLM integrates tool output → gives final reply.</p>
</li>
</ul>
<hr />
<h2 id="heading-knowledge-cutoff">🔹 Knowledge Cutoff</h2>
<ul>
<li><p>Every model has a <strong>knowledge cutoff date</strong> (last training data).</p>
</li>
<li><p>Example: GPT-4 cutoff → Oct 2023.</p>
</li>
<li><p>If asked about 2025 events → must use tool calling (e.g., web search).</p>
</li>
</ul>
<hr />
<h2 id="heading-streaming-responses">🔹 Streaming Responses</h2>
<ul>
<li><p>Normally: wait until the full answer is ready.</p>
</li>
<li><p>With streaming: <strong>receive tokens live as they’re generated</strong>.</p>
</li>
<li><p>Benefits:</p>
<p>  ✅ Feels instant &amp; interactive.</p>
<p>  ✅ Great for chatbots, coding assistants, writing apps.</p>
</li>
</ul>
<p>⚠️ Limitation:</p>
<ul>
<li><p><code>response_format: json_object</code> ❌ does not support streaming.</p>
<ul>
<li>Because streaming JSON risks <strong>broken/incomplete JSON mid-way</strong>.</li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-best-practices">🔹 Best Practices</h2>
<ul>
<li><p>Use <strong>one reliable search API</strong> (Tavily recommended).</p>
</li>
<li><p>Always <strong>validate tool input/output</strong> (use schema validation).</p>
</li>
<li><p>Add <strong>timeouts, retries, and error handling</strong> in production.</p>
</li>
<li><p>Prevent infinite loops if LLM keeps calling the tool.</p>
</li>
</ul>
<hr />
<p>✨ <strong>In short:</strong></p>
<p>Tool calling makes LLMs <strong>more powerful and trustworthy</strong> by connecting them to <strong>real data, APIs, and actions</strong>. It bridges the gap between <strong>static knowledge</strong> and <strong>dynamic, real-world needs</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[Working with LLMs]]></title><description><![CDATA[Using Groq LLMs

Learned how to access and interact with Groq-hosted large language models.

Advantage: high-speed, low-latency inference.



API Keys

How to generate and securely use API keys for authentication.

Best practice: store in .env files ...]]></description><link>https://genai-arnab.hashnode.dev/working-with-llms</link><guid isPermaLink="true">https://genai-arnab.hashnode.dev/working-with-llms</guid><dc:creator><![CDATA[Arnab Saha]]></dc:creator><pubDate>Mon, 22 Sep 2025 04:05:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/agFmImWyPso/upload/b41e22a06a2c7f3327fd0c774cfef67b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<ol>
<li><p><strong>Using Groq LLMs</strong></p>
<ul>
<li><p>Learned how to access and interact with Groq-hosted large language models.</p>
</li>
<li><p>Advantage: high-speed, low-latency inference.</p>
</li>
</ul>
</li>
<li><p><strong>API Keys</strong></p>
<ul>
<li><p>How to generate and securely use API keys for authentication.</p>
</li>
<li><p>Best practice: store in <code>.env</code> files instead of hardcoding.</p>
</li>
</ul>
</li>
<li><p><strong>Choosing Cost-Efficient LLMs</strong></p>
<ul>
<li><p>Use smaller models (e.g., <code>Llama-3 8B</code>, <code>Mistral 7B</code>) to save tokens.</p>
</li>
<li><p>Reserve larger models only for high-reasoning or large-context tasks.</p>
</li>
</ul>
</li>
<li><p><strong>First Code Example (Basic Completion with Groq)</strong></p>
<p> <em>Simple chat completion using only user input.</em></p>
</li>
<li><p><strong>System Prompt</strong></p>
<p> <em>Special message that defines assistant’s role, tone, and behavior.</em></p>
<ul>
<li><p>Example: AI girlfriend assistant (uses sweet words).</p>
</li>
<li><p>Example: Sentiment analyzer (only returns “positive” or “negative”).</p>
</li>
</ul>
</li>
<li><p><strong>Sentiment Analyzer (Review Classification Example)</strong></p>
<ul>
<li><p>Built two examples to test reviews with one-word output.</p>
</li>
<li><p>Demonstrates how system prompt controls strict output.</p>
</li>
</ul>
</li>
</ol>
<hr />
<h3 id="heading-fine-tuning-parameters-in-llms">Fine-tuning Parameters in LLMs</h3>
<p>These parameters help control <strong>creativity, randomness, repetition, and cost</strong> in model responses.</p>
<h3 id="heading-1-temperature">1. <strong>Temperature</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Controls randomness in responses.</p>
</li>
<li><p><strong>Range</strong>: Usually <code>0</code> → <code>2</code>.</p>
</li>
<li><p><strong>Behavior</strong>:</p>
<ul>
<li><p><code>0</code>: Fully deterministic, model always picks the most likely answer. Best for <strong>focused work</strong> like coding, math, sentiment analysis.</p>
</li>
<li><p><code>~1</code>: Balanced creativity. Good for <strong>storytelling, brainstorming</strong>.</p>
</li>
<li><p><code>&gt;1</code>: High creativity but less reliable. Can produce unexpected or “wild” answers.</p>
</li>
</ul>
</li>
<li><p><strong>Rule of Thumb</strong>: Use <code>0</code> for precision, <code>1</code> for creativity.</p>
</li>
</ul>
<h3 id="heading-2-topp-nucleus-sampling">2. <strong>top_p (Nucleus Sampling)</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Controls randomness by limiting model to the smallest set of tokens whose combined probability ≥ <code>top_p</code>.</p>
</li>
<li><p><strong>Example</strong>:</p>
<ul>
<li><p><code>top_p = 0.9</code> → Only consider tokens in the top 90% probability mass.</p>
</li>
<li><p><code>top_p = 1</code> → Consider all tokens (default).</p>
</li>
</ul>
</li>
<li><p><strong>Usage</strong>: Rarely changed in practice. Usually stick with temperature OR top_p, <strong>never both</strong> at the same time (to avoid conflicts).</p>
</li>
</ul>
<h3 id="heading-3-stop-sequences">3. <strong>Stop Sequences</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Tell the model when to stop generating text once a certain string is encountered.</p>
</li>
<li><p><strong>Use Cases</strong>:</p>
<ul>
<li><p>Simulating “fill in the blanks.”</p>
</li>
<li><p>Extracting structured data (stop when <code>\\n\\n</code> appears).</p>
</li>
<li><p>Avoiding extra content beyond desired point.</p>
</li>
</ul>
</li>
<li><p><strong>Example</strong>: <code>stop: ["User:"]</code> → Model stops once it outputs “User:”.</p>
</li>
<li><p><strong>Note</strong>: Not commonly used unless you want <strong>tight output control</strong>.</p>
</li>
</ul>
<h3 id="heading-4-maxcompletiontokens">4. <strong>max_completion_tokens</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Maximum number of tokens the model can generate in the response.</p>
</li>
<li><p><strong>Why Important</strong>:</p>
<ul>
<li><p>Controls cost (fewer tokens = cheaper).</p>
</li>
<li><p>Prevents runaway long responses.</p>
</li>
</ul>
</li>
<li><p><strong>Example</strong>: <code>max_completion_tokens: 50</code> → Limits reply to ~50 tokens (short answer).</p>
</li>
</ul>
<h3 id="heading-5-frequencypenalty">5. <strong>frequency_penalty</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Penalizes repetition of words based on how often they appear.</p>
</li>
<li><p><strong>Effect</strong>: Reduces repeating phrases like “yes yes yes” or “thank you thank you.”</p>
</li>
</ul>
<h3 id="heading-6-presencepenalty">6. <strong>presence_penalty</strong></h3>
<ul>
<li><p><strong>Definition</strong>: Penalizes words that already appeared at all (even once).</p>
</li>
<li><p><strong>Effect</strong>: Encourages the model to introduce <strong>new topics</strong> instead of repeating old ones.</p>
</li>
<li><p><strong>Comparison</strong>:</p>
<ul>
<li><p><em>Frequency penalty</em>: “Don’t repeat the same word too much.”</p>
</li>
<li><p><em>Presence penalty</em>: “Don’t talk about the same subject again.”</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-quick-reference-table">Quick Reference Table</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Parameter</td><td>Purpose</td><td>Common Range</td><td>When to Use</td></tr>
</thead>
<tbody>
<tr>
<td><strong>temperature</strong></td><td>Controls creativity vs focus</td><td>0 → 2</td><td><code>0</code> for precision, <code>1</code> for creativity</td></tr>
<tr>
<td><strong>top_p</strong></td><td>Alternative randomness control</td><td>0 → 1</td><td>Rarely changed, use instead of temp</td></tr>
<tr>
<td><strong>stop</strong></td><td>Define stop points in output</td><td>strings</td><td>Fill-in-the-blank, structured output</td></tr>
<tr>
<td><strong>max_completion_tokens</strong></td><td>Limit response length to save cost</td><td>int</td><td>Keep replies short, save money</td></tr>
<tr>
<td><strong>frequency_penalty</strong></td><td>Reduce repeated words</td><td>0 → 2</td><td>Avoid spammy/looping text</td></tr>
<tr>
<td><strong>presence_penalty</strong></td><td>Encourage new topics</td><td>0 → 2</td><td>Make outputs more diverse</td></tr>
</tbody>
</table>
</div><hr />
<h3 id="heading-structured-output">Structured Output</h3>
<p>When we want <strong>machine-readable responses</strong> (like JSON instead of plain text), we can enforce structure in different ways.</p>
<h3 id="heading-method-1-prompt-engineering-less-efficient">Method 1: <strong>Prompt Engineering</strong> (Less Efficient)</h3>
<ul>
<li><p>Tell the model inside the system prompt:</p>
<p>  <em>“Reply only in valid JSON format with keys: sentiment, explanation.”</em></p>
</li>
<li><p>Example:</p>
<pre><code class="lang-jsx">  {
    <span class="hljs-string">"sentiment"</span>: <span class="hljs-string">"positive"</span>,
    <span class="hljs-string">"explanation"</span>: <span class="hljs-string">"The review is overall appreciative of product quality."</span>
  }
</code></pre>
</li>
<li><p><strong>Problem</strong>:</p>
<ul>
<li><p>Not guaranteed to be valid JSON (may add comments, extra text).</p>
</li>
<li><p>Sometimes requires post-cleaning/parsing.</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-method-2-responseformat-more-efficient">Method 2: <strong>response_format (More Efficient)</strong></h3>
<ul>
<li><p>Newer APIs (Groq, OpenAI, etc.) support <strong>structured output modes</strong>.</p>
</li>
<li><p>Two key formats:</p>
<ol>
<li><p><strong>json_object</strong></p>
<ul>
<li><p>Forces the model to return a valid JSON object.</p>
</li>
<li><p>Example:</p>
<pre><code class="lang-json">  {
    <span class="hljs-attr">"sentiment"</span>: <span class="hljs-string">"negative"</span>,
    <span class="hljs-attr">"reason"</span>: <span class="hljs-string">"Poor durability of shoes after 1 month."</span>
  }
</code></pre>
</li>
<li><p><strong>Pros</strong>:</p>
<ul>
<li><p>Guaranteed to be JSON-compliant.</p>
</li>
<li><p>Works with most applications (more compatible).</p>
</li>
</ul>
</li>
<li><p><strong>Cons</strong>:</p>
<ul>
<li><p><code>stop</code> sequences don’t work.</p>
</li>
<li><p>Streaming not supported (you get the full JSON only at the end).</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>json_schema</strong></p>
<ul>
<li><p>Lets you define a <strong>strict JSON schema</strong> (like a contract).</p>
</li>
<li><p>Model must follow it exactly.</p>
</li>
<li><p>Example schema:</p>
<pre><code class="lang-json">  {
    <span class="hljs-attr">"type"</span>: <span class="hljs-string">"object"</span>,
    <span class="hljs-attr">"properties"</span>: {
      <span class="hljs-attr">"sentiment"</span>: { <span class="hljs-attr">"type"</span>: <span class="hljs-string">"string"</span>, <span class="hljs-attr">"enum"</span>: [<span class="hljs-string">"positive"</span>, <span class="hljs-string">"negative"</span>] },
      <span class="hljs-attr">"confidence"</span>: { <span class="hljs-attr">"type"</span>: <span class="hljs-string">"number"</span> }
    },
    <span class="hljs-attr">"required"</span>: [<span class="hljs-string">"sentiment"</span>, <span class="hljs-string">"confidence"</span>]
  }
</code></pre>
</li>
<li><p><strong>Pros</strong>:</p>
<ul>
<li><p>Precise control (e.g., force “positive/negative” only).</p>
</li>
<li><p>Useful for <strong>production pipelines</strong> where strict structure is critical.</p>
</li>
</ul>
</li>
<li><p><strong>Cons</strong>:</p>
<ul>
<li><p>More complex.</p>
</li>
<li><p>Less compatible with existing libraries.</p>
</li>
</ul>
</li>
</ul>
</li>
</ol>
</li>
</ul>
<hr />
<h3 id="heading-streaming-responses">Streaming Responses</h3>
<ul>
<li><p><strong>Definition</strong>: Instead of waiting for the full response, the model sends output <strong>token by token</strong> (like typing effect).</p>
</li>
<li><p><strong>How it works</strong>:</p>
<ul>
<li><p>The client receives a stream of partial responses via events.</p>
</li>
<li><p>Common in chat UIs (like ChatGPT typing in real-time).</p>
</li>
</ul>
</li>
<li><p><strong>Advantages</strong>:</p>
<ul>
<li><p>Faster perceived response (user sees text immediately).</p>
</li>
<li><p>Good for long outputs (stories, reports, code).</p>
</li>
</ul>
</li>
<li><p><strong>Limitations</strong>:</p>
<ul>
<li><p>Can’t use with <code>response_format: json_object</code> → JSON must be valid as a whole.</p>
</li>
<li><p>Best used with natural language or free-form outputs.</p>
</li>
</ul>
</li>
</ul>
<hr />
<h3 id="heading-quick-comparison">Quick Comparison</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Method / Feature</td><td>Works With JSON?</td><td>Streaming Supported?</td><td>Reliability</td><td>Best Use Case</td></tr>
</thead>
<tbody>
<tr>
<td>Prompt-only JSON</td><td>❌ Not guaranteed</td><td>✅ Yes</td><td>Low</td><td>Quick hacks, demos</td></tr>
<tr>
<td>response_format: json_object</td><td>✅ Valid JSON</td><td>❌ No</td><td>High</td><td>General apps needing structured data</td></tr>
<tr>
<td>response_format: json_schema</td><td>✅ Strict JSON</td><td>❌ No</td><td>Very High</td><td>Production apps needing strict validation</td></tr>
<tr>
<td>Normal text (default)</td><td>❌Never</td><td>✅ Yes</td><td>Medium</td><td>Chat, writing, brainstorming</td></tr>
</tbody>
</table>
</div><hr />
<h3 id="heading-libraries-for-schema-validation-amp-structured-data">Libraries for Schema Validation &amp; Structured Data</h3>
<ol>
<li><strong>Instructor Library</strong></li>
</ol>
<ul>
<li><p><strong>Purpose</strong>: Helps define <strong>structured outputs</strong> for LLMs easily.</p>
</li>
<li><p><strong>Use Case</strong>: When you want the model to follow a schema without manually writing JSON parsing code.</p>
</li>
<li><p><strong>Features</strong>:</p>
<ul>
<li><p>Enforces structure.</p>
</li>
<li><p>Converts model output into typed objects.</p>
</li>
<li><p>Works with <code>response_format</code> or custom prompt outputs.</p>
</li>
</ul>
</li>
<li><p><strong>Example</strong>:</p>
<pre><code class="lang-jsx">  <span class="hljs-keyword">import</span> { Instructor } <span class="hljs-keyword">from</span> <span class="hljs-string">'instructor'</span>;

  <span class="hljs-keyword">const</span> sentimentSchema = Instructor.object({
      <span class="hljs-attr">sentiment</span>: Instructor.string(),
      <span class="hljs-attr">reason</span>: Instructor.string()
  });

  <span class="hljs-keyword">const</span> output = <span class="hljs-keyword">await</span> model.call({
      <span class="hljs-attr">prompt</span>: <span class="hljs-string">"Analyze this review..."</span>,
      <span class="hljs-attr">response_format</span>: sentimentSchema
  });

  <span class="hljs-built_in">console</span>.log(output.sentiment); <span class="hljs-comment">// "positive"</span>
</code></pre>
</li>
</ul>
<ol>
<li><strong>Zod</strong></li>
</ol>
<ul>
<li><p><strong>Purpose</strong>: A TypeScript-friendly <strong>runtime schema validation library</strong>.</p>
</li>
<li><p><strong>Use Case</strong>:</p>
<ul>
<li><p>Validates LLM output after receiving it.</p>
</li>
<li><p>Ensures that your app only works with <strong>correctly structured data</strong>.</p>
</li>
</ul>
</li>
<li><p><strong>Features</strong>:</p>
<ul>
<li><p>Parse and validate JSON objects.</p>
</li>
<li><p>Provides detailed error messages if validation fails.</p>
</li>
<li><p>Integrates with TypeScript for type safety.</p>
</li>
</ul>
</li>
<li><p><strong>Example</strong>:</p>
<pre><code class="lang-jsx">  <span class="hljs-keyword">import</span> { z } <span class="hljs-keyword">from</span> <span class="hljs-string">'zod'</span>;

  <span class="hljs-keyword">const</span> sentimentSchema = z.object({
      <span class="hljs-attr">sentiment</span>: z.enum([<span class="hljs-string">"positive"</span>, <span class="hljs-string">"negative"</span>]),
      <span class="hljs-attr">reason</span>: z.string()
  });

  <span class="hljs-keyword">const</span> parsed = sentimentSchema.parse(outputFromLLM);
  <span class="hljs-comment">// Throws error if outputFromLLM doesn't match the schema</span>

  <span class="hljs-built_in">console</span>.log(parsed.sentiment); <span class="hljs-comment">// "negative" or "positive"</span>
</code></pre>
</li>
</ul>
<hr />
<h3 id="heading-how-they-fit-together">How They Fit Together</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Library</td><td>When to Use</td><td>Pros</td><td>Example Use Case</td></tr>
</thead>
<tbody>
<tr>
<td>Instructor</td><td>During LLM call, enforce structured output</td><td>Easier integration with response_format</td><td>Structured sentiment analysis, form filling</td></tr>
<tr>
<td>Zod</td><td>After receiving LLM output, runtime validation</td><td>Strong TypeScript support, error handling</td><td>Validate sentiment output before saving to DB</td></tr>
</tbody>
</table>
</div><p><strong>Key Tip:</strong></p>
<ul>
<li><p>Use <strong>Instructor</strong> if you want the model to output structured data directly.</p>
</li>
<li><p>Use <strong>Zod</strong> to <strong>double-check or parse</strong> the output in your application safely.</p>
</li>
<li><p>Both can be combined: Instructor for enforcing, Zod for validating.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Basics of GenAi]]></title><description><![CDATA[1. Key Full Forms




AcronymFull FormShort MeaningExample Use



LLMLarge Language ModelAI model trained on massive text data to understand and generate languageChatGPT answering your questions

GPTGenerative Pre-trained TransformerType of LLM train...]]></description><link>https://genai-arnab.hashnode.dev/basics-of-genai</link><guid isPermaLink="true">https://genai-arnab.hashnode.dev/basics-of-genai</guid><dc:creator><![CDATA[Arnab Saha]]></dc:creator><pubDate>Sun, 21 Sep 2025 07:37:58 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/agFmImWyPso/upload/b41e22a06a2c7f3327fd0c774cfef67b.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-1-key-full-forms">1. <strong>Key Full Forms</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Acronym</td><td>Full Form</td><td>Short Meaning</td><td>Example Use</td></tr>
</thead>
<tbody>
<tr>
<td><strong>LLM</strong></td><td><strong>Large Language Model</strong></td><td>AI model trained on massive text data to understand and generate language</td><td>ChatGPT answering your questions</td></tr>
<tr>
<td><strong>GPT</strong></td><td><strong>Generative Pre-trained Transformer</strong></td><td>Type of LLM trained in two steps — first learns language patterns from huge data, then fine-tuned for tasks</td><td>GPT-4 writing a blog post</td></tr>
<tr>
<td><strong>RAG</strong></td><td><strong>Retrieval-Augmented Generation</strong></td><td>Technique where an LLM fetches extra data from an external source before answering, so it’s more accurate</td><td>An AI that searches a company database before replying</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-2-llms-large-language-models">2. <strong>LLMs (Large Language Models)</strong></h2>
<ul>
<li><p><strong>Definition:</strong> AI models trained on huge amounts of text data to understand and generate human-like language.</p>
</li>
<li><p><strong>Example:</strong> ChatGPT, Claude, Gemini — they can answer questions, write essays, or even generate code.</p>
</li>
<li><p><strong>Analogy:</strong> Like a super well-read friend who has read millions of books and can talk about almost anything.</p>
</li>
</ul>
<hr />
<h2 id="heading-3-gpt-vs-reasoning-apps">3. <strong>GPT vs Reasoning Apps</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>GPT (General Purpose)</td><td>Reasoning App</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Main Goal</strong></td><td>Broad knowledge &amp; natural conversation</td><td>Deep logical problem solving</td></tr>
<tr>
<td><strong>Strengths</strong></td><td>Creativity, language understanding, knowledge recall</td><td>Step-by-step reasoning, decision making</td></tr>
<tr>
<td><strong>Example</strong></td><td>GPT can write a poem or explain a science topic</td><td>A reasoning app can solve a complex math puzzle or plan a multi-step project</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-4-few-llms-amp-their-capabilities">4. <strong>Few LLMs &amp; Their Capabilities</strong></h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>LLM Name</td><td>Key Strengths</td><td>Example Use</td></tr>
</thead>
<tbody>
<tr>
<td><strong>GPT-4 / GPT-5</strong></td><td>Language understanding, creativity, coding</td><td>Writing blogs, solving coding problems</td></tr>
<tr>
<td><strong>Claude</strong></td><td>Long context handling, polite tone</td><td>Analyzing 100+ page documents</td></tr>
<tr>
<td><strong>Gemini</strong></td><td>Google search integration</td><td>Real-time updated answers</td></tr>
<tr>
<td><strong>LLaMA</strong></td><td>Open-source flexibility</td><td>Custom AI projects</td></tr>
<tr>
<td><strong>Gemma 2 Instruct</strong></td><td>Supports <strong>tool calling</strong> (can call APIs, databases, or other functions directly from responses)</td><td>Automating workflows — e.g., getting live stock prices, booking flights, or triggering scripts</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-5-tokens-amp-tokenizers">5. <strong>Tokens &amp; Tokenizers</strong></h2>
<ul>
<li><p><strong>Tokens:</strong> Small pieces of text (words or subwords) that an LLM reads and processes.</p>
</li>
<li><p><strong>Key Point:</strong> Models <strong>understand tokens, not whole words</strong>.</p>
</li>
<li><p><strong>Tokenizer:</strong> Breaks a sentence into tokens; different models use different tokenizers.</p>
<ul>
<li><p>Example: “I love cats” → <code>"I"</code>, <code>" love"</code>, <code>" cats"</code></p>
</li>
<li><p><code>"unbelievable"</code> → <code>"un"</code>, <code>"believ"</code>, <code>"able"</code></p>
</li>
</ul>
</li>
<li><p><strong>Tiktoken:</strong> Example tokenizer used by OpenAI models.</p>
</li>
<li><p><strong>Billing:</strong> You <strong>pay for tokens, not words</strong>.</p>
</li>
</ul>
<hr />
<h2 id="heading-6-context">6. <strong>Context</strong></h2>
<ul>
<li><p><strong>Definition:</strong> The combined information the model uses to generate a response.</p>
</li>
<li><p><strong>Made up of:</strong></p>
<ol>
<li><p><strong>User Inputs</strong> — Latest prompt</p>
</li>
<li><p><strong>Instructions</strong> — Rules or roles for the AI</p>
</li>
<li><p><strong>Additional Information</strong> — Facts, uploaded files, retrieved documents</p>
</li>
<li><p><strong>Message History</strong> — Previous conversation turns</p>
</li>
</ol>
</li>
<li><p><strong>Example:</strong> Asking <em>"Summarize this report"</em> includes the report, your request, prior clarifications, and assigned roles.</p>
</li>
</ul>
<hr />
<h2 id="heading-7-context-window">7. <strong>Context Window</strong></h2>
<ul>
<li><p><strong>Definition:</strong> Maximum number of tokens the model can remember at once.</p>
</li>
<li><p><strong>Examples:</strong></p>
<ul>
<li><p>GPT-3: ~2,048 tokens (~1,500 words)</p>
</li>
<li><p>GPT-4.1: Up to <strong>1 million tokens</strong> (~750,000 words)</p>
</li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-8-knowledge-cutoff">8. <strong>Knowledge Cutoff</strong></h2>
<ul>
<li><p><strong>Definition:</strong> Latest date up to which the model has been trained.</p>
</li>
<li><p><strong>Why it matters:</strong> Model won’t know events after this date unless connected to real-time tools.</p>
</li>
</ul>
<hr />
<h2 id="heading-9-attention-is-all-you-need">9. <strong>Attention Is All You Need</strong></h2>
<ul>
<li><p><strong>Definition:</strong> Research paper introducing <strong>Transformer architecture</strong>, which powers modern LLMs.</p>
</li>
<li><p><strong>Key idea:</strong> Uses <strong>attention</strong> to focus on important words rather than reading sequentially.</p>
</li>
</ul>
<hr />
<h2 id="heading-10-distilled-llms">10. <strong>Distilled LLMs</strong></h2>
<ul>
<li><p><strong>Definition:</strong> Smaller, faster versions of big LLMs via <strong>knowledge distillation</strong>.</p>
</li>
<li><p><strong>Benefits:</strong> Faster, cheaper, lighter.</p>
</li>
<li><p><strong>Trade-off:</strong> Slightly less depth in answers.</p>
</li>
</ul>
<hr />
<h2 id="heading-11-groqcloud">11. <strong>GroqCloud</strong></h2>
<ul>
<li><strong>Definition:</strong> Cloud platform providing <strong>ultra-fast inference</strong> using Groq chips.</li>
</ul>
<hr />
<h2 id="heading-12-inference">12. <strong>Inference</strong></h2>
<ul>
<li><p><strong>Definition:</strong> Time it takes for a model to process input and produce output.</p>
</li>
<li><p><strong>Factors:</strong> Model size, hardware, task complexity.</p>
</li>
</ul>
<hr />
<h2 id="heading-13-prompt-engineering">13. <strong>Prompt Engineering</strong></h2>
<ul>
<li><strong>Definition:</strong> Crafting prompts to <strong>improve answer quality, accuracy, and consistency</strong>. Good prompt engineering ensures the model outputs what you want in a clear, reliable way.</li>
</ul>
<h3 id="heading-types-of-prompting-amp-when-to-use">Types of Prompting &amp; When to Use</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Prompt Type</td><td>When to Use</td><td>Pros</td><td>Cons</td><td>Notes</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Zero-shot</strong></td><td>Simple tasks, when no examples are available</td><td>Quick, no setup`</td><td>Can be inconsistent, prone to hallucination</td><td>Works for general questions but less reliable for complex or multi-step tasks</td></tr>
<tr>
<td><strong>Few-shot</strong></td><td>Complex tasks, when accuracy and consistency matter</td><td>More reliable, reduces hallucination, guides style</td><td>Requires examples, slightly more setup</td><td>Preferred for multi-step tasks or specific formats</td></tr>
<tr>
<td><strong>Chain-of-Thought (CoT)</strong></td><td>Reasoning or multi-step problems, explaining logic</td><td>Produces step-by-step reasoning, helps debugging</td><td>Slower, verbose</td><td>Not needed if using reasoning-focused models (they handle steps internally)</td></tr>
<tr>
<td><strong>Negative Prompting</strong></td><td>Avoiding unwanted outputs (e.g., “Do not include…” instructions)</td><td>Can steer model away from errors</td><td>Can confuse model if overused</td><td>Use sparingly, combine with clear positive instructions</td></tr>
</tbody>
</table>
</div><hr />
<h3 id="heading-elements-of-a-prompt">Elements of a Prompt</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Element</td><td>Description</td><td>Example</td></tr>
</thead>
<tbody>
<tr>
<td><strong>Instructions</strong></td><td>What the model should do</td><td>“Write a formal email”</td></tr>
<tr>
<td><strong>Input Data</strong></td><td>Content or question to process</td><td>“Client request: …”</td></tr>
<tr>
<td><strong>Context</strong></td><td>Extra guidance</td><td>“You are an expert in project management”</td></tr>
<tr>
<td><strong>Output Indicator</strong></td><td>How answer should be formatted</td><td>“Use bullet points, max 150 words”</td></tr>
</tbody>
</table>
</div><hr />
<h3 id="heading-when-to-use-each-prompt">When to Use Each Prompt</h3>
<ul>
<li><p><strong>Zero-shot:</strong> Quick answers, testing ideas, or general questions.</p>
</li>
<li><p><strong>Few-shot:</strong> When style, accuracy, or specific formatting matters.</p>
</li>
<li><p><strong>CoT:</strong> Multi-step reasoning or tasks needing logic explanations.</p>
</li>
<li><p><strong>Negative prompting:</strong> Only to steer away from specific unwanted behaviors; combine with positive instructions.</p>
</li>
</ul>
<hr />
<h2 id="heading-types-of-prompting-with-examples"><strong>Types of Prompting with Examples</strong></h2>
<h3 id="heading-1-zero-shot-prompting">1. <strong>Zero-shot Prompting</strong></h3>
<p><em>(No examples are given; just instructions and input.)</em></p>
<p>✅ <strong>Example 1:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“Translate the following sentence into French: <em>I love learning new things.</em>”</p>
<p><strong>Output:</strong></p>
<p>“J’aime apprendre de nouvelles choses.”</p>
<p>✅ <strong>Example 2:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“Write a tweet about coffee in less than 15 words.”</p>
<p><strong>Output:</strong></p>
<p>“Coffee: the fuel that turns thoughts into action. ☕🔥”</p>
<hr />
<h3 id="heading-2-few-shot-prompting">2. <strong>Few-shot Prompting</strong></h3>
<p><em>(A few examples are provided before asking the model to generate new outputs.)</em></p>
<p>✅ <strong>Example 1:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“Classify the sentiment of the following reviews as Positive, Neutral, or Negative.</p>
<ul>
<li><p>‘The food was delicious and service was amazing!’ → Positive</p>
</li>
<li><p>‘The movie was okay, nothing special.’ → Neutral</p>
</li>
<li><p>‘The product broke the first day I used it.’ → Negative</p>
<p>  Now classify: ‘The delivery was quick but packaging was bad.’”</p>
<p>  <strong>Output:</strong></p>
<p>  “Neutral”</p>
</li>
</ul>
<p>✅ <strong>Example 2:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“Convert numbers to words.</p>
<ul>
<li><p>42 → forty-two</p>
</li>
<li><p>103 → one hundred three</p>
</li>
<li><p>999 → nine hundred ninety-nine</p>
<p>  Now convert: 275”</p>
<p>  <strong>Output:</strong></p>
<p>  “two hundred seventy-five”</p>
</li>
</ul>
<hr />
<h3 id="heading-3-chain-of-thought-cot-prompting">3. <strong>Chain-of-Thought (CoT) Prompting</strong></h3>
<p><em>(Ask model to “think step by step” for reasoning tasks.)</em></p>
<p>✅ <strong>Example 1:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“If a train travels 60 km in 1 hour, how far will it travel in 4.5 hours? Think step by step.”</p>
<p><strong>Output (CoT):</strong></p>
<ul>
<li><p>Speed = 60 km/h</p>
</li>
<li><p>Time = 4.5 hours</p>
</li>
<li><p>Distance = 60 × 4.5 = 270 km</p>
<p>  <strong>Final Answer:</strong> 270 km</p>
</li>
</ul>
<p>✅ <strong>Example 2:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“A shopkeeper bought 50 apples at ₹20 each. He sold them at ₹25 each. What is his profit? Think step by step.”</p>
<p><strong>Output (CoT):</strong></p>
<ul>
<li><p>Cost price per apple = ₹20</p>
</li>
<li><p>Selling price per apple = ₹25</p>
</li>
<li><p>Profit per apple = 25 – 20 = ₹5</p>
</li>
<li><p>Total apples = 50</p>
</li>
<li><p>Total profit = 50 × 5 = ₹250</p>
<p>  <strong>Final Answer:</strong> ₹250</p>
</li>
</ul>
<hr />
<h3 id="heading-4-negative-prompting">4. <strong>Negative Prompting</strong></h3>
<p><em>(Steer the model away from unwanted behavior.)</em></p>
<p>✅ <strong>Example 1:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“Write a professional email to a client about project delay. Do not use any casual words like ‘hey,’ ‘buddy,’ or emojis.”</p>
<p><strong>Output:</strong></p>
<p>“Dear Client,</p>
<p>We regret to inform you that the project will be delayed by two weeks…”</p>
<p>✅ <strong>Example 2:</strong></p>
<p><strong>Prompt:</strong></p>
<p>“Summarize this article in 100 words. Do not add your own opinions or analysis.”</p>
<p><strong>Output:</strong></p>
<p>“A summary of the article without extra interpretation.”</p>
<hr />
<h3 id="heading-general-tips-for-effective-prompting">General Tips for Effective Prompting</h3>
<ol>
<li><p><strong>Start simple and iterate</strong></p>
<ul>
<li><p>Test a basic prompt first, then refine.</p>
</li>
<li><p>Example: <em>“Summarize this article”</em> → <em>“Summarize in 100 words with bullet points.”</em></p>
</li>
</ul>
</li>
<li><p><strong>Clearly state instructions</strong></p>
<ul>
<li><p>Avoid ambiguous language.</p>
</li>
<li><p>Example: <em>“Write a professional email to a client summarizing the update in three bullet points.”</em></p>
</li>
</ul>
</li>
<li><p><strong>Use separators</strong></p>
<ul>
<li><p>Helps model distinguish instructions, data, and expected output.</p>
</li>
<li><p>Examples: <code>"""</code> or <code>###</code></p>
</li>
</ul>
</li>
<li><p><strong>Be specific and detailed</strong></p>
<ul>
<li><p>Include style, tone, format, and length.</p>
</li>
<li><p>Example: <em>“Write a 150-word summary in a casual tone suitable for teenagers.”</em></p>
</li>
</ul>
</li>
<li><p><strong>Provide examples of desired output</strong></p>
<ul>
<li><p>Guides the model on style and content.</p>
</li>
<li><p>Example: Show one sample summary before asking for another.</p>
</li>
</ul>
</li>
<li><p><strong>Avoid negative instructions when possible</strong></p>
<ul>
<li>Instead of <em>“Do not include slang,”</em> say <em>“Use professional language.”</em></li>
</ul>
</li>
<li><p><strong>Move from simple to complex</strong></p>
<ul>
<li><p>Break tasks into steps.</p>
</li>
<li><p>Example: First list key points, then expand each into paragraphs.</p>
</li>
</ul>
</li>
<li><p><strong>Reduce fluff</strong></p>
<ul>
<li>Avoid vague or overly descriptive language; keep prompts concise but clear.</li>
</ul>
</li>
<li><p><strong>Leverage leading words for code generation</strong></p>
<ul>
<li><p>Words like <code>Write</code>, <code>Generate</code>, <code>Create</code> help the model understand intent for code tasks.</p>
</li>
<li><p>Example: <em>“Generate a Python function that sorts a list of numbers in ascending order.”</em></p>
</li>
</ul>
</li>
</ol>
]]></content:encoded></item></channel></rss>