<?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 Nethra Ranganathan on Medium]]></title>
        <description><![CDATA[Stories by Nethra Ranganathan on Medium]]></description>
        <link>https://medium.com/@netraranga?source=rss-17103d483e0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1JxYMNEl_bqxssP1a-8QlQ.jpeg</url>
            <title>Stories by Nethra Ranganathan on Medium</title>
            <link>https://medium.com/@netraranga?source=rss-17103d483e0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:43:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@netraranga/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[Unlocking Insights: Making Sense of Unstructured Data with BERTopic and LLMs]]></title>
            <link>https://medium.com/@netraranga/unlocking-insights-making-sense-of-unstructured-data-with-bertopic-and-llms-fe1df45adfb7?source=rss-17103d483e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe1df45adfb7</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[text-analytics]]></category>
            <category><![CDATA[bertopic]]></category>
            <category><![CDATA[text-analysis]]></category>
            <category><![CDATA[unstructured-data]]></category>
            <dc:creator><![CDATA[Nethra Ranganathan]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 03:53:21 GMT</pubDate>
            <atom:updated>2025-02-03T22:30:34.908Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Quest for Insights</strong></h3><p>If there’s one word that defined my 2024, it was <strong>“insight”</strong>. Every senior leader I worked with — whether internally or on the client side — was focused on uncovering insights. The goal was always the same: to <strong>extract meaningful, actionable intelligence from various sources of text information</strong>.</p><p>For years, organizations have relied on established techniques like sentiment analysis and keyword extraction to sift through text data. But as the volume of unstructured text continues to grow, these methods are no longer enough. The post-ChatGPT AI boom has <strong>changed how we analyze unstructured data and has</strong> <strong>redefined what’s possible when it comes to extracting value from it</strong>.</p><h3><strong>1. The Rise of Unstructured Data</strong></h3><p><strong>Unstructured data is everywhere</strong>. It’s the free-form text in emails, product reviews on Amazon, images uploaded to Instagram, videos captured on smartphones — basically, any information that doesn’t conform to a predefined data model.</p><p>Structured data, in contrast, is organized by a predefined schema. Each field is defined with labels, type definitions, and a consistent tabular format — such as a CSV where every column has a specific purpose and follows strict rules. This organization makes structured data easy for machines to process and analyze.</p><p>However, althrough structured data is easier to handle for when it comes to analytics,<strong> unstructured data has grown to dominate the digital data landscape</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/0*SXzsu2AmTiOt-SIK.png" /><figcaption>Image by <a href="https://seekingalpha.com/article/4317681-mongodb-riding-the-data-wave">Richard Durant</a> from <a href="https://seekingalpha.com/article/4317681-mongodb-riding-the-data-wave">Seeking Alpha</a></figcaption></figure><blockquote>As of 2020 — Unstructured data is over 80% of all enterprise data, while 95% of businesses prioritize unstructured data management.</blockquote><p>This shift has reshaped the data landscape, <strong>presenting both opportunities and challenges for organizations</strong>. Unstructured data holds immense value — it’s where businesses can uncover insights that drive decisions if they can make sense of the data. For example:</p><ul><li>Product reviews can point to features customers love (or don’t)</li><li>Employee surveys can inform HR policies</li><li>Customer service feedback can guide agent coaching opportunities</li></ul><p>These are just a few of the many ways unstructured data can be used to unlock growth — whether by <strong>driving revenue or improving operational efficiency</strong>.</p><h3><strong>2. The Challenges of Unstructured Data</strong></h3><p>Despite its potential, working with unstructured data comes with significant challenges. <strong>The variety of data types makes it difficult to apply a universal approach</strong>. Text data requires extensive preprocessing due to things like typos, slang, acronyms. Images can have quality issues, and audio files often include background noise or unclear recordings.</p><p>Unstructured data is also frequently siloed across platforms, making it <strong>difficult to bring everything together for analytics</strong>. These obstacles mean that unlocking its value requires more than just advanced AI tools. It takes well-designed workflows to clean, organize, and prepare the data — critical steps for uncovering actionable insights.</p><h3>3. LLM Superpowers and Their Limits</h3><p>The post-ChatGPT era has highlighted the incredible potential of large language models (LLMs) in tackling unstructured data. LLMs excel at processing text, and multimodal models take this further by handling images &amp; audio in addition to text. They thrive in tasks like information extraction, summarization, and question answering, making them invaluable for addressing the complexities of unstructured data.</p><p>In just two years, advancements in the LLMs space have been remarkable. Context windows have increased by &gt; 20x, enabling analysis of lengthy documents or large datasets in a single pass. Some even allow direct file attachments, simplifying workflows and making these tools more user-friendly than ever before.</p><p>However, while LLMs offer immense potential, they come with limitations. Their performance heavily depends on the quality of input and instructions provided by the user — often known as the <em>prompt</em>. <strong>Feeding them large volumes of unstructured text without clear task guidance often results in subpar outcomes</strong>. LLMs can struggle with performing complex tasks in one shot, especially when the problem requires a nuanced understanding or involves processing extremely large datasets.</p><p>This is where <strong>task decomposition becomes critical</strong>. By breaking down complex workflows into smaller, manageable subtasks, LLMs can be integrated into workflows as highly effective components, rather than standalone solutions. Task decomposition not only reduces computational burdens but also <strong>improves resource efficiency, enabling models to process smaller, more focused inputs. </strong>This “divide and conquer” approach mirrors how humans simplify complicated tasks by breaking them into parts.</p><blockquote>This simplification of complicated tasks is a remarkable human ability, evident in the decomposition of one task into several simpler sub-tasks, which is analogous to the well-known algorithmic strategy called “divide and conquer Schraagen et al., 2000]”</blockquote><h3>4. Why ChatGPT Alone Isn’t Enough for Large-Scale Tasks</h3><p>One common question that arises when discussing the use of LLMs for business tasks is: “Why can’t we just use the ChatGPT to analyze our data?” To address this, I wanted to <strong>illustrate the limitations of using ChatGPT for large-scale, unstructured analysis</strong>.</p><p>Let’s assume I’m a clothing merchant looking to understand what customers are saying about my products. Using a dataset of clothing reviews from Kaggle, <strong>my goal was to uncover actionable insights from the perspecitve of the merchant — what type of clothes do customers like, what don’t they like and why, knowing this information will inform how to adjust future product launches all centered around the customer feedback</strong>. While ChatGPT is a powerful tool, relying on the chat interface alone for this type of analysis is often impractical for several reasons:</p><ul><li>It doesn’t scale well for large datasets.</li><li>It can’t integrate into workflows that require automation or handle sensitive data (e.g., reviews containing PII).</li></ul><p>To demonstrate these limitations, I uploaded a CSV file with ~23,000 customer reviews into ChatGPT and provided the following detailed instructions to 4o:</p><pre>You are an expert in organizing and analyzing product reviews. I will upload a CSV file containing reviews on various clothing products. Each review consists of a textual description of a customer&#39;s feedback. Your task is to:<br><br>Group similar reviews together based on common themes, sentiments, or topics.<br>Provide the following outputs:<br>Total number of groups identified.<br>A count of how many reviews are in each group.<br>A brief description (2-3 sentences) for each group that summarizes the shared themes, sentiment, or content of the reviews in that group.<br>Requirements:<br>Groups should focus on identifying meaningful patterns, such as recurring issues, positive highlights, or shared sentiments.<br>Avoid generic groupings like &quot;miscellaneous&quot; unless absolutely necessary.<br>Ensure the descriptions are concise, clear, and representative of the grouped reviews.<br>Input example:<br><br>The CSV file will contain a column labeled review_text with textual feedback.<br>Output example:<br><br>Total Groups: 5<br>Group 1: 120 reviews – Description: Customers praise the softness and comfort of the fabric, particularly for winter wear.<br>Group 2: 85 reviews – Description: Complaints about sizing issues, with many mentioning the product runs smaller than expected.<br>...<br><br>Do you understand the task? If so, please group the reviews in the uploaded CSV file and return the results.</pre><p>The aim here was not to “test” whether ChatGPT could do the job — it was to illustrate why relying solely on the chat interface for tasks like this is often unrealistic, as shown in the initial response below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FhOTn-fivgO_reuMRNXOdQ.png" /></figure><p>I prompted to proceed with the third option of streamlined clustering to complete the task. Below is final response I received:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1gj0_24YkVa_VjXxu2RTzg.png" /></figure><p>Despite providing an example input and output format to streamline the task, the execution fell short for several reasons:</p><ol><li><strong>Dataset Size:</strong> ChatGPT struggled with the sheer volume of data, leading to timeouts and incomplete analyses.</li><li><strong>Environment Constraints:</strong> The code interpreter lacked necessary Python packages, such as NLTK, and faced computational limitations during clustering operations.</li><li><strong>Simplified Outputs:</strong> To manage resource limitations, ChatGPT reduced the complexity of clustering, grouping reviews into only five clusters. It relied on TF-IDF to identify representative keywords but failed to capture the nuanced groupings described in the prompt</li></ol><p>This case study highlights the <strong>practical challenges</strong> of relying on an LLM’s chat interface for large-scale, unstructured data tasks. While ChatGPT is capable of delivering structured outputs in smaller or simpler contexts, it falls short when scalability, computational power, or nuanced understanding is required. For a more robust solution, <strong>businesses need workflows that can handle the full scope of the task, leveraging LLMs in conjunction with more scalable and specialized tools</strong>.</p><h3>5. BERTopic + LLMs: Traditional ML methods meet Generative AI</h3><p>One of my go-to methods combines traditional machine learning techniques with the enhanced capabilities of LLMs. It feels like traditional ML often gets overlooked in favor of newer, flashier AI tools, but it’s still incredibly effective for tasks like this.</p><p>The first component of this approach is topic modeling — a classic machine learning task for working with unstructured data. However, I use the <strong>revitalized methodology of BERTopic</strong>, a package created by Maarten Grootendorst who also authored <a href="https://www.amazon.com/Hands-Large-Language-Models-Understanding/dp/1098150961/ref=sr_1_1?dib=eyJ2IjoiMSJ9.1MUa46N8Y9QCki_IGnTl1T74Har-XhvVDPrysPvNR92nsYyi34b57CxjhRwJxtT_31ijjKnZXuhhoivedgpQuSfkbTh6FaqBpb6n7mC9RuW2sLQzFN0r962p5yyIQuWXJuPw16k65OUXg5r-RaUkBbazDQG1NFVhaVRt70CTNWgekW48Re4VLenrkZB4XTU3C3_Uou5YKVmE4GqpwS9pqMLfrLsFYhUZ93jmKsBtAl0.fOG-QRqQWi2uZ7u4VBoQ_XalrkGiRUtPcH2-Lk26Kec&amp;dib_tag=se&amp;hvadid=680640551436&amp;hvdev=c&amp;hvlocphy=9197851&amp;hvnetw=g&amp;hvqmt=e&amp;hvrand=8971381609895961553&amp;hvtargid=kwd-2098329602793&amp;hydadcr=19108_13375724&amp;keywords=hands+on+large+language+models&amp;qid=1737859595&amp;sr=8-1"><strong><em>Hands-On Large Language Models</em></strong></a>, an excellent resource for anyone looking to learn more about the LLMs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*1Mrbo-bzQzL3wg5BjoTzrQ.jpeg" /><figcaption>Image by <a href="https://maartengr.github.io/BERTopic/algorithm/algorithm.html">Maarten Grootendorst</a> from <a href="https://maartengr.github.io/BERTopic/algorithm/algorithm.html">Github</a></figcaption></figure><p>BERTopic leverages BERT embeddings to create dense, contextual representations of text, allowing for semantically meaningful clusters. Unlike traditional clustering methods like KMeans, which require specifying the number of clusters and force outliers into groups, BERTopic uses HDBSCAN (Hierarchical Density-Based Spatial Clustering). This allows the model to <strong>automatically determine the number of clusters and handle outliers more effectively</strong>, making it a flexible and powerful tool for text analysis.</p><p>Additionally, BERTopic provides the ability to <strong>refine the keywords that define each cluster</strong>. By omitting common stopwords and generic terms like “fit” or “clothing,” I was able to focus on more diverse and representative words for each cluster. This added level of customization improves the interpretability and quality of the clusters.</p><p><strong>Generating Detailed Themes with LLMs</strong><br>Once the clusters are created, I use LLMs to generate rich, contextual insights for each group. For this step, I pass the <strong>keywords and 100 randomly selected reviews from each cluster into the LLM</strong>. The model then generates a topic title and a concise description for each cluster. By combining the <strong>clustering capabilities of BERTopic with the interpretative strengths of LLMs, I can synthesize highly detailed themes that are both granular and actionable</strong>. The final outputs are consolidated into a markdown report for easy sharing and analysis.</p><h3>6. Applying the Methodology: Insights from a 23K Clothing Review Dataset</h3><p>I applied this methodology to the same 23k clothing review dataset to uncover insights on products. The first step was to filter the dataset into two subsets: high-rated reviews and low-rated reviews. This <strong>allowed me to analyze features that customers loved and identify areas needing improvement</strong> for different clothing items.</p><p>Next, I clustered the reviews using BERTopic, experimenting with hyperparameters to achieve an optimal number of clusters. Adjusting parameters such as min_samples and min_cluster_size helped refine the granularity of the clusters, striking a balance between smaller, focused groups and broader themes. The resulting clusters provided clear groupings of the more negative reviews, shown in the dataframe below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HjkA19NEuEogPAAF6SZAfA.png" /></figure><p>BERTopic also provides <strong>built-in visualizations</strong>, including reduced-dimensionality plots that display the embeddings in a visual manner. This visualization not only helps <strong>validate the coherence of the clusters but also provides a clear overview of how reviews are distributed across themes</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygsZfr8Cbl4tdgy5m__o4w.png" /></figure><p>The outputs from the clustering were the inputs for the LLM prompt. For each cluster, I structured a prompt that included:</p><ul><li><strong>Cluster Keywords</strong>: A list of the most representative words for the cluster.</li><li><strong>Random Review Samples</strong>: 100 reviews selected from the cluster to give the LLM context.</li></ul><p>The prompt states for the LLM to generate a topic title for a given cluster, description and areas of improvement, focusing on key insights and actionable feedback for product improvement.</p><pre>Your task is to analyze customer feedback to help a clothing retailer understand key topics and improve their products. Focus on identifying specific clothing items and their standout features, summarizing the overall customer sentiment, and recommending precise, actionable areas for improvement based on the feedback provided.<br><br>You will be provided with:<br><br>A list of example customer reviews (all 4- and 5-star ratings).<br>A set of keywords associated with the topic.<br>The output must strictly follow this JSON format:<br><br>{<br>    &quot;title&quot;: &quot;[Specific and descriptive title]&quot;,<br>    &quot;description&quot;: &quot;[Concise summary of the topic, including strengths and customer highlights]&quot;,<br>    &quot;areas_for_improvement&quot;: &quot;[Actionable insights for product improvement based on customer feedback. Be as specific as possible, such as what additional sizes, colors, or features are needed, or how certain aspects of the product should be changed.]&quot;<br>}<br><br>Important Guidelines:<br><br>Avoid generic terms like &#39;clothing&#39; or &#39;fit&#39; in the title and description.<br>Summarize the feedback in 2–3 sentences, focusing on specific strengths and customer highlights (e.g., fabric quality, design, color).<br>When suggesting areas for improvement, be specific and actionable. For example, instead of saying &#39;add more size options,&#39; specify what sizes customers are asking for (e.g., &#39;include petite and plus sizes&#39;). If durability is a concern, specify how (e.g., &#39;use double stitching or reinforce seams to prevent wear after multiple washes&#39;)</pre><p>By leveraging the cluster-specific keywords and representative review samples, the LLM produced detailed outputs that captured the essence of each group. These results were then consolidated into a markdown file. Below are some examples of outputs produced:</p><ol><li><strong>Improvement Needed in Activewear Comfort and Sizing Variety</strong>:<br>Customers frequently mention the Comfort Flex Yoga Pants for their soft material and flexibility, but many feel they run small and lack size variety. The vibrant colors received praise, yet several users reported that the stitching unraveled after a few washes, detracting from overall satisfaction.</li></ol><p><strong>Why this is helpful</strong>: This feedback enables merchants to prioritize changes that will directly improve customer satisfaction, such as expanding sizing options to be more inclusive and reinforcing product durability. These adjustments can reduce returns and build loyalty among diverse customer groups.</p><ol><li><strong>Customer Feedback on High-Waisted Jeans</strong>:<br>Customers appreciate the high-waisted jeans for their flattering silhouette and comfortable stretch fabric. However, many reviews indicate sizing inconsistencies, with some finding the jeans too tight around the thighs while being loose at the waist, impacting overall wearability.</li></ol><p><strong>Why this is helpful</strong>: Merchants can address sizing inconsistencies by implementing a more standardized sizing guide and exploring half sizes, which will enhance the fit for a broader customer base. Additionally, expanding the color range caters to customer demands for variety, potentially boosting sales.</p><p>This two-step process demonstrates a <strong>scalable approach to unstructured data analysis</strong>. By leveraging BERTopic’s clustering capabilities and the contextual power of LLMs, I was able to <strong>distill thousands of unstructured reviews into clear, actionable insights for future clothing improvements</strong>. Businesses can adopt similar workflows to gain deeper insights into customer feedback, optimize products, and inform data-driven decision-making at scale.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe1df45adfb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synthetic Data Generation with LLMs]]></title>
            <link>https://medium.com/@netraranga/synthetic-data-generation-with-llms-076f40cd947d?source=rss-17103d483e0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/076f40cd947d</guid>
            <category><![CDATA[synthetic-data]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Nethra Ranganathan]]></dc:creator>
            <pubDate>Thu, 26 Dec 2024 04:56:45 GMT</pubDate>
            <atom:updated>2025-02-03T22:35:08.903Z</atom:updated>
            <content:encoded><![CDATA[<h3>Popularity of RAG</h3><p>Over the past two years while working with financial firms, I’ve observed firsthand how they identify and prioritize Generative AI use cases, balancing complexity with potential value.</p><p><strong>Retrieval-Augmented Generation</strong> (RAG) often stands out as a foundational capability across many LLM-driven solutions, striking a balance between ease of implementation and real-world impact. By combining a <strong>retriever</strong> that surfaces relevant documents with an <strong>LLM</strong> that synthesizes responses, RAG <strong>streamlines knowledge access</strong>, making it invaluable for applications like customer support, research, and internal knowledge management.</p><p>Defining clear evaluation criteria is key to ensuring LLM solutions meet performance standards, just as Test-Driven Development (TDD) ensures reliability in traditional software. <strong>Drawing from TDD principles, an evaluation-driven approach sets measurable benchmarks to validate and improve AI workflows</strong>. This becomes especially important for LLMs, where the complexity of open-ended responses demands consistent and thoughtful evaluation to deliver reliable results.</p><p>For RAG applications, a typical evaluation set includes representative input-output pairs that align with the intended use case. For example, in chatbot applications, this might involve Q&amp;A pairs reflecting user inquiries. In other contexts, such as retrieving and summarizing relevant text, the evaluation set could include source documents alongside expected summaries or extracted key points. These pairs are often generated from a subset of documents, such as those that are most viewed or frequently accessed, ensuring the evaluation focuses on the most relevant content.</p><h3><strong>Key Challenges</strong></h3><p>Creating evaluation datasets for RAG systems has traditionally faced two major challenges.</p><ol><li>The process often relied on subject matter experts (SMEs) to manually review documents and generate Q&amp;A pairs, making it <strong>time-intensive, inconsistent, and costly</strong>.</li><li>Limitations preventing LLMs from processing visual elements within documents, such as tables or diagrams, as they are restricted to handling text. <strong>Standard OCR tools struggle to bridge this gap</strong>, often failing to extract meaningful information from non-textual content.</li></ol><h3>Multi-Modal Capabilities</h3><p>The challenges of handling complex documents have evolved with the introduction of multimodal capabilities in foundation models. Commercial and open-source models can now <strong>process both text and visual content</strong>. This vision capability eliminates the need for separate text-extraction workflows, offering an integrated approach for handling mixed-media PDFs.</p><p>By leveraging these vision features, <strong>models can ingest entire pages at once, recognizing layout structures, chart labels, and table content</strong>. This not only reduces manual effort but also improves scalability and data quality, making it a powerful enabler for RAG workflows that rely on accurate information from a variety of sources.</p><h3>Dataset Curation for Wealth Management Research Report</h3><p>To demonstrate a solution to the problem of manual evaluation set generation, I tested my approach using a sample document — the 2023 Cerulli report. <strong>This type of document is typical in wealth management, where analyst-style reports often combine text with complex visuals</strong>. For a RAG-powered search assistant, a knowledge corpus like this would likely contain many such documents.</p><p>My goal was to <strong>demonstrate how a single document could be leveraged to generate Q&amp;A pairs, incorporating both text and visual elements</strong>. While I didn’t define specific dimensions for the Q&amp;A pairs in this test, a real-world implementation would involve providing details on types of questions (comparative, analysis, multiple choice), topics (investment strategies, account types), and many other aspects. The primary focus of this experiment was to ensure the LLM generated questions that incorporated visual elements and produced reliable answers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Euv7imyg9AQrjJyUKUZ7pA.png" /><figcaption>POC Workflow</figcaption></figure><p>My workflow, illustrated in the diagram, leverages Anthropic’s Claude Sonnet 3.5 model, which simplifies the process of working with PDFs by handling the conversion of documents into images before passing them to the model. This <strong>built-in functionality eliminates the need for additional third-party dependencies, streamlining the workflow and reducing code complexity</strong>.</p><p>I excluded preliminary pages of the report like the table of contents and glossary, focusing on pages with relevant content and charts for generating Q&amp;A pairs. Below is the prompt I used to generate the initial question-answer sets.</p><pre>You are an expert at analyzing financial reports and generating question-answer pairs. For the provided PDF, the 2023 Cerulli report:<br><br>1. Analyze pages {start_idx} to {end_idx} and for **each** of those 10 pages:<br>   - Identify the **exact page title** as it appears on that page (e.g., &quot;Exhibit 4.03 Core Market Databank, 2023&quot;).<br>   - If the page includes a chart, graph, or diagram, create a question that references that visual element. Otherwise, create a question about the textual content.<br>   - Generate two distinct answers to that question (&quot;answer_1&quot; and &quot;answer_2&quot;), both supported by the page’s content.<br>   - Identify the correct page number as indicated in the bottom left corner of the page.<br>2. Return exactly 10 results as a valid JSON array (a list of dictionaries). Each dictionary should have the keys: “page” (int), “page_title” (str), “question” (str), “answer_1” (str), and “answer_2” (str). The page title typically includes the word &quot;Exhibit&quot; followed by a number.</pre><h3><strong>Q&amp;A Pair Generation</strong></h3><p>To refine the Q&amp;A generation process, I implemented a <strong>comparative learning approach</strong> that generates two distinct answers for each question. During the evaluation phase, these answers are assessed across key dimensions such as accuracy and clarity, with the stronger response selected as the final answer.</p><p>This approach mirrors how humans often find it easier to make decisions when comparing alternatives rather than evaluating something in isolation. It’s like an eye examination: the optometrist doesn’t ask if your vision has improved or declined but instead, presents two lenses and asks, Which is clearer, option 1 or option 2? This comparative process <strong>eliminates the ambiguity of assessing absolute improvement and focuses on relative differences</strong>, making the choice simpler and more actionable. Similarly, by presenting two concrete answer options, the system can more effectively evaluate which response is stronger.</p><p>This methodology is also cited as a best practice in the article <a href="https://www.oreilly.com/radar/what-we-learned-from-a-year-of-building-with-llms-part-i/">“What We Learned from a Year of Building with LLMs”</a> by leaders in the AI space. They highlight the value of pairwise comparisons, stating: <em>“</em><strong><em>Instead of asking the LLM to score a single output on a Likert scale, present it with two options and ask it to select the better one. This tends to lead to more stable results</em></strong><em>.”</em> I highly recommend reading their three-part series, as it provides invaluable insights into building effective systems with LLMs!</p><h3>LLM Evaluation</h3><p>For evaluating the generated Q&amp;A pairs, I used Claude Opus for its advanced reasoning capabilities. Acting as a “judge,” <strong>the LLM compared the two answers generated for each question and selected the better option based on criteria such as directness and clarity.</strong> This approach is supported by extensive research (Zheng et al., 2023) that showcases LLMs can perform evaluations on par with human reviewers.</p><p>This approach <strong>significantly reduces the amount of manual review required by SMEs</strong>, enabling a more scalable and efficient refinement process. While SMEs remain essential during the initial stages to spot-check questions and validate system outputs, this dependency diminishes over time. Once a sufficient level of confidence is established in the system’s performance, the need for frequent spot-checking is reduced, allowing SMEs to focus on higher-value tasks.</p><h3>Lessons Learned</h3><p>Claude’s PDF capability has a limit of 100 pages, so I broke the original document into four 50-page sections. When I tried processing each 50-page section in a single request — and explicitly instructed the model to generate one Q&amp;A pair per page — it still missed some pages. The token limit wasn’t the real problem; the model tended to focus on whichever content it considered most relevant, leaving certain pages underrepresented.</p><p>To address this, I experimented with processing the document in smaller batches, testing 5, 10, and 20 pages at a time. Through these tests, I found that batches of 10 pages (e.g., pages 1–10, 11–20, etc.) provided the best balance between precision and efficiency. Processing 10 pages per batch ensured consistent results across all pages while optimizing performance.</p><p>Another challenge was linking Q&amp;A pairs back to their source. Using tiny page numbers in a PDF’s footer alone didn’t consistently work. In contrast, page titles or clear headings at the top of each page served as reliable anchors. They were easier for the model to pick up and helped me accurately map each Q&amp;A pair to the right section.</p><h3>Example Output</h3><p>Below is an example page from the report, featuring two tables with numerical data. The following question was generated for this page:<br><strong>How has the distribution of AUM changed across different-sized Hybrid RIA firms?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V0wQe6grIZh7ohPSnFHt3w.png" /></figure><p><strong>Answer</strong>: Mid-sized firms ($25m to &lt;$100m) experienced a decline in AUM share from 2.3% to 1.0%.</p><p>In the first table, the 2017 column shows a 2.3% share of AUM for mid-sized firms, which decreases to 1.0% in 2022, thereby showcasing the LLM’s ability to synthesize visual and tabular content accurately.</p><h3>Benefits</h3><p>Combining caching, batching and a refined Q&amp;A workflow led to three key advantages:</p><p><strong>Caching</strong></p><ul><li>In my experiment, processing a singular report without caching would have cost $9, but by leveraging caching, I reduced this cost to $3 — a <strong>3x cost savings</strong>. Per Anthropic’s pricing model, creating a cache costs $3.75 / million tokens, however, reads from the cache are only $0.30 / million tokens. In contrast, input tokens cost $3 / million tokens when caching is not used.</li><li>In a real-world scenario with more than one document, the savings become even more significant. For example, processing 10,000 research reports of similar length without caching would cost $90,000 in input costs alone. With caching, this cost drops to $30,000, achieving the same precision and quality while saving <strong>$60,000</strong>.</li></ul><p><strong>Discounted Batch Processing</strong></p><ul><li>Using Anthropic’s Batches API cuts output costs in half, making it a much cheaper option for certain tasks. Once I had validated the prompts, I ran a single batch job to evaluate all the Q&amp;A answer sets at once. This method proved far more cost-effective than processing each Q&amp;A pair individually.</li><li>For example, Claude 3 Opus typically costs $15 per million output tokens. By using batching, this drops to $7.50 per million tokens — <strong>a 50% reduction</strong>. In my experiment, each Q&amp;A pair generated an average of 100 tokens, resulting in approximately 20,000 output tokens for the document. At the standard rate, this would have cost $0.30. With batch processing, the cost was reduced to $0.15, highlighitng how this approach optimizes costs for non-sequential tasks like evaluation runs.</li></ul><p><strong>Time Saved for SMEs</strong></p><ul><li>With more accurate, context-rich Q&amp;A pairs, Subject Matter Experts spent less time sifting through PDFs and clarifying details, and more time focusing on strategic insights. This approach also eliminates the need to hire additional staff or allocate internal resources for manually curating datasets, a process that can be time-consuming and expensive. By automating these tasks, companies save significantly on labor costs while streamlining SME workflows, making this a scalable and cost-effective solution</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=076f40cd947d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>