<?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 Pablo Rosa on Medium]]></title>
        <description><![CDATA[Stories by Pablo Rosa on Medium]]></description>
        <link>https://medium.com/@pablo.julian.rosa?source=rss-db1df57be8d2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KT6hnkh5fzlD1Kf_3ujD8A.jpeg</url>
            <title>Stories by Pablo Rosa on Medium</title>
            <link>https://medium.com/@pablo.julian.rosa?source=rss-db1df57be8d2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 17:13:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pablo.julian.rosa/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[The AI Engineer’s Trilemma When Integrating LLMs: Latency, Cost, and Accuracy]]></title>
            <link>https://medium.com/@pablo.julian.rosa/the-ai-engineers-trilemma-when-integrating-llms-latency-cost-and-accuracy-ab775cd25055?source=rss-db1df57be8d2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab775cd25055</guid>
            <category><![CDATA[llms-utilization]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Pablo Rosa]]></dc:creator>
            <pubDate>Thu, 07 Aug 2025 01:39:42 GMT</pubDate>
            <atom:updated>2025-08-07T01:39:42.425Z</atom:updated>
            <content:encoded><![CDATA[<h3>Motivation</h3><p>Working as a developer, rolling out features that serve hundreds or thousands of users sometimes feels just like being a DJ: you’re staring at a massive console bristling with buttons — and hitting the wrong one is all it takes to turn the whole party into a horror show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ff76y7gq9iV8gKCMwdeHhA.jpeg" /></figure><p>For the past two years, working with LLMs, I’ve had the chance to cook up a variety of features. On one end, there were the straightforward gigs — a simple API call to Gemini where you plug in an input and expect a specific output. On the other, things got spicy: building a full-blown agent system with multiple tools and sub-agents that must answer based on precise documentation — cue RAG as the unsung hero.</p><p>We’ve always tackled these challenges chasing the dream of a virtual brain that “gets” what we type or say and then performs the perfect action. These so-called brains are always sold as “the AI that will revolutionize ABC” or “an agent that can handle XYZ,” but let’s be honest — that’s just marketing fireworks. Under the hood, it’s miles of code enforcing business logic. Period. If your business logic is broken, no amount of AI magic will deliver stellar results.</p><p>So far, so futuristic, right? Well… don’t pop the champagne just yet. As much as we developers hate to admit it, the real rock stars in any company are the business metrics (I know, I know — product and dev metrics matter too), because if the company isn’t selling, none of those paychecks land. That’s exactly where we can flex our dev muscles to move the needle. How? We might not sway the top line of the P&amp;L, but we certainly grip the second line: costs. The real headache: how do we slash expenses without turning our AI into a slow, inaccurate slug?</p><p>That, my friends, is what I call the LLM trilemma.</p><h3>LLM Trilemma</h3><p>Alright, so what’s the trilemma? Does it only hit LLMs? Did I just discover some brand-new crisis? Let’s unpack it.</p><p>This trilemma is the three-way tug-of-war between:</p><ul><li><strong>Accuracy</strong> of the response,</li><li><strong>Latency</strong> (how fast our endpoint spits back an answer), and</li><li><strong>Cost</strong> to generate that answer.</li></ul><p>Boost accuracy, and you’ll probably see your response time creep up and your bill spike.<br>Slash latency, and accuracy or budget take the hit for that speed boost.<br>Cut costs, and you’re guaranteed to compromise either precision or responsiveness.</p><p>Is there some secret formula to serve up lightning-fast, razor-sharp responses on a shoestring budget? If only I had that magic recipe.</p><p>But hey, it’s not a new dilemma — this trade-off pops up in nearly every aspect of life (yes, I got a bit philosophical). Every gain in one area comes with a price in another, and the real art is in minimizing those regrets.</p><h3>The formula</h3><p>Here’s what’s worked for me day-to-day when cooking up solutions:</p><ol><li><strong>Scope the context</strong><br> — Are you hustling at a startup or chilling in a FAANG?<br> — Will your feature be used by your small team or by millions every day?<br> Figuring this out tells you which corner of our trilemma — accuracy, latency, or cost — you can afford to punt. At a startup chasing PMF, you want that “WOW” moment fast, so lean on accuracy and speed to hook users (you’ll have time to optimize later). In a FAANG-style scenario, your code might run a million times a day — so watch your pennies, but remember: users won’t bail if they wait 2–3 seconds (they’ve already input their credit card).</li><li><strong>Plan in bite-sized chunks</strong><br> Map out your MVP and, if it’s a beast, slice it into phases. This gives you a laser-focused view of where your metrics really get hit: Do you need RAG? Are you feeding the LLM a novel-length prompt? Is that third-party tool eating all your tokens? Breaking it down helps you pinpoint exactly where to trim costs, speed things up, or boost accuracy.</li><li><strong>Test small, test fast</strong><br> Spin up a lean POC — one endpoint, super focused — then hit it in Postman. Boom, instant clarity on your biggest pain point. Tweak, retest, rinse and repeat until it’s rock solid. It might feel slow at first, but trust me: nailing the process early skyrockets overall velocity. (Process secures product — that’s a motto right there.)</li><li><strong>Don’t just ship… document</strong><br> Okay, kidding — definitely ship it. But always include a no-BS rundown of what it can and can’t do: <em>“This version delivers ~97% accuracy in X seconds at a cost of $Y USD, and only covers scenario Z.”</em><br> Your development notes are nearly as critical as the code itself.</li></ol><h3>My toolbox</h3><p>Alright, so here’s a battle plan you can actually start using tomorrow morning:</p><p><strong>My go-to toolbox, ranked from “press-of-a-button” easy to “mildly terrifying” complex:</strong></p><ol><li><strong>Cheap LLMs</strong><br> There’s a fierce arms race out there — OpenAI, Meta, Anthropic, Google — they’re all sprinting to ship ever-better models at shrinking price tags. Right now, the undisputed champion for general-purpose sorcery is <strong>gemini-2.5-flash</strong>. Dirt cheap. Blazingly fast for how reliable it is. And it slurps up to <strong>1,048,576 tokens</strong> of input and spits back <strong>65,535</strong>. Insanity, right?</li><li><strong>RAG (Retrieval-Augmented Generation)</strong></li></ol><ul><li><strong>Pros:</strong> Drags your token bills down and still nails accuracy (…but only if you do it right).</li><li><strong>Cons:</strong> Adds a bit of waiting time.</li></ul><p>Emphasis on <strong>“if you do it right.”</strong> What’s your vector dimensionality — high? low? How exactly are you crafting your similarity query? Where do you store those vectors? Do you re-rank your hits? And a dozen other gotchas. Pro tip: dive into Pinecone’s docs — they practically wrote the book on vector search, and their product is rock solid.</p><ol><li><strong>Multi-Agent Systems</strong><br> This is the holy grail for slaying the trilemma. Imagine a tiny expert bot for every single task… or several, all humming along in parallel.<br>So why isn’t everyone doing it? Because it’s insanely hard to build one tool that spins up dozens of mini-tools, each with its own logic, error handling, and edge cases in production. But if you can pull it off, you get the ultimate orchestra of specialized agents, each playing its part to perfection.</li></ol><p>If you’re wrestling with the same trilemma and have a secret weapon, spill the beans — so we can all enjoy TikTok-speed latency, Swiss-watch accuracy… and pay no more than the cost of a latte!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab775cd25055" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop browsing, here’s the example you need (GoogleDrive API + Python)]]></title>
            <link>https://medium.com/@pablo.julian.rosa/stop-browsing-heres-the-example-you-need-googledrive-api-python-5b3d3075baaa?source=rss-db1df57be8d2------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b3d3075baaa</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-drive-api]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Pablo Rosa]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 12:18:15 GMT</pubDate>
            <atom:updated>2022-01-24T11:31:48.792Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMM8kkirRLyjtbp1kbUg6Q.png" /></figure><p>This article contains a very useful example about handling files using Google Drive API + Python. Hope it helps you!</p><p><strong>Motivation: </strong>It was very difficult for me to find a clear implementation about list, create, updates, etc files with the API provided by Google.</p><p><strong>Context:</strong> At my current work, my team had to reduce human effort managing files at Google Drive. So i started scripting. Take an eye, this article explain you just with html files, but the snippet is alike other formats.</p><p><strong>Problem:</strong> Diving into <a href="https://developers.google.com/drive/api/v3/about-sdk">documentation</a> provided by google, examples included didn’t satisfied myself. The same happened with other blogs and Stackoverflow’s Q&amp;A. All i found, didn’t explain paramount aspects to be focused on.</p><p><strong>Assumption</strong>: You are a big developer who, although you don’t know how to create Google API keys, you have tons of documentation in your backpack, so if you follow this <a href="https://developers.google.com/workspace/guides/configure-oauth-consent">gude</a>, i’m sure you won’t have any problems.</p><p>Begin with this.</p><p>Import our libraries (suggestion: read the <a href="https://pycqa.github.io/isort/">isort</a> documentation. It helps you improving your code)</p><pre># Built in packages<br>import time</pre><pre># Third party packages<br>import pandas as pd<br>from apiclient.http import MediaFileUpload</pre><pre># Credentials storaged local<br>from googleapiclient.discovery import build<br>from oauth2client.service_account import ServiceAccountCredentials</pre><pre># Local packages<br>#credentials stored local<br>from .credentials import gcp_credentials</pre><pre># In my case, i handle with html files.<br>FILE_NAME = &#39;file_name.html&#39;</pre><p>This is one of the <strong>foremost tips</strong> I haven’t found anywhere: make sure your file exists in the repo you’re pointing to. This API isn’t smart enough to recognize if your file is already in its repo. So if NO, then create. If YES, update. (No one expects to find duplicate files)</p><p>Load credentials</p><pre># Load credentials<br>scope = [&#39;<a href="https://www.googleapis.com/auth/drive&#39;">https://www.googleapis.com/auth/drive&#39;</a>]<br>gcp_cred = gcp_credentials()<br>creds = ServiceAccountCredentials.from_json_keyfile_dict(gcp_cred, scope)</pre><p>Instance the build method with credentials and define mimetype as text/csv to make explicit our file type we are working on.</p><pre>#Create my google drive service<br>service = build(&#39;drive&#39;, &#39;v3&#39;, credentials=creds)<br>mimetype = &#39;text/csv&#39;</pre><p>You need the folder_id parameter. It’s at the top of you browser, copy the string like the highlighted example below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlVQYksmVmqs3lgwxRzkVA.png" /></figure><pre>#Example folder id<br>FOLDER_ID = &#39;000111222333444AAABBBCCCDDDEEE&#39;</pre><p>As said before, first you need list all items included on your drive. Let’s move on!</p><p>We need to create a <a href="https://developers.google.com/drive/api/v3/search-files">query param</a> and give drive_id as parameters. Last one you’ll find in the same place where FOLDER_ID is.</p><pre>query = f&quot;parents in &#39;{FOLDER_ID}&#39; and trashed = false&quot; <br>page_token = None<br>DRIVE_ID = &#39;ThisIsAString0123456789&#39;<br>list_of_files = []<br>while True:<br>     response = service.files().list(<br>                corpora = &#39;drive&#39;,<br>                driveId = DRIVE_ID,<br>                q=query,<br>                pageSize=20,<br>                fields=&quot;nextPageToken, files(id, name)&quot;,<br>                pageToken=page_token,<br>                includeItemsFromAllDrives = True,<br>                supportsAllDrives= True).execute()<br>     <br>     list_of_files += response.get(&#39;files&#39;)<br>     page_token = response.get(&#39;nextPageToken&#39;, None)<br>     if page_token is None:<br>           break</pre><pre># All files included at our repo<br>files = []<br>for file in range(len(list_of_files)):<br>    if list_of_files[file].get(&#39;name&#39;):<br>        files.append({&#39;name&#39;: list_of_files[file].get(&#39;name&#39;),<br>                            &#39;id&#39;:list_of_files[file].get(&#39;id&#39;)})</pre><pre>df_files = pd.DataFrame(files)</pre><p>With all items listed, it’s time to check if the file exist or not in order to create or replace.</p><p>Second key tip: While creating a new file, it’s mandatory that FOLDER_ID being a <strong>list of string</strong>. If you don’t do this, API neither won’t fail or rise an error so be caution with this.</p><pre>if FILE_NAME in list(df_files.name):<br>    # Exists<br>    # YES:Update<br>    media = MediaFileUpload(FILE_NAME, mimetype=mimetype)<br>    index = df_files[df_files[&quot;name&quot;] == html_name].index<br>    service.files().update(<br>                fileId=df_files.loc[index[0], &quot;id&quot;],<br>                media_body=media,<br>                supportsAllDrives=True).execute()       <br>else:    <br>    # NO: CREATE<br>    file_metadata = {<br>                &quot;name&quot;: FILE_NAME,<br>                &quot;parents&quot;: FOLDER_ID, #REMEMBER: This is a list<br>                &quot;mimeType&quot;: mimetype,<br>                    }<br>    media = MediaFileUpload(html_name,<br>                            mimetype=mimetype,<br>                            resumable=True)<br>    service.files().create(<br>                body=file_metadata,<br>                media_body=media,<br>                supportsAllDrives=True).execute()</pre><p>Dear reader, hope this development, reduce human effort and also helps you to become a better developer. Please let me know if it is useful for you, i’ll be reading all your comments.</p><p>If you want, reach me at <a href="https://www.linkedin.com/in/pablo-rosa-2b1183aa/">LinkedIn</a>.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b3d3075baaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>