<?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 Lorenzo Colone on Medium]]></title>
        <description><![CDATA[Stories by Lorenzo Colone on Medium]]></description>
        <link>https://medium.com/@lorenzo.colone?source=rss-285452f1b08------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1O1r02Qn_lkP3nfJAal_aA.jpeg</url>
            <title>Stories by Lorenzo Colone on Medium</title>
            <link>https://medium.com/@lorenzo.colone?source=rss-285452f1b08------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:41:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lorenzo.colone/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[An approach for leveraging enterprise metadata in RAG applications]]></title>
            <link>https://medium.com/article-rag/an-approach-for-leveraging-enterprise-metadata-in-rag-applications-1ba7520941ae?source=rss-285452f1b08------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ba7520941ae</guid>
            <category><![CDATA[fuzzy-matching]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[knowledge-mining]]></category>
            <dc:creator><![CDATA[Lorenzo Colone]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 13:33:55 GMT</pubDate>
            <atom:updated>2025-04-04T13:33:55.163Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Authored by </em><a href="https://www.linkedin.com/in/josh-betts/"><em>Josh Betts</em></a><em> and </em><a href="https://www.linkedin.com/in/lorenzocolone/"><em>Lorenzo Colone</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44_oGubHWlzvlHmcXbXcuw.png" /><figcaption>Image AI-generated (<a href="https://www.copilot.microsoft.com/">Microsoft Copilot</a>)</figcaption></figure><h3><strong>Abstract</strong></h3><p>In this article, we’ll show why relying solely on semantic or hybrid search in a RAG (Retrieval Augmented Generation) system can sometimes lead to inaccurate or overly broad results — especially in specialized domains. We’ll explain how applying metadata filtering can significantly improve the precision of search results, helping your AI system retrieve exactly what the user needs, without confusion or noise.</p><h3><strong>Introduction</strong></h3><p>A successful RAG pipeline doesn’t only depend on how well it can semantically understand a query — it also depends heavily on how the underlying data is prepared and filtered. While techniques like semantic search (using vector embeddings and similarity scores) and hybrid search (combining vector and keyword search) are effective in surfacing related content, they often fall short when precision is critical.</p><p>This is particularly true in domains where small differences in language matter — for example, in healthcare, legal, or regulatory environments, where one term can change the entire context.</p><p>Take this example:</p><blockquote>A medical professional queries an AI assistant with “What are the latest treatments for Type 1 Diabetes in children?”. A standard hybrid search might return articles about diabetes in general or information about Type 2 Diabetes treatments, because the keywords “diabetes” and “treatment” appear in those documents and semantically overlap. However, these results are not specific enough and may include irrelevant or even misleading information.</blockquote><p>This is where metadata filtering becomes essential. By tagging documents in the index with clear metadata fields — such as disease type, patient age group, publication date, or source credibility — you can apply filters during search to exclude irrelevant content before retrieval even happens. In our example, by filtering on metadata like disease_type = Type 1 Diabetes and patient_group = children, the search will return only documents that match the exact context of the query, reducing noise and ensuring the LLM is working with the most relevant and accurate information.</p><p>In summary, while semantic and hybrid search improve recall by finding semantically related content, metadata filtering is the key to improving precision — helping your AI system answer questions more accurately and reliably, especially when the stakes are high.</p><p>We’ll explore one way of dealing with this issue that is currently serving a production solution for a manufacturing company operating in a B2B market. This solution opens up for exploring new ideas and inspire other practitioners.</p><h3><strong>Problem description</strong></h3><p><a href="https://www.alfalaval.com/">Alfa Laval</a> is a manufacturer of high-end equipment within fluid handling, separation and heat transfer technologies. Their product portfolio comprises thousands of items with global coverage of sale and services coordinated by sales distributors and channel partners.</p><p>Customer inquires are typically handled by internal experts, often facing challenges such as limited capacity, uneven knowledge distribution and different level of experience. In the AI team we pursued the idea to start leveraging valuable internal know-how to assist with product related questions, both to improve internal efficiency and customer satisfaction.</p><p>A surprising factor that emerged from an initial proof-of-concept was the lack of relevance on product-specific inquires, according to the feedback received by internal reviewers. After investigation, we found that irrelevant context injected into the LLM caused confusion between product properties and functionalities, leading to hallucinations and misleading conclusions.</p><p>In order to ensure optimal relevance, we proposed a methodology to pre-select (filter) the search space only to the entities of interest, before performing hybrid search and reranking. The entities of interest are in this case product names, which are typically mentioned in a user query. An additional challenge to overcome was the diverse product denomination and grammatical variations due to natural language, making it even harder to identify the product of interest and narrow down the search.</p><blockquote>An example of such overlap occurs when a product name differs by a single character, but the resolution point is significantly different (e.g., product code X11 vs. X10).</blockquote><p>As the majority of documents are by default not assigned to a standard product denomination across the company, data must first be prepared and labelled according to their product taxonomy.</p><h3><strong>Solution</strong></h3><p>To solve this problem, we used a few ingredients and the following recipe:</p><ul><li>A Custom Named Entity Recognition (<strong>CNER</strong>) model with the goal of extracting raw product names from the entire document base. To speed up the training process, an active learning strategy was used for fine tuning the transformer, by first training on a subset of documents, infer new instances on new documents and repeat the iterations until satisfactory accuracy.</li><li>A structured <strong>product taxonomy</strong> of official product denominations. Taxonomies are hierarchical tables that organize items into groups according to their properties. This taxonomy served as the foundation for mapping extracted entities to their correct product categories.</li><li>A combination of <strong>taxonomy fuzzy-matching</strong> and partial string matching algorithm to link the extracted entities to official taxonomy denominations. This ensures that the entities would inherit their rightful levels of taxonomy, which constitute the standard document blueprint needed to enrich the search index.</li><li>A pre-processing step to expand extracted abbreviations against an <strong>abbreviation glossary</strong> before fuzzy-matching, in order to increase the chances of matching these against an official denomination.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oUl7Jy5GGwMTEKx6KY_Whw.png" /><figcaption>Document-tagging flow at ingestion time. A CNER model is applied to extract the entities, which are then matched against official taxonomy names and used to enrich the index database.</figcaption></figure><ul><li>A Conversational Language Understanding (<strong>CLU</strong>) model tasked with extracting the product entity name from the user’s query. This model was trained on synthetically generated chat queries using grammatical variations of official product taxonomy names to mimic a natural language interaction. During training, it is important to tailor the prompt to generate utterances containing single or multiple product names and varying the context to obtain heterogeneous examples.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSmaXbyaGk9QVQmUvx39mA.png" /><figcaption>Entity extraction at query time. A CLU model is applied to extract the entities from the user query, which are then matched against official taxonomy names and used to pre-filter the search index before performing a hybrid search with a semantic ranking model.</figcaption></figure><p>The process is divided into enrichment during ingestion of the sources before indexing, and chat contextualization at query time, as displayed in the figures above.</p><h3><strong>Architecture</strong></h3><p>The solution is running on an Azure environment. Hybrid search and reranking is performed by Azure AI Search, while CNER and CLU models are trained using Azure AI Foundry and made available via Azure Functions.</p><p>The lifecycle for creating a CNER and CLU model are the same, it starts with defining the schema, then an iteration of labelling, training and improving models. Then once your models reach the required performance you can deploy and start to utilize the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nK3fbWIQRjjh6ZrD.png" /><figcaption>CNER and CLU Project development lifecycle <a href="https://learn.microsoft.com/en-gb/azure/ai-services/language-service/custom-named-entity-recognition/overview">Custom named entity recognition — Azure AI services | Microsoft Learn</a></figcaption></figure><p>Accurate and consistent labeling of the data is vital to the performance of the models. It isn’t uncommon to have multiple labelers labeling the data and so creating unambiguous and concrete labeling instructions is important and must be adhered to for uniform labeling results. From the below screenshot, you will see the portal offered within Azure which provides a labelling tool where users can manage the end to end project for the labelers, defining the instructions, target entities and review the labels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r3mGkVt6HugTWsAn.png" /><figcaption>Labelling data for CNER and CLU models <a href="https://learn.microsoft.com/en-us/azure/ai-services/language-service/conversational-language-understanding/how-to/tag-utterances?tabs=portal">How to tag utterances in Conversational Language Understanding — Azure AI services | Microsoft Learn</a></figcaption></figure><p>The service also provides the opportunity to utilize Auto-labeling features such as ‘<em>Auto-label with GPT’ </em>and ‘<em>Auto-label based on a model you’ve trained’</em>. We decided to utilize this service and found it to be highly beneficial to increase the labelled samples and assisting the labelers with the very manual process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oUPW8hwa60Hzx_q1.png" /><figcaption>Auto-labeling on Azure <a href="https://learn.microsoft.com/en-gb/azure/ai-services/language-service/custom-named-entity-recognition/how-to/use-autolabeling?tabs=autolabel-model">How to use auto-labeling in custom named entity recognition — Azure AI services | Microsoft Learn</a></figcaption></figure><h4>Why Use Both CNER &amp; CLU?</h4><p>With the document enrichment and query-time filtering in place, let’s explore why we used separate models for these stages. The use of CNER and CLU simply comes down to the applicability of the models and how the services are expected to be used. Azure’s CNER service is best used on a large amount of data, processing in batch where speed is not the optimized parameter. We tested our model with the live conversational data from user queries and we found it to be too slow for chatbot use.</p><p>However, Conversational Language Understanding (CLU) is designed to handle live conversations and is optimized for real-time processing. It is ideal for scenarios where you need to understand the overall intention of a conversation and extract key information quickly. CLU can be used in various scenarios, such as end-to-end conversational bots, human assistant bots, and command and control applications.</p><p>Through extensive testing, we observed that CNER outperformed CLU when enriching the document database, ensuring a structured and well-indexed search space. However, for conversational queries, CLU was significantly faster while still maintaining high accuracy. This once again highlights the importance of using the correct service at the right time.</p><h4>Taxonomy Matching</h4><p>Developing the CNER and CLU models was only half the challenge; next, we needed a matching step to link identified entities from either model to those in the product taxonomy.</p><p>The taxonomy itself was organized hierarchically, with product families at the root, intermediary groupings of products in the middle, and individual product names at the bottom. After identifying entities, we employed a matching protocol that combined fuzzy matching and string matching. This approach involved setting confidence thresholds and experimenting with multiple <a href="https://github.com/rapidfuzz/RapidFuzz?tab=readme-ov-file">RapidFuzz </a>scorers.</p><p>While the performance of both the CNER and CLU models was impressive, the matching step provided an additional layer of confidence. It enabled us to catch entities that were not listed in the taxonomy and filter them out. Once entities were matched, we could extract the hierarchical taxonomy relationships and store them in the Azure AI search index, enhancing filtering capabilities.</p><p>It is important to investigate different matching packages, in our case we moved from an existing <a href="https://github.com/seatgeek/fuzzywuzzy">FuzzyWuzzy</a> scorer to the same <a href="https://github.com/rapidfuzz/RapidFuzz?tab=readme-ov-file">RapidFuzz </a>scorer and we identified a significant improvement for our matching speed. RapidFuzz wraps highly-optimized implementations written in C++ which allows us to enjoy the flexibility of Python with the speed of compiled code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iry1NGxUSC2UB8I4" /><figcaption>The importance of choosing the right matching package FuzzyWuzzy vs RapidFuzz <a href="https://github.com/rapidfuzz/RapidFuzz?tab=readme-ov-file">rapidfuzz/RapidFuzz: Rapid fuzzy string matching in Python using various string metrics</a></figcaption></figure><h4>Azure AI Search</h4><p>It is widely recognized in Microsoft <a href="https://techcommunity.microsoft.com/blog/azure-ai-services-blog/azure-ai-search-outperforming-vector-search-with-hybrid-retrieval-and-reranking/3929167">documentation</a> that a Hybrid search (vector + keyword) accompanied by a Microsoft’s Semantic Ranker generally improves results in search solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7k_QGvgiR9Tmn6C_PZ0dlw.png" /><figcaption>Comparison between different search strategies as demonstrated in the <a href="https://techcommunity.microsoft.com/blog/azure-ai-services-blog/azure-ai-search-outperforming-vector-search-with-hybrid-retrieval-and-reranking/3929167">Azure AI Search documentation</a></figcaption></figure><p>However, as noted earlier, we encountered instances where using Hybrid + Semantic Ranker mistakenly confused product “X10” with “X11.”</p><p>To address this, we leveraged the <a href="https://learn.microsoft.com/en-us/azure/search/search-filters">filtering capabilities </a>of Azure AI search to refine results using the taxonomy-matched entities. By dynamically constructing the OData expression at query time with the CLU-matched entities, we were able to accurately narrow the search to only the relevant entities. This approach effectively resolved the issue of the system recommending incorrect products, especially those with similar names and common issues but distinct resolutions.</p><h3>Evaluation</h3><p>The following evaluation set up was specifically designed for this article. However, the process described differs from the in-depth internal evaluation used for the entire solution, which includes several hundreds of question-answering pairs.</p><p>To evaluate our approach, we collaborated with multiple experts to generate a list of complex questions designed to capture difficult cases. These questions targeted specific edge-cases where answers could be ambiguous without proper context, often related to particular product lines or equipment models within the same family but differing in properties. We defined our metric as the number of relevant documents returned by the search, focusing on the top 6 documents typically referenced in responses.</p><p>In total, we manually evaluated 120 sources. A source was considered relevant if it contained at least one instance of the relevant product within its metadata. Due to sensitivity concerns, we chose not to provide explicit examples.</p><p>This evaluation was carried out using a workbench where the same RAG workflow was tested on two different indices: one naïve index without taxonomy metadata, and another enriched index that included taxonomy structures extracted using CNER, with additional query enhancement using CLU. The figure below shows how their relevance compared based on the performance evaluation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4LLgOMfPrps5w0iCfajpDQ.png" /><figcaption>Average performance scores using a taxonomy-enriched index with CNER and CLU, vs a naïve index with simple document retrieval.</figcaption></figure><p>Using a naïve indexing approach, only 30% of the retrieved documents were relevant to the target product. The substantial discrepancy between the two methods can largely be attributed to the design of the question set, which was particularly advantageous to the enriched version. Nonetheless, by adding a deterministic filter based on the exact product name, the method ensures that only sources directly related to the product are selected—avoiding the retrieval of semantically similar but potentially irrelevant information. The results thus highlight the effectiveness of leveraging consistent reference data during both ingestion and inference phases to accurately identify and filter exact product names.</p><p>This evaluation focused solely on document relevance and did not consider response quality. However, comprehensive feedback collected from internal users over an extended period of six months indicated a substantial enhancement in answer quality and contextual relevance, which is a natural consequence of the filtering applied.</p><h3><strong>Considerations</strong></h3><p>Although there are several advantages in the implementation of CNER and CLU models, there are also some underlying weaknesses that practitioners should be aware of. To mention some, these models are rather sensitive to schemas, making it important to decide upfront the different kind of documents that will be handled by the model. In order to ensure an acceptable generalization capacity, it is important to design the training dataset around a statistically significant variance of entities, besides staying consistent and precise during data labelling. Additionally, implementing real-time CLU and fuzzy matching algorithms did result in some minor latency, though this was a trade-off for improved search performance.</p><p>Another consideration of this approach is that the filtering relies on the NER model’s accuracy. Thus, performing random validation checks should be a routine to ensure quality and scalability. Other general remarks should include the maintenance of machine learning models, advanced prompt engineering practices to support multi-turn RAG workflows, and human-application interaction management, all of which will impact the overall user experience.</p><p>As an alternative, or in conjunction with the CNER + CLU models, practitioners could consider using Azure AI Search’s scoring profiles. According to Azure AI Search documentation:</p><blockquote>Scoring profiles are used to boost the ranking of matching documents based on criteria. You can use scoring profiles for <a href="https://learn.microsoft.com/en-us/azure/search/search-lucene-query-architecture">keyword search</a>, <a href="https://learn.microsoft.com/en-us/azure/search/vector-search-overview">vector search</a>, and <a href="https://learn.microsoft.com/en-us/azure/search/hybrid-search-overview">hybrid search</a>. However, scoring profiles only apply to non-vector fields, so make sure your index has text or numeric fields that can be used in a scoring profile.</blockquote><p>Scoring profiles supplement the default scoring algorithm by boosting the scores of matches that meet the profile’s criteria. In our case, we could add a scoring profile to the product hierarchy metadata to boost the score when a product key word is matched.</p><p>Another important consideration was our evaluation of available LLMs for fuzzy matching at the time of implementation. While we explored their potential, we found their performance to be inconsistent and less reliable than traditional fuzzy matching techniques. Instead, RapidFuzz delivered more accurate and consistent results. However, with recent advancements, LLMs have become more reliable and intelligent, making it worthwhile to re-evaluate their effectiveness for fuzzy matching.</p><p>Lastly, consider experimenting with dynamic search methods, as relying solely on hybrid search may not always be optimal, especially when certain keywords need more weight. Instead of hybrid search, using keyword-based search could be more effective. Additionally, decomposing queries and applying multiple search strategies such as keyword, vector, or metadata filtering can yield more accurate results, which can then be joined and ranked for relevance. This flexible approach enhances search accuracy based on user intent.</p><h3><strong>Conclusions</strong></h3><p>This article introduced an approach to enhancing context relevance in enterprise RAG systems through a structured and controlled method. By leveraging a well-defined product taxonomy, the solution ensures that only the most relevant information is included in the LLM context. As a result, it not only improves contextual alignment but also minimizes the likelihood of hallucinations by filtering out incomplete or unrelated content.</p><p>While this approach has proven effective, it is one of many potential solutions for improving RAG-based AI applications. Future advancements in AI retrieval techniques may further enhance contextual accuracy and reduce hallucinations.</p><p>Lastly, this article also highlights the importance of having structured taxonomy data about the core product offering of an enterprise, as a common nomenclature adopted across the company and its customers.</p><h3><strong>Acknowledgments</strong></h3><p>This work was carried out under a partnership between Alfa Laval and Microsoft, and we would like to express our gratitude to <a href="https://www.linkedin.com/in/francescosparacio/">Francesco Sparacio</a>, <em>Lead Data Architect, </em><a href="https://www.linkedin.com/in/farahwsaab/">Farah Saab</a> <em>Data Engineer, </em><a href="https://www.linkedin.com/in/jonathan-clyde-a4a81b71/">Jon Clyde</a>, <em>DevOps Engineer, </em><a href="https://www.linkedin.com/in/adamjgblack/">Adam Black</a>, <em>UI Developer </em><a href="https://www.linkedin.com/in/johannes-wessl%C3%A9n-weiler/">Johannes Wesslén Weiler</a>, <em>Full-Stack Engineer, </em>for their valuable contributions throughout this project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ba7520941ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/article-rag/an-approach-for-leveraging-enterprise-metadata-in-rag-applications-1ba7520941ae">An approach for leveraging enterprise metadata in RAG applications</a> was originally published in <a href="https://medium.com/article-rag">Beyond Naive RAG</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>