<?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 Manickavasagam Lakshminarayanan on Medium]]></title>
        <description><![CDATA[Stories by Manickavasagam Lakshminarayanan on Medium]]></description>
        <link>https://medium.com/@manick2411?source=rss-a3d73c676fcb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YxVZjJ1C0jje6ZYH</url>
            <title>Stories by Manickavasagam Lakshminarayanan on Medium</title>
            <link>https://medium.com/@manick2411?source=rss-a3d73c676fcb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:36:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manick2411/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[Web Scraping made simple with URL Context]]></title>
            <link>https://medium.com/google-cloud/web-scraping-made-simple-with-url-context-eb4dbfecce97?source=rss-a3d73c676fcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb4dbfecce97</guid>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[webscracping]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <dc:creator><![CDATA[Manickavasagam Lakshminarayanan]]></dc:creator>
            <pubDate>Thu, 03 Jul 2025 01:39:15 GMT</pubDate>
            <atom:updated>2025-07-03T01:39:15.423Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>TL;DR:</strong>URL Context tool in Gemini (Now available in Vertex) is a game changer, helping to build better AI Applications that can scrape webpages easily and respond to you. All you gotta do is just pass the URL and let Gemini do its work.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnW8AADt94lh89qyJzVKpQ.png" /></figure><p>Context Engineering, a term that is commonly used now, is very key for building AI Applications. Providing the right context makes the model perform better and helps you achieve needed goal faster and easier.</p><p>Providing right Context is tough, You might need to scrape webpages, build RAG systems, Upload documents, connect different systems and many more.</p><p>Google has made our lives a little easier with the introduction of URL Context tool. First this was introduced in AI Studio(Dev). Now also enabled in Vertex for Enterprise usage.</p><h3>What does URL Context do?</h3><p>All you need to do is pass the URL, which you need the gemini to scrape and ground its response, in the prompt itself. Automatically the Gemini API scrapes the web content be it a plain html, a web page or a PDF and responds to your query.</p><p><strong>Benefit for you?</strong> Apart from no need to build confusing RAG systems, Token usage goes drastically down compared to actual grounding when giving the whole content.</p><h3>How to use it?</h3><p>Now let’s try to build a simple FAQ bot which answers questions based on an FAQ Website.</p><p>All we gotta do is initialize URL Context tool similar to google search tool and send the prompt with the URL.</p><pre>#Initialize client<br>client = genai.Client(vertexai=True,project=PROJECT_ID,location=LOCATION)<br><br>#Initialize the URL Context Tool<br>url_context_tool = Tool(<br>    url_context = UrlContext<br>)<br><br>#Initiate a generate content request.<br>response = client.models.generate_content(<br>    model=&quot;gemini-2.5-flash-lite-preview-06-17&quot;,<br>    contents=&quot;&quot;&quot;Answer Query based on given FAQ URL.<br>FAQ URL = https://cloud.google.com/vertex-ai/generative-ai/docs/faq<br><br>I want to understand about throughput provisioning.&quot;&quot;&quot;,<br>    config=GenerateContentConfig(<br>        tools=[url_context_tool],<br>        response_modalities=[&quot;TEXT&quot;],<br>    )<br>)<br><br>print(&quot;+++++++++++++++Response+++++++++++++++&quot;)<br>print(response.text)<br>print(&quot;+++++++++++++++URL METADATA+++++++++++++++&quot;)<br>print(response.candidates[0].url_context_metadata)</pre><p>As simple as that. And it just works. Below is the response.</p><pre>You should use Provisioned Throughput (PT) for generative AI applications in production that require consistent throughput. PT guarantees a predictable and consistent user experience, which is essential for time-sensitive workloads. It also offers deterministic monthly or weekly cost structures, making budget planning more accurate.<br><br>For more details, you can refer to the &quot;Provisioned Throughput overview&quot; section on the page.</pre><p>It also gives the URL Context metadata giving the details like retrieval status for the given URL.</p><pre>url_metadata=[UrlMetadata(<br>  retrieved_url=&#39;https://cloud.google.com/vertex-ai/generative-ai/docs/faq&#39;,<br>  url_retrieval_status=&lt;UrlRetrievalStatus.URL_RETRIEVAL_STATUS_SUCCESS: &#39;URL_RETRIEVAL_STATUS_SUCCESS&#39;&gt;<br>)]</pre><p>And just like that, you have an FAQ bot built, just by passing URLs and nothing else.</p><p>You can also try it yourself in the <a href="https://github.com/manick2411/gemini-utils/blob/main/Web_Scraping_made_simple_with_URL%C2%A0Context.ipynb">notebook</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb4dbfecce97" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/web-scraping-made-simple-with-url-context-eb4dbfecce97">Web Scraping made simple with URL Context</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accelerating AI Development: Effortless Prompt Sync with Vertex AI Prompt Management]]></title>
            <link>https://medium.com/google-cloud/accelerating-ai-development-effortless-prompt-sync-with-vertex-ai-prompt-management-c53e5e6299ca?source=rss-a3d73c676fcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c53e5e6299ca</guid>
            <category><![CDATA[prompt]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <category><![CDATA[llmops]]></category>
            <dc:creator><![CDATA[Manickavasagam Lakshminarayanan]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 02:36:48 GMT</pubDate>
            <atom:updated>2025-01-06T02:36:48.489Z</atom:updated>
            <content:encoded><![CDATA[<p>TL;DR: Vertex AI Prompt Management simplifies managing prompts for AI apps. Instead of manually copying prompts between a UI and code, you can now create and perfect them in the Vertex AI Studio UI, then directly import them into your code with a simple ID. Changes in the UI are instantly reflected in the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7SP9CWsuGafPUGWkvvmpg.jpeg" /></figure><p>In this era of Gen Apps, One of the most important “code” is nothing but Plain English Instructions that you give to LLMs fondly called as Prompt.</p><h3>AS-IS</h3><p>Currently, most of us, when building gen apps, We build and try out our prompts in UI-based AI Studios where we try different prompting strategies and also play with different settings of LLM such as temperature, top-p,top-k….</p><p>Then there is the manual part of copying the prompts and parameters to Python code where we use SDKs and call appropriately.</p><h3>The Problems</h3><p>With the fast pace developments of LLMs, Most models get small upgrades very often. When this happens, sometimes it completely derails our app, as the response for the same prompt might vary significantly. So to make these prompts suit the new model, there is a need to improve the prompt.</p><p>When the prompt is improved, again, there is the need to copy paste the prompt and do the whole deployment again.</p><p>In some sophisticated LLMOps, There might be some external DBs which might act as Prompt Repositories which will again bring in some cost and complexity for hosting a separate DB.</p><h3>What do we want</h3><p>It would be highly efficient if we can test and finalize the prompts in the UI and directly import it in code using some identifier with the expectation that we can also update parameters and everything in the UI and all updates seamlessly reflect in the code without the need for any additional modifications.</p><h3><strong>Why Prompt Management matters</strong></h3><p>A better prompt management will ensure</p><ul><li>Reduced errors</li><li>Improved collaboration</li><li>Easier scaling of applications</li></ul><h3>Vertex Prompt Management</h3><p>Vertex Prompt Management makes the lives of AI engineers very easy with the tight integration between the UI-based AI Studio and code sync-up. Solving the key problems as discussed above.</p><h3>How to use it</h3><h3>Step 1: Reach Prompting UI</h3><p>First go to Freeform Prompting option in Vertex AI Studio</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*6lcnySO-3ulYkwpBz-38JQ.png" /><figcaption>Accessing Freeform</figcaption></figure><h3>Step 2: Perfect your prompt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zcxnwG_crFRDn7D7WrWZXA.png" /><figcaption>Freeform Prompting — Vertex AI Studio Screen</figcaption></figure><p>This is where the magic happens where you can use the different features to perfect your prompts from system instructions, variables, examples, parameters and every feature of the Vertex AI Studio.</p><h3>Step 3: Save the prompt</h3><p>Once the prompt is finalized, you can give it a name and save it using the save button in the top right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*aEhuWHbp8sXdxIe-LTLtjw.png" /><figcaption>Save Prompt Dialogbox</figcaption></figure><h3>Step 4: Find the prompt ID</h3><p>You can find the prompt ID from the URL in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hnvk4ZJGU4OhPo4j3sXs6w.png" /><figcaption>Prompt ID — From Browser</figcaption></figure><h3>Step 5: Importing the prompt in Code</h3><p>Now that we have perfected the prompt and strored it. Now, let’s see the magic of easily porting everything into code.</p><pre>from vertexai.preview import prompts<br><br>prompt = prompts.get(&quot;4496910748382920704&quot;) #prompt id from UI<br><br>prompt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*84LdXk2AqqFxxB1RrEnI3w.png" /><figcaption>Output for above code</figcaption></figure><p>It’s as simple as this to import the prompt from UI Vertex AI Studio to code. The best part is that any changes you make to the same prompt in theUI all gets reflected instantaneously.</p><h3>Step 6: Assembling the prompt</h3><p>Let us also see how simple it is to change the variable and assemble it and get as a string prompt which can be used in any SDK or any framework.</p><pre>assembled_prompt = prompt.assemble_contents(user_input = &quot;Dosa&quot;) #user_input is the variable name given in the UI<br>assembled_prompt[0].text</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0WOdL-a30p5g3jS916-Zw.png" /><figcaption>Output for above code</figcaption></figure><h3>Step 7: Executing the prompts</h3><p>We can also easily execute the prompt with the same settings and model that are stored from theUI.</p><pre>prompt.generate_content(contents=prompt.assemble_contents(**prompt.variables[0]))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZ-NAAwpt0UTWiBJM9e_NA.png" /><figcaption>Output from above code</figcaption></figure><p>We can also execute after changing the variables directly.</p><pre>prompt.generate_content(contents=prompt.assemble_contents(user_input = &quot;Dosa&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GALF8d-QgT36Yzg07KiZTw.png" /><figcaption>Output from above code</figcaption></figure><p>We can also create new version of the prompts, new prompts, list prompts using the same python Vertex AI SDK.</p><p>Most changes, like Model Change, Model Parameters, Prompts, Prompt variables,System Instructions all reflect instataneously once saved in UI.</p><p>Vertex Prompt Management also allows exporting and importing prompts, making it easier to upgrade environments after finalizing a prompt.</p><p>In conclusion, <strong>Prompt Management is made extremely simple</strong> now with a tight integration between UI and code in <strong>Vertex Prompt Management</strong>. Better version controls will be an added plus.</p><p>You can try it yourself, and to make it easier, I have provided a notebook.</p><p><a href="https://github.com/manick2411/gemini-utils/blob/main/Prompt_management_made_simple_with_Vertex_AI.ipynb">gemini-utils/Prompt_management_made_simple_with_Vertex_AI.ipynb at main · manick2411/gemini-utils</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c53e5e6299ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/accelerating-ai-development-effortless-prompt-sync-with-vertex-ai-prompt-management-c53e5e6299ca">Accelerating AI Development: Effortless Prompt Sync with Vertex AI Prompt Management</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Benchmarking LLM Tokenization: Indic Languages Under the Lens]]></title>
            <link>https://medium.com/@manick2411/benchmarking-llm-tokenization-indic-languages-under-the-lens-6b86844e54e9?source=rss-a3d73c676fcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b86844e54e9</guid>
            <category><![CDATA[benchmark]]></category>
            <category><![CDATA[indian-languages]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[tokenization]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Manickavasagam Lakshminarayanan]]></dc:creator>
            <pubDate>Wed, 01 Jan 2025 14:09:42 GMT</pubDate>
            <atom:updated>2025-01-01T14:09:42.670Z</atom:updated>
            <content:encoded><![CDATA[<h4>Here we see how different models are effective at tokenizing different Indic Languages like Tamil,Hindi,Bengali and few others.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tFP7OsJiikf7G8De0WXdpA.jpeg" /></figure><p><strong>TL;DR </strong>This article compares tokenization performance for Indic languages across various LLMs (including GPT-4o, Gemini, Sarvam 1, and several open-source models). We found that Sarvam 1 excels in token optimization for Indic languages, using much fewer tokens than others like Llama 3.3. However, GPT-4o and Gemini 2.0 offer the best performance overall despite requiring more tokens than English. Tokenization optimization for Indic languages is an area needing more improvements.</p><p><strong>Tokenization</strong> is the process in which texts are converted into easily processable blocks known as tokens which can be easily processed by Language Models. This serves as the first step in getting inference from a LLM where the input human readable text is converted into machine understandable blocks ready for processing.</p><p>The main focus of the article is to bring out how efficiently different models from different providers tokenize indic languages like <strong>Tamil, Hindi, Marathi, Bengali, Telugu, Malayalam, Sanskrit, </strong>along with<strong> English</strong>, which most languages process very efficiently compared to others.</p><p>The models that are compared are</p><ol><li><strong>OpenAI GPT 4o</strong>, latest model in GPT series.</li><li><strong>Google Gemini 2.0 Flash</strong>, latest model in Gemini series.</li><li><strong>Anthropic Claude 3.5 Sonnet</strong>, latest and best performant model in Claude series.</li><li><strong>Saravam 1</strong>, latest model from Indian origin company Sarvam AI.</li><li><strong>Deepseek v3</strong>, latest and best open source model right now.</li><li><strong>Meta Llama 3.3</strong>, latest model in llama series.</li><li><strong>Qwen QVQ</strong>, latest model from Qwen team.</li><li><strong>Krutrim-spectre-V2</strong>, latest model from Indian origin company OLA Krutrim.</li><li><strong>Phi 3.5 mini instruct</strong>, available model from Microsoft leading SLM Phi series.</li></ol><h3>Experiment</h3><p>The experiment is as follows —</p><ul><li>Get a single sentence with same meaning and almost same number of words in selected languages.</li><li>Find number of tokens for the selected sentences, from different languages, from the models via APIs or HuggingFace Tokenizers.</li></ul><h3>Why is this needed</h3><ul><li>Tokenization serves as both the foundational pre-processing and final post-processing stage in LLM inference workflows.Highly optimized tokenization can translate to <strong>better performance</strong> from the LLM.</li><li>Other important factor is <strong>Pricing</strong>. As most LLM providers calculate the pricing based on the number of tokens sent and received, Better optimized tokenization means <strong>lower pricing</strong>.</li><li>Developers can better choose LLMs based on the usecase, language and pricing.</li></ul><h3>Sentences</h3><ol><li>English — The little bird flew quickly from the tall tree and landed gently on the soft green grass near the garden.</li><li>Tamil — சிறிய பறவை உயரமான மரத்திலிருந்து வேகமாகப் பறந்து, தோட்டத்திற்கு அருகில் மென்மையான பச்சை புல்லில் மெதுவாக இறங்கியது.</li><li>Hindi — छोटी चिड़िया ऊँचे पेड़ से तेज़ी से उड़ी और बगीचे के पास नरम हरी घास पर धीरे से उतरी।</li><li>Telugu — చిన్న పక్షి ఎత్తైన చెట్టు నుండి వేగంగా ఎగిరి, తోట దగ్గర మృదువైన పచ్చ గడ్డిపై సున్నితంగా వాలింది.</li><li>Malayalam — ചെറിയ പക്ഷി ഉയരമുള്ള മരത്തിൽ നിന്ന് വേഗത്തിൽ പറന്നു, പൂന്തോട്ടത്തിനടുത്തുള്ള മൃദുവായ പച്ച പുല്ലിൽ പതിയെ ഇറങ്ങി.</li><li>Marathi — एक लहान पक्षी उंच झाडावरून वेगाने उडाला आणि बागेजवळच्या मऊ हिरव्या गवतावर हळूवारपणे उतरला.</li><li>Bengali — ছোট পাখিটি লম্বা গাছ থেকে দ্রুত উড়ে গিয়ে বাগানের কাছে নরম সবুজ ঘাসে আলতো করে নামল।</li><li>Sanskrit — लघुः खगः उच्चात् वृक्षात् शीघ्रम् उत्पत्य उपवनसमीपे मृदुले हरिततृणे शनैः अवतरत्।</li></ol><h3>Token Counting Process</h3><h3>OpenAI GPT 4o</h3><p>Number of Tokens for GPT 4o is got from the <a href="https://platform.openai.com/tokenizer">OpenAI’s Tokenization website</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*doBeQfjAOA2OVIP9QZPogw.png" /><figcaption>OpenAI Tokenizer Website</figcaption></figure><h3>Google Gemini 2.0 Flash</h3><p>Number of Tokens for Gemini can be got in different ways. Easy way to visualize and see the number of tokens is via GCP Vertex AI Studio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*TeFsik5Szw2i-FyFZHlNDw.png" /><figcaption>Vertex AI Studio Tokenizer View</figcaption></figure><h3>Anthropic Claude 3.5 Sonnet</h3><p>Number of Tokens from Claude is got via Count Tokens API via Anthropic Python SDK.</p><pre>client.messages.count_tokens(model=&quot;claude-3-5-sonnet-20241022&quot;,messages=[{&quot;role&quot;: &quot;user&quot;,&quot;content&quot;: sentence}],)</pre><h3>Open Source Models available in HuggingFace</h3><p>For open source models that are available in Hugging Face (Sarvam 1,Deepseek v3,Llama 3.3,QVQ,Phi 3.5), Number of tokens can be calculated easily using the Hugging Face Transformers python library.</p><pre>tokenizer = AutoTokenizer.from_pretrained(model_name)<br>tokens = tokenizer(sentence)<br>number_of_tokens= len(tokens.input_ids)</pre><h3>Krutrim-spectre-V2</h3><p>For Krutrim-spectre-V2, There is no separate count token API. So request was sent to the chat completions API and number of tokens was got from usage metadata using the Krutrim Python SDK.</p><pre>tokens = client.chat.completions.create(model=&quot;Krutrim-spectre-V2&quot;, messages=[{&quot;role&quot;: &quot;user&quot;,&quot;content&quot;: sentence}])<br>number_of_tokens = tokens.usage[&quot;prompt_tokens&quot;]</pre><h3>Results</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FjtGCA%2F3%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FjtGCA%2F3%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FjtGCA%2Fplain-s.png%3Fv%3D3&amp;type=text%2Fhtml&amp;schema=dwcdn" width="900" height="549" frameborder="0" scrolling="no"><a href="https://medium.com/media/c38722a4cc1f0854bbb6ce07709dbe4f/href">https://medium.com/media/c38722a4cc1f0854bbb6ce07709dbe4f/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=%2F%2Fembed.chartblocks.com%2F1.0%2F%3Fc%3D67750fde3ba0f65c4a6d54a3%26t%3D428cf18cd3a248c&amp;display_name=ChartBlocks&amp;url=https%3A%2F%2Fpublic.chartblocks.com%2Fc%2F67750fde3ba0f65c4a6d54a3%3Ft%3D428cf18cd3a248c&amp;image=https%3A%2F%2Fd3ugvbs94d921r.cloudfront.net%2F67750fde3ba0f65c4a6d54a3.png%3Ft%3D428cf18cd3a248c&amp;type=text%2Fhtml&amp;schema=chartblocks" width="3000" height="1000" frameborder="0" scrolling="no"><a href="https://medium.com/media/039084414c7efef60c3133e9a0a3a4d1/href">https://medium.com/media/039084414c7efef60c3133e9a0a3a4d1/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2Ff3IrI%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2Ff3IrI%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2Ff3IrI%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="1000" height="551" frameborder="0" scrolling="no"><a href="https://medium.com/media/460ac5fc1fcd630fc73ab9879091ed02/href">https://medium.com/media/460ac5fc1fcd630fc73ab9879091ed02/href</a></iframe><h3>Inference</h3><ul><li>Best Optimized Tokenization is achieved by <strong>Sarvam 1</strong> for the Indic Languages, Achieving around 80% lesser tokens compared to Llama 3.3 on Tamil as well as better performance across most of the indic languages and maintainig around 1x the english tokens.</li><li>In the best task performing models,<strong> GPT 4o</strong> and <strong>Gemini 2.0 Flash</strong> have better optimized tokenization for the indic languages though needing around 2x the english tokens for processing.</li><li>In the Open Source Models, <strong>DeepSeek V3</strong> is surprisingly having a good optimization for the indic languages tokenization(2–4x the english tokens) while other models are having very low optimizations(greater than 4x english tokens).</li></ul><h3>Conclusion</h3><p><strong>Sarvam 1</strong>, originating from Indian Based AI Company seems to prove its Indic languages processing capability. Sarvam AI has done a good job in optimizing the tokenizer for the Indic languages. Nevertheless, the actual performance of Sarvam 1 across various tasks requires further validation.</p><p><strong>Gemini</strong> and <strong>GPT 4o</strong> are the best models which can be used for Indic Languages based tasks right now, given their versatility in performances across different tasks and better optimized tokenizations.</p><p>Most open source models from big players are yet to reach the needed optimization as achieved in English.</p><p>To unlock the full potential of LLMs for Indic languages, LLM providers must prioritize better tokenization. This is because even the best-optimized usable models like GPT4o and Gemini 2.0 require roughly two times the number of tokens as English leading to significant increases in cost and latency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b86844e54e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of LLMs: Gemini Function Calling Simplified with Vertex AI SDK]]></title>
            <link>https://medium.com/google-cloud/unlocking-the-power-of-llms-gemini-function-calling-simplified-with-vertex-ai-sdk-3c8c0f906a61?source=rss-a3d73c676fcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c8c0f906a61</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[vertex-ai]]></category>
            <category><![CDATA[llm-function-calling]]></category>
            <dc:creator><![CDATA[Manickavasagam Lakshminarayanan]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 06:04:32 GMT</pubDate>
            <atom:updated>2024-08-02T06:04:32.598Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>TL;DR</strong>: <strong>Function Calling</strong> enables LLMs like <strong>Gemini</strong> to access external data sources, but implementing it can be challenging. The <strong>Vertex AI Python SDK</strong> simplifies this process by allowing easy conversion of Python functions to Tools, automating function execution, and streamlining result parsing. This article demonstrates how developers can leverage the SDK to implement Function Calling with minimal effort, focusing on solving business problems rather than dealing with technical complexities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b46vduzJPmXHA5XMMk8dEw.jpeg" /></figure><p>With <strong>Generative AI</strong> being the talk everywhere, Generative AI Models like <strong>Gemini</strong> are at the center of them. While these models demonstrate impressive reasoning abilities, they often <strong>lack real-time connectivity to the external world</strong>. This is where <strong>Function Calling</strong> comes into play, giving them the ability to interact with external world like getting current weather information, or fetching details from your own database.</p><h3><strong>Function Calling: Bridging AI and External Data</strong></h3><p><strong>Function Calling</strong> enables Models to use Tools (as they are popularly called) which enable them to connect to external world by using APIs or Functions.</p><p><strong>How Function Calling Works</strong></p><ol><li><strong>Tool Definition:</strong> Functions and APIs are defined as Tools, typically using the OpenAPI format, and presented to the model during initialization.</li><li><strong>User Query:</strong> When a user poses a question, the model assesses which Tool is most appropriate to answer it.</li><li><strong>Tool Selection and Execution:</strong> The model selects the relevant Tool and provides the necessary arguments for its execution.</li><li><strong>Function Execution:</strong> The specified function or API call is executed with the provided arguments.</li><li><strong>Result Processing:</strong> The execution result is returned to the model for interpretation.</li><li><strong>Response Generation:</strong> The model analyzes the data obtained from the Tool and formulates a response to the user’s query, incorporating the most up-to-date information.</li></ol><p>This process enables models to provide accurate, timely responses by leveraging external data sources and functionalities. This beautiful illustration from <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling">Vertex Function Calling Documentation</a> explains the process wonderfully. You can also read it to get more understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*Lq-Vb_ZwHq1mvclHCJaPBg.png" /><figcaption>Source: Google Vertex AI Documentation</figcaption></figure><h3><strong>Challenges in Implementing Function Calling</strong></h3><p>While Function Calling offers powerful capabilities, developers often encounter several pain points during implementation:</p><ol><li><strong>Complex Tool Definitions:</strong> Function Calling typically requires tool definitions in OpenAPI format. This process can be time-consuming and challenging, especially when formatting intricate requirements.</li><li><strong>Parsing Model Responses:</strong> Interpreting the model’s output to extract the correct arguments for function execution can be complex. This step often requires careful handling to ensure accurate data flow.</li><li><strong>Formatting Function Results: </strong>After executing a function, developers must format the results in a specific way before passing them back to the model. This additional step adds complexity to the workflow.</li><li><strong>Integration Overhead:</strong> While these tasks may seem like one-time setups, they often require significant time and effort to implement correctly. The cumulative effect of these challenges can slow down development and increase the potential for errors.</li></ol><p>These pain points highlight the need for streamlined solutions that can simplify the Function Calling process, allowing developers to focus on core functionality rather than implementation details.</p><h3><strong>Simplifying Function Calling with GCP Vertex AI Python SDK</strong></h3><p>The <strong>GCP Vertex AI Python SDK</strong> offers powerful features that address the challenges mentioned earlier, allowing GenAI developers to focus on core functionalities rather than implementation details.</p><p><strong>Key Features:</strong></p><ol><li><strong>Seamless Tool Creation:</strong> Convert standard Python functions directly into the Tool format required by Gemini.</li><li><strong>Automated Workflow:</strong> Automatically parse arguments, execute functions, and pass results to the Gemini model.</li></ol><p>For a comprehensive example of Function Calling implementation, refer to <a href="https://github.com/manick2411/gemini-utils/blob/main/Function_Calling_Made_Easy_by_Vertex_Python_SDK.ipynb">this notebook</a></p><h3><strong>Streamlined Python Function to Tool Conversion</strong></h3><p>To leverage the SDK’s capabilities, developers should create Python functions with the following best practices:</p><ol><li><strong>Comprehensive Docstrings</strong>: Include detailed information about the function’s purpose, required arguments, and return values.</li><li><strong>Type Hints</strong>: Use proper function declarations with type hints.</li><li><strong>Vertex AI Best Practices</strong>: Adhere to additional guidelines outlined in the <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#best-practices">Vertex documentation</a> for optimal model performance.</li></ol><p>Let’s illustrate this with a common Function Calling example: retrieving current weather data for use in Generative AI Models.</p><p>In this scenario, we’ll create a Tool for Gemini that fetches the current weather for a specified city using the OpenWeather API. Here’s an example of how to structure the Python function:</p><pre>def get_current_weather_data(city:str) -&gt; str:<br>  &quot;&quot;&quot;<br>  Gets weather in the specified location.<br>  Args:<br>      city: The city for which to get the weather as a str.<br>  Returns:<br>      Whole Weather data as a dictionary<br>  &quot;&quot;&quot;<br>  url = f&quot;https://api.openweathermap.org/data/2.5/weather?q={city}&amp;appid={userdata.get(&#39;OPENWEATHER_API_KEY&#39;)}&quot;<br>  response = requests.get(url)<br>  return response.json()[&quot;weather&quot;][0][&quot;description&quot;]</pre><p>The Vertex Python SDK showcases its true potential in its ability to transform Python functions into Gemini Tools with remarkable ease. This process, which typically involves complex steps, is condensed into just two lines of code:</p><pre>get_current_weather_func = FunctionDeclaration.from_func(get_current_weather_data)<br>weather_tool = Tool(function_declarations=[get_current_weather_func],)</pre><p>This tool can be directly passed to Gemini as follows.</p><pre>model = GenerativeModel(&quot;gemini-1.5-flash-001&quot;,tools=[weather_tool],)</pre><h3><strong>Streamlining Function Execution with Automatic Handling</strong></h3><p>The Vertex SDK introduces a powerful feature: the <strong>AutomaticFunctionCallingResponder</strong> class. This class resolves the remaining challenges in the Function Calling process.</p><p>When Gemini needs to execute a function, the AutomaticFunctionCallingResponder takes charge. It seamlessly parses Gemini’s response, extracts the necessary arguments, executes the function, and relays the results back to Gemini. This automation significantly simplifies the development process.</p><p>Here’s how to implement this feature:</p><pre>afc_responder = AutomaticFunctionCallingResponder(max_automatic_function_calls=5,) # Initialize AFC with maximum number of function calls allowed<br>chat = model.start_chat(responder=afc_responder) # Initialize a Chat with AFC as responder</pre><p>Let’s see this in action with a practical example:</p><pre>response1 = chat.send_message(&quot;I am from Mumbai. I am planning to go outside now. Should i carry a umbrella?&quot;)<br>print(response1.text)<br><br>## Output: <br># It&#39;s overcast in Mumbai. You might want to carry an umbrella just in case.</pre><p>In this scenario, the AutomaticFunctionCallingResponder does all the heavy lifting behind the scenes, delivering a seamless experience for the developer.</p><p>To verify the function call process, you can examine the chat history:</p><pre>chat.history<br><br>&quot;&quot;&quot;Output:<br>[role: &quot;user&quot;<br> parts {<br>   text: &quot;I am from Mumbai. I am planning to go outside now. Should i carry a umbrella?&quot;<br> },<br> role: &quot;model&quot;<br> parts {<br>   function_call {<br>     name: &quot;get_current_weather_data&quot;<br>     args {<br>       fields {<br>         key: &quot;city&quot;<br>         value {<br>           string_value: &quot;Mumbai&quot;<br>         }<br>       }<br>     }<br>   }<br> },<br> role: &quot;user&quot;<br> parts {<br>   function_response {<br>     name: &quot;get_current_weather_data&quot;<br>     response {<br>       fields {<br>         key: &quot;result&quot;<br>         value {<br>           string_value: &quot;overcast clouds&quot;<br>         }<br>       }<br>     }<br>   }<br> },<br> role: &quot;model&quot;<br> parts {<br>   text: &quot;It\&#39;s overcast in Mumbai. You might want to carry an umbrella just in case. \n&quot;<br> }]<br>&quot;&quot;&quot;</pre><p>This output clearly illustrates the entire process: from the initial user query to the function call, and finally to Gemini’s informed response.</p><p>In conclusion, the <strong>Vertex AI SDK</strong> significantly reduces development time by automating complex processes. This allows AI developers to concentrate on solving core business problems rather than getting bogged down in implementation details.</p><p>You can try it yourself, and to make it easier, I have provided a notebook.</p><p><a href="https://github.com/manick2411/gemini-utils/blob/main/Function_Calling_Made_Easy_by_Vertex_Python_SDK.ipynb">gemini-utils/Function_Calling_Made_Easy_by_Vertex_Python_SDK.ipynb at main · manick2411/gemini-utils</a></p><p>References:</p><ol><li>Vertex AI Function Calling Documentation : <a href="https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling">https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling</a></li><li>GitHub Repo: <a href="https://github.com/manick2411/gemini-utils/">https://github.com/manick2411/gemini-utils</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c8c0f906a61" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/unlocking-the-power-of-llms-gemini-function-calling-simplified-with-vertex-ai-sdk-3c8c0f906a61">Unlocking the Power of LLMs: Gemini Function Calling Simplified with Vertex AI SDK</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>