<?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 Srutimala Deka on Medium]]></title>
        <description><![CDATA[Stories by Srutimala Deka on Medium]]></description>
        <link>https://medium.com/@sruti.mail20?source=rss-622a72510b0f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Zhe0nnfxan_XFbloDtzIFw.png</url>
            <title>Stories by Srutimala Deka on Medium</title>
            <link>https://medium.com/@sruti.mail20?source=rss-622a72510b0f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:35:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sruti.mail20/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[Sub-Second Inference on Snowflake: Real-Time Recommendations Powered by Snowflake ML and Snowpark…]]></title>
            <link>https://medium.com/snowflake/sub-second-inference-on-snowflake-real-time-recommendations-powered-by-snowflake-ml-and-snowpark-80731353bee2?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/80731353bee2</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[snowpark-container]]></category>
            <category><![CDATA[latency-optimization]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Tue, 12 Aug 2025 19:49:10 GMT</pubDate>
            <atom:updated>2025-08-12T19:49:10.550Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sub-Second Inference on Snowflake: Real-Time Recommendations Powered by Snowflake ML and Snowpark Container Services</h3><p>Author: Srutimala Deka</p><p>Co-Authors: Puneet Lakhanpal, Vivek Kanna Jayaprakash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lHUhxwrLKVcw08z0KB7hlw.png" /><figcaption>generated using gemini flash</figcaption></figure><blockquote>Ever wondered how brands offer tailored solutions to each of their customers at lightning speed?</blockquote><p>We took the example of a credit card recommendation solution that caters to each user on the website — all at once, using <a href="https://www.snowflake.com/en/">Snowflake</a>!</p><p>We built a <strong>custom recommendation model </strong>and deployed it in the same environment where the data resides, with the provision to use the model within any custom website.</p><p><strong>In this blog we aim to:</strong></p><ul><li><strong>Provide insights into deploying and optimizing ML models for low latency inference on Snowpark Container Services (SPCS), addressing a critical need for many businesses.</strong></li><li><strong>Outline architectural patterns and optimizations such as leveraging specific technical configurations to achieve desired performance metrics.</strong></li><li><strong>Showcase a POC that achieved an impressive inference of 0.17 seconds latency for 200 concurrent users.</strong></li></ul><h3>Problem Statement</h3><p>When a customer visits a credit card website or mobile application, a delay of even a few seconds in receiving a personalized recommendation can lead to:</p><ul><li><strong>Missed Opportunities</strong>: A delayed recommendation means a lost chance to engage the customer at their peak interest. The relevancy and impact of a recommendation diminish rapidly with time.</li><li><strong>Negative Brand Image</strong>: A clunky, slow experience can erode trust and negatively impact brand perception, making it harder to build long-term customer loyalty.</li></ul><p>Our objective in this series of experiments is to directly address the critical pain point of building and deploying a credit card recommendation model within Snowflake such that its inference latency is consistently <strong>1 second or less for up to 200 concurrent users.</strong></p><h3>Solution Design and its Components</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2iVHK_OHag5Pa-pu" /></figure><p>The following design components compose the final solution:</p><ol><li><strong>Snowflake:</strong> The foundational platform where the credit card data resides. By having the credit card data directly within Snowflake, we eliminate the need for costly and time-consuming data movement to external platforms for model training and inference. This ensures data residency, simplifies governance and compliance, and significantly reduces the security risks associated with moving sensitive financial data. Its robust data warehousing capabilities provide a reliable and scalable source for our recommendation model.</li><li><strong>Machine Learning Model (Python with numpy, sklearn, Snowflake Python Notebooks):</strong> The core intelligence generating credit card recommendations. An LTR (Learning to Rank) model was developed using standard Python libraries. Building the model within Snowflake Python Notebooks ensures that data and development happen in the same secure environment, preventing data egress.</li><li><strong>Snowpark Container Services (SPCS):</strong> The robust deployment and serving environment for our model within Snowflake. SPCS is a fully managed service within Snowflake that allows users to deploy and run containerized applications, including custom machine learning models, directly within the Snowflake environment. SPCS is critical for achieving low inference latency by providing a dedicated, scalable environment for model serving. Its ability to leverage CPU and GPU compute pools allows us to select the optimal hardware for our LTR model, while multiple compute nodes enable parallel processing of inference requests, significantly boosting throughput and reducing individual request latency.</li><li><strong>Ray Serve:</strong> A framework for highly scalable and performant model serving. The key benefit of Ray Serve in our scenario is its <strong>dynamic request batching</strong>. For an LTR model, individual inference requests might be small. Ray Serve efficiently groups multiple incoming requests into larger batches, which can then be processed much more efficiently by the underlying hardware (CPU/GPU). This maximizes compute utilization and significantly reduces the per-request latency for our credit card recommendations, contributing directly to the 1-second target.</li><li><strong>Ngrok:</strong> A secure tunneling service for exposing local services to the internet. Ngrok played a crucial role during the <em>experimentation and testing phase</em> to rapidly expose our model running in various environments (like Google Colab or a local Ray cluster) for external access and latency testing.</li></ol><h3>Experimentations Conducted with Snowflake SPCS</h3><p>The goal to a sub-second inference latency for credit card recommendations involved a series of experiments designed to uncover optimal configurations within Snowpark Container Services (SPCS).</p><p>The results, summarized below, reveal an interesting interplay of compute resources, architectural choices, and optimizations -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*WeWTr82UCRJ8U74VZTmumg.png" /></figure><h3>Initial Baseline and Bottleneck</h3><p>Our first attempt, deploying the <strong>LTR Model in SPCS on High memory CPU nodes</strong>, yielded a latency of <strong>1.9 seconds for 50 users</strong>. The single instance of CPU nodes wasn’t enough; further optimization of compute and serving strategy was required to hit our sub-second target.</p><h3>Optimization with Ngrok and CPU_X64_S Compute</h3><p>A significant improvement occurred when we deployed the <strong>LTR Model in SPCS with Ray and Ngrok on a single CPU_X64_S instance</strong>. The latency plummeted to a remarkable <strong>0.280 seconds for 200 users</strong>. This can be attributed to the following:</p><ul><li><strong>Ray’s Efficiency with Dynamic Batching:</strong> This result strongly validates the power of Ray Serve’s dynamic batching. By efficiently grouping multiple inference requests, the CPU_X64_S instance, though seemingly smaller than “high memory CPU nodes” was able to process requests much more effectively.</li><li><strong>Ngrok’s Role in Testing:</strong> While Ngrok wouldn’t be part of a production architecture, its presence here was crucial for simulating real-world client requests and measuring true end-to-end latency from an external perspective. It provided a quick and easy way to expose our SPCS service for external testing without complex network configurations, accelerating our experimentation cycle.</li><li><strong>Optimal CPU Selection:</strong> The CPU_X64_S instance type within SPCS provided a good balance of CPU power and memory for our LTR model when combined with Ray’s batching, proving that ‘more’ isn’t always ‘better’ for specific workloads if not utilized efficiently.</li></ul><h3>Google Colab for External Benchmarking</h3><p>The experiment with the <strong>LTR Model in Google Colab + Ngrok on an NVIDIA T4 GPU</strong> provided a stark contrast, resulting in a significantly higher latency of <strong>6.2 seconds for 200 users</strong>. This outcome, despite using a powerful NVIDIA T4 GPU (known for its inference capabilities), underscores a crucial point:</p><ul><li><strong>Environmental Overhead:</strong> Running in a general-purpose environment like Google Colab, even with a strong GPU, introduces considerable overhead (e.g., network latency, containerization layers not optimized for serving, potential resource sharing with other users) that severely impacts real-time inference performance.</li><li><strong>GPU vs. CPU for LTR:</strong> While GPUs excel at highly parallelized tasks typical of deep learning, a simpler LTR model, especially one optimized with numpy and served efficiently with Ray’s CPU-focused batching, might not see the same dramatic benefit from a GPU, or the overhead of GPU utilization might negate its advantages if the model isn’t designed to fully saturate the GPU. This suggests that for certain shallow learning models, a well-optimized CPU-based serving strategy can outperform a less optimized GPU deployment.</li></ul><h3>The Optimized Configuration</h3><p>Our final, most refined experiment involved the <strong>LTR Model in SPCS with Ray &amp; Ngrok (optimized) on 5 core CPU_X64_S</strong>. This configuration achieved an impressive <strong>0.170 seconds for 200 users</strong>, slightly outperforming the previous non-optimized CPU_X64_S result.</p><ul><li><strong>Optimized Configuration:</strong> Performing further fine-tuning of the Ray Serve configuration and using numpy array operation showed incremental improvement validating the iterative nature of performance engineering.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*KjyVfY1qJlWhc1YYN8l8fw.png" /><figcaption>optimized configurations</figcaption></figure><p>This result represents our optimal balance. We achieved <strong>sub-second latency (0.170s)</strong>, comfortably within our 1-second target, for a significant load of <strong>200 concurrent users</strong>. Crucially, this was accomplished on a <strong>5-core CPU_X64_S</strong> instance.</p><h3>Final Verdict: Best Performance vs. Minimal Compute</h3><p>While changing our recommendation model could result in a slightly altered performance, our experimentation with the LTR model demonstrates that by intelligently combining Snowflake SPCS, Ray Serve’s dynamic batching, and careful model/code optimization, we can achieve:</p><ul><li><strong>Exceptional Latency:</strong> Consistently below our 1-second target, ensuring a seamless user experience.</li><li><strong>Scalability:</strong> Handling 200 concurrent users with ease.</li><li><strong>Cost Efficiency:</strong> Achieving this performance on a modest 5 core CPU_X64_S instance, rather than expensive GPU compute or overly large CPU nodes, which aligns with responsible resource utilization.</li></ul><p>Snowflake’s Snowpark Container Services, when paired with the right serving strategies, is a highly capable platform for deploying and scaling real-time machine learning inference, empowering businesses to deliver truly personalized and instantaneous experiences.</p><h3>References</h3><ol><li><a href="https://www.snowflake.com/en/blog/container-runtime-GPU-training-inference/">Container Runtime For GPU Training &amp; Inference</a> — Use GPU in Snowflake Notebooks</li><li><a href="https://quickstarts.snowflake.com/guide/intro_to_snowpark_container_services/index.html#1">Deploy Model in SPCS</a> — Quickstart to push a model into SPCS and create a service</li><li><a href="https://docs.snowflake.com/en/user-guide/ui-snowsight/notebooks-external-access">External access for Snowflake Notebooks</a> — Create an external access integration for PyPI</li></ol><h4>Have questions or want to explore how this solution can work for your organization?</h4><h4>Feel free to reach out to us at <a href="/service/mailto:appsupport@kipi.ai">appsupport@kipi.ai</a> — we’re here to help!</h4><blockquote>Connect with the authors on LinkedIn for further discussions on AI in Snowflake:</blockquote><blockquote><a href="https://www.linkedin.com/in/srutimala-deka-825190186/">Srutimala Deka</a> from Kipi.ai, <a href="https://www.linkedin.com/in/puneet-lakhanpal-3b49266/">Puneet Lakhanpal</a> from Snowflake, <a href="https://www.linkedin.com/in/vivek-kanna-jayaprakash/">Vivek Kanna</a> from Kipi.ai</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80731353bee2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snowflake/sub-second-inference-on-snowflake-real-time-recommendations-powered-by-snowflake-ml-and-snowpark-80731353bee2">Sub-Second Inference on Snowflake: Real-Time Recommendations Powered by Snowflake ML and Snowpark…</a> was originally published in <a href="https://medium.com/snowflake">Snowflake Builders Blog: Data Engineers, App Developers, AI, &amp; Data Science</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mitigating Risks in LLM Applications]]></title>
            <link>https://medium.com/@sruti.mail20/mitigating-risks-in-llm-applications-06e92ef9b7fb?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/06e92ef9b7fb</guid>
            <category><![CDATA[llm-guardrails]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm-evaluation]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llm-applications]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Sat, 31 May 2025 15:17:45 GMT</pubDate>
            <atom:updated>2025-05-31T15:19:19.814Z</atom:updated>
            <content:encoded><![CDATA[<p>Solutions and Tools to prevent catastrophe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N-4ybnc99oVhwYt9" /><figcaption>Photo by <a href="https://unsplash.com/@okaylizzi?utm_source=medium&amp;utm_medium=referral">Lizzi Sassman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As LLM becomes popular and we discover new ways to harness it, I personally feel compelled to stay up to date on the risks and protective measures throughout the development and deployment lifecycle — not just as a best practice, but a necessity for building trustworthy and effective AI solutions.</p><p>Here’s summarizing what I learned in this blog.</p><h3>Common Risks in LLM-Based Applications</h3><ol><li>Prompt Injection: Users trying to manipulate the LLM’s instructions, bypass its safety features, or extract <strong>sensitive </strong>information e.g., “ignore previous instructions…”</li><li>Inappropriate User Input: Users providing sensitive data or asking to generate inappropriate content that goes against company policy or ethics.</li><li>Inappropriate LLM Output: The LLM generating responses that are toxic, discriminatory, or are generally unsuitable for users.</li><li>Hallucinations: A common problem where the LLM generates factually incorrect and made-up information.</li><li>Extreme Autonomy to LLM: The LLM making critical decisions without human oversight.</li></ol><h3>Preventive Measures and Helpful Tools</h3><h4>💉Prompt Injection</h4><p>I) Implement programmatic rules to detect patterns in common prompt injection techniques such as certain words.</p><p>II) Have an LLM summarize <strong>intent </strong>of the user input to evaluate if it is an attempt at prompt injection.</p><p>III) Remove or mask sensitive information that goes into LLM so that it doesn’t have access to such information in the first place.</p><blockquote>If possible, use predefined templates or input frameworks (select boxes), limiting the liberty provided by free text input.</blockquote><blockquote>Tools like LangChain’s prompt templates or LlamaIndex’s query engines can be designed with initial filtering layers.</blockquote><h4>❗Inappropriate User Input</h4><p>I) For sensitive information in user input, use <strong>NLP </strong>to identify and redact Personal Information, confidential company data, etc.</p><p>II) Use an LLM to <strong>flag </strong>user input of containing sensitive data.</p><p>II) Classify user input as inappropriate using a trained <strong>ML model</strong> for a cheaper option and flag the input.</p><blockquote>Google Cloud’s Generative AI Safety API and Azure AI Content Safety provides safety attribute detection.</blockquote><h4>‼️Inappropriate LLM Output</h4><p>I) Similar to user input filtering, <strong>programmatically monitor </strong>LLM’s generated response for harmful keywords, phrases, and patterns.</p><p>II) Use an LLM to <strong>flag </strong>harmful content in the response.</p><p>III) For fine-tuned LLM model, <strong>underlying data</strong> should be unbiased and emphasize ethics during training.</p><blockquote>OpenAI Moderation API can check generated response for safety. Google Responsible AI and Microsoft also provide frameworks to assess LLM fairness.</blockquote><h4>🚩Hallucinations</h4><p>I) For RAG applications, verify the groundedness of the LLM’s response for the provided context.</p><p>II) Include a confidence score with the LLM’s response to indicate its certainty — if possible.</p><p>III) Instruct the LLM to provide its reasoning and sources to ensure groundedness.</p><blockquote>Many frameworks like <strong>TruLens, LangSmith, RAGAS — </strong>support groundedness evaluation.</blockquote><h4>🎱Extreme Autonomy to LLM</h4><p>I) For high-stakes scenarios in medical or legal, implementing a human-in-the-loop to review and approve LLM response.</p><p>II) Change the persona of the LLM response, by curating its purpose and role from an ‘expert’ or ‘teacher’ to a ‘helpful assistant’ only.</p><blockquote>Having a human in the loop is the most reliable way to prevent <strong>unpredictable incidents</strong> involving LLMs where it can lead to litigation or loss of life.</blockquote><blockquote>A layered defense strategy has to be implemented in real world applications and that includes rigorous testing like any other application.</blockquote><p>As always, find me on LinkedIn <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">here </a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wW6Gfck5LJbK8qer" /><figcaption>Photo by <a href="https://unsplash.com/@ilhamfzn?utm_source=medium&amp;utm_medium=referral">Mohamad Ilham Fauzan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06e92ef9b7fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build : AI Assistant with Google’s Agent Development Kit (ADK)]]></title>
            <link>https://medium.com/@sruti.mail20/build-ai-assistant-with-googles-agent-development-kit-adk-3d67acd026eb?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d67acd026eb</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[agentic-workflow]]></category>
            <category><![CDATA[ai-assistant]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Sun, 25 May 2025 14:59:09 GMT</pubDate>
            <atom:updated>2025-05-25T14:59:09.313Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build : AI Assistant with Google’s Agent Development Kit (ADK)</h3><p>Fast, Familiar and Fun!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YbhtkxAVUjYUUGkE" /><figcaption>Photo by <a href="https://unsplash.com/@danielkcheung?utm_source=medium&amp;utm_medium=referral">Daniel K Cheung</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is Google’s ADK and why it was love at first encounter for me?</h3><p>Google Agent Development Kit (ADK) is a framework that provides abstraction to the process of building, deploying, and orchestrating LLM agents. It’s designed to make agent development be more like traditional software development.</p><p>Key Benefits:</p><ul><li>It is an<strong> open-source</strong> framework</li><li>This framework is model and deployment-<strong>agnostic </strong>— so that you are not bound my these constraints in your solution</li><li>ADK provides <strong>abstraction </strong>for the agent’s decision-making loops, and tool usage — this single handedly transforms an AI development process into a software development experience</li><li><strong>Python </strong>being the underlying language which is popular and easy to use. Every functionality and ‘tool’ is a regular python function.</li></ul><blockquote>For a thorough understanding, check out their page <a href="https://developers.googleblog.com/en/agent-development-kit-easy-to-build-multi-agent-applications/">here</a>.</blockquote><h3>What did we build?</h3><p>My dream to have a Jarvis-like personal assistant has started to take shape with this ADK framework.</p><p>While we are far away from having synthetic intelligence (SI), for many tasks, we can define tools and logic to have agents simulate real intelligence. I am starting with a google calendar event manager that asks for relevant details and also checks the weather before putting it on my calendar.</p><blockquote>Check out <a href="https://medium.com/@sruti.mail20/build-with-n8n-ai-agent-with-dynamic-reasoning-cf3ec84320e2">this blog</a> where I built the same assistant with n8n cloud software.</blockquote><h3>Project Components</h3><h4>The first step is to open up this <a href="https://google.github.io/adk-docs/get-started/quickstart/#project-structure">quick start</a> from google to understand the structure of the framework.</h4><p>The project uses the following components:</p><ol><li><strong>The ADK module</strong>: Simply pip-install the library <em>google-adk</em> and setup an application in GCP and you are good to start developing.</li><li><strong>LLM Model</strong>: I used Gemini (gemini-2.0-flash), so I created my google project and api keys before getting started. You can deploy your own LLM model and use here for inference. One LLM is the decision maker in the workflow and the one to dictates the flow.</li><li><strong>Tools</strong>: Tools are nothing but the additional components that help the LLM do its job seamlessly. LLMs are language models and can answer from its knowledge base but to access the external world, it will need API keys and certain privileges to <strong>put words into action</strong>. In this case, the weather and calendar tools were defined as python functions . I used the <a href="https://weatherstack.com/documentation">weather stack</a> api for forecasted weather and allowed access to my primary calendar to the agent app.</li></ol><h3>Understanding what happens behind the scene</h3><ol><li><strong>User Request:</strong> The user’s current input and its system prompt is analyzed for persona and other details. We can provide our own prompt to dictate the agent’s purpose.</li><li><strong>Reasoning and Tool Selection: </strong>Based on analysis, the LLM performs reasoning to determine the best course of action, which can be — ask clarifying questions or invoke a tool or another agent.</li><li><strong>Tool Awareness:</strong> The LLM is aware of the tools defined due to the function names, docstrings, and input/output types. This helps the LLM to decide the appropriate tool to use and when to use them. It also intelligently <strong>generates the required arguments</strong> for the selected tool (function). <strong>ADK abstracts how the tools are ‘visible’ to the LLM and how it is invoked.</strong></li><li><strong>Iterate &amp; Generate Output: </strong>The agent receives the output of the executed tool (or another agent). This output is then incorporated back into the agent’s context for further decision making and eventually finishing the task.</li></ol><h3>Example Code</h3><h4>Definition for Calendar Event Tool</h4><pre>def set_calendar_event(event: dict) -&gt; dict:<br>    <br>    &quot;&quot;&quot;set event on calendar with the attributes collected from user. Use your conversation to fill up the parameters correctly<br>    such as timezone can be inferred based on the city (India/kolkata by default).<br><br>    Args:<br>        event (dict): event details we know so far<br>        in the below format:<br>        event = {<br>                &#39;summary&#39;: &#39;Google I/O 2015&#39;,<br>                &#39;location&#39;: &#39;Default&#39;,<br>                &#39;description&#39;: &#39;A chance to hear more about Google\&#39;s developer products.&#39;,<br>                &#39;start&#39;: {<br>                    &#39;dateTime&#39;: &#39;2015-05-28T09:00:00-07:00&#39;,<br>                    &#39;timeZone&#39;: &#39;Asia/Kolkata&#39;,<br>                },<br>                &#39;end&#39;: {<br>                    &#39;dateTime&#39;: &#39;2015-05-28T17:00:00-07:00&#39;,<br>                    &#39;timeZone&#39;: &#39;Asia/Kolkata&#39;,<br>                },<br>                &#39;recurrence&#39;: [<br>                    &#39;RRULE:FREQ=DAILY;COUNT=2&#39;<br>                ],<br>                &#39;attendees&#39;: [],<br>                &#39;reminders&#39;: {<br>                    &#39;useDefault&#39;: True<br>                },<br>                }<br><br><br>    Returns:<br>        status: error or success status<br>    &quot;&quot;&quot;<br>        <br>    # Load credentials (after OAuth flow)<br>    <br>    SCOPES = [&quot;https://www.googleapis.com/auth/calendar.events&quot;]<br>    creds = Credentials.from_authorized_user_file(&#39;C:/Users/wwwsh/Agent_AI_GCP/multi_tool_agent/token.json&#39;, SCOPES)<br>    print(creds)<br>    print(&quot;EVENT from llm &quot;, event)<br>    # Build the service object<br>    service = build(&#39;calendar&#39;, &#39;v3&#39;, credentials=creds)<br>    event = service.events().insert(calendarId=&#39;primary&#39;, body=event).execute()<br>    return &#39;Event created: %s&#39; % (event.get(&#39;htmlLink&#39;))</pre><p>Notice the docstring provided. It defines the purpose of the function and the arguments. It can also define how the API call should look like, so that LLM can follow the format with dynamic arguments (as I did)— or we can programmatically use variables from LLM response and plug it into the API call.</p><blockquote>While hallucination can be a rare problem based on my testing with gemini -using a memory or session (another ADK component) can greatly help.</blockquote><h4>Definition for the Core Agent</h4><pre>root_agent = Agent(<br>    name=&quot;calendar_event_setting_agent&quot;,<br>    model=&quot;gemini-2.0-flash&quot;,<br>    description=&quot;Agent that talk to the user about setting calendar event and ask followup questions &quot;<br>    &quot;in order to fill missing details about the calendar event. &quot;,<br>    instruction=&quot;Answer questions using ask_gemini tool and ask questions when details are missing for &quot; \<br>    &quot;logging event into the calendar.&quot; \<br>    &quot;Unless mentioned, events are always single day based.&quot; \<br>    &quot;It is Important to check weather and alert user for extreme weather prediction on that day. &quot; \<br>    &quot;Create the event after confirming from user.&quot;,<br>    tools=[ask_gemini, check_weather, set_calendar_event],<br>)</pre><p><strong>The most exciting thing about this framework is the turnaround time</strong> — I built this within a couple of days and most of it was spent on setting up permissions and testing rather than building the agent.</p><p>Can’t wait to build a more complex, multi-agent system that act like a real assistant.</p><p>As always, you can find me on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn</a>. I am open to grabbing a coffee to chitchat about AI and data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*49k0JuAu7e15KJ75" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d67acd026eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build with n8n: AI Agent with dynamic reasoning]]></title>
            <link>https://medium.com/@sruti.mail20/build-with-n8n-ai-agent-with-dynamic-reasoning-cf3ec84320e2?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf3ec84320e2</guid>
            <category><![CDATA[personal-assistant]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[n8n-workflow]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Wed, 07 May 2025 14:12:42 GMT</pubDate>
            <atom:updated>2025-05-07T14:32:08.311Z</atom:updated>
            <content:encoded><![CDATA[<p>Jarvis was not built in a day!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QFmd7ttRKqEf6MNH" /><figcaption>Photo by <a href="https://unsplash.com/@lazargugleta?utm_source=medium&amp;utm_medium=referral">Lazar Gugleta</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I was gifted an Alexa by my organization couple of years back. Since then I have dreaded her frequent <em>sorry I don’t know how to help you with that. </em>As a data scientist, I now constantly think about making a smarter assistant.</p><p>To start with, I wanted to try out building an agent that could schedule events on my calendar but also make decisions for me without me having to spoon-feed it everything — in short<strong> give my machine some form of reasoning capability</strong>!</p><p>I am using <a href="https://n8n.io/"><strong>n8n</strong></a><strong> </strong>to build an AI Agent that can help me put events on my calendar —<strong> but take it one step further </strong>— the idea is to have my assistant check the weather, my past schedules and my preferences to ensure <strong>I plan my life in a more conscious way.</strong></p><blockquote>The MVP described below shows how to incorporate weather data and allow the agent to fish for more information from the user until it can save the event on the calendar.</blockquote><h3>Scope of the Agent</h3><p>It should be able to handle the following queries from user-</p><ol><li><strong>VAGUE QUERIES</strong>: “Schedule a meetup with the team next week”.</li><li><strong>VAGUE QUERIES with more math</strong>: “Schedule a haircut on the last weekend of the month”.</li><li><strong>DERIVE EVENT PARAMETERS from user query</strong>: “Put Andy’s birthday on the calendar for 27th May”</li><li><strong>STRAIGHT FORWARD</strong>: I have a flight to Bangalore on the 18th at 5am.</li></ol><h3><strong>The N8N Workflow</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXsCItxeyllaWTYLrLF8qA.png" /></figure><p>I can trigger the workflow by sending a message on my whatsapp to the configured number.</p><p><strong>First Half</strong>: Goal is to get all the required information from the user to set the event!</p><p>The agent dynamically understands what to ask for and it can run on a loop as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDdTGA_j7pvk2VM_vOoYoA.png" /></figure><p><strong>Second half</strong>: Goal is to inquire about the weather in the next 5 days and make suggestions and set the event is user approves.</p><p>Recommendations are made based on any alarming weather data. Additional node here could lookup personal preferences from the database to add to the recommendation the agent makes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*tE4qO-LOOoIPP3DY2WVaLw.png" /></figure><h3><strong>Database for intermediate operations</strong></h3><p>Using Snowflake as our database to ensure that event parameters are cleanly updated and retrieved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*45UwwwIA005zC-Rm3Sc6pA.png" /></figure><h3>Agent Interaction</h3><p>Interaction with the Agent on my whatsapp looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qE_k7sUYzazn7za72p2Qw.png" /></figure><p>Potential enhancements beyond the MVP:</p><ol><li>Handle multi-day event scheduling.</li><li>Design and build a source that understands the user behavior over time to make smarter recommendations while scheduling events.</li><li>Have an Orchestrator Agent that decides which path to take — making this more dynamic.</li></ol><p>This was a lot of fun!</p><p>If you have any suggestions or ever want to brainstorm on building something substantial, connect with me on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn </a>or lets meet for a cup of coffee.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p1tERXUKBtlwjtp0" /><figcaption>Photo by <a href="https://unsplash.com/@jdent?utm_source=medium&amp;utm_medium=referral">Jason Dent</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf3ec84320e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart Retail: Real-Time Ad Curation & Product Recommendations Powered by LLMs]]></title>
            <link>https://medium.com/@sruti.mail20/smart-retail-real-time-ad-curation-product-recommendations-powered-by-llms-d5363de8b6e3?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5363de8b6e3</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[retail-marketing]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Thu, 10 Apr 2025 08:16:51 GMT</pubDate>
            <atom:updated>2025-04-10T08:35:29.200Z</atom:updated>
            <content:encoded><![CDATA[<h4>Build an app that serves consumer with customized ad and relevant product recommendation in real time.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*16azpD_BQJpjKtLas38lNw.png" /></figure><p>Ad targeting is a complex process. Businesses are throwing money at ads, hoping <em>something</em> sticks. The problem is getting the right ad in front of the right person, fast because every irrelevant product recommendation is a potential customer lost.</p><p>So, I built a proof-of-concept app in Streamlit that uses GenAI to cut through the noise. Basically, I wanted to see if we could make ads and product suggestions feel less like spam. (Think Amazon trying to make you buy a house ladder since you bought it once 10 months ago!)</p><p>Here’s what I mean:</p><ul><li><strong>Making product searches spot-on.</strong> No more sifting through irrelevant results.</li><li><strong>Generating ads that grab your attention.</strong> Nothing generic, nothing boring.</li><li><strong>Giving you product recommendations that make sense, even if we don’t know your shopping history.</strong> Imagine walking into a store for the first time but the staff still <em>gets</em> you.</li></ul><p>Under here is a small demo of the app (excuse my voice quality):</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPoaiRZS5c6Y%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPoaiRZS5c6Y&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPoaiRZS5c6Y%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/407cc53adf7e5edaa58f1711295854f8/href">https://medium.com/media/407cc53adf7e5edaa58f1711295854f8/href</a></iframe><h3>Solution Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*uUub4W24Jd8C07cAIF3Nag.png" /></figure><blockquote>a) Implemented an embedding model for product search. To ensure user query is fulfilled to the ‘t’ we used LLM to extract structured components from the query, which was used in a <strong>post-processing </strong>step<strong>.</strong></blockquote><blockquote>b) LLM model to generate customized ad copy and images for each user in real time.</blockquote><blockquote>c) Considering a very important problem where user has no history of purchase in the database (a <strong>cold start)</strong> for product recommendation, we have looked at similar products rather than similar users.</blockquote><h3>* Product Search</h3><p>Once user types in a product search query — either on a search engine or on the ecommerce site — it will trigger a search for the product.</p><ol><li><strong>Product Embeddings</strong>: We have prepared embeddings for the product catalog using “msmarco-distilbert-base-v3”. These embeddings are numerical representations of the products, taking product related features such as description, price, brand name, product category, subcategory, etc to ensure product characteristics are encompassed in this embeddings.</li></ol><p>We have also used FAISS indexing to facilitate product search once embeddings are generated. Its simple and fast.</p><p>2. D<strong>ynamically user query analysis</strong>: Using an LLM, we processed the user query to extract query characteristics such as desired brands so that it can be used for accuracy in product search. This was important since when we take top 10 products after embedding match, it may leave out certain characteristics which user may have explicitly specified.</p><pre><strong>Query</strong>- I want hiking shoes in mid-range from Nike or addidas. Do not show from Puma.<br><br><strong>LLM structured Output</strong>-<br>        1) Brands_include: Nike, addidas<br>        2) Brands_exclude: Puma<br>        3) Query: hiking shoes in mid-range price</pre><p>This can also be done with an NER (name entity recognition) model and some rules based parsing but LLMs are much more robust as it understands the nuances of the english language.</p><p>3. <strong>Post Processing &amp; Final Product List</strong>: Using the LLM output, we filter out on brands they want or explicitly want to exclude. This can be further extended to include checks for desired price, color, etc as part of post-processing step and then produce the final product list.</p><blockquote>The pre-calculated embeddings will be updated as new products are released. So the frequency of updating these embeddings is purely driven by business operations.</blockquote><h3>* Ad Curation</h3><p>Based on the user query, the ad copy is curated. I added specific prompt allowing the model to be quirky as well as respectful. We can also fine-tune our LLM to adopt the<strong> Brand voice</strong>.</p><p>Since I am using Gemini API, I could use it to generate the ad heading and description of the image to go with it. I use this image description to generate image using <strong>stable-diffusion-xl</strong>.</p><blockquote>For image generation, DALL-E is another alternative. Here’s a <a href="https://www.bentoml.com/blog/a-guide-to-open-source-image-generation-models"><strong>guide </strong></a>to the open source models for image generation.</blockquote><h3>* Product Recommendation</h3><p>Product recommendation can take many shapes depending on the flow of data in the solution.</p><p>In this solution, we have considered a cold start approach — meaning the user has no history of previous purchase in the system, so we can not profile and match them to similar users. In this case, we look for similar PRODUCTS and not similar users!</p><p>I have used unsupervised KMeans <strong>clustering algorithm</strong> to group products under clusters. Thereafter, the product that the user is searching for becomes our reference cluster. To arrive at similar products, we find the closest clusters to this reference cluster using distance metric.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*o97Jqb0E_5rgymQUJCVyuw.png" /><figcaption>Close clusters are similar in context and attributes</figcaption></figure><p>Example: if i was looking for <strong>camping gear </strong>then the related products could be sweat-wicking hoodies and hiking backpacks. These will appear as the closest cluster to our reference cluster if we implement the clusters correctly.</p><blockquote>We can enrich this approach my finding users who bought the products in our initial product search and refine recommended products list by cross referencing the two datasets, even in a cold start use case.</blockquote><h3>Github Code</h3><p>Find the code in my repo <a href="https://github.com/ShhrutiDeka/Retail/tree/main"><strong>here</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GeHAD9tgFpsxk9A2" /><figcaption>Photo by <a href="https://unsplash.com/@brettwharton?utm_source=medium&amp;utm_medium=referral">Brett Wharton</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Thanks for reading. You may have questions or suggestions regarding this approach — feel free to connect on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn</a>, we can discuss it over coffee.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5363de8b6e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ad Curation and Optimization: GenAI for Retail Growth]]></title>
            <link>https://medium.com/@sruti.mail20/ad-curation-and-optimization-genai-for-retail-growth-1ff725084fec?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ff725084fec</guid>
            <category><![CDATA[gen-ai-for-business]]></category>
            <category><![CDATA[ad-personalization]]></category>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[advertising]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 14:13:41 GMT</pubDate>
            <atom:updated>2025-04-06T14:13:41.507Z</atom:updated>
            <content:encoded><![CDATA[<h4>For established as well as emerging businesses</h4><p>I recently went down a rabbit hole for ad curation and thought to myself how can I bring LLM into the mix for specific industry usage. Today we are looking at retail.</p><p>In this blog, we will outline how LLM can fit into your retail ad curating workflow and take over revenue driving tasks while also discussing ways to strategically utilize LLMs within optimal budget, without compromising on performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*33i4bL200mf8A3-n" /></figure><p>Photo by <a href="https://unsplash.com/@arturtumasjan?utm_source=medium&amp;utm_medium=referral">Artur Tumasjan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></p><h3>Lets take a look at the components in the advertising pipeline</h3><ol><li><strong>Customer Searches query</strong>: Lets say user searched for “summer shorts in blue”. This is tracked from the e-commerce site itself or any search engine.</li><li><strong>Intent determination of search query</strong>: User intention behind the search determines further downstream processes. If it is simply educational, then maybe their intention is not to buy the product so we can utilize our resources elsewhere.</li><li><strong>Keyword matching for products</strong>: From the user search query, keywords are matched. This can be done using a simple string search or embedding models. An embedding model is superior to regular string search as it can also match products based on context similarity.</li><li><strong>Targeted ads</strong>: User is targeted with ads related to their search query. Compelling ad-copies are created based on a template of ‘creative elements’ that may use product details, image and headline placements, making it dynamic for each case. This is the obvious area where we can use LLM but we’ll talk about it a bit later in the blog.</li><li><strong>Ad Bidding</strong>: The retailer sets a bid for the ad placement based on revenue generating capacity of the products and/or customer value.</li><li><strong>Ad Display to customer</strong>: This can happen in their search results, across platforms (like Instagram) or using cookies in other websites they visit.</li><li><strong>Measure Ad Performance</strong>: Based on customer’s interaction with the ad, performance is logged and tracked. Ad keywords and bidding price can be optimized based on this information over time.</li></ol><h3>Challenges that can be addressed using LLM</h3><blockquote><em>1. Even with dynamic ads, if the base ‘creative elements’ are not changed often, then </em><strong><em>ad-fatigue</em></strong><em> can occur among users.</em></blockquote><blockquote><em>2. </em><strong><em>Timely</em></strong><em> and </em><strong><em>relevant </em></strong><em>ads can drive impulse purchases. This may be missing due to limitations in automated ad curation.</em></blockquote><blockquote><em>3. Templatized </em><strong><em>Generic ads </em></strong><em>fail to capture attention, resulting in low interaction and conversion rates.</em></blockquote><blockquote><em>4. Failing to </em><strong><em>optimize bidding strategies</em></strong><em> can result in wasted ad spend and low ROI.</em></blockquote><h3>Before we proceed, lets understand the cost associated with LLMs</h3><p>The cost that comes with using LLM is possibly one of the biggest barrier to adopting genAI in most businesses. Here are the factors that drive cost:</p><h3>Size of LLMs</h3><p>You may have heard about LLMs being either small or big. A small LLM means that the model has fewer parameters and is trained on a smaller dataset. It isn’t necessarily bad but it may be only suitable for particular tasks and require fine tuning (trained again on your datasets), which requires compute cost.</p><p>While large LLMs can have billions of parameters and trained on a wide variety of large datasets, making it well versed on the world’s general knowledge. These are often expensive and you will see why in the next point.</p><blockquote><strong><em>Large LLMs</em></strong><em>: Versatility but higher operational and API costs.<br></em><strong><em>Small LLMs</em></strong><em>: Cost-effectiveness but may require fine-tuning and have limited scope.</em></blockquote><h3>Infrastructure for LLMs</h3><p>Most popular LLMs like OpenAI, Gemini and more, provide <strong>APIs </strong>to access the model. These APIs do not need any infrastructure to maintain but have limitations on the ‘tokens’ you can send and receive. Tokens are chunk of characters that the LLM processes for each API request. Pricing depends on tokens you are sending and receiving.</p><p>But not all APIs are charged so it is important to do some research on the latest LLMs in the market. It is also important to take note of whether these APIs are maintained regularly for stable use in production.</p><p><strong>Open-source</strong> LLMs, like the ones accessible via hugging-face, say <strong>Llama2–70b-chat </strong>and <strong>Mixtral-8x7B-Instruct</strong> do not have cost associated with each invocation. But these models have to be <strong>hosted </strong>in your system, preferably on the cloud — so bigger models will add to the cost of operation.</p><blockquote><strong><em>API</em></strong><em>: Convenience, top performance, scalability, may have ongoing costs, may raise privacy concerns<br></em><strong><em>Self-Hosting</em></strong><em>: Control, potentially lower long-term costs, but requires expertise and infrastructure.</em></blockquote><p>In most cases, APIs are better for an MVP and for a long term vision, a hosted LLM would be more cost effective. There is also a component of <strong>privacy </strong>which will be covered in subsequent blogs.</p><h3>Incorporating LLM within your current solution</h3><p>Now we are ready to discuss how LLMs can be incorporated in your retail ad workflow.</p><ol><li><strong>User query Intention</strong>: LLMs can help understand the intent behind search queries, particularly those that are vague. For emerging businesses, a probabilistic model can determine the intention and LLM can be invoked only for the indeterminate probabilities, ie, cases where all probabilities are closely equal for a given query.</li><li><strong>Product Tags</strong>: Incorrect products tags that prevent from accurate product search can be tackled using <strong>multimodal </strong>LLMs. Multimodal LLMs can process multiple forms of data such as text, images, audio, and video. These can generate tags and accurate descriptions from product images. For emerging businesses, products with low ROI or missing tags can be first targeted before investing in improvement efforts to reduce computation overhead.</li><li><strong>Generate dynamic &amp; trendy ads</strong>: LLM can generate ads based on user personality, tone of search query and overall branding. This also includes generating <strong>dynamic images</strong> that are relevant in the market and to the customer. For emerging businesses, a suitable open source LLM or free API based LLM calls can be used.</li><li><strong>Bidding Efficiency</strong>: While machine learning models commonly make bidding efficient, <strong>AI agents </strong>can take it a step further for real-time bidding. An Agent is an LLM-based intelligent solution that drives all actions from gathering the right data, analyzing them and taking appropriate actions, in this case, making profitable bid for the business. Agents are the new hype and for good reason. It is predicted to reduce the dependency on humans in the upcoming years for many tasks.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*ahBB535HPxeWIRPU" /></figure><p>Photo by <a href="https://unsplash.com/@goian?utm_source=medium&amp;utm_medium=referral">Ian Schneider</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></p><p>Now that you are well acquainted with the possibilities of GenAI, you might have questions regarding the implementation of these solutions in your business. It is best practice to take a phased approach in incorporating these to maintain low risk as well as cost.</p><p>Thanks for reading. Let me know if I missed anything, happy to discuss over <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn</a> or a cup of coffee.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ff725084fec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshoot Tableau: Dynamic Filters with Fixed LODs]]></title>
            <link>https://medium.com/@sruti.mail20/troubleshoot-tableau-dynamic-filters-with-fixed-lods-d70ead82abc5?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d70ead82abc5</guid>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[lod]]></category>
            <category><![CDATA[dynamic-filters]]></category>
            <category><![CDATA[fixed]]></category>
            <category><![CDATA[parameters-in-tableau]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Sat, 16 Dec 2023 18:13:23 GMT</pubDate>
            <atom:updated>2024-01-09T05:41:07.462Z</atom:updated>
            <content:encoded><![CDATA[<p>Two ways to apply dynamic filter with a fixed LOD calc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZmJ7Q178CqQDWVrWOrhKA.png" /></figure><p>This is a follow up of my <a href="https://medium.com/@sruti.mail20/a-practical-guide-to-using-lods-in-tableau-37e99bd94506">previous blog</a> on all LODs in Tableau. In this one, we’ll see <strong>two</strong> approaches to address unresponsive filters with fixed LOD calcs.</p><blockquote><strong>Approach 1:</strong></blockquote><blockquote><strong>Fixed LOD and Context Filter</strong></blockquote><p>By definition, FIXED LOD will ensure that the calc doesn’t take any other field into consideration. Take note of the filter hierarchy in Tableau- context filter gets applied before fixed LODs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/1*wa8h539RmxKOL8PSgcA11g.png" /></figure><h4>In Superstore Data, when we visualize customer’s first Orders in Furniture Category, we put the Category filter into context. Otherwise, we get customer’s first Orders, out of which some are from Furniture Category.</h4><p><em>Context Matters.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBRFG8S_Rmh7EcnW16loyQ.png" /><figcaption>Numbers change after putting Filter in Context (greyed pill)</figcaption></figure><p>When we put the filter into ‘Context’ it applies the filter first and the LOD is applied on the resultant dataset.</p><blockquote><strong>Approach 2:</strong></blockquote><blockquote><strong>Fixed LOD and parameters</strong></blockquote><p><strong>When context filter needs to affect *some* calculations in the view but NOT ALL.</strong></p><p>If we need to avoid context filter as it may interfere with the rest of the visualizations, rewrite fixed LOD to include a parameter <em>[category parameter]</em></p><p><strong><em>{ fixed [Customer ID]: min( if [Category]=[category parameter]<br>then<br>[Order Date] END ) }</em></strong></p><p>Make this parameter a user filter.</p><p>Notice how we are using the Category filter inside the LOD, so that it evaluates first— same as using a context filter.</p><blockquote><em>Have you faced any trouble when using Fixed LOD with Dashboard filters? It might be worth solving them once and for all. Ping me!</em></blockquote><p>Connect with me on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d70ead82abc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Practical Guide to using LODs in Tableau]]></title>
            <link>https://medium.com/@sruti.mail20/a-practical-guide-to-using-lods-in-tableau-37e99bd94506?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/37e99bd94506</guid>
            <category><![CDATA[lod]]></category>
            <category><![CDATA[calculations]]></category>
            <category><![CDATA[fixed]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[granularity]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Sun, 03 Dec 2023 11:12:13 GMT</pubDate>
            <atom:updated>2023-12-16T18:15:12.016Z</atom:updated>
            <content:encoded><![CDATA[<p>How to use the most powerful feature in Tableau explained in three simple examples</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*2ZFSdY-g_fq5h97K.jpg" /></figure><h4>LOD (Level of Detail) in Tableau</h4><p>Every dataset comes with its own level of granularity. While analyzing the data an analyst would traditionally transform the data to the required granularity before use or perform complex calculations over the dataset.</p><p>In Tableau, when we drag and drop fields into view, the granularity is set at that level and all measures are aggregated on that level. To introduce a KPI which requires a different granularity without altering the visualization, LOD calculations are used.</p><h4>Applying LODs to our Sales Use Case</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Whei96Y2KQHfTOChORQokQ.png" /><figcaption>Subset of Sales Data from Highest to Lowest Granularity</figcaption></figure><p>The dataset’s highest level of detail is REGION and most granular level is ORDER ID.</p><p>Tableau has three LOD types: Fixed, Include, Exclude</p><p>The general syntax is :</p><p><em>{ &lt;LOD Keyword&gt; &lt;Dim A&gt;, &lt;Dim N&gt; : &lt;aggregation function&gt; &lt;Field X&gt; }</em></p><blockquote><strong>FIXED LOD</strong></blockquote><p>We want to show Profit by Region and Ship Mode in a bar chart. In the same view, we want users to be able to <strong>compare</strong> this Profit to the total Profit for a given Region.</p><p>Fixed LODs are perfect for such comparison since we know EXACTLY which field we want to aggregate on and it should be <strong>influenced by no other field</strong> in the viz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*fPdEh7RHsEiL9iPzE52OXQ.png" /><figcaption>Fixed calculation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70090g1-mIwa6djBUQh_Ew.png" /><figcaption><strong>Green bars</strong>: Total Profit for entire Region, <strong>Black bars</strong>: Profit for both dimensions in view</figcaption></figure><p>It is clear from the viz that<strong> First Class</strong> shipping has low contributions to the overall <strong>Profit for Central Region</strong>.</p><blockquote><strong>INCLUDE LOD</strong></blockquote><p>Now we want to include a calculation that shows the maximum number of orders placed by a single customer for a given Region &amp; Ship Mode.</p><p>Include LODs are perfect for this because we want to introduce a new field Customer ID to the calculation in addition to the fields already in view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*SNlYRwUVeGEaYtu6pWEBVg.png" /><figcaption>Include calculation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sl07mvRi9zCcLvnRj-eO3g.png" /><figcaption>Max Orders Placed represented as circles</figcaption></figure><p>Here we did not use FIXED because we want the calculation to be influenced by the other dimensions in the view.</p><p>The Include LOD is calculated first (deeper level than the view) and then aggregated on the higher level of the view.</p><blockquote><strong>EXCLUDE LOD</strong></blockquote><p>Let’s add another dimension to the viz that goes one level deeper. The field <strong>Segment</strong> gives us product segments which were part of an Order ID.</p><p>But we are only interested to see Profit by other fields in the view except Segment. So we use Exclude LOD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*4LtqGjyh-Jz_lBVkqOSfOw.png" /><figcaption>Exclude calculation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZF7S_EcdZi4UKawSwj2bEA.png" /><figcaption>Extreme left: Profit by Ship Mode &amp; Region only</figcaption></figure><p>Exclude LOD is useful when we want to exclude particular dimensions (lower level fields) from calculation’s granularity and only aggregate on higher granularity present in the view.</p><p>In the viz above we can see Profit is highest for <strong>West Region</strong> within <strong>First Class</strong> Ship Mode. Subsequent charts are influenced by <strong>Segment</strong> if they are NOT using Fixed LOD on <strong>another field</strong> or NOT explicitly excluding <strong>Segment</strong>.</p><p>For more knowledge on the topic refer to the <a href="https://www.tableau.com/learn/whitepapers/understanding-lod-expressions">whitepaper</a> from Tableau</p><blockquote><em>LODs give us great control and ease in calculation so it also requires careful consideration when using with filters. A separate blog will cover that in the upcoming months.</em></blockquote><p>UPDATE: The next <a href="https://medium.com/@sruti.mail20/troubleshoot-tableau-dynamic-filters-with-fixed-lods-d70ead82abc5">blog</a> is live!</p><p>Connect with me on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37e99bd94506" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamically Change Tableau Dashboard Background]]></title>
            <link>https://medium.com/@sruti.mail20/dynamically-change-tableau-dashboard-background-fa89cf0c8a3c?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa89cf0c8a3c</guid>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 14:39:59 GMT</pubDate>
            <atom:updated>2023-07-13T08:31:15.288Z</atom:updated>
            <content:encoded><![CDATA[<p>No sheet swaps! No dynamic zone visibility setup!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cfonSrqDxm38-FmxngStgg.png" /></figure><h4>This approach came into being when I was creating the above <a href="https://public.tableau.com/app/profile/sruti7854/viz/CustomerChurnDashboard_16888967643820/Dashboard#1">Dashboard</a> and wanted a more subtle background instead of a monochromatic one covering my entire Dashboard.</h4><p>This method is an extension of the traditional approach but much simpler and highly customizable.</p><blockquote>Step 1: Create a parameter</blockquote><p>The parameter will be filled in by user action, so we do not add a list of values. If parameter will be exposed to Dashboard user, then we will add a list of parameter values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*R0hwoClytTHpCvXzyHoTcw.png" /><figcaption>All Allowable values as it depends on action</figcaption></figure><blockquote>Step 2 : Create a sheet with parameter in shape</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*Mh6aj75T1eW7uVD824Xvow.png" /><figcaption>Different parameter values will be assigned to different shapes</figcaption></figure><blockquote>Step 3: Create parameter action (optional for user click action)</blockquote><p>The parameter values are filled from a field ‘<em>Types of Service’ </em>present<em> </em>in the data source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*FvXVy8niDAANmCbY1t-oJw.png" /></figure><blockquote>Step 4 : Assign custom shapes to different parameter values in the sheet created in step 2</blockquote><p>Here the backgrounds are <em>png</em> images which are kept in Tableau Repository folder in our local system, so that they become available inside our shapes mark.</p><p>Adjust the size of the shape if needed.</p><p>The background is created using <strong><em>Figma</em></strong>. A follow up blog will explain how to achieve this.</p><p><strong>Update: The blog can be found </strong><a href="https://medium.com/@sruti.mail20/using-figma-for-dashboard-designs-3a95817426ea"><strong>here</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n50aSTgbIZQ_5b8P_i41Zw.png" /></figure><blockquote>Step 5: Add the sheet in the Dashboard</blockquote><p>As a final step, make sure the sheet is lying under all the other sheets in the layout hierarchy pane.</p><p>All done!</p><p>Follow for more!</p><p>Connect with me on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">Linkedin</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa89cf0c8a3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VizQL & The Process of Rendering Tableau Dashboards]]></title>
            <link>https://medium.com/@sruti.mail20/vizql-the-process-of-rendering-tableau-dashboards-336b16570349?source=rss-622a72510b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/336b16570349</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[vizql]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[tableau-server]]></category>
            <dc:creator><![CDATA[Srutimala Deka]]></dc:creator>
            <pubDate>Sat, 14 Jan 2023 06:20:27 GMT</pubDate>
            <atom:updated>2023-01-20T04:10:13.764Z</atom:updated>
            <content:encoded><![CDATA[<p>In our quest to optimize Tableau Dashboards, it is good to know how Dashboards are rendered in production. Leveraging this, we can positively influence users’ experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*6YYtsgwj0vICrwAy.gif" /><figcaption>Rendering is like carving marble</figcaption></figure><p>Rendering in tableau refers to the view that is created after Tableau interprets the design and charts in the workbook.</p><p>So we have created our Dashboard and subsequently published it to Tableau Server or Tableau Public. It is possible that our Dashboard performance on Desktop is faster than on the Server.</p><p>This makes us wonder…</p><h4>So, what happens once our Dashboard is published?</h4><p>To understand this, we need to know about Tableau’s VizQL.</p><blockquote><strong>VizQL</strong></blockquote><blockquote>VizQL essentially creates queries of user requests. Every action, say dragging fields into view, generates a corresponding query that gets translated to a language VizQL can interpret. VizQL then creates the visual for that user action.</blockquote><p>Tableau uses VizQL to translate Dashboard design into queries as well. Additional <em>calculations</em> are performed over the queries generated.</p><h3><strong>How does VizQL Work?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*eo2fYpPKgBUHs0Wdt1h1wg.png" /><figcaption>Step by Step process of how VizQL works</figcaption></figure><ol><li>Dashboard is opened or requested by user.</li><li>VizQL determines its layout by parsing the TWB file as a whole. The workbook is pulled into the memory as a single file. This reinforces the need to design dashboard in conjunction with the rest of the workbook.</li><li>Dashboard and worksheets are interpreted as XML elements to create the view. Unnecessary elements, including containers and marks in the Dashboard will lead to a complex translation affecting load time.</li><li>Queries built by VizQL are sent to Data Source for requesting data. Multiple small queries are sent in parallel. While some data sources handle parallel queries like a pro, some don’t. Large queries are sent first followed by smaller ones but with too many queries, the wait-time increases even with the pro data sources.</li></ol><p>Data from the data source is returned to VizQL after which <strong>rendering</strong> takes place in two phases:</p><blockquote>Server Side Rendering</blockquote><p>In Server Side, the rendered visual is sent to the user’s browser as an image. This can cause slight latency as query and images get transferred over the network but Tableau Server’s capacity does make up for it.</p><p>For complex visualizations, Server Side rendering is fast with the downfall of a slower interactivity such as tooltip due to transmission to and from the browser.</p><blockquote>Client Side Rendering</blockquote><p>In Client Side, rendering happens in the user’s browser itself(enabled by default). Web browsers that include the HTML 5 &lt;canvas&gt; element, support this rendering. Tableau admins can configure client-side rendering in <a href="https://help.tableau.com/current/server-linux/en-us/tsm_overview.htm">TSM</a> by tweaking the ‘complexity threshold’. So if threshold is put at 30 then Dashboard will be rendered in Tableau Server for complexity 40.</p><p>Both the rendering techniques together provide a smooth user experience.</p><p>Developers can test the threshold to find the best configurations ideal for user interactivity. For more details, check out the <a href="https://help.tableau.com/current/server/en-us/browser_rendering.htm">official doc</a>.</p><h4>For best practices on creating optimized calculations, worksheets and dashboards check out my <a href="https://medium.com/@sruti.mail20/tableau-dashboard-optimization-5998a724c2a4">previous blog</a>.</h4><p>Connect with me on <a href="https://www.linkedin.com/in/srutimala-deka-825190186/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=336b16570349" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>