<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ground it in your data on AI Vault</title><link>https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/</link><description>Recent content in Ground it in your data on AI Vault</description><generator>Hugo</generator><language>en</language><atom:link href="https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/index.xml" rel="self" type="application/rss+xml"/><item><title>Embeddings</title><link>https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/embeddings/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/embeddings/</guid><description>&lt;p&gt;An &lt;strong&gt;embedding&lt;/strong&gt; turns text (or an image, or audio) into a list of numbers — a &lt;strong&gt;vector&lt;/strong&gt; —&#10;that captures its &lt;em&gt;meaning&lt;/em&gt;. It&amp;rsquo;s the mechanism behind&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/rag/"&gt;RAG&lt;/a&gt;, but it&amp;rsquo;s useful far beyond that.&lt;/p&gt;&#10;&lt;h2 id="the-core-idea"&gt;The core idea&lt;/h2&gt;&#10;&lt;p&gt;Text with similar meaning maps to &lt;strong&gt;nearby&lt;/strong&gt; vectors; unrelated text maps far apart. &amp;ldquo;cat&amp;rdquo;&#10;and &amp;ldquo;kitten&amp;rdquo; land close together; &amp;ldquo;car&amp;rdquo; lands elsewhere. That&amp;rsquo;s the whole trick — meaning&#10;becomes distance you can measure.&lt;/p&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; Txt[Text] --&amp;gt; M[Embedding model]&#10; M --&amp;gt; Vec[Vector of numbers]&#10; Vec --&amp;gt; Space[Vector space - similar meaning is nearby]&lt;/pre&gt;&#10;&lt;h2 id="how-you-use-them"&gt;How you use them&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Use the &lt;strong&gt;same embedding model&lt;/strong&gt; for everything you compare — vectors from different models&#10;aren&amp;rsquo;t comparable.&lt;/li&gt;&#10;&lt;li&gt;Measure closeness with &lt;strong&gt;cosine similarity&lt;/strong&gt; (angle between vectors).&lt;/li&gt;&#10;&lt;li&gt;Store and search them in a &lt;strong&gt;vector database&lt;/strong&gt; (see &lt;a href="https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/rag/"&gt;RAG&lt;/a&gt;).&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="uses-beyond-rag"&gt;Uses beyond RAG&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Semantic search&lt;/strong&gt; — find by meaning, not keywords.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Clustering&lt;/strong&gt; — group similar items automatically.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Classification&lt;/strong&gt; — label text by nearest known examples.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Deduplication&lt;/strong&gt; — spot near-duplicate content.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Recommendations&lt;/strong&gt; — &amp;ldquo;more like this&amp;rdquo;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="practical-notes"&gt;Practical notes&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Dimensions&lt;/strong&gt; — vectors have a fixed length (e.g. hundreds to thousands of numbers); more&#10;isn&amp;rsquo;t always better.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Model choice&lt;/strong&gt; matters — pick one suited to your language and domain.&lt;/li&gt;&#10;&lt;li&gt;Embeddings are &lt;strong&gt;cheap&lt;/strong&gt; compared to generation; embedding a large corpus is routine.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="strengths--limitations"&gt;Strengths &amp;amp; limitations&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Strengths&lt;/strong&gt; — turns meaning into measurable distance; cheap and reusable; powers search,&#10;clustering, and classification.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Limitations&lt;/strong&gt; — quality depends on the model and domain; fixed at embed time (re-embed when&#10;data changes); misses exact keywords — pair with keyword / hybrid search.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="sources"&gt;Sources&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Reimers &amp;amp; Gurevych, &lt;em&gt;Sentence-BERT&lt;/em&gt; (2019) — &lt;a href="https://arxiv.org/abs/1908.10084"&gt;arXiv:1908.10084&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://platform.openai.com/docs/guides/embeddings"&gt;OpenAI — Embeddings&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;</description></item><item><title>RAG (Retrieval-Augmented Generation)</title><link>https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/rag/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/foundations/ground-in-data/rag/</guid><description>&lt;h2 id="goal"&gt;Goal&lt;/h2&gt;&#10;&lt;p&gt;The goal of &lt;strong&gt;RAG&lt;/strong&gt; is to retrieve relevant information from an external data source and add&#10;it to the prompt &lt;em&gt;before&lt;/em&gt; the foundation model generates an answer. This lets the model&#10;answer from your organization&amp;rsquo;s data instead of relying only on knowledge learned during&#10;training.&lt;/p&gt;&#10;&lt;h2 id="basic-pipeline"&gt;Basic pipeline&lt;/h2&gt;&#10;&lt;p&gt;Collect documents → parse → chunk → embed → store in a vector store → retrieve → augment →&#10;generate.&lt;/p&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; D[Documents] --&amp;gt; P[Parse]&#10; P --&amp;gt; C[Chunk]&#10; C --&amp;gt; E[Embed]&#10; E --&amp;gt; V[(Vector store)]&#10; Q[User question] --&amp;gt; R[Retrieve]&#10; V --&amp;gt; R&#10; R --&amp;gt; A[Augment prompt]&#10; A --&amp;gt; M[Foundation model]&#10; M --&amp;gt; Ans[Answer]&lt;/pre&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Step&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Role&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Parse&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Read and extract content from PDF, Word, HTML, or other sources&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Chunking&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Split documents into small passages for more precise retrieval&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Embedding&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Convert text into numeric vectors that capture semantic meaning&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Vector store&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Store and index the embeddings&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Retrieval&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Find the passages most relevant to the user&amp;rsquo;s question&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Augmentation&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Insert the retrieved content into the prompt as context&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Generation&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The foundation model uses that context to produce the answer&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;h2 id="embeddings"&gt;Embeddings&lt;/h2&gt;&#10;&lt;p&gt;An &lt;strong&gt;embedding&lt;/strong&gt; converts text into a numeric vector that represents its meaning — text with&#10;similar meaning maps to nearby vectors. Use the &lt;strong&gt;same embedding model&lt;/strong&gt; for both documents&#10;and the query, and measure relevance with &lt;strong&gt;cosine similarity&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>