<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nicholas on Medium]]></title>
        <description><![CDATA[Stories by Nicholas on Medium]]></description>
        <link>https://medium.com/@nicholas_49178?source=rss-f672b6243df1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*FfBibisWPZTSVxq7</url>
            <title>Stories by Nicholas on Medium</title>
            <link>https://medium.com/@nicholas_49178?source=rss-f672b6243df1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:05:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicholas_49178/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SOTA Q&A over MSMarco text (~9M chunks) in 4 minutes on Laptop]]></title>
            <link>https://medium.com/thirdai-blog/sta-q-a-over-msmarco-text-9m-chunks-in-4-minutes-on-laptop-7164f23331c0?source=rss-f672b6243df1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7164f23331c0</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Nicholas]]></dc:creator>
            <pubDate>Thu, 11 Apr 2024 00:10:37 GMT</pubDate>
            <atom:updated>2024-04-16T13:52:07.505Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build Generative Q &amp; A over 10M Docs on a Laptop in 4 minutes</h3><p>With the latest release of ThirdAI, we can build a Q&amp;A system on <a href="https://microsoft.github.io/msmarco/">MSMarco</a>, the largest BEIR Benchmark — achieving SoTA accuracy in less than the time it takes you to read this article!</p><p>Running on my M1 MacBook Air with 16GB of RAM (using only the CPU cores), the following demo takes only 4 minutes and achieves an accuracy that is on par with or exceeds that of popular Embedding Models.</p><p><strong>1. Getting Started</strong></p><p>Run pip3 install &quot;thirdai&gt;=0.7.41&quot; to ensure you have installed ThirdAI with version 0.7.41 or later. If you don’t already have one you can go <a href="https://www.thirdai.com/try-bolt/">here</a> to get a trial license for ThirdAI. Now let’s import the library and download the dataset.</p><pre>from thirdai import neural_db as ndb<br>from thirdai import demos<br>import pandas as pd<br>import time<br><br># Downloads msmarco and puts all of the documents into a csv file.<br>documents, train_queries, test_queries, _ = demos.download_beir_dataset(&quot;msmarco&quot;)</pre><p><strong>2. Building the System</strong></p><pre>qna_model = ndb.NeuralDB(low_memory=True)<br><br>start = time.perf_counter()<br><br>qna_model.insert([<br>    ndb.CSV(<br>        documents,<br>        id_column=&quot;DOC_ID&quot;,        # Indicates which column stores the document ids.<br>        strong_columns=[&quot;TITLE&quot;],  # Indicates which column contains the title.<br>        weak_columns=[&quot;TEXT&quot;],     # Indicates which column contains the text.<br>)])<br><br>end = time.perf_counter()<br>print(f&quot;Completed in {end-start:.3f} s&quot;)</pre><p>And that’s it! With just a few lines of code, you’ve created a search system that has scaled to 8.8 million documents in just a matter of minutes, without any specialized hardware!</p><p><strong>3. Evaluation</strong></p><pre>def parse_labels(labels):<br>    return list(map(int, labels.split(&quot;:&quot;)))<br><br><br>def evaluate(qna_model, test_queries):<br>    test_df = pd.read_csv(test_queries)<br>    test_df[&quot;DOC_ID&quot;] = test_df[&quot;DOC_ID&quot;].map(parse_labels)<br><br>    true_positives = 0<br>    start = time.perf_counter()<br>    for _, row in test_df.iterrows():<br>        result = qna_model.search(row[&quot;QUERY&quot;], top_k=5)<br>        if len(result) and result[0].id in row[&quot;DOC_ID&quot;]:<br>            true_positives += 1<br>    end = time.perf_counter()<br><br>    precision = true_positives / len(test_df)<br>    print(f&quot;precision@1={precision:.3f}&quot;)<br>    avg_time = (end - start) / len(test_df) * 1000<br>    print(f&quot;average query time: {avg_time:.3f} ms&quot;)<br><br>evaluate(qna_model=qna_model, test_queries=test_queries)</pre><p>Output:</p><pre>precision@1=0.791<br>average query time: 21.369 ms</pre><p>We see here that ThirdAI achieves a precision@1 of 0.791, so how does that compare to the state-of-the-art embedding models and other retrieval systems?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANyA5GWPPZxwsohsNdsdgA.png" /><figcaption>* Numbers for Google T5 and OpenAI Ada are computed using exact search over the embeddings. Using ANN search with a Vector DB will result in slightly worse accuracy.</figcaption></figure><p>Now what about the feasibility of these alternatives? OpenAI Ada Embeddings will require 54GB of storage just to store the embeddings, with the Vector DB imposing additional resource requirements on top of that. ThirdAI requires just 10–12GB of the RAM on my laptop.</p><p>Running an open source Embedding Model such as T5 will require GPUs to sustain a reasonable throughput, and will also likely require similar hardware in production to achieve low query latency. ThirdAI has a latency of 21 ms latency just on a laptop, without requiring any specialized hardware, and this same code could easily be run on whatever infrastructure you have at hand already with comparable results.</p><p><strong>4. Domain Specialization</strong></p><p>While this system already achieves a comparable accuracy to the best Embedding Models, what if we want to improve it further? One of the defining characteristics of successful production search systems is their ability to continually improve based on user interactions. For example, say a company uses the custom acronym IDD to mean “initial design document”. Since this acronym doesn’t appear in the training data used to create the LLMs in the search system, user queries like the “summarize the IDD for project xyz” will fail since the system doesn’t understand the acronym used. With domain specialization, the system can adapt to understand these relationships and answer queries like this correctly. These user interactions allow the underlying system to learn patterns/trends in user preferences that aren’t present in the raw documents.</p><p>A major limitation of the Vector DB + Embedding Model approach is there is no efficient way to implement this continual learning, especially at scale. Finetuning the embedding model requires more expensive GPU hours and is a complicated process requiring careful selection of negative samples, data cleaning, and other techniques that are still the subject of ongoing research. Even if we succeed in finetuning the embedding model, we will have to regenerate all of the embeddings and rebuild the Vector DB, which will take even more time and incur more cost. It is also worth noting that some embedding services like OpenAI Ada embeddings are currently <a href="https://platform.openai.com/docs/guides/fine-tuning">not fine-tunable</a> at all.</p><p>With ThirdAI, we can efficiently domain specialize (or finetune) based on user interactions without having to rebuild the entire system. With just a few more seconds and lines of code we can leverage the 300,000 training queries in the MSMarco dataset to boost performance.</p><pre>train_df = pd.read_csv(train_queries)<br>train_df[&quot;DOC_ID&quot;] = train_df[&quot;DOC_ID&quot;].map(parse_labels)<br><br>start = time.perf_counter()<br><br>qna_model.supervised_train_with_ref_ids(<br>    queries=train_df[&quot;QUERY&quot;].to_list(), labels=train_df[&quot;DOC_ID&quot;].to_list()<br>)<br><br>end = time.perf_counter()<br>print(f&quot;finetuned in {end-start:.3f} s&quot;)<br><br>evaluate(qna_model=qna_model, test_queries=test_queries)</pre><p>Output:</p><pre>finetuned in 2.164 s<br>precision@1=0.814<br>average query time: 21.012 ms</pre><p>Now if we rerun the evaluation, we see that the precision@1 has improved to 0.814 just by feeding sample user interactions into the system, and the whole finetuning process just took a few seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Deact5xrftydG7FXc_n3Pg.png" /><figcaption>Comparison of ThirdAI with and without Domain Specialization.</figcaption></figure><p><strong>A note on Energy Efficient AI</strong></p><p>Another point of emphasis should be the environmental impact. While new advances in AI are undoubtably impressive and revolutionary, the energy requirements are enormous. The next generation of Nvidia H100 GPUs in production are alone projected to <a href="https://www.tomshardware.com/tech-industry/nvidias-h100-gpus-will-consume-more-power-than-some-countries-each-gpu-consumes-700w-of-power-35-million-are-expected-to-be-sold-in-the-coming-year">surpass the energy usage of a small nation</a>. Finding energy efficient alternatives is essential as this technology continues to develop. A system like ThirdAI that uses only a fraction of the computing resources and requires no hardware accelerators offers a path to significantly less energy usage when deploying generative AI systems.</p><p><strong>Conclusion</strong></p><p>Building a search system using the standard recipe of Embedding Models and Vector DBs quickly runs into a host of issues such as generating and storing the embeddings, scaling the system, and specializing it to your knowledge base.</p><p>In this demo we presented a new solution to these problems, with a system that has unparalleled scaling without sacrificing on accuracy. If you are interested in learning more about our technology, please reach out to contact@thirdai.com.</p><p><strong>Links</strong></p><ul><li>Full Demo Notebook: <a href="https://github.com/ThirdAILabs/Demos/blob/main/neural_db/msmarco.ipynb">https://github.com/ThirdAILabs/Demos/blob/main/neural_db/msmarco.ipynb</a></li><li>Get a ThirdAI Trial License: <a href="https://www.thirdai.com/try-bolt/">https://www.thirdai.com/try-bolt/</a></li><li>Learn more about ThirdAI: <a href="https://www.thirdai.com/">https://www.thirdai.com</a></li><li>MSMarco Dataset: <a href="https://microsoft.github.io/msmarco/">https://microsoft.github.io/msmarco/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7164f23331c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thirdai-blog/sta-q-a-over-msmarco-text-9m-chunks-in-4-minutes-on-laptop-7164f23331c0">SOTA Q&amp;A over MSMarco text (~9M chunks) in 4 minutes on Laptop</a> was originally published in <a href="https://medium.com/thirdai-blog">ThirdAI Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>