<?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 Baris Bilen on Medium]]></title>
        <description><![CDATA[Stories by Baris Bilen on Medium]]></description>
        <link>https://medium.com/@alibarisbilen1?source=rss-a45f0e43b524------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*shC_Z3s7Q0eAAGXW7T-WrQ.jpeg</url>
            <title>Stories by Baris Bilen on Medium</title>
            <link>https://medium.com/@alibarisbilen1?source=rss-a45f0e43b524------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:28:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alibarisbilen1/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[We save $8k/Year: Why We Picked BigQuery-native Dataform over dbt Cloud]]></title>
            <link>https://medium.com/plus-minus-one/we-save-8k-year-why-we-picked-bigquery-native-dataform-over-dbt-cloud-d90f78632efe?source=rss-a45f0e43b524------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90f78632efe</guid>
            <category><![CDATA[dataform]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt-cloud]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <dc:creator><![CDATA[Baris Bilen]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 19:03:17 GMT</pubDate>
            <atom:updated>2026-01-20T19:03:17.162Z</atom:updated>
            <content:encoded><![CDATA[<p>A guide to scaling data pipelines with Dataform + Airflow for BigQuery teams without a pricey vendor lock-in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q-dZ05kx91efeepn" /><figcaption>Photo by <a href="https://unsplash.com/@jdiegoph?utm_source=medium&amp;utm_medium=referral">Diego PH</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the modern analytics engineering stack, dbt has become the go-to tool for SQL transformation layer over the last few years, for a number of reasons. With modularity, testability, and a models-as-code philosophy at its core, it does a decent job bringing the software engineering practices to ETL/ELT processes. But somewhere along the way, it has come to my attention that modern data stack became a procurement exercise, where you need to lock yourself into a data warehouse, an ingestion tool, an orchestrator, an observability platform and so on, each with its own contract and onboarding. You can see the industry’s response in the growing adoption of unified frameworks such as <a href="https://getbruin.com/manifest/">Bruin</a>, <a href="https://sqlmesh.readthedocs.io/en/stable/">SQLMesh</a> and others.</p><blockquote>For teams already on Google Cloud, there’s a much simpler and cheaper path that’s been hiding in plain sight: <strong><em>Dataform</em></strong><em>.</em></blockquote><p>It does what dbt does, it’s native to BigQuery, and it costs nothing beyond your existing compute. To <a href="https://www.youtube.com/shorts/fsExlQQxbQE">borrow</a> from Pulp Fiction, dbt is a “<em>Quarter Pounder</em>” and Dataform is a “<em>Royale with Cheese</em>”. Same burger, different packaging, except the latter comes free with your BigQuery meal.</p><p>This post walks through why we went with <a href="https://cloud.google.com/blog/products/data-analytics/introducing-dataform-in-ga">Dataform</a> instead of dbt when building our transformation layer, and how we orchestrate it with Airflow.</p><h3>1) Why Dataform Wins</h3><p>At their core, Dataform and dbt both solve the same problem the same way; managing SQL-based transformations with a modular approach and enforcing version control to increase transparency over data’s journey within the organization. They both employ models-as-code approach in which you define transformations and execution order declaratively, where Dataform uses JavaScript syntax and dbt uses Jinja syntax. Having covered the similarities, let’s get to the nuances, which heavily favor Dataform.</p><ol><li><strong>Pricing</strong></li></ol><p>The most important motivator favoring Dataform over dbt. dbt Cloud <a href="https://www.getdbt.com/pricing">charges</a> you $100/month per developer seat. That’s $6000/year for a mid-sized team of five, before you write a single query. On the other hand, Dataform is free and you only pay for the compute resources which you were already paying for, where the Dataform itself adds nothing to your bill. Scale to ten analysts and that’s $12k/year you’re not spending on transformation tooling. This savings is around $8k–$9k for us as we have 7–8 analysts and backend developers combined.</p><p><strong>2. BigQuery-native setup</strong></p><p>Dataform lives inside BigQuery. Your lineage shows up natively in BigQuery console. Dataform validates your queries against BigQuery in real-time and shows you the estimated bytes to be processed before you run anything (no surprises on your invoice). dbt Cloud can also connect to BigQuery, but it’s a separate system with its own UI, lineage graphs and documentation page. Check out my blog post from January 2024 if you are interested in setting up dbt Cloud &amp; BigQuery together (well, you shouldn’t be anymore).</p><p><a href="https://alibarisbilen1.medium.com/onboard-your-first-end-to-end-analytics-workflow-on-dbt-cloud-using-bigquery-at-no-cost-b2e363969777">Onboard your first end-to-end analytics workflow on dbt Cloud using BigQuery at no cost</a></p><p><strong>3. AI-assistance</strong></p><p>Dataform now includes Gemini on the side (Gemini 2 as of January 2026, which handles most code generation tasks well). You can generate queries and config files from natural language prompts directly in the editor. This is part of BigQuery’s broader AI capabilities and <strong>not a</strong> separately charged add-on.</p><p><strong>4. Where dbt still wins</strong></p><p>dbt supports Snowflake, Redshift, Databricks and others, and if you are cloud-agnostic or have multiple warehouses, this flexibility will definitely help you. If you’re not, it’s overhead on your bill that you’re paying for but not using. In addition to that, I have to admit that dbt’s community is larger than that of Dataform, but this is subject to change as Dataform is backed by Google, so the ecosystem gap will likely narrow over time as BigQuery’s market share keeps <a href="https://venturebeat.com/ai/bigquery-is-5x-bigger-than-snowflake-and-databricks-what-google-is-doing-to-make-it-even-better">climbing</a>.</p><h3><strong>2 ) A Practical Example</strong></h3><p>Dataform uses what’s called SQLX as its language, and that is essentially SQL with a configuration dictionary at the top. Here’s how a simple model looks like:</p><pre>config {<br>    type: &quot;table&quot;,<br>    schema: &quot;marketing_datamart&quot;,<br>    description: &quot;Cleaned and deduplicated ad performance data&quot;,<br>    bigquery: {<br>        partitionBy: &quot;date&quot;, -- specify the partitioned field<br>        clusterBy: [&quot;campaign&quot;] -- specify the clustered field<br>}<br>    assertions: {<br>        nonNull: [&quot;ad_id&quot;, &quot;date&quot;, &quot;spend&quot;]<br>        -- you can add many more assertions as part of quality checks<br>    }<br>}<br><br>-- an optional pre-operations block to run before the main query.<br>-- here we see that this table has a full-refresh policy. alternatively,<br>-- it could&#39;ve been partial refresh (delete last ten days, etc.) or<br>-- anything like upsert-merge operation based on keys.<br>pre_operations {<br>    ${when(incremental(),<br>        `DELETE FROM ${self()}`<br>    )}<br>}<br><br>-- the main query<br>SELECT<br>    ad_id,<br>    campaign_id,<br>    date,<br>    SUM(impressions) AS impressions,<br>    SUM(clicks) AS clicks,<br>    SUM(spend) AS spend<br>FROM ${ref(&quot;t_ads_raw&quot;)}<br>GROUP BY 1, 2, 3</pre><p>The config block is to declare the materialization type (table or view), tags, amendment logic (incremental or non-incremental (which is full refresh)). You can also define some data quality checks here using “<a href="https://docs.cloud.google.com/dataform/docs/assertions">assertions</a>”, which removes the need for a solution like Great Expectations.</p><p>Let me also share some reference file examples where we define our table references, and a sample <em>workflow_settings.yml</em> where we define some default project-level configurations like region, repository name etc.</p><pre>// definitions/sources.js<br>// Declare source tables from your staging layer<br>[<br>    &quot;t_ads_raw&quot;,<br>    &quot;t_campaigns_raw&quot;, <br>    &quot;t_spend_raw&quot;,<br>].forEach((name) =&gt;<br>    declare({<br>        schema: &quot;staging&quot;,<br>        name<br>    })<br>);</pre><p>And below is a sample <em>workflow_settings.yml</em>:</p><pre>defaultProject: your-gcp-project<br>defaultDataset: staging<br>defaultAssertionDataset: dataform_assertions<br>defaultLocation: europe-west3<br>dataformCoreVersion: 3.0.35</pre><p>→ Please note that these files do not follow a specific folder structure or naming convention. So you can organize your model, config and settings files however you want. Having said, it’s always good idea to organize them by layer or by domain to keep it tidy.</p><p>This is how it appears on Dataform UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQ-EJWDZPDYWcofNPuylZg.png" /><figcaption>Compilation check after writing the model, showing estimated bytes to be processed (both for incremental and non-incremental runs)</figcaption></figure><h3><strong>3) Orchestrating with Airflow</strong></h3><p>To orchestrate Dataform jobs, one doesn’t really need Airflow since these jobs can also be scheduled directly on BigQuery, but that would not be a good practice if you already have some pipelines running on Airflow as it will isolate these jobs from the existing ones and will reduce overall visibility. On a personal note, I always prefer to put things on Airflow to make data pipelines more transparent and manageable.</p><p>Airflow 2 has Google Dataform <a href="https://airflow.apache.org/docs/apache-airflow-providers-google/stable/operators/cloud/dataform.html">operators</a> built-in, and we are going to use those operators to trigger Dataform executions. Due to the concept of <a href="https://airflow.apache.org/docs/apache-airflow-providers-google/stable/operators/cloud/dataform.html#create-workflow-invocation">workflow invocation</a>, it might seem a bit ambiguous in the first look but I cover what’s required just below. Only two operators and you’re done, simple as that.</p><p>a) Define a task using<em> </em><strong><em>DataformCreateCompilationResultOperator</em></strong><em> </em>to fetch the master branch for the expressions</p><pre># Compile the Dataform repository<br>compile_dataform = DataformCreateCompilationResultOperator(<br>    task_id=&quot;compile_dataform&quot;,<br>    project_id=&quot;your-gcp-project&quot;,<br>    region=&quot;europe-west3&quot;,<br>    repository_id=&quot;your-dataform-repo&quot;,<br>    compilation_result={<br>        &quot;git_commitish&quot;: &quot;main&quot;,<br>    },<br>    gcp_conn_id=&quot;google_cloud_default&quot;,<br>)</pre><p>→ <strong><em>DataformCreateCompilationResultOperator</em></strong><em> </em>compiles your Dataform project into an executable plan, but doesn’t actually run anything. It basically validates the current snapshot at a specific Git commit (say, master branch that your Dataform workspace is connected to), by resolving all dependencies, references, SQLX files and config. For dbt users, this will look quite identical to <em>dbt compile</em> command.</p><p>b) Define a task using <strong><em>DataformCreateWorkflowInvocationOperator</em></strong><em> </em>to trigger the expression</p><pre># Run a specific Dataform model and its dependencies<br>meta_ads_etl = DataformCreateWorkflowInvocationOperator(<br>    task_id=&quot;meta_ads_etl&quot;,<br>    project_id=&quot;your-gcp-project&quot;,<br>    region=&quot;europe-west3&quot;,<br>    repository_id=&quot;name-of-your-dataform-repo&quot;,<br>    workflow_invocation={<br>        &quot;compilation_result&quot;: &quot;{{ task_instance.xcom_pull(task_ids=&#39;compile_dataform&#39;)[&#39;name&#39;] }}&quot;,<br>        &quot;invocation_config&quot;: {<br>            &quot;included_targets&quot;: [{<br>                &quot;database&quot;: &quot;your-gcp-project&quot;,<br>                &quot;schema&quot;: &quot;marketing_datamart&quot;,<br>                &quot;name&quot;: &quot;t_meta_ads_cleaned&quot;<br>            }],<br>            &quot;transitive_dependencies_included&quot;: True,<br>        }<br>    },<br>    gcp_conn_id=&quot;google_cloud_default&quot;,<br>)</pre><p>→ <strong><em>DataformCreateWorkflowInvocationOperator </em></strong>simply defines the specific model that you want to execute.</p><p>In the end, these will look like the following in your DAG code.</p><pre>compile_dataform &gt;&gt; meta_ads_etl</pre><p>Then you are all done. Dataform for transformations, Airflow for orchestration, BigQuery for everything else. Each tool doing what it’s good at, without an external vendor in the middle.</p><p>If this was helpful, feel free to follow for more posts on building modern data pipelines. Have questions or want to share your own experience with Dataform? Drop a comment!</p><p>If you want to be a part of our great team here at PlusMinusOne, make sure to check out our <a href="https://www.linkedin.com/company/plusminusone-inc/jobs/">openings</a>. At <a href="https://www.plusminusone.co/">PlusMinusOne</a>, we love to learn and share our experiences.</p><p><strong>Resources</strong></p><ul><li><a href="https://medium.com/qodea/dataform-whats-the-story-ffa66d83d484">Dataform: What’s the Story?</a></li><li><a href="https://cloud.google.com/blog/products/data-analytics/introducing-dataform-in-ga">Introducing Dataform in GA</a></li><li><a href="https://www.getdbt.com/pricing">dbt Cloud Pricing</a></li><li><a href="https://venturebeat.com/ai/bigquery-is-5x-bigger-than-snowflake-and-databricks-what-google-is-doing-to-make-it-even-better">BigQuery Is 5x Bigger Than Snowflake and Databricks</a></li><li><a href="https://airflow.apache.org/docs/apache-airflow-providers-google/stable/operators/cloud/dataform.html">Airflow Dataform Operators</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90f78632efe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plus-minus-one/we-save-8k-year-why-we-picked-bigquery-native-dataform-over-dbt-cloud-d90f78632efe">We save $8k/Year: Why We Picked BigQuery-native Dataform over dbt Cloud</a> was originally published in <a href="https://medium.com/plus-minus-one">Plus Minus One</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementation of context-aware LLM chat models using Azure OpenAI]]></title>
            <link>https://alibarisbilen1.medium.com/making-of-a-context-aware-llm-chat-model-4464a82fa3a2?source=rss-a45f0e43b524------2</link>
            <guid isPermaLink="false">https://medium.com/p/4464a82fa3a2</guid>
            <category><![CDATA[embedding-model]]></category>
            <category><![CDATA[azureopenaiservice]]></category>
            <category><![CDATA[azureopenai]]></category>
            <category><![CDATA[context-aware-ai]]></category>
            <category><![CDATA[llmops]]></category>
            <dc:creator><![CDATA[Baris Bilen]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 17:03:15 GMT</pubDate>
            <atom:updated>2025-06-30T21:26:50.482Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A simple, practical guide on implementing contextually-aware custom chat models and common pitfalls</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G3-OBpodc46RGfLr" /><figcaption>Photo by <a href="https://unsplash.com/@hazelz?utm_source=medium&amp;utm_medium=referral">Hazel Z</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, I’ll give an overview of how we can enrich our chat models to create more customized and personalized interactions. The guide will rather be a practical one where we’ll explore the use of embedding models and building context-enriched chat models using Azure OpenAI <a href="https://azure.microsoft.com/en-us/products/ai-services/openai-service">service</a> (a SDK that helps developers build applications using GPT models), rather than a theoretical one that dives deep into the algorithms. At the end, I also share a link to my repository to help you implement a simple app on your own in the blink of an eye.</p><h3>1) What is a context/contextually-aware LLM model?</h3><p>Context-aware LLM models are basically LLM models that answer user questions based on a pre-defined context, where the context can be provided in the form of text, PDF, image, or else. Have you ever copied and pasted your code to the ChatGPT (I guess many of us did before the launch of Cursor/Windsurf) and asked for an improvement, or have you ever uploaded a PDF document and asked for a summary? If yes, you are already familiar with the concept.</p><p>For sure, such a feature has long been in the use in ChatGPT, and recently got more popular with tools such as <a href="https://notebooklm.google/">NotebookLM</a> from Google.</p><blockquote><em>If you haven’t tried NotebookLM yet, please give it a try as it’s impressive with its state-of-the-art Gemini models and native integration with other Google products such as Docs, Slides, YouTube videos etc.</em></blockquote><p><a href="https://notebooklm.google/">Gemini Notebook | AI Research Tool &amp; Thinking Partner</a></p><p>This guide will show you how to do that programmatically, so that you can use it in your LLM applications.</p><h3>2) The mechanism behind <em>embedding models</em></h3><p>To be able to enrich our base chat model with relevant content, we should first perform relevance check, and that’s where <strong>embedding models</strong> come into play.</p><p>In simple terms, embedding models are algorithms that turn your data (in our case it is text) into vectors, where the vectors can be consumed my machine learning models to measure relevance between elements, clustering, etc. The output of an embedding model is a called an embedding, which is a <a href="https://platform.openai.com/docs/guides/embeddings">vector</a> of floating point numbers. In our case, we will basically have embeddings of our context (pre-defined information like the PDF we upload to ChatGPT) and the question asked by the user, where we will evaluate the relevance between them using <a href="https://en.wikipedia.org/wiki/Cosine_similarity">cosine similarity</a>, a simple metric used to determine how similar two vectors are in a multi-dimensional space. The end goal here is to make sure that the question and the information that we think will help the model are indeed relevant, otherwise we will have provided a non-relevant context to the chat model which will most probably cause the model to hallucinate answers (confident but incorrect information), or provide a vague, generic, or off-topic answer, also resulting in wasted tokens and thus higher costs for applications at scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SVQN5CNhV1Hqazck.png" /><figcaption>An example illustration of cosine similarity in text matching. Image from Image from <a href="https://datascience-enthusiast.com/DL/Operations_on_word_vectors.html">https://datascience-enthusiast.com/DL/Operations_on_word_vectors.html</a>.</figcaption></figure><h3>3) Implementation</h3><p>In this guide, I will use my resume (PDF) as my context.</p><h4><strong>1. Extract text out of our source file</strong></h4><p>First, we need to read in the PDF and extract the text out of it. Our embedding model will need a .txt file to vectorize the content. Below code helps us do so.</p><pre># Open and parse the PDF<br>with pdfplumber.open(pdf_path) as pdf:<br>    for page in pdf.pages:<br>        text = page.extract_text()<br>        if text:  # Some pages may be empty<br>            full_text += text + &quot;\n&quot;<br><br># Output the extracted text<br>print(full_text)<br><br># Optionally save to a .txt file for inspection<br>with open(&quot;output.txt&quot;, &quot;w&quot;, encoding=&quot;utf-8&quot;) as f:<br>    f.write(full_text)</pre><p>We will use this “output.txt” for relevance check.</p><h4><strong>2. Setting up the resources on Azure AI Foundry</strong></h4><p>Having created the resources in Azure, now we need to deploy the models in Azure AI Foundry.</p><p>If you don’t have any Azure resources available, you can use the following guides to kickstart your Azure journey. Setting up your account, billing and resources should not take more than 10 minutes. You have $200 free credit that you can use to experiment. You can benefit from the below web pages.</p><ul><li><a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal">Official documentation</a> on creating and managing resources</li><li><a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model">Official documentation</a> for deploying your models in Azure AI Foundry</li></ul><p>First, let’s create the chat model itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdmrACtubQvnpk6cG-FRTw.png" /></figure><p>And then create the embedding model as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bpNiqSs_pFeN-LHpRN7Zlg.png" /></figure><h4><strong>3. Implementation of the embedding model and constructing the chat model using Azure OpenAI Service</strong></h4><p>As I have explained above in chapter #2, we need to create a vector out of the output.txt.</p><pre># define the client object<br>client = AzureOpenAI(azure_endpoint=conn_config[&quot;azure_endpoint&quot;],<br>                     api_version=conn_config[&#39;api_version&#39;],<br>                     api_key=conn_config[&#39;api_key&#39;])<br><br># Read the text from output.txt (your resume)<br>with open(&quot;output.txt&quot;, &quot;r&quot;, encoding=&quot;utf-8&quot;) as f:<br>    resume_text = f.read()<br><br># Get embedding from Azure OpenAI<br>response = client.embeddings.create(input=resume_text,<br>                                    model=conn_config[&quot;embedding_model&quot;])<br><br># Extract the embedding vector<br>resume_embedding = response.data[0].embedding<br><br># Print embedding (optional — this is a long array of numbers)<br>print(f&quot;Embedding generated! Vector length: {len(resume_embedding)}&quot;)</pre><p>Do the same operation for the user question, and check the cosine similarity to decide whether they are relevant or not. Don’t forget, the app should not accept/throw an exception the if question is deemed non-relevant. If that is really the case, a different approach might be to still take the question and not using the context provided to the chat, and letting it answer as if there was no context provided.</p><pre># Create embedding for the question<br>question_response = client.embeddings.create(<br>    input=question,<br>    model=embedding_model<br>)<br>question_embedding = question_response.data[0].embedding<br><br># Compute similarity<br>similarity = utils.cosine_similarity(<br>    np.array(question_embedding),<br>    np.array(resume_embedding))<br>print(f&quot;\nSimilarity Score: {similarity:.4f}&quot;)<br><br># If Similar Ask GPT, if not print not relevant<br>  if similarity &gt; config[&quot;similarity_score_threshold&quot;]:<br>      print(&quot;Question is relevant to the resume. Asking GPT...\n&quot;)</pre><p>I have defined <em>config[“similarity_score_threshold”]</em> as 0.6 in my config file but this is just a placeholder for now. Determining the threshold is always a trade-off between false positives, true negatives, etc. There is no universal rule for choosing such a threshold as it depends on your data. Thus, to optimize it, I would suggest doing iterations based on your context and expectations.</p><ul><li>The full code can be found in my GitHub repository <a href="https://github.com/barisbilen1/context-aware-LLM-azure/blob/initial_push/prompt.py">here</a>.</li></ul><p>In the end, it is a simple while loop that will continue taking user’s questions as long as they are relevant to the resume’s content.</p><pre>while True:<br>    question = input(&quot;\nAsk a question about your resume (or type &#39;quit&#39; to exit): &quot;).strip()<br>    if question.lower() == &#39;quit&#39;:<br>        print(&quot;Exiting the chat...&quot;)<br>        break<br><br>    # Create embedding for the question<br>    question_response = client.embeddings.create(<br>        input=question,<br>        model=embedding_model<br>    )<br>    question_embedding = question_response.data[0].embedding<br><br>    # Compute similarity<br>    similarity = utils.cosine_similarity(<br>        np.array(question_embedding),<br>        np.array(resume_embedding))<br>    print(f&quot;\nSimilarity Score: {similarity:.4f}&quot;)<br><br>    # If Similar Ask GPT, if not print not relevant<br>    if similarity &gt; config[&quot;similarity_score_threshold&quot;]:<br>        print(&quot;Question is relevant to the resume. Asking GPT...\n&quot;)<br><br>        messages = [<br>            {<br>                &quot;role&quot;: &quot;system&quot;,<br>                &quot;content&quot;: &quot;You are an assistant that answers questions based on the user&#39;s resume. Only use the resume provided to answer questions.&quot;<br>            },<br>            {<br>                &quot;role&quot;: &quot;user&quot;,<br>                &quot;content&quot;: f&quot;Resume:\n{resume_text}\n\nQuestion:\n{question}&quot;<br>            }<br>        ]<br><br>        # had to create another client for chat model because o4-mini is not supported in westeurope region.<br>        chat_response = client2.chat.completions.create(<br>            model=conn_config[&quot;chat_model&quot;],<br>            messages=messages,<br>            temperature=1<br>        )<br><br>        answer = chat_response.choices[0].message.content<br>        print(f&quot;Answer: {answer}&quot;)<br><br>    else:<br>        print(&quot;Question is not relevant enough to the resume based on similarity.&quot;)</pre><p><strong>→ Notice that in the second element of the <em>messages</em> variable above, we supply the context to the chat model along with the user input.</strong></p><p>An example prompt is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vW3C24ILfY1ub9r5sIT78g.png" /><figcaption>Screenshot from terminal</figcaption></figure><p>The question passed the similarity check, and chat model is provided with the relevant context thereafter, enabling us to get an answer based on our resume instead of a generic answer.</p><h4>4. Implement it on your own</h4><p>If your Azure resources, API endpoints and keys are ready, it will take no more than 10 minutes to build and run my simple app in your local machine.</p><p>Clone my <a href="https://github.com/barisbilen1/context-aware-LLM-azure/tree/initial_push">repository</a> first and follow the README file. In short, you’ll have to create a virtual Python environment, and fill in these two config files I created accordingly. One is to specify the connection details (these will come from a secret manager in production environment of course), the other is to specify the path of your source file, and the threashold for cosine similarity check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5k5yNk_QLsu7lSGOxlgjg.png" /><figcaption>Connection config and static config</figcaption></figure><h3>4) Possible improvements for production environment</h3><p>Above was just an example with a single source file. In most cases, we have multiple files and multiple folders, and we might want to provide their context to the chat model when we ask a question. If that’s the case, generating embeddings of the source files each time we run the application is not a feasible solution. Instead, we should store those embeddings (the vectors) in a database, eliminating the need to re-generate them again and again. The database structure will definitely not be a tabular one, instead it will be a <a href="https://www.cloudflare.com/learning/ai/what-is-vector-database/">vector db</a> where we store the individual vectors. The core functionality of vector databases is to quickly find vectors that are most similar to a given query vector, and when we achieve that, we will be able to provide the most relevant context to our model, and ignore the other ones. Doing so will also enable you to leverage Retrieval-Augmented Generation (RAG). Here is a nice article summarizing the both concepts.</p><p><a href="https://writer.com/engineering/rag-vector-database/">RAG vector database explained</a></p><p>Although I am not (and can’t be) sure, this should essentially be the way how the context-aware chat models integrated in Confluence or Jira work. Tools and the way of implementation might be different than above considering the scale, but the main logic must be the same.</p><p>Having said, one should also consider the refresh cycle of the vectors, to capture the additions and updates in the source files. That is again a trade-off between how up-to-date you would like to stay with your underlying context and related computation costs.</p><p>Thank you for reading! Feel free to hit me up if you have any questions/feedbacks.</p><h3>Resources and further readings</h3><ul><li><a href="https://www.cloudflare.com/learning/ai/what-are-embeddings/">What are embeddings in machine learning?</a></li><li><a href="https://platform.openai.com/docs/guides/embeddings">Vector embeddings</a></li><li><a href="https://en.wikipedia.org/wiki/Cosine_similarity">Cosine Similarity</a></li><li><a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal">Creating and managing Azure resources</a></li><li><a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model">Deploy a model in Azure AI Foundry portal</a></li><li><a href="https://www.cloudflare.com/learning/ai/what-is-vector-database/">What is a vector database?</a></li><li><a href="https://writer.com/engineering/rag-vector-database/">RAG vector database explained</a></li><li><a href="https://github.com/barisbilen1/context-aware-LLM-azure">My project repository</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4464a82fa3a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Onboard your first end-to-end analytics workflow on dbt Cloud using BigQuery at no cost]]></title>
            <link>https://alibarisbilen1.medium.com/onboard-your-first-end-to-end-analytics-workflow-on-dbt-cloud-using-bigquery-at-no-cost-b2e363969777?source=rss-a45f0e43b524------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2e363969777</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[bigquery]]></category>
            <dc:creator><![CDATA[Baris Bilen]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 20:26:43 GMT</pubDate>
            <atom:updated>2024-01-01T20:26:43.100Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A naïve introduction to modern data engineering practices with a step-by-step guide to help you deploy your first dbt project using Google BigQuery for free</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MEE1R1W7nAI3lLR1" /><figcaption>Photo by <a href="https://unsplash.com/@sunder_2k25?utm_source=medium&amp;utm_medium=referral">Sunder Muthukumaran</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Contents</h4><p>· <a href="#6240">What is dbt?</a><br>· <a href="#7dea">How does dbt help data teams?</a><br>· <a href="#0678">Key features of dbt</a><br>· <a href="#9917">A step-by-step guide to onboard a sample analytics workflow on dbt Cloud</a><br> ∘ <a href="#c634">Step 0) Integrate dbt Cloud and BigQuery</a><br> ∘ <a href="#d02e">Step 1) Importing our data</a><br> ∘ <a href="#caa5">Step 2) Define a source for the ingestion of raw data</a><br> ∘ <a href="#41f7">Step 3) Construct staging models</a><br> ∘ <a href="#28bf">Step 4) Define main models</a><br>· <a href="#967c">Bonus (Dashboarding with Google Looker Studio</a>)</p><h3>What is dbt?</h3><p><a href="https://www.getdbt.com/">dbt</a> is a development framework that helps data teams streamline and modularize their analytics workflows, and established itself as one of the pioneers of modern data engineering stack. Standing for ‘<em>data build tool’</em>, dbt is not just an acronym but a game-changer for data professionals seeking efficiency, collaboration, and reliability in their analytics workflows.</p><p>dbt basically compiles and runs your SQL-like analytics code against your data platform (BigQuery, Databricks, Snowflake, etc.), and along with its focus on modularity, dependency management, testing, and documentation, it unleashes the power of analytics engineering. In this article, we delve into the capabilities of dbt and implement a mini project to explore how it empowers data teams to elevate their analytics workflows to new heights.</p><h3>How does dbt help data teams?</h3><p>In traditional data teams, there are mainly two roles, which are data engineers and data analysts. Data engineers are mainly responsible for maintaining data infrastructure and ETL processes and data analysts are mostly the ones who query the data and build up dashboards to drive actionable insights to support business activities. In this traditional setting, dbt identifies a gap between two roles and offers a new paradigm for analytics workflows, by taking advantage of <strong>data warehouses</strong>.</p><blockquote><a href="https://www.coursera.org/articles/data-warehouse?utm_medium=sem&amp;utm_source=gg&amp;utm_campaign=B2C_EMEA__coursera_FTCOF_career-academy_pmax-multiple-audiences-country-multi&amp;campaignid=20858198824&amp;adgroupid=&amp;device=c&amp;keyword=&amp;matchtype=&amp;network=x&amp;devicemodel=&amp;adposition=&amp;creativeid=&amp;hide_mobile_promo&amp;gclid=Cj0KCQiAv8SsBhC7ARIsALIkVT2Q41wrfI6Pnwrtu1lVOlXKeaNUxsxTIruU60y1yumN5Zej7aGoqlkaAhG_EALw_wcB"><strong>Data warehouses</strong></a> combine a database and a computer for transforming data. They support ad-hoc analysis and custom reporting, help you build data pipelines and ML workflows. As of January 2024, <a href="https://cloud.google.com/bigquery?hl=en">BigQuery</a>, <a href="https://www.databricks.com/">Databricks</a>, and <a href="https://www.snowflake.com/en/">Snowflake</a> are the most widely adopted data warehouses in the data analytics industry.</blockquote><p>In this new paradigm, a new concept of “<a href="https://www.getdbt.com/what-is-analytics-engineering">analytics engineering</a>” is introduced, in which the traditional ETL becomes so-called “ELT” (Extract-Load-Transform) where all the transformations (all the way from data ingestion to producing final tables) are computed “on” the data platform, enabling data teams to leverage the power of cloud computing and unified &amp; simplified workflows.</p><h3>Key features of dbt</h3><ol><li><strong>Modularity:</strong> dbt encourages the creation of modular and reusable SQL-like code, making it easier to manage and maintain data transformations.</li><li><strong>Dependency Management:</strong> dbt automatically manages dependencies between different SQL files, ensuring that transformations are executed in the correct order (it offers a built-in data lineage tool).</li><li><strong>Testing:</strong> Users can write tests for their SQL code to ensure that the data meets specific criteria and catches errors early in the development process. dbt also allows testing for the data itself, where it can continuously check the soundness of your source tables.</li><li><strong>Documentation:</strong> Documentation often lags behind the code it is meant to describe. This can happen because documentation is a separate process from the coding itself that lives in another tool like Confluence. dbt provides automated tools for documenting data transformations, making it easier for team members to understand and collaborate on data workflows. With its built-in “<a href="https://docs.getdbt.com/docs/collaborate/documentation">doc block</a>” functionality, we can document our data flow “on the go”, and we can also view lineage in a graph through a dedicated web page.</li><li><strong>Version Control:</strong> Integrates with version control systems like Git, allowing users to track their code/config changes over time.</li><li><strong>Deployment and scheduling:</strong> In dbt, we can create a production-grade data pipeline in a deployment environment (to run dbt in production with a dedicated production branch &amp; schema), schedule a job, review the results and artifacts of a job. That reduces the development effort that would be spent by data engineers when setting up orchestration tools like Airflow, or alert management tools like PagerDuty (dbt also has a built-in <a href="https://five.co/blog/webhooks-explained/">outbound webhook</a> that can send messages to a specified address in case of a failure).</li></ol><h3>A step-by-step guide to onboard a sample analytics workflow on dbt Cloud</h3><p>The rest of the article walks us through the steps we need to take to onboard a sample dbt Cloud &amp; BigQuery powered data pipeline at <strong>no cost</strong>. For this, we are going to use BigQuery Sandbox which is a free, no-cost way to experiment with BigQuery.</p><blockquote><em>All codes are available in my GitHub </em><a href="https://github.com/barisbilen1/dbt-mini-project_london_biking"><em>repository</em></a><em>.</em></blockquote><h4>Step 0) Integrate dbt Cloud and BigQuery</h4><p>To do so, we first need to have our BigQuery account and dbt Cloud account integrated. If you don’t have a GCP account yet, you can create a free-tier account by clicking “<em>Start Free</em>” button here in <a href="https://cloud.google.com/?hl=en">this</a> page. After that we need to create a service account, which you can do so by following the steps in <a href="https://cloud.google.com/iam/docs/service-accounts-create">this</a> guide from Google. You can choose your role as “owner”. Having generated your service account, go to “<em>Keys</em>” section in service account page and then click “<em>ADD KEY</em>”, in order to create JSON file that hosts the associated key for your service account. In the end, don’t forget to download this JSON file to your local computer.</p><p>What we need to do now is to provide this service account key to the dbt project we will work on. Assuming that you have created your dbt account from <a href="https://www.getdbt.com/signup">here</a> (make sure to select “Developer” plan in <em>Billing</em> tab under <em>Account Settings</em> to proceed with the free plan), create a new project from the top right button in <em>Projects </em>tab, and upload your JSON file <em>by clicking</em><strong><em> “Upload a Service Account JSON file” </em></strong>button (also make sure to select “BigQuery” as your connection type. Now we have successfully configured the dbt-BigQuery connection.</p><blockquote><strong>Remark 1:</strong> In case of any challenges when setting dbt Cloud-BigQuery connection, you can follow <a href="https://medium.com/simform-engineering/quickstart-for-dbt-cloud-and-bigquery-run-your-first-dbt-model-ce7824784ae3#82f0">this</a> great article by Rahul Nathjogi.</blockquote><blockquote><strong>Remark 2:</strong> In our mini project, we use our personal account. If you want to deploy your project within a company account at your job, please make sure;<br> i) your service account is granted with “job user” and “data editor” roles<br> ii) you have access to the internal BigQuery account of your company<br> iii) you have access to the projects.</blockquote><h4>Step 1) Importing our data</h4><p>For such illustrative mini projects, it’s always convenient to use public datasets, as they are hosted on BigQuery (Google pays for the storage so you don’t have to worry) and are easy to locate.</p><p>For our project, we’re going to use “<em>london_bicycles</em>” dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IQ2SvRMnoIfpFUbnhC-Ueg.png" /><figcaption>Click “+ADD” button on the top left and search for “London bicycle hires”</figcaption></figure><p>Data is coming from <em>Santander Cycles</em>, which is London’s public bicycle hire scheme for short journeys. There are two tables in this dataset, namely <em>cycle_hire</em> and <em>cycle_stations</em>, in which the former contains details of the bike hires from 2011 to 2023, including information such as start &amp; stop timestamps, ride duration and station names, where the latter stores more station-specific data. In our mini project, we’ll use the former, the <em>cycle_hires</em>. This table consists of 80+ million rows, but we’ll be using a subset for the sake of keeping things simple for illustration purposes.</p><p>Since this public dataset is served on <em>bigquery-public-data </em>project, where we don’t have the permissions to create tables, views, or save queries, we need to carry our data to our own project in order to have more control over it. We do so by creating a temporary table from this table and copying it into our own project, as a new table.</p><pre>SELECT<br>  rental_id,<br>  duration, -- in seconds<br>  bike_id,<br>  start_station_name,<br>  end_station_name,<br>  EXTRACT(DATE FROM start_date AT TIME ZONE &quot;UTC&quot;) AS date<br>FROM<br>  `bigquery-public-data`.`london_bicycles`.cycle_hire<br>WHERE<br>  start_date &gt; &quot;2023-01-01 12:00:00 UTC&quot;<br>ORDER BY<br>  date ASC;</pre><p>With the query above, we only focus on the bike hires in the first two weeks of 2023, and this reduces the row count to 233k.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9WZ4VE2_8zuankPDiMI9Q.png" /><figcaption>Create our raw data from the public dataset and copy the resulting table to our own project.</figcaption></figure><p>Now our raw data (<em>cycle_hires_raw</em>) is ready on BigQuery and is ready to be processed through dbt Cloud as our source table.</p><p>To start development, we go to dbt Cloud IDE and create a new branch on our git repository from the top left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGwhiUKxb05SLGLHkDiqrQ.png" /><figcaption>Create/change branch from the top left</figcaption></figure><h4>Step 2) Define a source for the ingestion of <em>raw data</em></h4><p>We save the following code block as <em>“src_london_biking.yml”, </em>to define our source table.</p><pre>version: 2<br><br>sources:<br>  - name: london_biking<br>    database: bigquery-dbt-project-baris<br>    schema: london_biking<br>    tables:<br>      - name: cycle_hires_raw</pre><p>Place this .yml file under <em>models/staging/london_biking/src_london_biking.yml.</em></p><h4>Step 3) Construct staging models</h4><p>In step 2) we have defined our source table that will be processed through our workflow. As a general practice, we construct a <em>staging</em> model, to prepare the data for further analysis. We save the below code block as <em>“stg_cycle_hires.sql” </em>and place it under <em>models/staging/london_biking/stg_cycle_hires.sql</em>. Note that the file extension is “<em>.sql</em>”, as this is a <em>model </em>(model: piece of work to be executed, written in SQL/Jinja-like syntax).</p><pre>with<br>    cycle_hires as (<br><br>        select<br>            rental_id,  -- unique identifier for each ride<br>            duration as ride_duration,<br>            bike_id,<br>            start_station_name as start_station,<br>            end_station_name as end_station,<br>            date as rental_date<br>        from {{ source(&quot;london_biking&quot;, &quot;cycle_hires_raw&quot;) }}<br><br>    )<br><br>select * from cycle_hires</pre><h4>Step 4) Define main models</h4><p>In this step, we’ll aggregate our data to drive some insights. Aggregation in data analysis is crucial for simplifying complex datasets and deriving meaningful insights by summarizing individual data points into key metrics. For instance, meaningful metrics for a bike rental company could include;</p><p>a) <strong>Average ride duration in most popular routes:</strong> helps optimize bike allocation, marketing efforts, and infrastructure development.</p><pre>with<br>    ride_duration as (<br><br>        select<br>            start_station,<br>            end_station,<br>            avg(ride_duration) / 60 as average_ride_duration<br>        from {{ ref(&quot;stg_cycle_hires&quot;) }}<br>        where ride_duration &lt; 864000 --&gt; exclude the rentals with duration over 10 days, possibly indicating a long term lease or data error<br>        group by start_station, end_station<br>        order by average_ride_duration desc<br><br>    )<br><br>select * from ride_duration</pre><p>Save this model as <em>calculate_avg_ride_duration.sql </em>and place it under <em>models/marts/core/.</em></p><p>b) <strong>Utilization rate</strong>: calculating the percentage of time bikes are in use versus idle provides insights into overall bike demand and fill ratio (fill ratio being a measure of how efficiently the bike demand is met).</p><pre>with<br>    bike_usage as (<br><br>        select<br>            bike_id,<br>            sum(ride_duration) / 60 as ride_duration_daily_sum,  -- convert seconds to minutes<br>            rental_date<br>        from {{ ref(&quot;stg_cycle_hires&quot;) }}<br>        where ride_duration &lt; 864000 --&gt; exclude the rentals with duration over 10 days, possibly indicating a long term lease or data error<br>        group by rental_date, bike_id<br><br>    ),<br><br>    bike_usage_rates as (<br><br>        select<br>            rental_date,<br>            avg(ride_duration_daily_sum / 1440) as daily_utilization_rate --&gt; /1440 to get the % usage in 24 hours<br>        from bike_usage<br>        group by rental_date<br>        order by rental_date desc<br><br>    )<br><br>select * from bike_usage_rates</pre><p>Save this model as <em>calculate_utilization_rate.sql </em>and place it under <em>models/marts/core/.</em></p><p>In the end, below is the visual representation of our workflow, i.e. lineage graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7ejwDx9NLNCzUfYwhS_pQ.png" /><figcaption>Lineage graph of our simple work flow, provided by dbt as a built-in feature.</figcaption></figure><p>We are now ready to run our workflow by running “dbt run” command in console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p0kSaXweBdIVO0QKlDWr5g.png" /><figcaption>run “dbt run” command to run the work flow</figcaption></figure><p>Let’s go to BigQuery to see whether those tables are actually created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKFep9BiifrdljcSpvxXhA.png" /><figcaption>Two new output tables are created as a result of our models</figcaption></figure><p>Our dbt-cloud based analytics workflow comes to an end here. In real life, these output tables would probably be fed into a machine learning model or a BI tool such as Tableau, PowerBI or Looker Studio, in order to provide analysts summarized &amp; visualized data to enable them to drive actionable insights.</p><h3>Bonus</h3><p>Here in this bonus section, I would like to introduce Looker Studio (successor of Google Data Studio following Google’s acquisition of Looker), Google’s BI solution. After producing the final tables, I wanted to take a quick look into the data and thought this might be a good opportunity to try out Looker Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBQ_JomNNrBYQrQ3-vMaZQ.png" /><figcaption>Click “Explore with Looker Studio”</figcaption></figure><p>After clicking “Explore with Looker Studio”, a new tab will open up in which you can make your report on top of this table. It is pretty much similar to Tableau or any other BI tool, in which you can add the metrics you’d like to visualize/filter at various aggregation levels.</p><p>If you want to add more tables to your report (which you would probably do), click “Add data” button at the very bottom right, and choose your BigQuery table from the pop-up window that you want to enrich your report with. Below is the report I could come up with after 15 mins of looking around.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_3usVqi_9uIJ5b6QvwNF1A.png" /><figcaption>A basic Looker Studio report revealing the metrics we have calculated throughout our mini project</figcaption></figure><p>If you have made it this far, I’d like to thank you for reading! I hope the article gave at least an inspiration to delve deeper into the modern analytics stack in general. Feel free to hit me up if you have any questions/feedbacks. Cheers!</p><h3>Resources</h3><ul><li><a href="https://courses.getdbt.com/courses/dbt-cloud-and-bigquery-for-developers">dbt Cloud and BigQuery for Developers</a></li><li><a href="https://courses.getdbt.com/courses/fundamentals">dbt Fundamentals</a></li><li><a href="https://medium.com/simform-engineering/quickstart-for-dbt-cloud-and-bigquery-run-your-first-dbt-model-ce7824784ae3#6e5d">QuickStart for DBT Cloud and Bigquery | Run Your First DBT Model</a></li><li><a href="https://www.analytics8.com/blog/dbt-overview-what-is-dbt-and-what-can-it-do-for-my-data-pipeline/#">What is dbt?</a></li><li><a href="https://www.coursera.org/articles/data-warehouse?utm_medium=sem&amp;utm_source=gg&amp;utm_campaign=B2C_EMEA__coursera_FTCOF_career-academy_pmax-multiple-audiences-country-multi&amp;campaignid=20858198824&amp;adgroupid=&amp;device=c&amp;keyword=&amp;matchtype=&amp;network=x&amp;devicemodel=&amp;adposition=&amp;creativeid=&amp;hide_mobile_promo&amp;gclid=Cj0KCQiAv8SsBhC7ARIsALIkVT2Q41wrfI6Pnwrtu1lVOlXKeaNUxsxTIruU60y1yumN5Zej7aGoqlkaAhG_EALw_wcB">Data warehouse: Definition, Uses and Examples</a></li><li><a href="https://www.getdbt.com/what-is-analytics-engineering">What is Analytics Engineering?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2e363969777" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>