<?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 Triumph Urias on Medium]]></title>
        <description><![CDATA[Stories by Triumph Urias on Medium]]></description>
        <link>https://medium.com/@triumphurias?source=rss-e2b8aac57ea7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QJD4RDy6OMbJndOFQl-AiQ.jpeg</url>
            <title>Stories by Triumph Urias on Medium</title>
            <link>https://medium.com/@triumphurias?source=rss-e2b8aac57ea7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:09:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@triumphurias/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[POV: Google Cloud NEXT ’25]]></title>
            <link>https://triumphurias.medium.com/pov-google-cloud-next-25-be608c19a933?source=rss-e2b8aac57ea7------2</link>
            <guid isPermaLink="false">https://medium.com/p/be608c19a933</guid>
            <category><![CDATA[aritificial-intelligence]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Triumph Urias]]></dc:creator>
            <pubDate>Thu, 10 Apr 2025 09:04:02 GMT</pubDate>
            <atom:updated>2025-04-10T09:04:02.833Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G54Cwc-spvtbYMkkbkGOng.png" /></figure><p>I’m absolutely convinced that just as GUI transformed how we use computers, Artificial Intelligence and more specifically, Agentic AI is going to make a similar, if not greater, impact on human-computer interactions.</p><p>Last night I watched the Google Cloud Next ’25 opening keynote and I am very excited by the announcements around AI.</p><p>Asides the introduction of Gemini 2.5 pro and flash which is in itself mid-blowing, here are other things that got me excited:</p><h3><strong>Agent Development Kit and Agent Engine</strong></h3><p>I had the privilege of getting a preview of this a few weeks ago before it became generally available and I couldn’t wait to get my hands on it. It’s finally here and I’m excited about the prospects it holds. To build multi-agent systems, test, evaluate and deploy them seamlessly and securely would definitely positively impact the development lifecycle for AI products.</p><p>When I found out about this kit being released, I worried about integration with other frameworks that I have become familiar with such as LangChain and CrewAI. Need I say much about my relief when I found out that indeed I can equip my ADK agents with other agents as tools even if they were built with 3rd-party libraries.</p><p>Now, to the recurring “challenge” when it comes to Generative AI — EVALUATION. I’ve spent the last few weeks upskilling in this area as it is critical in POC to Production conversations (<a href="https://www.linkedin.com/posts/triumph-urias_deploy-test-evaluate-gen-ai-apps-was-issued-activity-7313138204201697280-oNgy?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAABsYy6EBppbPYoW7dlLu75CUYDGe9V-lfc8">Post</a>). It’s super exciting to see that ADK comes with built-in evaluation. Now, as a developer, I can assess agent performance which would give me more confidence and help me convince stakeholders as they consider taking these systems into production.</p><p>I can go on-and-on but suffice it to say that I am very excited about this and I can’t wait to try it out in the coming weeks and build more powerful agents in future.</p><h3><strong>Agentspace</strong></h3><p>Few weeks ago, I made a post announcing that I had attained a new Google Skill Badge in Deploying Agentspace (<a href="https://www.linkedin.com/posts/triumph-urias_deploy-agentspace-was-issued-by-google-cloud-activity-7311767570804621312-YJ44?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAABsYy6EBppbPYoW7dlLu75CUYDGe9V-lfc8%29">Post</a>). Agentspace is live! Getting insights from the myriad of structured and unstructured datasets that companies own across Drive, Email, Chat tools, etc. can be virtually impossible. Well, with Agentspace you can integrate all these data sources together and with the power of Google Search and Conversational AI with Gemini significantly cut-down time to insight.</p><p>Probably the best part of Agentspace is taking action right from the interface without having to open (yet another) app. You can have your agent send emails, schedule meetings and take other actions on your behalf without leaving the conversation.</p><h3><strong>Google Distributed Cloud</strong></h3><p>Now there’s another sticky issue. “Compliance” with regulations, security and data privacy policies. Over the past months (oh wow, it’s actually almost a year) working with Deloitte, I can’t tell you how many times I’ve seen organizations worry about compliance during conversations around AI and rightfully so. With Google Distributed Cloud, Google in collaboration with NVIDIA, is able to bring Gemini to on-prem servers and the impact this would have is tremendous.</p><p>I must confess that I wonder about the cost factors in the Nigerian clime but I’m confident that we can always find a way to defeat obstacles and build revolutionary solutions that make impact to all stakeholders.</p><h3>Conclusion</h3><p>The supposed future of AI is here and I’m glad to witness it. 😁</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be608c19a933" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You Need a Spotter: Life Lessons from the Gym and Office]]></title>
            <link>https://triumphurias.medium.com/you-need-a-spotter-life-lessons-from-the-gym-and-office-46c1148afa43?source=rss-e2b8aac57ea7------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c1148afa43</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[work]]></category>
            <category><![CDATA[gym]]></category>
            <category><![CDATA[work-culture]]></category>
            <category><![CDATA[life-lessons]]></category>
            <dc:creator><![CDATA[Triumph Urias]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 07:06:44 GMT</pubDate>
            <atom:updated>2025-02-03T07:06:44.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="A spotter assisting someone with his lift on the bench press." src="https://cdn-images-1.medium.com/max/640/0*z94uFlmf1ZLqBnG0" /></figure><p>August 2024, I decided to start working out in the gym. I had started a new role, in a new company, in a new city and the H.M.O. covered gym visits to a gym not too far from where I lived so it made sense. I mean who doesn’t like free things but I digress…</p><p>When I first started working out, I had a fear of going to the gym when there were a lot of people around. I didn’t want to look silly lifting light weights or using bad form. I thought it was better to exercise alone, where no one could see my mistakes. But over time, I realized that having people around is actually one of the best parts of working out. There are experienced lifters who can help correct my form, people who can spot me on heavier lifts, and an overall environment that pushes me to do better.</p><p>Backtrack to June 2024. I had just started a new role, in a new company, in a new city, and I needed to make a good first impression (or first impressions because it was quite the probation period).</p><p>I was hesitant to speak up in meetings. I wanted to be careful with my contributions, worried that I might say something incorrect or ask a question that made me look inexperienced. But just like in the gym, I found that my teammates were more than willing to help. They wanted to see me succeed, just as gym bros want to see each other improve. The more I engaged, the more I learned, and the better I became at my job.</p><p>Over the past couple of months, I’ve found that there are a number of similarities between the gym and the office and I want to share these insights with you.</p><p>The summary is, <strong>“You need a Spotter”</strong></p><h3>A Spotter to Tell You “This is Too Light for You”.</h3><p>It was one of those Saturday mornings at the gym. I had just finished a number of programs upstairs. I had done some sets of dumbell curls, dumbell shoulder presses, etc., and my hands were FINISHED (or so I thought).</p><p>I went downstairs to do a few sets of the declined chest press and call it a day but then I ran into him. We had seen ourselves in the gym a number of times and given each other the nod now and again but we weren’t “guys” like that. For one, he had his crew that he always worked out with and I am not the “make-a-new-friend” type of guy.</p><p>He and his workout partner had just done their set and were leaving the machine. She (his workout buddy) had finished last and her weights were still on the machine. As I approached to take my seat and start my set, “This is too light for you na”, he said. “Shebi you saw me upstairs and all the work I was doing? Abeg my hands are finished.”, I replied with a chuckle. I mean my hands really felt like they were finished and the weight load his partner had left was just about right for me as at the last time I checked so yh, I was doing my best.</p><p>I did one set at that weight load and decided, “You know what, let’s see if he’s right.” He had said it with such a convinced tone that I just had to try this thing he said. I loaded a few more plates (or maybe one more) and behold, I had a new minimum. He was right. That was too light for me.</p><p>“Triumph, take one or two of your colleagues, go to [redacted]’s office, sit with their team, and hear what they have to say so you can facilitate implementation on the [redacted] project in such a way that meets their specific needs.”, she said. “I literally just got here yesterday. Can I just sit in the office and do the comfortable things?”, I thought. I knew this was part of what I signed up for. Infact, to me, it was an exciting part of the role, sitting with clients, listening to their pain points, and building solutions for them that make an immediate impact. It was exciting but I thought I needed more time. Nope. I was ready I just didn’t know it yet.</p><p>When I went to the client’s office with my teammate and had the session, it was clear to me that getting the call to go visit this client and my teammate&#39;s support and confidence in our abilities as a united front were the catalysts I needed to unlock this hidden potential.</p><p>Often times, we underestimate our strengths and choose weights and tasks that are too easy. A spotter can call you out, telling you it’s time to push yourself harder.</p><p>Just like in the gym, growth comes outside your comfort zone and you need a spotter to tell you when you’ve been in that weight class for too long.</p><p>You need that spotter.</p><h3>A Spotter to Scream “One More!”</h3><p>Walk past any bench press or squat stations at the gym in peak hours and you’re sure to hear “ONE MORE!, “UP!”, “PUSH!” or any other version of these motivational exclamations.</p><p>A good spotter would ask you how many reps you’re going for before you start the set. “10 reps” you might say and then you get in position.</p><p>9 reps later you’re about to give up but this is a mental battle, not a physical one. You need someone to scream “one more” and somehow you get the extra mental strength to fulfill your promise to yourself that you would do 10 reps and somehow you do.</p><p>— — — — — — — — — —</p><p>“What if they ask questions about this project? Please be around to respond.”, I texted my manager. I had promised to deliver a presentation during a firm-wide townhall on a project we had worked on and I had suddenly started developing cold feet. I wasn’t going to back down (at least I want to think so) but I needed to find a way to get myself out of the spotlight as quickly as possible.</p><p>His response, though not the most preferred at the moment, in retrospect, was the best response I could receive. “You’re capable.”</p><p>He didn’t say more. I do not remember exactly how I replied but I know I didn’t reply with “Thank you that’s what I wanted to hear.” I was terrified to bits! It was most likely something along the lines of “Oh [redacted], please oh… “. He on the other hand didn’t reply again.</p><p>Showtime! I had to deliver this presentation. Somehow, I did and the feedback was positive. I knew in the back of my mind that my manager would jump in if and when necessary but I didn’t need to have that knowledge at the fore when getting into the presentation. If I did, maybe I would have given up.</p><p>Just when you’re about to give up, a good spotter pushes you to fulfill make good on your promises and that’s how you grow.</p><p>You need that spotter.</p><h3>A Spotter to Guide Your Approach</h3><p>“Five is a number.” — Probably the best thing I’ve ever heard in the gym so far.</p><p>Let me explain. Most sets are counted in reps of 10 and so when I don’t think I’m able to hit 10 reps in a weight class, I find myself not attempting at all. On this faithful day, I found myself in a bench press rotation with one of the “henchest” guys in the gym. I did my humble set and stepped aside for the senior man to do his. When the rotation was complete and everyone had done their set, it was my turn again (As they say, “No matter how much you hide, your turn will come” 😆 ).</p><p>I calmly approached to repeat my humble set and he goes, “Do [redacted] na”. He wanted me to go A WHOLE 10KG higher. “Guy abeg, make I no kill myself here oh”, I said playfully. He responded with equal parts laughter and seriousness. “Do it guy… Okay, just try, five is a number.”</p><p>“I dey for you, no fear”, he concluded as he signaled others to add the extra plates and took the spotter’s position.</p><p>I mean if one of the most physically built guys I’ve seen around here is going to spot me on this set, what do I have to fear?</p><p>To my greatest surprise, I did 5 reps of this new weight class. Of course, he granted some assistance but the fact that I pushed it at all was all the motivation I needed. I had found my new minimum and I did a few more sets on this weight class.</p><p>Two things:</p><p>1.) The big picture is often a daunting one but when the task is broken down into smaller digestible bits and approached in this manner, it’s most times the case that we deliver exceptional results that we wouldn’t have been able to have we spent too much time looking at the big picture. Managers who are able to break down the “ask” to simpler tasks are the best spotters you can have.</p><p>2.) My role is a client-facing role and while I enjoy talking to people about their challenges and coming up with solutions for them, it can be really intimidating to get on a call and all the other attendees are from the client’s side. Many times, I’ve been dragged or had to drag a teammate into an impromptu call just so there’s a familiar face on the call. That’s a good spotter.</p><p>Someone who can break large tasks into manageable bits and someone who can show up to give you some extra confidence.</p><p>You need that spotter.</p><h3>A Spotter to Give a Slight Nudge When You’ve Stalled</h3><p>The exclamation, “one more!” is often followed by a slight nudge to the bar you’re lifting. I always thought when that is done, the spotter has lifted the bar but I’ve been a spotter for some people and I find that when I do that, I’m not actually lifting, they’re still the ones pushing it.</p><p>Sometimes, a slight touch on the bar is all it takes to help you push through a stalled rep. A spotter’s small assistance can be the difference between failing and completing the lift.</p><p>Deadline day… You’ve hit writer’s block and this proposal deck is still not ready. You put a call through to a teammate who comes in and in a few minutes the last pieces of the puzzle are put together and we’re good to go. That extra set of eyes was all it took to get you past the limitation.</p><p>You can’t always do it alone.</p><p>You need that spotter.</p><h3>A Spotter to Receive the Weight When You Can’t Do Anymore</h3><p>Okay, let’s be real. Sometimes, you just can not.</p><p>You’ve listened to one too many motivational speakers telling you to push beyond your comfort zone and now you’re attempting to bench more than you should. 2 reps in and your hands are giving up. No amount of shouting “one more!” can help and now you’re genuinely done. You’ve hit failure. Anything more, you would injure yourself.</p><p>Your spotter needs to receive the bar from you.</p><p>In the office, having a support system means knowing that when you’re overwhelmed, someone can step in to help. “Share the deck with me and I’ll give it a look”, is sometimes the exact sentence you want to hear when you’re approaching a deadline.</p><h3>A Spotter to Tell You “You Did Great.”</h3><p>“You is a what?… You is a beast!”. I mean it wasn’t the most confident set, I struggled throughout but hearing those words from this spotter was a bit flattering. It made me smile a bit because “Why this guy dey whine me?” but at the same time, “Lol, thanks man… “.</p><p>EOY, time to go on holidays but the managers gather us for a final session and hand us personalized notes of gratitude and recognition, and that made my whole year.</p><p>After a tough session, it’s encouraging when your spotter acknowledges your effort and tells you that you did well. That small recognition goes a long way. At work, positive reinforcement is just as important. Whether it’s a simple “Great job!” after a presentation or recognition for hard work, validation fuels motivation and builds confidence.</p><p>You need that spotter</p><h3>Conclusion: Success and Growth is a Team Effort</h3><p>Choose a great gym, choose a great work place.</p><p>Get a good spotter (or spotters), be a good spotter.</p><p>PS: This isn’t just about the gym and the office. This is about life. Don’t go through life alone. Have friends, have confidants, have God. Have a spotter. ❤️&amp; 💡</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46c1148afa43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Double-Edged Sword of AI-Generated Videos: Harnessing Potential, Addressing Risks]]></title>
            <link>https://triumphurias.medium.com/the-double-edged-sword-of-ai-generated-videos-harnessing-potential-addressing-risks-5b3022cb4578?source=rss-e2b8aac57ea7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b3022cb4578</guid>
            <category><![CDATA[responsible-ai]]></category>
            <category><![CDATA[deepfakes]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Triumph Urias]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 09:59:51 GMT</pubDate>
            <atom:updated>2025-01-06T09:59:51.139Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDD2JCfcqgcVHqVwzZf67Q.jpeg" /></figure><p>If you’ve been following the evolution of AI in video generation, you’ve likely come across the “Will Smith eating pasta” clip. This viral snippet has, in many ways, become the unofficial litmus test for evaluating multimodal foundation models — the systems enabling machines to generate realistic videos from simple prompts.</p><p>Recently, I came across a thought-provoking tweet:</p><blockquote>“Name a single positive reason for why you should be able to generate videos of people doing shit they didn’t do.”</blockquote><figure><img alt="Screenshot of Tweet saying, “Name a single positive reason for why you should be able to generate videos of people doing shit they didn’t do.”" src="https://cdn-images-1.medium.com/max/973/1*1L6WOCF6eZu7u0GKoMgqGQ.jpeg" /></figure><p>At first, I was stumped. But then, a plausible use case came to mind:</p><p>Imagine an actor (say, Will Smith) booked to appear in a commercial. Due to pre-existing commitments, he’s unable to attend the shoot. An AI-generated video could allow the project to move forward without disrupting schedules or contracts. Problem solved, right?</p><p>But herein lies the ethical conundrum. While such technology offers undeniable benefits — like resolving scheduling conflicts or enabling creatives to reimagine storytelling — it also opens the door to misuse, particularly in creating harmful deepfakes.</p><h3>Deepfakes: A Threat or a Tool?</h3><p>Deepfakes aren’t new. In fact, as far back as 2020, they had gotten such significant traction that the BBC questioned whether they were <em>“a threat to democracy or just a bit of fun”</em> (<a href="https://www.bbc.com/news/business-51204954">article</a>). And today, their potential for harm has only grown.</p><p>From political disinformation to malicious personal attacks, the risks are real and escalating. Yet, like most technological advances, the solution isn’t to ban the tool outright but to ensure its responsible development and use.</p><h3>How Do We Move Forward?</h3><p>To strike a balance between innovation and ethical responsibility, we must adopt a multi-pronged approach:</p><ol><li><strong>Promote Responsible Use:</strong> Stakeholders — from developers to policymakers — must emphasize ethical AI practices, ensuring that technologies are designed with safeguards against misuse.</li><li><strong>Educate the Public:</strong> Awareness is critical. Educating people, especially vulnerable populations, about the risks of AI-generated content and how to identify deepfakes is essential for societal resilience.</li><li><strong>Invest in Detection Tools:</strong> Technologies like Google DeepMind’s <a href="https://deepmind.google/technologies/synthid/">SynthID</a> offer innovative solutions for identifying and labeling AI-generated media, helping to distinguish real from fake.</li><li><strong>Implement Robust Regulations:</strong> Frameworks like the <a href="https://artificialintelligenceact.eu/">EU AI Act</a> and <a href="https://www2.deloitte.com/us/en/pages/deloitte-analytics/solutions/ethics-of-ai-framework.html">Deloitte’s Trustworthy AI Framework</a> provide a starting point for creating policies that govern AI responsibly, penalizing misuse while encouraging ethical innovation.</li></ol><h3>A Call to Action</h3><p>AI is not inherently good or evil; it’s a tool shaped by how we use it. By fostering collaboration among technologists, policymakers, and educators, we can mitigate the dangers while harnessing AI’s transformative potential.</p><p>Learn more about my background, certifications, and professional journey at my website: <a href="https://triumphurias.com/">triumphurias.com</a>.</p><h3>Join the Conversation</h3><p>What other measures can we take to address the risks of AI-generated content? Share your thoughts with me. Let’s shape the future of AI together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b3022cb4578" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving RAG AI Systems]]></title>
            <link>https://triumphurias.medium.com/improving-rag-ai-systems-d310708923e2?source=rss-e2b8aac57ea7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d310708923e2</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[chromadb]]></category>
            <category><![CDATA[rags]]></category>
            <dc:creator><![CDATA[Triumph Urias]]></dc:creator>
            <pubDate>Sun, 07 Jan 2024 22:47:04 GMT</pubDate>
            <atom:updated>2024-01-07T22:47:04.868Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="RAG Diagram from LangChain" src="https://cdn-images-1.medium.com/max/918/1*S7Jdkpd4SlaeLaEwAkZGKQ.png" /><figcaption>RAG Diagram from <a href="https://python.langchain.com/docs/use_cases/question_answering/">LangChain</a></figcaption></figure><p>If you’ve been in the AI field in recent times, you’ve definitely heard of Retrieval Augmented Generation (RAG) as a technique for building domain-specific question-answering systems (or more generally, chatbots 😆).</p><p>There are a couple of challenges anyone who has built a RAG application either as a side project or for use in a production environment would have stumbled upon and in this article, I will discuss some techniques to overcome these challenges. Much of what I’ll share in this article are learnings from DeepLearning.AI’s recently released course, <a href="https://www.deeplearning.ai/short-courses/advanced-retrieval-for-ai/?utm_campaign=chroma-launch&amp;utm_content=277272442&amp;utm_medium=social&amp;utm_source=linkedin&amp;hss_channel=lcp-18246783">Advanced Retrieval for AI with Chroma</a>.</p><h3><strong>INTRODUCTION</strong></h3><p>Before we go any further, let me do a quick crash course to remind us of what RAG is and how it works.</p><p>RAG is a technique for building Generative AI (GenAI) chatbots to answer questions based on specific user-provided data.</p><p>In general, GenAI models (like ChatGPT) are trained on a large corpus of data and so can usually answer most of our questions. Some of the downsides of this are, that the model has no knowledge of more recent data, has no knowledge of an organization’s internal data, etc.</p><p>To give the model access to the data (context) it needs to answer certain questions (queries), it is necessary to pass the data to the model. The problem tho, is that the models have a context window which prevents me (us) from just passing in all the available data. We need to limit the data to only the relevant data for the query. Also, it is important in some cases to make sure the model doesn’t just respond based on assumptions (known as hallucination) but rather sticks to real information and when there’s no answer, it says so. In comes <strong>Retrieval Augmented Generation</strong>.</p><p>In RAG applications, data is chunked and embedded (converted to vectors/ numbers in a multi-dimensional space, representing the sentimental and contextual meanings of the individual words) and stored in a vector database (vectordb). When the user asks a question, the query is also embedded (using the same embedding model) and the query embedding is used to check through the stored embeddings and “retrieve” relevant document chunks based on the similarities between the chunks and the queries.</p><p>These retrieved document chunks are then passed to the LLM model along with the user’s query and in most cases, some necessary instructions (or prompts) that guide the LLM’s behavior.</p><p>This article isn’t too focused on RAG so I wouldn’t go into more detail but I hope the above overview is sufficient to lay a foundation or jug your memory as the case may be. For more details, <a href="https://medium.com/@onkarmishra/using-langchain-for-question-answering-on-own-data-3af0a82789ed">this article</a> by <a href="https://medium.com/@onkarmishra?source=post_page-----3af0a82789ed--------------------------------">Onkar Mishral</a> would be very beneficial.</p><p><strong>Problems with RAG</strong></p><p>When building RAG applications today, all AI Engineers face the same common challenge of how to deal with irrelevant queries as well as irrelevant results.</p><p>In production environments, it’s common to find users asking questions to the system that aren’t relevant to the data uploaded. It could be that they ask questions that really can’t be answered by the data or they ask questions that result in the system retrieving document chunks that may not be relevant to what the user has in mind, bringing in the concept of <strong>relevancy versus distraction</strong> — more on that later.</p><blockquote>“Imagine all your data as a cloud of points sitting in this high-dimensional space. A query that lands inside the cloud is likely to find nearest neighbours that are (sort of) densely packed and close together inside the cloud but a query that lands outside the cloud is likely to find nearest neighbours from a lot of different parts of the cloud so they tend to be more spread out.”</blockquote><blockquote>- Anton Troynikov</blockquote><p>Another (more often overlooked) challenge when building RAG systems is the issues with the context window of your embedding model. Embedding models also have a limited context window and so tend to truncate any characters or tokens beyond their context window. This makes it critical to handle your text splitting carefully (this is beyond the scope of today’s article).</p><p>Much of the focus of this article would be on how to make sure the context (document chunks) passed to the LLM consists more of relevant documents than distractors.</p><h3><strong>QUERY EXPANSION</strong></h3><p>Paper: <a href="https://arxiv.org/abs/2305.03653">https://arxiv.org/abs/2305.03653</a></p><p>The query expansion techniques try to get different “perspectives” on the user’s query to cause the retrieval process to search over a wider dimensional space for relevant document chunks. This can be achieved in two ways:</p><ul><li>Expansion with generated answers</li><li>Expansion with multiple queries</li></ul><p><strong>Expansion with Generated Answer</strong></p><figure><img alt="Flow for Query Expansion with Generated Answer" src="https://cdn-images-1.medium.com/max/652/1*xz6fyOBC40_YR27dO3SCtA.png" /><figcaption>Flow for Query Expansion with Generated Answer</figcaption></figure><p>With this technique, the user’s query is first passed to an LLM prompted to come up with a hypothetical answer for the user’s query (essentially the model is asked to hallucinate — I guess hallucinating is not always bad after all 😆).</p><p>This hypothetical answer is concatenated with the orignal query and then passed into the vector database to search for relevant document chunks. This new combination moves the query elsewhere in the high-dimensional space, hopefully generating better results for the retrieval search.</p><p>The retrieved documents are passed with the user’s query into the LLM to generate an answer as usual.</p><p><strong>Expansion with Multiple Queries</strong></p><figure><img alt="Flow for Query Expansion with Multiple Queries" src="https://cdn-images-1.medium.com/max/806/1*Dv3nmjgIjNTy-_RStSD-Eg.png" /><figcaption>Flow for Query Expansion with Multiple Queries</figcaption></figure><p>In expanding with multiple queries, the first LLM is prompted to generate additional questions that are related to the original query and would help in getting the needed information. It’s important to also include in the prompt that the model generates simple questions to improve the usefulness of the generated queries in retrieving relevant document chunks from the vector database.</p><p>These new queries as well as the original query are used to search the vectordb for relevant documents. <a href="https://www.trychroma.com/">ChromaDB</a> particularly shines in this technique because it is able to handle multiple queries in parallel for document retrieval and so all you need do is pass in the list of all queries to be used as such:</p><pre>queries = [original_query] + augmented_queries<br>results = chroma_collection.query(query_texts=queries, n_results=5, include=[&quot;documents&quot;])</pre><p>The above code snippet would return 5 relevant documents for each of the queries passed in. Since these queries are similar, it’s possible to have duplicated documents. It is therefore necessary to deduplicate the document set so as to manage tokens being passed into the LLM.</p><p>And then finally, the retrieved documents are passed with the original query into the LLM for an answer.</p><p>___</p><p>When working with Query Expansion techniques, you find that Prompt Engineering as a concept becomes even more important because you’re dealing with at least one more LLM. It is therefore important to experiment with your prompts and see which works best for your use case.</p><h3><strong>CROSS-ENCODER RE-RANKING</strong></h3><p>Previously, I had alluded to the concept of relevancy versus distraction. Well, documents retrieved from a vector database have varying levels of relevance to the query with which they were retrieved. In practice, you find that some may even have very low relevance and as such just end up being distractions to the LLM.</p><p>Take a scenario where a user asks a question about LangChain and in the database, only 2 document chunks actually address the user’s question; but in building the RAG system, the engineer specified that 5 documents be retrieved, this automatically means that 3 of the retrieved documents are distractors to the LLM — This is just a very generic scenario to explain the concept. In practice, it’s a little more nuanced.</p><p>This is even much more the case when you use <strong>Expansion with Multiple Queries </strong>as discussed in the preceding section because even more documents are retrieved and as such there is an increased likelihood of having distractors in the mix.</p><p>In addition, it’s a common occurrence where the answer to a query is within a knowledge base (text corpus stored in the vectordb) but somehow the RAG system doesn’t find the answer or doesn’t find the best answer. In many cases, increasing the number of relevant documents retrieved solves this issue. But why?</p><p>Well, the simplest answer is that the retrieval system didn’t retrieve the “best fit” chunk in the first set of chunks when the number of retrieved documents were fewer but when the required number was expanded, it found it.</p><p>Remember, when working with GenAI, it’s best practice to manage your tokens either as a strategy to manage costs (if you’re working with a paid model) or at the very least to improve results (paid service or not) as the model has more tokens to use in generating answers.</p><p>— -</p><p>I wouldn’t go into the nut-and-bolts of how cross-encoder models work here but in this context, the cross-encoder is used to score the relevance of a given document (chunk) to the user’s query.</p><p>— -</p><figure><img alt="Flow for Cross-encoder Re-ranking" src="https://cdn-images-1.medium.com/max/708/1*OPxF3w8_0yvIvG4I-ClNQQ.png" /><figcaption>Flow for Cross-encoder Re-ranking</figcaption></figure><p>Say you retrieve 10 documents from the database, when they’re compared with the user’s query using the cross-encoder, you may find that the document in position 9 is more relevant to the query than the document in position 3.</p><p>It is, therefore, necessary to re-order the documents so that the more relevant documents are brought higher up in the listing, and with that, if you want to pass in only 5 chunks to the LLM, you’re sure that those are the top 5 most relevant chunks.</p><pre>query = &quot;...&quot;<br>results = chroma_collection.query(query_texts=query, n_results=10, include=[&#39;documents&#39;])<br><br>retrieved_documents = results[&#39;documents&#39;][0]<br><br># Load the cross encoder model<br>from sentence_transformers import CrossEncoder<br>cross_encoder = CrossEncoder(&#39;cross-encoder/ms-marco-MiniLM-L-6-v2&#39;)<br><br># Create input pairs for the cross encoder amd predict scores for their relevance<br>pairs = [[query, doc] for doc in retrieved_documents]<br>scores = cross_encoder.predict(pairs)<br><br>relevant_documents = []<br><br># Sort the scores and add the top documents corresponding with the top 5 to <br># the list of relevant documents to be passed into the LLM as context<br>for i in np.argsort(scores)[::-1][5]:<br>  relevant_docuemnts.append(retrieved_docuemnts[i]</pre><p>The code snippet above shows the process of handling the cross-encoder re-ranking using a sentence transformers cross-encoder model.</p><h3><strong>CONCLUSION</strong></h3><p>While RAG is a very effective way of ensuring your GenAI system is giving users accurate and relevant answers to their queries, there are still shortcomings with it and it’s important to pay close attention to the retrieval process in working towards improving the overall system. I hope with this article, you find some guidance on how to improve your systems.</p><p>With this article, I wanted to keep things as simple and high-level as possible and so with the code snippets shared, I assumed the reader has handled package installations as well as necessary imports. Should any of my readers encounter issues when trying to implement these, please reach out to me and I would be glad to help out as much as I can.</p><p>Did you find this useful or insightful, remember to give me a clap and share the article as well. Also, feel free to share your thoughts and comments below. Find out more about me and my projects as well as my writings on my website: <a href="http://triumphurias.com/">triumphurias.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d310708923e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>