<?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 Ayushg on Medium]]></title>
        <description><![CDATA[Stories by Ayushg on Medium]]></description>
        <link>https://medium.com/@ayushgs?source=rss-2c7dbe499fff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Oh7pvvgqNQF5t4dH</url>
            <title>Stories by Ayushg on Medium</title>
            <link>https://medium.com/@ayushgs?source=rss-2c7dbe499fff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 06 Apr 2026 10:00:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayushgs/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[Classification with GenAI for Enterprises: GPT vs Customized LLMs]]></title>
            <link>https://medium.com/@ayushgs/classification-with-genai-for-enterprises-gpt-vs-customized-llms-3f10d15c5f31?source=rss-2c7dbe499fff------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f10d15c5f31</guid>
            <category><![CDATA[gpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Ayushg]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 09:36:06 GMT</pubDate>
            <atom:updated>2025-04-16T09:36:06.361Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGFzTpKeoiUpTrLvmbFGfw.png" /></figure><h3>Introduction</h3><p>Enterprise applications use classification problems throughout their technology stack. These can include intent detection to route user requests to the right service, product category classification in retail, or document type identification when extracting data from unstructured files. The number of classes in these tasks typically ranges from 10 to 100. During our work with enterprises, we’ve frequently observed that public LLMs like GPT become less effective as the number of classes increases. This experiment aims to validate this performance decline and evaluate whether personalized LLMs provide better results.</p><h3>Objective</h3><p>While public LLMs like OpenAI’s GPT-4o and Claude Sonnet 3.5/3.7 are attractive for their seamless integration, they often underperform in real-world production environments. At scale, these models become prohibitively expensive to use. For example, a marketing technology company processing 2.7M NLP classifications on marketing documents chose to continue using classic NLP models despite GenAI’s accuracy benefits, as OpenAI’s estimated costs would reach $0.5M per month. These models also present challenges in regulated industries like fintech and healthcare due to data privacy concerns, and they typically respond more slowly than lighter, optimized alternatives. A viable alternative is customizing LLMs through fine-tuning smaller open-weight models and embedding business knowledge to achieve accurate classifications.</p><p>Since the privacy and cost advantages of customized LLMs are well established, this experiment focuses on evaluating how classification accuracy changes as the number of classes increases. We also compare the performance of proprietary, general-purpose models against customized, fine-tuned LLMs to determine if domain-specific training provides meaningful advantages.</p><h3>Data Preparation</h3><p>For this experiment, we used an open-source dataset available on Hugging Face: <a href="https://huggingface.co/datasets/gretelai/synthetic_text_to_sql">gretelai/synthetic_text_to_sql</a>. This dataset contains high-quality, synthetic Text-to-SQL samples created using <strong>Gretel Navigator</strong> and spans across 100 distinct domains or verticals, with each vertical containing nearly 900–1000 samples.</p><p>Out of the full dataset, we focused on two key columns:</p><ul><li><strong>domain</strong>: This column includes around 100 unique domain values, which we used as classification labels.</li><li><strong>sql_prompt</strong>: This contains the actual user input. This serves as the input for our classification task.</li></ul><p>To build a meaningful and scalable classification problem, we needed a subset of domains that were closely related. For this, we applied a <strong>clustering-based approach</strong>:</p><ol><li>We embedded the sql_prompt texts using a Sentence Transformer model—<strong>&quot;all-MiniLM-L6-v2&quot;</strong>, an open-source, lightweight model suitable for semantic understanding.</li><li>We then applied <strong>K-Means clustering</strong> with n_clusters=3 on the embedded representations to group similar domains based on prompt semantics.</li><li>From the resulting clusters, we selected one cluster containing 58 domains with strong semantic overlap. After manually reviewing the cluster, we removed 8 loosely connected classes to finalize a set of <strong>50 well-aligned classes</strong> for our experiments.</li></ol><p>Using this refined group, we created benchmark datasets with varying numbers of classes specifically 5, 10, 20, 25, and 50. For each class count, we sampled <strong>10 examples per class</strong>. This means the dataset size scaled as follows:</p><ul><li>5 classes → 50 samples</li><li>10 classes → 100 samples</li><li>20 classes → 200 samples</li></ul><p>and so on.</p><p>Importantly, we ensured <strong>class continuity across groups. T</strong>he classes included in the 5-class set are also part of the 10-class set, and so forth. This approach helps maintain the experimental integrity and allows us to reliably assess the impact of increasing class diversity on model performance.</p><p>The data, excluding the benchmark samples for each of the selected classes, was used to prepare the training dataset. Since each class had around 1,000 examples, we created a total training set of around 40,000 samples to fine-tune the Llama model and compare its performance against the GPT model.</p><h3>GPT-4o Evaluation</h3><p>Using benchmark datasets with varying class sizes, we crafted a clear and consistent prompt format to evaluate GPT-4o’s classification performance. The prompt provided unambiguous instructions for the model to select the most appropriate domain from a provided list of domain names for a given SQL-related question. We structured the output as a simple JSON format to ensure reliable evaluation.</p><p>Here’s an example of the prompt structure:</p><pre>Given a domain list: [&#39;forestry&#39;, &#39;marine biology&#39;, &#39;aquaculture&#39;, &#39;agriculture&#39;, &#39;wildlife conservation&#39;], select the most appropriate domain for the provided question. Your response should be a JSON with the &quot;domain&quot; key containing the domain name and nothing else.<br><br>Sample Format:<br>Sample Question: Find the latest movie which &quot;Gabriele Ferzetti&quot; acted in.<br>Response: {&quot;domain&quot;: &quot;imdb&quot;}<br><br>Now, process the following question accordingly.<br>Question: {{question}}</pre><p>For each benchmark dataset (with 5, 10, 20, 25, and 50 classes), the corresponding list of domains in the prompt was updated to match the set of classes used. The same structure was maintained across all experiments to ensure consistency.</p><p>The results with GPT-4o showed a clear trend: as the number of classes increased, the model’s accuracy in correctly identifying the appropriate domain <strong>decreased beyond use</strong>. This decline highlights the challenge of scaling general-purpose models for fine-grained classification tasks.</p><p>The performance drop is visualized in the graph below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOjmGokzzGAb8ZEacAgCMQ.png" /><figcaption>Fig 1: Accuracy of GPT-4o Model Varying Across Increasing Number of Classes</figcaption></figure><h3>Fine-tuning and Evaluating Meta-Llama-3.1–8B-Instruct</h3><p>In the second experiment, we evaluated how a customized model — <strong>Meta-Llama-3.1–8B-Instruct</strong> — performs when fine-tuned on our domain classification task. We trained this base model first on the dataset with 50 classes, and then applied it to inference with different number of classes.</p><p>We trained three versions of the model, each with a different amount of training data to study impact of training examples on accuracy:</p><ul><li><strong>Model A</strong>: Fine-tuned with 2,000 samples</li><li><strong>Model B</strong>: Fine-tuned with 5,000 samples</li><li><strong>Model C</strong>: Fine-tuned with 40,000 samples</li></ul><p>All models were evaluated using the same benchmark datasets and inference format as in the GPT-4o experiment. This ensured a fair comparison of performance across both approaches.</p><p>The table below summarizes the accuracy scores for GPT-4o and all three fine-tuned models across the benchmark datasets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ag5dVwRoKza9pLTUSgfDeA.png" /><figcaption><em>Table 1: Accuracy Comparison of Various Experiments with Increasing Number of Classes</em></figcaption></figure><p>The following graph presents a visual representation of the accuracy trends highlighted in the comparison table above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phB18_NTitn0II1pFNYI2A.png" /><figcaption>Fig 2: Accuracy Trend Across Varying Class Distributions During Inference</figcaption></figure><p>It can be seen from the graph and the comparison table, the fine-tuned models performed significantly better than general models, and showed consistent competency with increasing number of classes. As expected, <strong>accuracy improved with more training data</strong>. Model C (trained on 40K samples) consistently achieved the highest accuracy across all class groupings (5, 10, 20, 25, 50).</p><p>It can be noted that while we fine-tuned a single model and evaluated it across multiple class groupings, <strong>training separate models for specific class ranges</strong> could potentially yield even higher accuracy.</p><h3>Conclusion</h3><p>Our experiments clearly highlight a key insight: <strong>general-purpose LLMs struggle with accuracy as task complexity increases</strong>, especially in classification problems with a growing number of classes. This limitation becomes critical in enterprise applications where precision drives downstream decisions.</p><p>In contrast, <strong>customized LLMs, fine-tuned on domain-specific data, consistently outperform general models</strong>, making them a more reliable choice for production use. While fine-tuning requires initial development effort, tools like Genloop make this process more accessible and scalable.</p><p>As complexity grows, so does the performance gap, <strong>favoring tailored solutions over generic ones</strong>. For enterprises, the path forward is clear: <strong>invest in quality data and model customization to unlock the true potential of AI in production systems</strong>.</p><h3>About Genloop</h3><p><a href="https://genloop.ai">Genloop</a> delivers customized LLMs that provide unmatched cost, control, simplicity, and performance for production enterprise applications. Please visit <a href="http://genloop.ai/">genloop.ai</a> or email <a href="mailto:founder@genloop.ai">founder@genloop.ai</a> for more details. Schedule a <a href="https://genloop.ai/request-demo">free consultation call</a> with our GenAI experts for personalized guidance and recommendations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGEFKc5gZGfvWmHSU09tww.png" /><figcaption><a href="https://genloop.ai/request-demo">https://genloop.ai/request-demo</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f10d15c5f31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Text to SQL: The Ultimate Guide for 2025]]></title>
            <link>https://medium.com/@ayushgs/text-to-sql-the-ultimate-guide-for-2025-3fa4e78cbdf9?source=rss-2c7dbe499fff------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fa4e78cbdf9</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[text-to-sql]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Ayushg]]></dc:creator>
            <pubDate>Thu, 13 Feb 2025 13:15:40 GMT</pubDate>
            <atom:updated>2025-02-17T14:10:20.341Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cj31SIay6herhM1uUsIVg.png" /></figure><h3>Introduction</h3><p>Data is the backbone of software companies, and SQL is the backbone of data management. Over 80% of the world’s structured data is stored in relational databases, with SQL serving as the primary language for accessing and managing it. Every day, millions of data analysts, data scientists, and developers rely on SQL to query and manipulate data. In essence, SQL acts as a bridge between you and your data.</p><h3>The Challenge and Solution</h3><p>Translating natural language questions into SQL queries is a complex task that often delays insights. This process is particularly difficult for non-technical users, making it hard for them to gather insights and make data-driven decisions. As a result, crucial opportunities are sometimes missed, or decisions are delayed.</p><p>Large Language Models (LLMs) offer a promising solution by automating the generation of SQL queries. By doing so, they help bridge the gap between data and its stakeholders. Text-to-SQL technology has emerged as one of the top three applications of Generative AI since 2023, enabling companies to unlock insights faster and empower a wider range of users to interact with data effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4l1lLwZzXC9Xhx2nMTK92w.png" /><figcaption>A Text-to-SQL example (above), and Evolutionary Process of Text-to-SQL Research (below). Source: <a href="https://arxiv.org/abs/2406.08426">arXiv:2406.08426</a> (Next-Generation Database Interfaces)</figcaption></figure><p>A lot has changed in the space of Generative AI (GenAI) since 2023. There have been significant improvements in both closed and open-weight models, as well as new methods for customizing these models using techniques like fine-tuning with <a href="/637ef12a4ca447ac94c2297211ba6757?pvs=25">QLoRA</a>. In this blog, we will explore how to implement text-to-SQL in 2025. Genloop has been collaborating with enterprise clients on text-to-SQL solutions, and here, we provide a comprehensive guide on the approaches you can try. We will also objectively compare these methods to help you choose the best approach for your needs.</p><h3>Understanding the Basics: Glossary</h3><ul><li><strong>Table Identification</strong>: The process of accurately determining which table(s) should be used to retrieve data for a specific question or query.</li><li><strong>Business Rules</strong>: A set of business knowledge or rules that are relevant to the specific use case. This includes domain knowledge, business formulas, and customer-specific rules.</li><li><strong>Context</strong>: All the information and metadata about the database required to retrieve the necessary data for answering a query. This includes tables, schemas, columns, descriptions, etc.</li><li><strong>SQL Writer</strong>: A module that takes the relevant context and generates an SQL query. This is typically powered by an LLM or an agent.</li><li><strong>SQL Executor</strong>: A module that executes an SQL query and returns the corresponding data. It may also include mechanisms to validate or correct SQL queries.</li><li><strong>SQL Data</strong>: The data is retrieved by executing the SQL query. This is used to prepare a response to the user’s input or question.</li><li><strong>Decorator</strong>: The final module that processes the SQL data and user input to prepare a natural language response. This module often includes an LLM and features like chart creation. In some cases, it may also validate the correctness of the response.</li></ul><h3>Different Approaches to Text to SQL</h3><h3>1. Prompting the Smartest LLM</h3><p>The simplest solution is just to give all the schemas, columns, tables, and table descriptions (collectively called context) to the biggest and smartest model with the hope that it will be smart enough to reason and arrive at the right SQL query. This SQL query when executed gives us the SQL data, which the decorator uses to prepare the final response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WJr-13fG2iH3uZAi6NpDA.png" /><figcaption>Architecture of Text to SQL: Prompting the Smartest LLM</figcaption></figure><p>While this approach requires the LLM to handle significant complexity, it might yield reasonable accuracy for smaller schemas and straightforward queries. However, as schemas grow larger and queries become more complex — as they typically do in real-world production systems — this method often falls short. The context window of the LLM becomes a limiting factor, and such models are expensive, slow, and require transferring sensitive business data to third-party servers.</p><p><strong>Performance Metrics:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vrz6LXeXNh5KqPeRNobE-g.png" /><figcaption>Attribute Scoring: Prompting the Smartest LLM</figcaption></figure><p><strong>Bonus: A Sample Prompt Template</strong></p><pre>### System Prompt Template: SQL Query Generator<br><br>You are a highly intelligent assistant specialized in generating SQL queries. <br>Your role is to analyze the user query and generate a correct and optimized SQL query based on the provided database information. <br>The output should follow standard SQL syntax and consider all constraints, table relationships, and requirements mentioned in the input.<br><br>- --<br><br>#### Inputs Provided<br><br>1. User Query: A natural language description of the data the user wants to retrieve.<br><br>2. Database Information:<br><br>- Tables and Columns: A list of tables with their descriptions and columns.<br><br>- Relationships: Descriptions of relationships between tables (e.g., foreign keys, joins).<br><br>- Sample Data (if available): Example data from tables for context.<br><br>- --<br><br>#### Database Information Format<br><br>Each table is provided as follows:<br><br>- Table Name: `&lt;table_name&gt;`<br>- Description: `&lt;table_description&gt;`<br>- Columns:<br>- `&lt;column_name&gt;`: `&lt;data_type&gt;` (&lt;constraints&gt;)<br>- ...<br><br>#### Instructions for SQL Query Generation<br><br>1. Understand the User Query: Parse the query to identify the intent and required data.<br><br>2. Analyze Table Information: Identify the relevant tables, columns, and relationships needed to construct the query.<br><br>3. Generate the Query:<br><br>- Use appropriate SQL commands (`SELECT`, `INSERT`, `UPDATE`, `DELETE`, etc.).<br><br>- Include filters, joins, grouping, or sorting as needed.<br><br>- Ensure the query adheres to the schema and data types.<br><br>4. Validate Query Structure:<br><br>- Ensure the SQL query is syntactically correct.<br><br>- Optimize for performance by minimizing unnecessary joins and filters.<br><br>5. Output: Return the SQL query as plain text. Provide a brief explanation of the query if needed.</pre><h3>2. RAG with Fast General-Purpose LLMs</h3><p>In the first approach, we just dumped the complete information to an LLM hoping it would figure everything out. The second approach is to fetch only the relevant information through RAG (Retrieval Augmented Generation) techniques, break the problem into simpler tasks, and have those simpler tasks performed in orchestration through relatively faster general-purpose LLMs like <a href="https://platform.openai.com/docs/models#gpt-4o">GPT-4o</a>, <a href="https://www.anthropic.com/news/claude-3-5-sonnet">Claude</a>, <a href="https://www.llama.com/docs/model-cards-and-prompt-formats/llama3_3/">Meta Llama 3.3 70B</a>, <a href="https://api-docs.deepseek.com/news/news1226">DeepSeek-v3</a>, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ruK9DaPIk8Nh0vlUe1FcNQ.png" /><figcaption>Architecture of Text to SQL: RAG with Fast General-Purpose LLMs</figcaption></figure><p>The first step is to select the relevant information from the complete context. This could either be done through vector search-based retrieval, where the question maps to a related canonical question, which further has pre-selected tables, schemas, and examples that can be used. Or, it could be useful to identify the relevant tables through a Table Intent Classification LLM. Once the right tables are selected, the rules and schema governing those tables are collected and supplied as the context for downstream processing.</p><p>After the relevant context is found, a general-purpose LLM is used to generate an SQL query from the given context and query. Since the context is already filtered by RAG, general-purpose LLMs are able to do a better job.</p><p>The process of selecting the best model for this could be iterative. We suggest going with the smarter models prioritizing accuracy (example: gpt-4o). Once satisfied, you can try even smaller models (like GPT-4o-mini) and evaluate their accuracy for your use case on your test set.</p><p><strong>Performance Metrics:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7rxiD5e4-cKBbbqx1mnLw.png" /><figcaption>Attribute Scoring: RAG with Fast General-Purpose LLMs</figcaption></figure><p><strong>Bonus: A Sample Prompt Template for Table Intent LLM</strong></p><pre>### Prompt: Classify Relevant Tables for SQL Query<br><br>You are a highly intelligent assistant specializing in SQL query generation. <br>Your task is to analyze the user query and classify which table(s) from the database should be used to construct the SQL query. <br>Consider the table descriptions and their columns to make your decision.<br><br>- --<br><br>#### Input Format<br><br>- User Query:<br>- A natural language description of the data the user wants to retrieve.<br><br>- Database Information:<br>- A list of tables, their descriptions, and columns.<br><br>----<br>- Example Database:<br><br>1. Table Name: `customers`<br><br>- Description: Contains customer details.<br><br>- Columns:<br><br>- `customer_id`: `int` (Primary Key)<br><br>- `name`: `varchar`<br><br>- `email`: `varchar`<br><br>2. Table Name: `orders`<br><br>- Description: Contains order information, including customer IDs and order dates.<br><br>- Columns:<br><br>- `order_id`: `int` (Primary Key)<br><br>- `customer_id`: `int` (Foreign Key referencing `customers.customer_id`)<br><br>- `order_date`: `date`<br><br>3. Table : `products`<br><br>- Description: Contains product details.<br><br>- Columns:<br><br>- `product_id`: `int` (Primary Key)<br><br>- `name`: `varchar`<br><br>- `price`: `decimal`<br><br>---<br><br>#### Task<br><br>Analyze the user query to determine which table(s) should be used. Consider the following:<br><br>1. Does the user query mention attributes or concepts tied to specific columns or descriptions?<br><br>2. Are multiple tables required due to relationships (e.g., joins)?<br><br>3. Exclude irrelevant tables.<br><br><br>#### Output Format<br>Output the result is a json with keys &#39;tables&#39; (the relevant tables) and &#39;explanation&#39; (brief explanation for why the tables are relevant). Return &#39;NA&#39; if no tables are relevant.</pre><h3>3. Agents with General-Purpose LLMs</h3><p>AI agents are autonomous software systems that perceive their environment and take actions to achieve specific goals. They can operate independently, learn from experience, and make decisions based on their programming and environmental inputs.</p><p>A simple RAG with a general-purpose model cannot recover from errors. This is where agents come to the rescue. A simple agentic system could have 2 agents, a context agent that collects the most relevant context to share. RAG is a simplified implementation of this context agent. The other agent is the SQL agent which uses workers like SQL Writer (LLM) and SQL Executor to produce the RAG-based for generating the response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MscuwCcQ01qSDU8cIJN6Yw.png" /><figcaption>Architecture of Text to SQL: Agents with General-Purpose LLMs</figcaption></figure><p>A real example of such approach is the <a href="https://github.com/GoogleCloudPlatform/Open_Data_QnA">Open Data QnA</a> by Google.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*feoiLpHsp_jRKxujLLVp0A.png" /><figcaption>Open Data QnA Architecture. Source: <a href="https://github.com/GoogleCloudPlatform/Open_Data_QnA">https://github.com/GoogleCloudPlatform/Open_Data_QnA</a></figcaption></figure><p>Such system is able to successfully recover from many mistakes and common syntactical errors because of the agentic planning and interaction. The query enhancement step also gets better since the agents are better able to follow the business rules due to the multi-step nature of the system as opposed to a single-shot nature of the RAG approach.</p><p>However, this approach takes longer to get the response. The increase in accuracy in this approach comes at the expense of cost and latency. This is because the models have not become smarter or better but essentially the agentic nature gave the system more steps and time to get to the answer and also correct itself from the errors.</p><p><strong>Performance Metrics:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VT8C9fqtEL69NA2ekzRobQ.png" /><figcaption>Attribute Scoring: Agents with General-Purpose LLMs</figcaption></figure><p><strong>Bonus</strong><em>:</em></p><p><em>Various tools help simplify agent building and execution. </em><a href="https://github.com/microsoft/autogen"><em>AutoGen</em></a><em>, </em><a href="https://github.com/openai/swarm"><em>OpenAI Swarm</em></a><em>, </em><a href="https://ai.pydantic.dev/"><em>Pydantic AI</em></a><em>, and </em><a href="https://www.crewai.com/"><em>Crew AI</em></a><em> are some frameworks to get started with agentic workflows</em>.</p><h3>4. Customized Contextual LLMs</h3><p>While the previous approaches can typically deliver 70–85% accuracy, customizing large language models (LLMs) to build personalized contextual models can help you push beyond that threshold. If you’re experiencing challenges with any of the attributes mentioned above or need more tailored results, this approach is your best bet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_0ApSvQL2Lxa0RPJ5-9Jg.png" /><figcaption>Architecture of Text to SQL: Customized Contextual LLMs</figcaption></figure><p>The approach is to fine-tune open-weight models such as Llama, Mistral, and Qwen, tailoring them to better understand the business and domain-specific needs.</p><p>Here’s how it works: when a user query comes in, the first customized LLM is responsible for establishing the correct context for downstream tasks. It not only understands the user query but also identifies relevant data tables and devises an execution plan. This plan is then passed to the SQL Writer LLM, which generates a query specific to your domain, accounting for business rules such as how growth is calculated or the formulas used for quarterly sales. Afterward, the SQL data is processed by the Decorator LLM and returned as a response. Since the entire execution is highly contextual, it rarely needs any error recovery.</p><p>By adopting this model, enterprises gain full ownership of their AI, enjoying unmatched cost-effectiveness, control, and performance. With ownership, the model can be deployed behind the company’s firewall, ensuring complete data security. Moreover, because the model is fine-tuned for the business, it delivers unparalleled accuracy. The smaller size of these models also means they require a much faster path to response — up to 250x quicker than general LLMs — resulting in the fastest response times.</p><p>This approach has proven highly effective in our enterprise engagements. We will dive deeper into the benefits and workflow details in an upcoming blog post. However, it’s important to note that while this approach offers exceptional value, it requires a significant effort in development effort to build, scale, and maintain these LLMs.</p><p><strong>Performance Metrics:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X6bV0kYPTWIl5bIp8STnuQ.png" /><figcaption>Attribute Scoring: Customized Contextual LLMs</figcaption></figure><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qo0XNVbsMULQYHI3J09UuA.png" /><figcaption>Final Comparison Table of All Approaches</figcaption></figure><p>If you have a straightforward use case, a RAG-based general model might suffice. However, for use cases with significant scale — where rental AI costs skyrocket — or if you require the highest accuracy standards or have privacy concerns, <strong>Approach 4: Customized Contextual Models</strong> is essential. Make an informed decision using the <a href="https://genloop.ai/should-you-fine-tune">Should I Fine-Tune</a> tool.</p><h3>About Genloop</h3><p><a href="https://genloop.ai">Genloop</a> delivers customized LLMs that provide unmatched cost, control, simplicity, and performance for production enterprise applications. Please visit <a href="http://genloop.ai/">genloop.ai</a> or email <a href="mailto:founder@genloop.ai">founder@genloop.ai</a> for more details. Schedule a <a href="https://genloop.ai/request-demo">free consultation call</a> with our GenAI experts for personalized guidance and recommendations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NJ8oe33YvQhZfokWB-o_AQ.png" /><figcaption><a href="https://genloop.ai/request-demo">https://genloop.ai/request-demo</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fa4e78cbdf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>