<?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 Sahil Sawant on Medium]]></title>
        <description><![CDATA[Stories by Sahil Sawant on Medium]]></description>
        <link>https://medium.com/@sahil.sawant55555?source=rss-22f2044e3caf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sahil Sawant on Medium</title>
            <link>https://medium.com/@sahil.sawant55555?source=rss-22f2044e3caf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 12:38:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sahil.sawant55555/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[Building Trustworthy Data Pipelines: Metadata-Driven Data Validation with Great Expectations]]></title>
            <link>https://medium.com/@sahil.sawant55555/building-trustworthy-data-pipelines-metadata-driven-data-validation-with-great-expectations-ff3951fd06c5?source=rss-22f2044e3caf------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff3951fd06c5</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[azure-sql-server]]></category>
            <category><![CDATA[metadata]]></category>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[great-expectations]]></category>
            <dc:creator><![CDATA[Sahil Sawant]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 21:38:25 GMT</pubDate>
            <atom:updated>2025-12-07T21:38:25.164Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s data-driven world, ensuring the quality of data is more critical than ever. Poor-quality data can lead to erroneous business decisions, wasted resources, and lost opportunities. When building data pipelines, data validation is not just an afterthought; it needs to be integrated into every stage of the pipeline to ensure that only clean, reliable data makes it to the end-users.</p><p>One powerful tool for achieving this is <strong>Great Expectations</strong> — a Python-based framework designed to provide data validation, data profiling, and data documentation. When combined with a <strong>metadata-driven architecture</strong>, Great Expectations can help automate data quality checks and make them dynamic, adaptable, and scalable.</p><p>In this post, I’ll walk you through how to leverage <strong>Great Expectations</strong> to build robust data validation checks within metadata-driven pipelines in <strong>Azure Databricks</strong>, using <strong>Azure SQL Server</strong> to store the metadata. We’ll explore how metadata-driven validation can ensure that your data pipelines are both trustworthy and resilient to changes in the data structure.</p><h4>Why Metadata-Driven Data Validation?</h4><p>Before diving into the technical details, let’s first understand why a metadata-driven approach is so powerful for data validation.</p><ol><li><strong>Scalability</strong>: Metadata-based validation rules can be applied to different data sources without hardcoding logic for every dataset. As new datasets or data sources come in, the pipeline can automatically adjust based on the metadata, reducing manual intervention.</li><li><strong>Flexibility</strong>: Business rules evolve, and so should the validations. With a metadata-driven approach, updates to validation criteria can be made by simply modifying the metadata in <strong>Azure SQL Server</strong> — no need to change the underlying pipeline code.</li><li><strong>Centralization</strong>: Storing the validation rules and expectations as metadata in a central repository (SQL Server) provides a single source of truth. This makes it easy to manage, update, and monitor your data quality rules without duplicating effort.</li><li><strong>Automated Monitoring and Alerts</strong>: With Great Expectations, validation checks are automatically run on the incoming data, and alerts are triggered when the data fails to meet the defined expectations. This ensures data issues are detected early in the pipeline.</li></ol><h4>Integrating Great Expectations with Azure Databricks</h4><p>To ensure our data pipeline produces high-quality data, we need a validation framework that checks the data at various stages of the ETL process. <strong>Great Expectations</strong> is ideal for this task, and it integrates seamlessly with <strong>Azure Databricks</strong>, allowing us to run validation checks on datasets in real-time or batch processing scenarios.</p><p>Here’s how we set up Great Expectations within Databricks:</p><ol><li><strong>Install Great Expectations</strong>: First, install the Great Expectations package within your Databricks cluster:</li></ol><pre>pip install great_expectations</pre><p><strong>2. Initialize Great Expectations</strong>: Once installed, create a new <strong>Great Expectations</strong> project. In Databricks, this can be done through a notebook:</p><pre>import great_expectations as gx<br>context = gx.get_context()</pre><p><strong>3. Create a Data Asset</strong>: Define your dataset as a <strong>data asset</strong> that will be used by Great Expectations to perform validation:</p><pre>batch = context.get_batch({&#39;datasource&#39;: &#39;my_datasource&#39;, &#39;data_asset_name&#39;: &#39;my_data_asset&#39;})</pre><p>This is where the metadata-driven part comes into play. Instead of hardcoding dataset details, you fetch this information dynamically from <strong>Azure SQL Server</strong>.</p><h4>How Metadata Drives Data Validation</h4><p>The core advantage of a metadata-driven approach is that the validation criteria (expectations) are stored and managed outside the pipeline code. In our case, this metadata is stored in <strong>Azure SQL Server</strong>.</p><p>Here’s how it works:</p><ol><li><strong>Metadata Definition in SQL Server</strong>: We store important metadata in a structured way within SQL Server. For example, for each dataset, we store the following:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GhqzJ8MEL7RRWNzhcdsY7A.png" /><figcaption>Example of Rule Master table on SQL server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h78NahTyNVHDgKXRrl0hRQ.png" /><figcaption>Example of Rule Execution table on SQL server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wHFxE77hWucGretYC25fsQ.png" /><figcaption>Example of DQ Rule Parameters table on SQL server</figcaption></figure><p>Now joining all these three tables to generate the expectation mappings in below format:</p><pre>expectation_mappings: List[Dict[str, Any]] = [<br>        {<br>            &quot;expectation&quot;: &quot;ExpectColumnValuesToNotBeNull&quot;,<br>            &quot;params&quot;: {&quot;column&quot;: &quot;member_age&quot;}<br>        },<br>        {<br>            &quot;expectation&quot;: &quot;ExpectColumnValueToBeBetween&quot;,<br>            &quot;params&quot;: {&quot;column&quot;: &quot;member_age&quot;, &quot;min_value&quot;: 60, &quot;max_value&quot;: 120}<br>        },<br>        {<br>            &quot;expectation&quot;: &quot;ExpectColumnValueLengthsToBeBetween&quot;,<br>            &quot;params&quot;: {&quot;column&quot;: &quot;claim_id&quot;, &quot;min_value&quot;: 1, &quot;max_value&quot;: 5}<br>        }<br>    ]</pre><p><strong>Applying Expectations in Great Expectations</strong>: Once the validation rules are fetched from SQL Server, <strong>Great Expectations</strong> applies these rules dynamically to incoming data. For example, if the metadata specifies that the <em>member_age </em>column should be between 60 and 120, you can set an expectation like:</p><pre># Define expectation dynamically based on metadata<br>expectation = batch.expect_column_value_between(&quot;member_age&quot;, 60, 120)</pre><p>Similarly, for uniqueness, if the metadata specifies that <em>member_age </em>must be unique, you can define:</p><pre>batch.expect_column_values_to_be_unique(&quot;member_age&quot;)</pre><h4>Automating Data Quality Monitoring</h4><p>Once the validation expectations are in place, the next step is to automate the monitoring of these expectations as data flows through the pipeline.</p><ol><li><strong>Continuous Validation</strong>: In your Databricks pipeline, after each transformation step or data load, Great Expectations automatically checks the data against the defined expectations.</li><li><strong>Alerts and Notifications</strong>: If the data fails any validation check, <strong>Great Expectations</strong> triggers an alert or logs the issue. This could be integrated with monitoring tools or used to generate a report for data quality dashboards.<br>Example:</li></ol><pre># Log or send an alert if validation fails<br>if not batch.validate():<br>    send_alert(&quot;Data validation failed!&quot;)</pre><p><strong>3. Documentation and Reporting</strong>: With <strong>Great Expectations</strong>, you can automatically generate data quality documentation. This makes it easy to track data quality over time and share the status of your data pipeline with stakeholders.</p><h4>Conclusion</h4><p>Building trustworthy data pipelines requires robust data validation at every stage of the ETL process. By integrating <strong>Great Expectations</strong> with a <strong>metadata-driven approach</strong>, you can ensure that your pipelines are adaptable, scalable, and resilient to changes in data sources and business rules.</p><p>Storing metadata in a centralized repository like <strong>Azure SQL Server</strong> and using it to dynamically define and apply validation rules makes your pipeline more flexible and reduces the risk of human error or outdated validation logic.</p><p>With <strong>Great Expectations</strong> automating your data quality checks, you can rest easy knowing that your data pipeline is continuously validating and ensuring clean, reliable data — giving you the confidence to make data-driven decisions.</p><p>Let me know if you’d like to dive deeper into any specific section or need further adjustments!</p><p>Contributors — Check out <a href="https://medium.com/u/a67fa6edef6c">Akshayprabhu</a>’ s profile who helped me implement the connectivity with Azure SQL Server and finalizing the data model for metadata.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff3951fd06c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Enhanced BERTopic Framework and Algorithm
for Improving Topic Coherence and Diversity]]></title>
            <link>https://medium.com/@sahil.sawant55555/an-enhanced-bertopic-framework-and-algorithm-for-improving-topic-coherence-and-diversity-6b53d749e4ba?source=rss-22f2044e3caf------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b53d749e4ba</guid>
            <category><![CDATA[bertopic]]></category>
            <category><![CDATA[topic-modeling]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Sahil Sawant]]></dc:creator>
            <pubDate>Wed, 13 Sep 2023 19:31:29 GMT</pubDate>
            <atom:updated>2023-09-13T19:53:53.636Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Topic Modeling?</h3><p>Topic modeling is a powerful unsupervised machine learning technique that has found applications in various domains, from social media analysis to healthcare and cybersecurity. It allows us to uncover latent thematic topics within a corpus of documents. While several traditional topic modeling methods like LDA, NMF, Top2Vec, they often overlook the context of words in a sentence, which limits their ability to generate coherent and diverse topics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*RUGrVwMjoLaz9_NcbQR9Yw.png" /><figcaption><a href="https://dl.acm.org/doi/10.1145/2133806.2133826">Figure source: Blei, D.M. (2010) Probabilistic topic models communications of the ACM, 55(4) 77–84</a></figcaption></figure><h3>BERTopic</h3><p>To overcome the issues of traditional methods, <a href="https://maartengr.github.io/BERTopic/index.html">BERTopic </a>was introduced. It is topic modeling technique that leverages clustering techniques and a class-based variation of TF-IDF to generate coherent topic representations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*pF3iewYqpqMt3XzqcrOiRw.png" /><figcaption>Base Framework of BERTopic</figcaption></figure><h3>An Enhanced BERTopic Framework</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8D3xspH8okHX4_PiVPTQA.png" /><figcaption>Advanced BERTopic Framework</figcaption></figure><p>In this figure, we present an improved version of the BERTopic framework, which includes a Document Vector Dimension Optimizer (DVDO). This enhancement allows for the dynamic optimization of the number of dimensions for each document vector, resulting in more optimal topics. Unlike the original framework, which used a constant dimension across all datasets for each document embedding method, our DVDO adapts to the characteristics of each dataset.</p><p><strong>Key Components of the Enhanced BERTopic Framework:</strong></p><ol><li><strong>Document Vector Dimension Optimizer (DVDO):</strong> This pivotal addition to the BERTopic framework dynamically optimizes the number of dimensions for each document vector. By doing so, it tailors the dimensionality of document embeddings to the specific dataset, ensuring more effective topic generation.</li><li><strong>K-means Cluster Generator (KCG):</strong> Integrated into the framework, the KCG plays a vital role in optimizing document vector dimensions. It assists the DVDO in determining the ideal dimensions to capture the underlying document relationships.</li><li><strong>Sentence Transformers (SBERT):</strong> The foundation of document embeddings, SBERT models like “paraphrase-multilingual-MiniLM-L12-v2” are used to map sentences and paragraphs into dense vector spaces. The framework offers flexibility for users to choose alternative embedding models to suit their specific requirements, such as Google’s Universal Sentence Encoder, OpenAI GPT-2, or our Context-aware Embedding Model.</li><li><strong>UMAP Embedded Dimension Reducer (EDR):</strong> UMAP is employed to reduce the dimensions of document embeddings. By default, it reduces them to five dimensions, but users can adjust the dimensionality as needed. We utilize this flexibility of UMAP and provide the best and optimized dimensionality specific to the corpus used during training of the model.</li><li><strong>HDBSCAN Document Clustering Engine (DCE):</strong> The HDBSCAN module clusters semantically similar documents based on the reduced embedded vectors.</li><li><strong>c-TF-IDF Topic Representation Generator (TRG):</strong> This module generates topics by treating all documents within the same cluster as a single document. It employs a class-based TF-IDF (c-TF-IDF) computation to identify the most significant words or phrases within each cluster, enhancing topic quality and coherence.</li></ol><p>By combining these components, the enhanced BERTopic framework with DVDO offers a more dynamic and adaptable approach to topic modeling. It ensures that document vector dimensions are optimized for each dataset, resulting in improved topic quality and relevance.</p><p><strong>Conclusion</strong></p><p>The enhanced BERTopic framework with the Document Vector Dimension Optimizer represents a significant advancement in topic modeling. It addresses the limitations of static dimensionality and provides a more adaptable and effective approach for generating coherent and diverse topics from textual data. Researchers and practitioners can benefit from this enhanced framework to extract valuable insights across various domains and datasets.</p><p>P.S: More details about this paper available <a href="https://www.researchgate.net/publication/364747531_An_Enhanced_BERTopic_Framework_and_Algorithm_for_Improving_Topic_Coherence_and_Diversity">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b53d749e4ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>