<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Kevin Scott — AI Systems &amp; Performance Engineering</title>
<link>https://biscuitsandgravy.ai/research.html</link>
<atom:link href="https://biscuitsandgravy.ai/research.xml" rel="self" type="application/rss+xml"/>
<description>Research writing on AI systems and performance — embedding compression, dimensionality reduction, retrieval-augmented generation, and interactive explorations.</description>
<image>
<url>https://biscuitsandgravy.ai/og-image.png</url>
<title>Kevin Scott — AI Systems &amp; Performance Engineering</title>
<link>https://biscuitsandgravy.ai/research.html</link>
</image>
<generator>quarto-1.10.18</generator>
<lastBuildDate>Sat, 20 Jan 2024 00:00:00 GMT</lastBuildDate>
<item>
  <title>Dimensionality Reduction in Embedding Spaces: A Comparative Analysis of DCT and SVD for RAG Systems</title>
  <dc:creator>Kevin Scott and Ethan Davis</dc:creator>
  <link>https://biscuitsandgravy.ai/posts/welcome.html</link>
  <description><![CDATA[ 





<section id="abstract" class="level2">
<h2 class="anchored" data-anchor-id="abstract">Abstract</h2>
<p>We present a methodological framework for evaluating dimensionality reduction techniques in dense embedding spaces for Retrieval-Augmented Generation (RAG) systems. Specifically, we examine Discrete Cosine Transform (DCT) and Singular Value Decomposition (SVD) applied to the column space of embedding matrices, followed by quantization. Our evaluation protocol centers on retrieval consistency - measuring whether reduced representations retrieve the same contextual chunks as full-dimensional embeddings. This work was conducted in collaboration with Ethan Davis at SAS Institute Inc.</p>
</section>
<section id="introduction" class="level2">
<h2 class="anchored" data-anchor-id="introduction">Introduction</h2>
<p>Dense embeddings from transformer-based models typically operate in high-dimensional spaces (d ∈ {384, 768, 1024, 1536}). While these representations capture rich semantic information, their dimensionality poses computational and storage challenges. This work examines column-space reduction techniques that aim to preserve retrieval quality in RAG pipelines.</p>
</section>
<section id="theoretical-framework" class="level2">
<h2 class="anchored" data-anchor-id="theoretical-framework">Theoretical Framework</h2>
<section id="column-space-reduction" class="level3">
<h3 class="anchored" data-anchor-id="column-space-reduction">Column Space Reduction</h3>
<p>Given an embedding matrix <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BE%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bn%20%5Ctimes%20d%7D"> where <img src="https://latex.codecogs.com/png.latex?n"> represents the number of documents and <img src="https://latex.codecogs.com/png.latex?d"> the embedding dimension, we seek a transformation <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BT%7D:%20%5Cmathbb%7BR%7D%5Ed%20%5Crightarrow%20%5Cmathbb%7BR%7D%5Ek"> where <img src="https://latex.codecogs.com/png.latex?k%20%5Cll%20d">.</p>
</section>
<section id="discrete-cosine-transform-dct" class="level3">
<h3 class="anchored" data-anchor-id="discrete-cosine-transform-dct">Discrete Cosine Transform (DCT)</h3>
<p>The DCT provides an orthogonal transformation that concentrates signal energy in low-frequency components:</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BE%7D'%20=%20%5Cmathbf%7BE%7D%20%5Cmathbf%7BD%7D%5ET"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BD%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bd%20%5Ctimes%20d%7D"> is the DCT matrix. We retain the first <img src="https://latex.codecogs.com/png.latex?k"> columns of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BE%7D'">, exploiting the energy compaction property commonly observed in natural signals.</p>
</section>
<section id="singular-value-decomposition-svd" class="level3">
<h3 class="anchored" data-anchor-id="singular-value-decomposition-svd">Singular Value Decomposition (SVD)</h3>
<p>We apply SVD directly to the embedding matrix for dimensionality reduction:</p>
<ol type="1">
<li>Compute SVD: <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BE%7D%20=%20%5Cmathbf%7BU%7D%20%5Cboldsymbol%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET"></li>
<li>Truncate to <img src="https://latex.codecogs.com/png.latex?k"> components: <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BE%7D_k%20=%20%5Cmathbf%7BU%7D_k%20%5Cboldsymbol%7B%5CSigma%7D_k%20%5Cmathbf%7BV%7D_k%5ET"></li>
<li>Project embeddings: <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BE%7D'%20=%20%5Cmathbf%7BE%7D%20%5Cmathbf%7BV%7D_k"></li>
</ol>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BV%7D_k%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bd%20%5Ctimes%20k%7D"> contains the first <img src="https://latex.codecogs.com/png.latex?k"> right singular vectors, effectively projecting from <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5Ed"> to <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%7BR%7D%5Ek">.</p>
</section>
</section>
<section id="quantization-strategies" class="level2">
<h2 class="anchored" data-anchor-id="quantization-strategies">Quantization Strategies</h2>
<p>Post-reduction quantization further compresses representations:</p>
<section id="scalar-quantization" class="level3">
<h3 class="anchored" data-anchor-id="scalar-quantization">Scalar Quantization</h3>
<ul>
<li>Map continuous values to discrete levels</li>
<li>B-bit quantization: 2^B levels</li>
<li>Consider Lloyd-Max quantizer for optimal level placement based on distribution</li>
</ul>
</section>
<section id="vector-quantization" class="level3">
<h3 class="anchored" data-anchor-id="vector-quantization">Vector Quantization</h3>
<ul>
<li>k-means clustering in reduced space</li>
<li>Codebook size determines compression ratio</li>
<li>Product quantization for large-scale applications</li>
</ul>
</section>
</section>
<section id="proposed-evaluation-methodology" class="level2">
<h2 class="anchored" data-anchor-id="proposed-evaluation-methodology">Proposed Evaluation Methodology</h2>
<section id="retrieval-consistency-metric" class="level3">
<h3 class="anchored" data-anchor-id="retrieval-consistency-metric">Retrieval Consistency Metric</h3>
<p>For query <img src="https://latex.codecogs.com/png.latex?q">, let: - <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BR%7D_%7B%5Ctext%7Bfull%7D%7D(q,%20k)"> = top-<img src="https://latex.codecogs.com/png.latex?k"> retrieved chunks using full embeddings - <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%7BR%7D_%7B%5Ctext%7Breduced%7D%7D(q,%20k)"> = top-<img src="https://latex.codecogs.com/png.latex?k"> retrieved chunks using reduced embeddings</p>
<p>We define retrieval consistency as:</p>
<p><img src="https://latex.codecogs.com/png.latex?%5Ctext%7BRC@%7Dk%20=%20%5Cfrac%7B%7C%5Cmathcal%7BR%7D_%7B%5Ctext%7Bfull%7D%7D(q,%20k)%20%5Ccap%20%5Cmathcal%7BR%7D_%7B%5Ctext%7Breduced%7D%7D(q,%20k)%7C%7D%7Bk%7D"></p>
</section>
<section id="experimental-protocol" class="level3">
<h3 class="anchored" data-anchor-id="experimental-protocol">Experimental Protocol</h3>
<ol type="1">
<li><strong>Corpus Preparation</strong>: Segment documents into semantically coherent chunks</li>
<li><strong>Embedding Generation</strong>: Apply pre-trained encoder (e.g., BERT, Sentence-BERT, E5)</li>
<li><strong>Dimensionality Reduction</strong>:
<ul>
<li>For SVD: Compute on training subset, apply to full corpus</li>
<li>For DCT: Direct application of transformation matrix</li>
</ul></li>
<li><strong>Quantization</strong>: Apply scalar or vector quantization to reduced embeddings</li>
<li><strong>Evaluation</strong>:
<ul>
<li>Sample diverse query set</li>
<li>Compare retrieval sets between full and reduced representations</li>
<li>Measure RC@k for k ∈ {1, 5, 10, 20, 50}</li>
<li>Analyze distribution of retrieval rank changes</li>
</ul></li>
</ol>
</section>
<section id="additional-metrics" class="level3">
<h3 class="anchored" data-anchor-id="additional-metrics">Additional Metrics</h3>
<p>Beyond retrieval consistency, consider: - <strong>Semantic Similarity Preservation</strong>: Correlation between cosine similarities in original vs.&nbsp;reduced space - <strong>Computational Efficiency</strong>: Indexing time, query latency, memory footprint - <strong>Reconstruction Error</strong>: <img src="https://latex.codecogs.com/png.latex?%5C%7C%5Cmathbf%7BE%7D%20-%20%5Cmathbf%7BE%7D'%5Cmathbf%7BT%7D%5E%7B%5Cdagger%7D%5C%7C_F"> where <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%7BT%7D%5E%7B%5Cdagger%7D"> is the pseudo-inverse</p>
</section>
</section>
<section id="theoretical-considerations" class="level2">
<h2 class="anchored" data-anchor-id="theoretical-considerations">Theoretical Considerations</h2>
<section id="information-theoretic-perspective" class="level3">
<h3 class="anchored" data-anchor-id="information-theoretic-perspective">Information-Theoretic Perspective</h3>
<p>The fundamental question: what is the intrinsic dimensionality of semantic embeddings? Rate-distortion theory suggests embeddings contain redundancy that can be exploited.</p>
</section>
<section id="dct-vs-svd-key-differences" class="level3">
<h3 class="anchored" data-anchor-id="dct-vs-svd-key-differences">DCT vs SVD: Key Differences</h3>
<p><strong>SVD:</strong> - Data-dependent transformation - Optimal linear dimensionality reduction (in Frobenius norm) - Requires singular value decomposition - Captures global variance structure</p>
<p><strong>DCT:</strong> - Data-independent transformation - Assumes local smoothness in embedding space - <img src="https://latex.codecogs.com/png.latex?O(n%20%5Clog%20d)"> computation via FFT - Natural frequency interpretation</p>
</section>
</section>
<section id="implementation-considerations" class="level2">
<h2 class="anchored" data-anchor-id="implementation-considerations">Implementation Considerations</h2>
<section id="computational-complexity" class="level3">
<h3 class="anchored" data-anchor-id="computational-complexity">Computational Complexity</h3>
<ul>
<li><strong>SVD</strong>: <img src="https://latex.codecogs.com/png.latex?O(%5Cmin(n%5E2d,%20nd%5E2))"> for full decomposition</li>
<li><strong>DCT</strong>: <img src="https://latex.codecogs.com/png.latex?O(nd%20%5Clog%20d)"> via FFT implementation</li>
<li><strong>Quantization</strong>: <img src="https://latex.codecogs.com/png.latex?O(nd)"> for scalar, <img src="https://latex.codecogs.com/png.latex?O(ndk_c)"> for <img src="https://latex.codecogs.com/png.latex?k_c">-means vector quantization</li>
</ul>
</section>
<section id="numerical-stability" class="level3">
<h3 class="anchored" data-anchor-id="numerical-stability">Numerical Stability</h3>
<p>When implementing SVD on high-dimensional embeddings:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Direct SVD on embedding matrix</span></span>
<span id="cb1-2">U, S, Vt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> np.linalg.svd(embeddings, full_matrices<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">False</span>)</span>
<span id="cb1-3">projection_matrix <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Vt[:k].T</span>
<span id="cb1-4">reduced_embeddings <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> embeddings <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">@</span> projection_matrix</span></code></pre></div></div>
</section>
</section>
<section id="open-research-questions" class="level2">
<h2 class="anchored" data-anchor-id="open-research-questions">Open Research Questions</h2>
<ol type="1">
<li><strong>Optimal Dimensionality Selection</strong>: How to determine k without extensive empirical search?</li>
<li><strong>Query-Dependent Reduction</strong>: Can we adaptively select dimensions based on query characteristics?</li>
<li><strong>Non-linear Alternatives</strong>: Would manifold learning techniques preserve retrieval quality better?</li>
<li><strong>End-to-End Learning</strong>: Can we train embeddings aware of downstream compression?</li>
</ol>
</section>
<section id="conclusion" class="level2">
<h2 class="anchored" data-anchor-id="conclusion">Conclusion</h2>
<p>This work outlines a rigorous framework for evaluating dimensionality reduction techniques in RAG systems. The trade-off between computational efficiency and retrieval quality remains an active area of research. Future work should focus on establishing theoretical guarantees and developing adaptive compression strategies.</p>
</section>
<section id="acknowledgments" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgments">Acknowledgments</h2>
<p>This research was conducted in collaboration with Ethan Davis at SAS Institute Inc.&nbsp;We thank the SAS Institute for computational resources and support.</p>
</section>
<section id="references" class="level2">
<h2 class="anchored" data-anchor-id="references">References</h2>
<ol type="1">
<li>Johnson, W. B., &amp; Lindenstrauss, J. (1984). Extensions of Lipschitz mappings into a Hilbert space.</li>
<li>Jegou, H., Douze, M., &amp; Schmid, C. (2011). Product quantization for nearest neighbor search.</li>
<li>Reimers, N., &amp; Gurevych, I. (2019). Sentence-BERT: Sentence embeddings using Siamese BERT-networks.</li>
</ol>
<hr>
<p><em>This methodology paper outlines ongoing research. Implementations and empirical results will be shared upon completion of experiments.</em></p>


</section>

 ]]></description>
  <category>RAG</category>
  <category>dimension-reduction</category>
  <category>embeddings</category>
  <category>information-retrieval</category>
  <guid>https://biscuitsandgravy.ai/posts/welcome.html</guid>
  <pubDate>Sat, 20 Jan 2024 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
