<?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 Sridevi Panneerselvam on Medium]]></title>
        <description><![CDATA[Stories by Sridevi Panneerselvam on Medium]]></description>
        <link>https://medium.com/@sridevi17j?source=rss-d4eaea66b269------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BrlUKUHg8iHx5WYMmfkYUA.png</url>
            <title>Stories by Sridevi Panneerselvam on Medium</title>
            <link>https://medium.com/@sridevi17j?source=rss-d4eaea66b269------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:48:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sridevi17j/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[Agent2Agent Protocol(A2A)]]></title>
            <link>https://medium.com/@sridevi17j/agent2agent-protocol-a2a-71026ad5709c?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/71026ad5709c</guid>
            <category><![CDATA[a2a-protocol]]></category>
            <category><![CDATA[agent-to-agent-protocol]]></category>
            <category><![CDATA[a2a]]></category>
            <category><![CDATA[agent2agent]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Mon, 21 Apr 2025 12:47:45 GMT</pubDate>
            <atom:updated>2025-04-21T12:47:45.820Z</atom:updated>
            <content:encoded><![CDATA[<p>A2A is Google’s new open protocol for agent‑to‑agent communication. Let us see more about A2A in this blog.</p><h3>What is A2A?</h3><p>A2A stands for Agent2Agent. It is a communication standard between two different Agents. A2A is built on existing standards like HTTP, JSON‑RPC and Server‑Sent Events. Now any two agents from different frameworks can discover each other and exchange tasks and results, if they both follow this A2A protocol. An example is given below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*VvMneWsedTO_WX7rmAilFg.png" /><figcaption>A2A -Example</figcaption></figure><p>In A2A we have</p><ol><li>Client Agent (Client)</li><li>Remote Agent (Server)</li></ol><blockquote>Client Agents are the one who send the task. Remote Agents are the one who executes the task.</blockquote><h3><strong>How it works</strong></h3><h4>Discover agents</h4><p>Remote Agent publishes an Agent Card at https://&lt;base-url&gt;/.well-known/agent.json. This card lists the agent’s skills and capabilities. The client agent fetches Remote Agent’s Agent Cards using HTTP GET and reads their capabilities. Client reads the capabilities of each Remote Agent and finds the right agent for task and sends the task to them.</p><h4>Sending a task</h4><p>Client Agent uses,</p><ul><li>tasks/send for non‑streaming tasks.</li><li>tasks/sendSubscribe to get streaming updates.</li></ul><p>When the client agent sends the task, the JSON specification would be like below.</p><p>See the Method — tasks/send</p><p>message.parts.text — contains the task message from Client to Remote agent. Here the task message is “Tell me a Joke”.</p><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: 1,<br>  &quot;method&quot;:&quot;tasks/send&quot;,<br>  &quot;params&quot;: {<br>    &quot;id&quot;: &quot;de38c76d-d54c-436c-8b9f-4c2703648d64&quot;,<br>    &quot;message&quot;: {<br>      &quot;role&quot;:&quot;user&quot;,<br>      &quot;parts&quot;: [{<br>        &quot;type&quot;:&quot;text&quot;,<br>        &quot;text&quot;: &quot;tell me a joke&quot;<br>      }]<br>    },<br>    &quot;metadata&quot;: {}<br>  }<br>}</pre><h4>Receive results</h4><p>Below is the response from Remote Agent to Client Agent when Client asked for a Joke.</p><p>artifacts.parts.text — Contains the response from Remote to Client Agent.</p><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: 1,<br>  &quot;result&quot;: {<br>    &quot;id&quot;: &quot;de38c76d-d54c-436c-8b9f-4c2703648d64&quot;,<br>    &quot;sessionId&quot;: &quot;c295ea44-7543-4f78-b524-7a38915ad6e4&quot;,<br>    &quot;status&quot;: {<br>      &quot;state&quot;: &quot;completed&quot;,<br>    },<br>    &quot;artifacts&quot;: [{<br>      &quot;name&quot;:&quot;joke&quot;,<br>      &quot;parts&quot;: [{<br>          &quot;type&quot;:&quot;text&quot;,<br>          &quot;text&quot;:&quot;Why did the chicken cross the road? To get to the other side!&quot;<br>        }]<br>      }],<br>    &quot;metadata&quot;: {}<br>  }<br>}</pre><h4>Cancelling a Task</h4><p>Client can cancel the task. See the JSON sent when the client cancels the task.</p><p>method — tasks/cancel</p><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: 1,<br>  &quot;method&quot;:&quot;tasks/cancel&quot;,<br>  &quot;params&quot;: {<br>    &quot;id&quot;: &quot;de38c76d-d54c-436c-8b9f-4c2703648d64&quot;,<br>    &quot;metadata&quot;: {}<br>  }<br>}<br></pre><p>Now see the response from Remote Agent to Client Agent</p><p>state — canceled</p><pre>//Response<br>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: 1,<br>  &quot;result&quot;: {<br>    &quot;id&quot;: &quot;de38c76d-d54c-436c-8b9f-4c2703648d64&quot;,<br>    &quot;sessionId&quot;: &quot;c295ea44-7543-4f78-b524-7a38915ad6e4&quot;,<br>    &quot;status&quot;: {<br>      &quot;state&quot;: &quot;canceled&quot;<br>    },<br>    &quot;metadata&quot;: {}<br>  }<br>}<br></pre><p>There are other RPCs, such as <a href="https://google.github.io/A2A/#/documentation?id=get-a-task">tasks/get</a> and <a href="https://google.github.io/A2A/#/documentation?id=resubscribe-to-task">tasks/resubscribe</a>, <a href="https://google.github.io/A2A/#/documentation?id=set-task-push-notification-config">tasks/pushNotification/set</a> . Explore them when you get some time.</p><h4>MCP and A2A — Similarities and Differences</h4><h4>Similarities:</h4><ul><li>Both use HTTP transport and SSE for streaming.</li><li>Both use JSON-RPC protocol standard for communication</li></ul><h4>Differences:</h4><ul><li>MCP connects Agents to External Tools</li><li>A2A connects Agents with each other.</li><li>MCP mostly handles text data, but A2A supports Multimodal inputs.</li></ul><p>Hope this blog gave you a basic idea of what A2A is, you can get more info from their <a href="https://google.github.io/A2A/#/">technical document</a>.</p><p>I usually post LLM related technical issues and solution. Feel free to check out my articles in medium. Follow me for more!</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71026ad5709c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving the Gmail API Authentication Challenge in CI/CD Pipelines]]></title>
            <link>https://medium.com/@sridevi17j/solving-the-gmail-api-authentication-challenge-in-ci-cd-pipelines-d8caf33f4ac7?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8caf33f4ac7</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[workflow-automation]]></category>
            <category><![CDATA[browserless]]></category>
            <category><![CDATA[gmail-api]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Mon, 17 Mar 2025 09:31:30 GMT</pubDate>
            <atom:updated>2025-03-17T09:31:30.442Z</atom:updated>
            <content:encoded><![CDATA[<p>Authenticating with Google APIs can be straightforward in local development environments, but it presents unique challenges in CI/CD pipelines. In this article, I’ll share how to overcome a common roadblock: handling Gmail API authentication in GitHub Actions without browser-based authentication flows.</p><h3>The Challenge</h3><p>When working with the Gmail API locally, the typical authentication flow looks like this:</p><ol><li>You create a project in Google Cloud Console and enable the Gmail API.</li><li>You download credentials.json containing your OAuth client ID and secret.</li><li>On first run, your script opens a browser where you grant permission.</li><li>A token.pickle file is generated containing your credentials.</li></ol><p>This works perfectly on your local machine, but fails in CI/CD environments like GitHub Actions where:</p><ul><li>There’s no browser for the OAuth flow.</li><li>The workflow runs headlessly.</li><li>You need to securely store credentials.</li></ul><h3>The Solution</h3><p>The solution involves three key steps:</p><h3>1. Generate the token.pickle file locally</h3><p>First, authenticate locally to generate your token.pickle file. This is a one-time process.</p><h3>2. Extract and store the token as a GitHub Secret named GMAIL_TOKEN</h3><p>Use this script to extract the token data and format it as JSON:</p><pre>import pickle<br>import json<br><br># Read existing token<br>with open(&#39;token.pickle&#39;, &#39;rb&#39;) as file:<br>    creds = pickle.load(file)<br># Convert to JSON string<br>token_json = json.dumps({<br>    &#39;token&#39;: creds.token,<br>    &#39;refresh_token&#39;: creds.refresh_token,<br>    &#39;token_uri&#39;: creds.token_uri,<br>    &#39;client_id&#39;: creds.client_id,<br>    &#39;client_secret&#39;: creds.client_secret,<br>    &#39;scopes&#39;: creds.scopes<br>})<br>print(token_json)</pre><p><strong>Copy the output and store it as a GitHub Secret named </strong><strong>GMAIL_TOKEN.</strong></p><h3>3. Modify your authentication code to handle GMAIL_TOKEN</h3><p>Update your authentication code to work with either a local token.pickle file or the JSON credentials from the environment:</p><pre>from google.oauth2.credentials import Credentials<br>from google_auth_oauthlib.flow import InstalledAppFlow<br>from google.auth.transport.requests import Request<br>from googleapiclient.discovery import build<br>import os<br>import json<br><br>class GmailAuthenticator:<br>    def __init__(self):<br>        self.SCOPES = [&#39;https://www.googleapis.com/auth/gmail.readonly&#39;,<br>                      &#39;https://www.googleapis.com/auth/gmail.modify&#39;]<br>        self.service = self.authenticate()<br>        <br>    def authenticate(self):<br>        &quot;&quot;&quot;Sets up and returns Gmail API service&quot;&quot;&quot;<br>        if &#39;GMAIL_TOKEN&#39; in os.environ:<br>            try:<br>                token_json = json.loads(os.environ[&#39;GMAIL_TOKEN&#39;])<br>                creds = Credentials.from_authorized_user_info(token_json, self.SCOPES)<br>                if creds and creds.expired and creds.refresh_token:<br>                    creds.refresh(Request())<br>                return build(&#39;gmail&#39;, &#39;v1&#39;, credentials=creds)<br>            except Exception:<br>                return &quot;Failed to authenticate: Invalid token format&quot;<br>        else:<br>            return &quot;Authentication failed: GMAIL_TOKEN environment variable not found&quot;</pre><h3>4. Configure your GitHub Actions workflow</h3><p>Finally, set up your workflow to use the stored credentials:</p><pre>name: Gmail API Workflow<br>on:<br>  workflow_dispatch:<br>jobs:<br>  process-emails:<br>    runs-on: ubuntu-latest<br>    env:<br>      GMAIL_TOKEN: ${{ secrets.GMAIL_TOKEN }}<br>    steps:<br>      - uses: actions/checkout@v2<br>      - name: Set up Python<br>        uses: actions/setup-python@v2<br>        with:<br>          python-version: &#39;3.9&#39;<br>      - name: Install dependencies<br>        run: |<br>          pip install -r requirements.txt<br>      - name: Run script<br>        run: python your_script.py</pre><h3>5. Run the workflow</h3><p>Now run the workflow to test your code whether it picks up the GMAIL_TOKEN and authenticates you.</p><h3>Common Issues and Their Solutions</h3><p>Some of the common issues on this workflow is given below. Check this out to know how to solve the common issues.</p><h3>Token Expiration</h3><p>Google tokens expire. If you get an error like RefreshError: invalid_grant, you may need to generate a new token locally and update your GitHub secret.</p><h3>Scope Mismatch</h3><p>If your CI/CD environment shows invalid_scope: Bad Request, ensure the scopes in your token match the ones your code is requesting. Check your stored token with:</p><pre>import json<br>token_data = json.loads(os.environ[&#39;GMAIL_TOKEN&#39;])<br>print(token_data[&#39;scopes&#39;])</pre><p>If missing scopes, regenerate the token with all required scopes.</p><h3>File Parsing Issues</h3><p>If you get _pickle.UnpicklingError: invalid load key, &#39;{&#39;., you&#39;re trying to use pickle.load() on a JSON string. Ensure your authentication code properly handles both formats.</p><h3>Best Practices</h3><ol><li><strong>Security</strong>: Always store tokens as encrypted secrets in your CI/CD environment</li><li><strong>Scope Limiting</strong>: Request only the scopes your application needs</li><li><strong>Refresh Handling</strong>: Implement proper error handling for token refreshing</li><li><strong>Token Rotation</strong>: Periodically regenerate tokens to follow security best practices</li></ol><h3>Conclusion</h3><p>By using this approach, you can successfully authenticate with the Gmail API in CI/CD environments without browser-based flows. This pattern can be adapted for other Google APIs and similar OAuth-based services that typically require interactive authentication.</p><p>The key insight is leveraging the ability to serialize credentials to JSON and recreate them programmatically, allowing your automated workflows to access APIs securely without human intervention.</p><p>Hope this post helps you with the information you wanted. Incase if you find it struggle in any of the steps, please do comment with your issues, I will be happy to help and share my knowledge.</p><p>I regularly share AI and LLM content, but this article is different from my regular content. I’ve documented this solution primarily for my personal reference. Feel free to read my other medium posts, typically focus on practical tech solutions and troubleshooting tips for large language models.</p><p>Follow me for more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8caf33f4ac7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Solve Error Failed to access secure storage: Platform secure storage failure: DBus error…]]></title>
            <link>https://medium.com/@sridevi17j/how-to-solve-error-failed-to-access-secure-storage-platform-secure-storage-failure-dbus-error-f624bdcfbabc?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/f624bdcfbabc</guid>
            <category><![CDATA[wsl]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Sat, 08 Mar 2025 08:19:32 GMT</pubDate>
            <atom:updated>2025-03-08T08:19:32.393Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Solve Error Failed to access secure storage: Platform secure storage failure: DBus error- While Configuring goose in wsl</h3><h3>What is Goose:</h3><p>Goose is an open-source agent built for automating various tasks like coding, and web scraping etc. It handles both simple and complex operations through both a CLI and Desktop application. For more details on Goose check out here- <a href="https://block.github.io/goose/docs/category/getting-started">Getting Started | codename goose</a>.</p><p>This post is intentionally brief to help you quickly overcome the specific DBus error and continue with your Goose work. Watch for future articles where I’ll cover everything about Goose, setup process, and practical applications in detail.</p><h3>Issue:</h3><p>When setting up Goose in WSL (Windows Subsystem for Linux), you might encounter this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3MFz81GjPLm7iqXw9XYolQ.png" /></figure><p>This quick guide will save you time troubleshooting this specific issue.</p><h3>Solution: Setting LLM API Key as Environment Variable</h3><p>The primary issue occurs because WSL struggles with secure storage access. Instead of fighting with Goose’s default configuration approach, set your API key as an environment variable:</p><pre>echo &#39;export GOOGLE_API_KEY=&quot;your-api-key-here&quot;&#39; &gt;&gt; ~/.bashrc<br>source ~/.bashrc</pre><p>When manually entering the API key through the regular Goose configuration process, users encounter the error in wsl. However, by setting it as an environment variable first and then running goose configure, the system automatically detects the API key in the third step, indicates it&#39;s saved, and proceeds with configuration without any DBus-related errors.&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y6IlPSzrxBtFZIYtgA7pkA.png" /></figure><p>The second issue is a warning, asking us to set the Path</p><h3>Issue:</h3><p>Warning: Goose installed, but /root/.local/bin is not in your PATH. Add it to your PATH by editing ~/.bashrc, ~/.zshrc, or similar: export PATH=”/root/.local/bin:$PATH” Then reload your shell (e.g. ‘source ~/.bashrc’, ‘source ~/.zshrc’) to apply changes.</p><h3>Solution:</h3><p>set the path and reload the shell.</p><pre>echo &#39;export PATH=&quot;$HOME/.local/bin:$PATH&quot;&#39; &gt;&gt; ~/.bashrc<br>source ~/.bashrc</pre><p>Hope this guide helps someone struggling with the same issue.</p><p>Follow me for more LLM related technical posts!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f624bdcfbabc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving-common_get_hf_file: llama.cpp]]></title>
            <link>https://medium.com/@sridevi17j/resolving-common-get-hf-file-llama-cpp-1f0c626ef7b7?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f0c626ef7b7</guid>
            <category><![CDATA[cuda-toolkit]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[build-issue]]></category>
            <category><![CDATA[cuda]]></category>
            <category><![CDATA[llama-cpp]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 04:56:07 GMT</pubDate>
            <atom:updated>2025-02-06T04:56:07.745Z</atom:updated>
            <content:encoded><![CDATA[<h3>Resolving-common_get_hf_file: llama.cpp built without libcurl, downloading from Hugging Face not supported and CUDA Toolkit Not Found issues in llama.cpp</h3><p>Are you getting this error when you try to build your llama.cpp? Try below steps to resolve this.</p><p>Note:- I built llama.cpp using CUDA and i ended up with above error.</p><h4>Solution: Use the build command like below, which will resolve the issue.</h4><pre>cmake -B build -DLLAMA_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON</pre><h4>Additional issues and solutions</h4><p>Some of the Additional Issues that i faced was “CUDA Toolkit Not Found”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*VFEcUHknrhdGuwq0AUeEtQ.png" /></figure><h4>Steps for resolving CUDA issues:</h4><p>Step 1: Install CUDA</p><pre>sudo apt-get install cuda-toolkit-12-4</pre><p>step 2: Check whether CUDA is installed,- using below commands</p><pre>nvidia-smi</pre><p>It will show the result like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*iPUb4EDk0WR8CZLy5G1cWw.png" /></figure><p>You can also use below command to check the CUDA and its version</p><pre>PS C:\Users\sride&gt; nvcc --version<br>nvcc: NVIDIA (R) Cuda compiler driver<br>Copyright (c) 2005-2024 NVIDIA Corporation<br>Built on Thu_Mar_28_02:30:10_Pacific_Daylight_Time_2024<br>Cuda compilation tools, release 12.4, V12.4.131<br>Build cuda_12.4.r12.4/compiler.34097967_0</pre><p>Step 3: set CUDA path and reload bash.</p><pre>sridevi@Sridevi:/usr/local$ export PATH=/usr/local/cuda-12.4/bin:$PATH<br>sridevi@Sridevi:/usr/local$ source ~/.bashrc</pre><p>This will fix the CUDA toolkit not found issues.</p><p>Hope this article helps you. If any queries pls, post it in the comments, happy to help.</p><p>I do write about technical issues that we face while working with LLMs,</p><p>Follow me for more!</p><p>Medium — <a href="https://medium.com/@sridevi17j">https://medium.com/@sridevi17j</a>.</p><p>LinkedIn — <a href="https://www.linkedin.com/in/sridevi-panneerselvam/">https://www.linkedin.com/in/sridevi-panneerselvam/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f0c626ef7b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finetuning with Unsloth: The Game-Changer in LLM Fine-tuning]]></title>
            <link>https://medium.com/@sridevi17j/finetuning-with-unsloth-the-game-changer-in-llm-fine-tuning-e32262701195?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/e32262701195</guid>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[unsloth]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 11:13:26 GMT</pubDate>
            <atom:updated>2024-10-31T11:43:22.852Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Unsloth</h3><p>Unsloth is a framework that accelerates Large Language Model (LLM) fine-tuning while reducing memory usage. It achieves this by completely rewriting how we handle the underlying computations during the fine-tuning process.</p><h4>The LoRA Fine-tuning Vs Unsloth Finetuning</h4><ol><li>Regular LoRA uses PyTorch’s autograd:</li></ol><p>(X being big matrix multiplied twice, once with W and once with AB)</p><pre>X - Input Matrix <br>W - Model Weight Matrix<br>A &amp; B - LoRA Matrices<br><br># Multiplication order is like below<br>temp1 = X * W<br>temp2 = X * (A * B)<br>output = temp1 + temp2</pre><p>2. Unsloth Lora uses manual autograd:</p><p>(X being big matrix multiplied only once at the end)</p><pre>X - Input Matrix <br>W - Model Weight Matrix<br>A &amp; B - LoRA Matrices<br><br># Multiplication order is like below<br>output = X * (W + A * B) (AB is multipled and then added with W) finally multiplied with X once.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*kS8pybnz35rkEVMcwdajPg.png" /><figcaption>Source:- <a href="https://unsloth.ai/introducing">Unslot AI</a></figcaption></figure><p>The multiplication order used in Unsloth’s optimization minimizes memory and computation by focusing on the smaller matrices first.</p><p><strong>Effect of Unsloth:</strong> Finetuning an LLM on Alpaca dataset took 23 hours and 15 minutes on a T4 GPU using regular HuggingFace training, but with Unsloth’s optimized training it only took 2 hours and 34 minutes on the same GPU making it 8.8x faster. Source:- <a href="https://unsloth.ai/introducing#:~:text=On%20the%20infamous%20Alpaca%20dataset%20on%20a%20single%20Tesla%20T4%20GPU%2C%20Huggingface%27s%20original%20implementation%20takes%20a%20long%2023%20hours%20and%2015m%2C%20whilst%20our%20Max%20offering%20takes%202%20hours%20and%2034m%2C%20which%20is%208.8x%20faster.%20On%20SlimOrca%2C%20391%20hours%20is%20shaved%20to%2051%20hours%20or%20a%207.6x%20speedup.">Link</a></p><h4>How Unsloth achieves this?</h4><p>Unsloth rewrote all kernels using Triton (OpenAI’s programming language designed for GPU operations), to make it super fast.</p><p>Let’s apply Unsloth’s optimization technique to fine-tune a Llama-3 model with custom data. We’ll go through the implementation step by step to illustrate the full fine-tuning process.</p><p><strong>Install packages</strong></p><pre>!pip install unsloth<br># Also get the latest nightly Unsloth!<br>!pip uninstall unsloth -y &amp;&amp; pip install --upgrade --no-cache-dir &quot;unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git&quot;</pre><p><strong>Load the Model</strong></p><pre>from unsloth import FastLanguageModel<br>import torch<br>max_seq_length = 2048 # Choose any!<br>dtype = None  # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+<br>load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.<br>model, tokenizer = FastLanguageModel.from_pretrained(<br>    model_name = &quot;unsloth/Llama-3.2-3B&quot;, # choose from unsloth available models<br>    max_seq_length = max_seq_length,<br>    dtype = dtype,<br>    load_in_4bit = load_in_4bit,<br>    # token = &quot;hf_...&quot;, # use one if using gated models like meta-llama/Llama-2-7b-hf<br>)</pre><p><strong>Configure Model with Lora and Unsloth Parameters for Optimized Fine-Tuning</strong></p><pre>model = FastLanguageModel.get_peft_model(<br>    model,<br>    r = 16, # Choose any number &gt; 0 ! Suggested 8, 16, 32, 64, 128<br>    target_modules = [&quot;q_proj&quot;, &quot;k_proj&quot;, &quot;v_proj&quot;, &quot;o_proj&quot;,<br>                      &quot;gate_proj&quot;, &quot;up_proj&quot;, &quot;down_proj&quot;,],<br>    lora_alpha = 16,<br>    lora_dropout = 0, # Supports any, but = 0 is optimized<br>    bias = &quot;none&quot;,    # Supports any, but = &quot;none&quot; is optimized<br>    # [NEW] &quot;unsloth&quot; uses 30% less VRAM, fits 2x larger batch sizes!<br>    use_gradient_checkpointing = &quot;unsloth&quot;, # True or &quot;unsloth&quot; for very long context<br>    random_state = 3407,<br>    use_rslora = False,  # We support rank stabilized LoRA<br>    loftq_config = None, # And LoftQ<br>)</pre><p><strong>Load dataset for fine-tuning (Custom dataset is used in the below step)</strong></p><pre>prompt_instruction = &quot;&quot;&quot;Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.<br><br>### Instruction:<br>{}<br><br>### Input:<br>{}<br><br>### Response:<br>{}&quot;&quot;&quot;<br><br>EOS_TOKEN = tokenizer.eos_token # Must add EOS_TOKEN<br>def formatting_prompts_func(examples):<br>    instructions = examples[&quot;instruction&quot;]<br>    inputs       = examples[&quot;input&quot;]<br>    outputs      = examples[&quot;output&quot;]<br>    texts = []<br>    for instruction, input, output in zip(instructions, inputs, outputs):<br>        # Must add EOS_TOKEN, otherwise your generation will go on forever!<br>        text = prompt_instruction.format(instruction, input, output) + EOS_TOKEN<br>        texts.append(text)<br>    return { &quot;text&quot; : texts, }<br>pass<br><br>from datasets import load_dataset<br>dataset = load_dataset(data_files=&#39;fasthtml_dataset.jsonl&#39;, path=&quot;/content&quot;, split = &quot;train&quot;)<br>dataset = dataset.map(formatting_prompts_func, batched = True,)</pre><p><strong>Configure fine-tuning parameters</strong></p><pre>from trl import SFTTrainer<br>from transformers import TrainingArguments<br>from unsloth import is_bfloat16_supported<br><br>trainer = SFTTrainer(<br>    model = model,<br>    tokenizer = tokenizer,<br>    train_dataset = dataset,<br>    dataset_text_field = &quot;text&quot;,<br>    max_seq_length = max_seq_length,<br>    dataset_num_proc = 2,<br>    packing = False, # Can make training 5x faster for short sequences.<br>    args = TrainingArguments(<br>        per_device_train_batch_size = 2,<br>        gradient_accumulation_steps = 4,<br>        warmup_steps = 5,<br>        # num_train_epochs = 1, # Set this for 1 full training run.<br>        max_steps = 30,<br>        learning_rate = 2e-4,<br>        fp16 = not is_bfloat16_supported(),<br>        bf16 = is_bfloat16_supported(),<br>        logging_steps = 1,<br>        optim = &quot;adamw_8bit&quot;,<br>        weight_decay = 0.01,<br>        lr_scheduler_type = &quot;linear&quot;,<br>        seed = 3407,<br>        output_dir = &quot;outputs&quot;,<br>        report_to = &quot;none&quot;, # Use this for WandB etc<br>    ),<br>)</pre><p><strong>My GPU memory stats before finetuning</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*yQIUNP__of8SvuOXTpwOWg.png" /></figure><p><strong>Now Train(fine-tune) the Model</strong></p><pre>trainer_stats = trainer.train()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*kJXElmRBH9OmfzHYFNTOsA.png" /></figure><p>Below is how you can check the memory status after fine-tuning</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*zETHioE8AbODiq5HRNOcAg.png" /></figure><p><strong>Time for Inference! Check what your model has learned.</strong></p><pre>FastLanguageModel.for_inference(model) # Enable native 2x faster inference<br>inputs = tokenizer(<br>[<br>    prompt_instruction.format(<br>        &quot;Explain the reordering functionality for todos in the FastHTML application.&quot;, # instruction<br>        &quot;&quot;, # input<br>        &quot;&quot;, # output - leave this blank for generation!<br>    )<br>], return_tensors = &quot;pt&quot;).to(&quot;cuda&quot;)<br>from transformers import TextStreamer<br>text_streamer = TextStreamer(tokenizer)<br>_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 128)</pre><p>Below is the response of the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0M08grA-si4bHFalwGGnnw.png" /></figure><p>I fine-tuned a model on a custom dataset(FastHTML documentation) using unsloth. With max_steps set to 30, the training was completed in just 1.7 minutes. This is notably efficient compared to traditional fine-tuning, which would have likely taken over 30 minutes for the same task.</p><p>After completing the fine-tuning process, you can save your model using various methods (save_pretrained or save_pretrained_merged) based on your deployment needs.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*MsrJzZAYKFJ7P7lLvS1Xlw.png" /></figure><p>Below is how the files will be saved</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*a-ZupP7XFsIT6P8AsZ6yXw.png" /></figure><ul><li><strong>save_pretrained</strong>: Saves only the LoRA adapter weights (small, just modifications). Files include adapter_config.json and adapter_model.safetensors.</li><li><strong>save_pretrained_merged</strong>: Saves the entire model with LoRA merged into the base weights (larger, ready for deployment). Files include config.json, pytorch_model-*, and generation_config.json</li><li><strong>save_pretrained_ggml</strong> : Saves model in a legacy CPU-optimized format for efficient inference (smaller, quantized). Files include model.ggml.bin and config.json.</li><li><strong>save_pretrained_gguf</strong> : Saves model in modern CPU-optimized format with better metadata handling (smaller, quantized). Files include model.gguf and tokenizer.json.</li></ul><p>Learn more about <a href="https://docs.unsloth.ai/basics/saving-and-using-models">Saving &amp; Using Models with Unsloth Documentation</a> and explore the available options.</p><p>I hope this blog provides enough information to get started with Unsloth. Future posts will dive into topics like exporting saved models to Ollama. Check out my other articles for more LLM insights, and follow me for ongoing updates!</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e32262701195" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Resolving 504 Gateway Timeout for Python flask app in Vercel Deployments: A Step-by-Step Guide”]]></title>
            <link>https://medium.com/@sridevi17j/resolving-504-gateway-timeout-for-python-flask-app-in-vercel-deployments-a-step-by-step-guide-e784d8a5ee18?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/e784d8a5ee18</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[504-gateway-timeout]]></category>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[flask]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Tue, 08 Oct 2024 12:25:59 GMT</pubDate>
            <atom:updated>2024-10-08T12:25:59.400Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you encountering a 504 Gateway Timeout error when deploying your Python flask app to Vercel? You’re not alone. This frustrating issue can occur during runtime, even if the deployment seems successful. In this guide, I’ll share how I resolved this problem, which wasn’t as straightforward as modifying the vercel.json file.</p><h4><strong>The Problem:</strong></h4><p>When deploying a Python app, you might encounter a 504 Gateway Timeout error in your runtime logs. This error indicates that your function is taking too long to execute, exceeding Vercel’s default timeout limit.</p><h4>The Solution:</h4><p>The key to solving this issue lies in Vercel’s UI settings, not in the vercel.json file as you might expect. Here&#39;s how to fix it:</p><ol><li>Log in to your Vercel dashboard.</li><li>Select your project.</li><li>Navigate to the “Settings” tab.</li><li>In the left sidebar, scroll down and click on “Functions”.</li><li>Look for the “Function Max Duration” setting.</li><li>Increase the value to a suitable duration (e.g., 40 seconds).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9cAYOJT1TzicLOGPcQ2zw.png" /></figure><p>Save and Redeploy your application for the changes to take effect.</p><h4>Important Notes:</h4><ul><li>This solution is specifically for Python deployments on Vercel.</li><li>The 504 Gateway Timeout error may only appear in runtime logs, not in the UI during deployment.</li><li>Modifying the vercel.json file to include both functions and builds properties can lead to deployment errors.</li><li>Increasing the function duration may impact billing, so be sure to check Vercel’s pricing details.</li></ul><h4>Why This Works:</h4><ul><li>Vercel’s default function timeout is often too short for more complex Python applications. By increasing the max duration through the UI, you’re giving your function more time to complete its execution before Vercel terminates it.</li></ul><h4>Conclusion</h4><ul><li>While it might seem counterintuitive that the solution isn’t in the vercel.json configuration, using the UI settings provides a simple and effective way to resolve the 504 Gateway Timeout error for Python deployments on Vercel. Remember to monitor your function&#39;s performance and adjust the timeout as needed to balance functionality and cost.</li></ul><p>By following these steps, you should be able to successfully deploy your flask app on Vercel without encountering the dreaded 504 Gateway Timeout error. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e784d8a5ee18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fix “system does not have Windows Long Path support enabled” Error]]></title>
            <link>https://medium.com/@sridevi17j/how-to-fix-system-does-not-have-windows-long-path-support-enabled-error-115c367560e6?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/115c367560e6</guid>
            <category><![CDATA[finetune-llm]]></category>
            <category><![CDATA[unsloth]]></category>
            <category><![CDATA[llama-3-2]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Sat, 28 Sep 2024 18:53:29 GMT</pubDate>
            <atom:updated>2024-09-28T18:54:09.211Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been trying to fine-tune LLaMA 3.2 with Unsloth, and I hit an error right from the first step. Specifically, while running pip install unsloth, I encountered the below error message. Just thought I’d document it here in case it’s helpful to others.</p><blockquote>This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at <a href="https://pip.pypa.io/warnings/enable-long-paths">https://pip.pypa.io/warnings/enable-long-paths</a></blockquote><p>Let’s walk through how to fix this issue and get your pip installations working smoothly.</p><p><strong>Understanding the Problem</strong></p><p>Windows has a default limit on file path lengths, which can cause issues when installing certain packages, especially those with deeply nested directories. The unsloth package seems to be one that’s affected by this limitation.</p><p><strong>The Solution: Enabling Long Path Support</strong></p><p>To resolve this, we need to modify a Windows registry setting. Here’s how:</p><ol><li>Open PowerShell as Administrator</li><li>Run the Following Command</li></ol><pre>New-ItemProperty -Path &quot;HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem&quot; -Name &quot;LongPathsEnabled&quot; -Value 1 -PropertyType DWORD -Force</pre><p>This command creates a new registry entry that enables support for long file paths.</p><p><strong>Conclusion</strong></p><p>Enabling long path support in Windows can solve many installation issues, not just for pip but for other development tools as well. If you’re a developer working on Windows, this is a helpful setting to enable to avoid path-related headaches in the future.</p><p>Remember, always be cautious when modifying system settings, and ensure you understand the implications of the changes you’re making.</p><p>I’ll be sharing more LLM-related challenges and fine-tuning issues as I encounter them. Follow me for updates and tips!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=115c367560e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FastHTML Part2: Exploring Forms and User Input]]></title>
            <link>https://medium.com/@sridevi17j/fasthtml-part2-exploring-forms-and-user-input-4e29250b3895?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e29250b3895</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[fasthtml]]></category>
            <category><![CDATA[htmx]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 05:35:59 GMT</pubDate>
            <atom:updated>2024-09-26T05:35:59.551Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*T8DP4SpXnD7cBOlEpHsg5w.jpeg" /></figure><p>Welcome back to our FastHTML series! In our previous post, we introduced the basics of FastHTML and created a simple dynamic web application. Today, we’re taking it further by exploring how to work with forms and handle user input effectively in FastHTML.</p><h3>Setting Up Our Environment</h3><p>First, make sure you have FastHTML installed:</p><pre>pip install python-fasthtml</pre><h3>Building a User Registration Form</h3><p>Let’s create a simple user registration form to demonstrate FastHTML’s form-handling capabilities.</p><pre>from fasthtml.common import *<br>from dataclasses import dataclass<br>app, rt = fast_app()<br>@dataclass<br>class User:<br>    username: str<br>    email: str<br>    password: str<br>def validate_user(user: User):<br>    errors = []<br>    if len(user.username) &lt; 3:<br>        errors.append(&quot;Username must be at least 3 characters long&quot;)<br>        if &#39;@&#39; not in user.email:<br>            errors.append(&quot;Invalid email address&quot;)<br>            if len(user.password) &lt; 8:<br>                errors.append(&quot;Password must be at least 8 characters long&quot;)<br>                return errors<br>@rt(&quot;/&quot;)<br>def get():<br>    return Titled(&quot;User Registration&quot;,<br>                  Form(Input(type=&quot;text&quot;, name=&quot;username&quot;, placeholder=&quot;Username&quot;),<br>                       Input(type=&quot;email&quot;, name=&quot;email&quot;, placeholder=&quot;Email&quot;),<br>                       Input(type=&quot;password&quot;, name=&quot;password&quot;, placeholder=&quot;Password&quot;),<br>                       Button(&quot;Register&quot;, type=&quot;submit&quot;),<br>                       hx_post=&quot;/register&quot;,<br>                       hx_target=&quot;#result&quot;<br>                       ),<br>                       Div(id=&quot;result&quot;)<br>                       )<br>@rt(&quot;/register&quot;)<br>def post(user: User):<br>    errors = validate_user(user)<br>    if errors:<br>        return Div(Ul(*[Li(error) for error in errors]), id=&quot;result&quot;, style=&quot;color: red;&quot;)<br>    return Div(f&quot;Registered: {user.username} ({user.email})&quot;, id=&quot;result&quot;, style=&quot;color: green;&quot;)<br>serve()</pre><p>Let’s break this down:</p><ol><li>We define a User dataclass to represent our user data structure.</li><li>In the get function, we create a form using FastHTML components:</li></ol><ul><li>Form creates the HTML form element.</li><li>Input creates input fields for username, email, and password.</li><li>Button creates a submit button.</li><li>hx_post=&quot;/register&quot; tells HTMX to send a POST request to &quot;/register&quot; when the form is submitted.</li><li>hx_target=&quot;#result&quot; specifies where to display the result of the form submission.</li></ul><p>3. The post function handles form submission:</p><ul><li>It takes a User object as a parameter. FastHTML automatically parses the form data into this object.</li><li>We return a Div with a confirmation message, which will replace the content of the #result div.</li></ul><h3>A Note on Validation</h3><p>Just like pydantic here the data validation is happening through dataclass.</p><h3>Conclusion</h3><p>This tutorial has demonstrated how to create and handle forms in FastHTML.</p><p>I’ve noticed how proficient developers are with Next.js, building complete applications without even needing to focus on the backend. Now, FastHTML is entering the competition, allowing apps to be created without the need for separate client-side scripts , let’s see what new possibilities it will bring to the table.</p><p>In our next post, we’ll explore how to integrate FastHTML with databases to persist user data. We’ll build on this registration form to create a full user management system.</p><p>Stay tuned as we continue to dive deeper into FastHTML’s capabilities and how it compares to other web frameworks in handling common web development tasks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e29250b3895" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with FastHTML: Building Dynamic Web Apps with Python(Part 1)]]></title>
            <link>https://medium.com/@sridevi17j/getting-started-with-fasthtml-building-dynamic-web-apps-with-python-part-1-199cb79732bc?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/199cb79732bc</guid>
            <category><![CDATA[frameworks-and-libraries]]></category>
            <category><![CDATA[htmx]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[fasthtml]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Wed, 18 Sep 2024 18:42:27 GMT</pubDate>
            <atom:updated>2024-11-08T19:16:31.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/575/0*R89pbloO0H5-D2Es.jpeg" /></figure><p>Ever wished you could build interactive websites using just Python? Enter FastHTML, a Python framework that makes this possible. Let’s dive into creating a simple, dynamic web app with FastHTML.</p><h4>What is FastHTML:</h4><p>FastHTML is a Python web framework that lets you create dynamic web applications easily. It combines Python’s simplicity with modern web features, allowing you to build interactive websites without writing much JavaScript.</p><h4>Your First FastHTML App:</h4><p>Let’s create a simple app that displays a greeting and lets users change it with a button click. Here’s the complete code:</p><pre>from fasthtml.common import *<br><br>app, rt = fast_app()<br><br>@rt(&quot;/&quot;)<br>def get():<br>    return Titled(&quot;FastHTML Demo&quot;,<br>        Div(&quot;Hello, World!&quot;, id=&quot;greeting&quot;),<br>        Button(&quot;Change Greeting&quot;, <br>               hx_post=&quot;/change-greeting&quot;, <br>               hx_target=&quot;#greeting&quot;)<br>    )<br><br>@rt(&quot;/change-greeting&quot;)<br>def post():<br>    return Div(&quot;Hello, FastHTML!&quot;, id=&quot;greeting&quot;)<br><br>serve()</pre><h3>Importing and Setting Up</h3><pre>from fasthtml.common import *<br>app, rt = fast_app()</pre><p>from fasthtml.common import * imports all the necessary components from FastHTML.</p><p>fast_app() creates our application and returns two things:</p><ul><li>app: The main application object</li><li>rt: A decorator for defining routes (we&#39;ll explain this next)</li></ul><h3>The rt Decorator</h3><pre>@rt(&quot;/&quot;)<br>def get():<br>    # function body</pre><ul><li>rt is a decorator that defines a route in our web application.</li><li>@rt(&quot;/&quot;) means this function will handle requests to the root URL (&quot;/&quot;).</li><li>The function name get indicates that this route handles HTTP GET requests.</li></ul><h3>Handling GET Requests</h3><pre>def get():<br>    return Titled(&quot;FastHTML Demo&quot;,<br>        Div(&quot;Hello, World!&quot;, id=&quot;greeting&quot;),<br>        Button(&quot;Change Greeting&quot;, <br>               hx_post=&quot;/change-greeting&quot;, <br>               hx_target=&quot;#greeting&quot;)<br>    )</pre><ul><li>This function defines what happens when someone visits our website.</li><li>Titled creates a page with a title and main content.</li><li>Div creates a &lt;div&gt; element with the text &quot;Hello, World!&quot; and an id &quot;greeting&quot;.</li><li>Button creates a button that, when clicked, will trigger a POST request to &quot;/change-greeting&quot; and update the element with id &quot;greeting&quot;.</li></ul><h3>Handling POST Requests</h3><pre>@rt(&quot;/change-greeting&quot;)<br>def post():<br>    return Div(&quot;Hello, FastHTML!&quot;, id=&quot;greeting&quot;)</pre><ul><li>This route handles POST requests to “/change-greeting”.</li><li>The function name post indicates it&#39;s for HTTP POST requests.</li><li>It returns a new Div element that will replace the existing greeting.</li></ul><h3>Returning Content</h3><p>In FastHTML, you return HTML content by returning FastHTML components (like Div, Button, etc.). These components are Python objects that FastHTML converts to HTML before sending to the browser.</p><h3>Starting the Server</h3><pre>serve()</pre><pre>Link: http://localhost:5001<br>INFO:     Will watch for changes in these directories: [&#39;C:\\Users\\AIbee\\OneDrive\\Desktop\\test&#39;]<br>INFO:     Uvicorn running on http://0.0.0.0:5001 (Press CTRL+C to quit)<br>INFO:     Started reloader process [35308] using WatchFiles<br>INFO:     Started server process [27992]<br>INFO:     Waiting for application startup.<br>INFO:     Application startup complete.</pre><p>Now your app is running at localhost:5001, see below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spCTIcX1ba2b9On83gx0oQ.png" /></figure><h3>How FastHTML Differs from API Frameworks</h3><ol><li><strong>HTML Generation</strong>: Unlike API frameworks that typically return JSON, FastHTML returns HTML directly. This HTML can then be inserted into the page without needing JavaScript to parse and render it.</li><li><strong>Server-Side Rendering</strong>: FastHTML handles HTML generation on the server, reducing the need for client-side rendering logic.</li><li><strong>HTMX Integration</strong>: FastHTML works seamlessly with HTMX, allowing for dynamic content updates without writing JavaScript.</li><li><strong>Simplified Routing</strong>: The rt decorator and function names (get, post, etc.) simplify route definition compared to some API frameworks.</li></ol><h3>The Magic of HTMX</h3><p>FastHTML uses HTMX behind the scenes to make your app dynamic:</p><ul><li>hx_post=&quot;/change-greeting&quot; tells HTMX to make a POST request to &quot;/change-greeting&quot; when the button is clicked.</li><li>hx_target=&quot;#greeting&quot; specifies that the response should update the element with id &quot;greeting&quot;.</li></ul><p>This allows parts of your page to update without a full page reload, creating a smooth, app-like experience.</p><h3>Conclusion</h3><p>FastHTML combines the simplicity of Python with modern web development practices. It allows you to create dynamic, interactive web applications with minimal JavaScript, making it an excellent choice for Python developers venturing into web development.</p><p>By understanding each component — from route decoration to HTML generation and HTMX integration — you’re now equipped to start building your own FastHTML applications.</p><p>This is just the beginning! There’s much more to explore with FastHTML, and we’ll cover it in the upcoming articles. Happy coding, and see you in the next part of the FastHTML series!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=199cb79732bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving AttributeError: ‘LatentAttentionConfig’ object has no attribute…]]></title>
            <link>https://medium.com/@sridevi17j/resolving-attributeerror-latentattentionconfig-object-has-no-attribute-4c001aec2461?source=rss-d4eaea66b269------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c001aec2461</guid>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[attribute-error]]></category>
            <category><![CDATA[hugging-face]]></category>
            <dc:creator><![CDATA[Sridevi Panneerselvam]]></dc:creator>
            <pubDate>Wed, 18 Sep 2024 14:07:46 GMT</pubDate>
            <atom:updated>2024-09-18T14:07:46.537Z</atom:updated>
            <content:encoded><![CDATA[<h3>Resolving AttributeError: ‘LatentAttentionConfig’ object has no attribute ‘_attn_implementation_internal’</h3><p>When working with transformer models, you may encounter an AttributeError stating that the ‘LatentAttentionConfig’ object has no attribute ‘_attn_implementation_internal’. This error typically occurs due to version incompatibility between your code and the transformer library you’re using. <br>The root cause of this issue is often related to changes in the internal implementation of attention mechanisms across different versions of the transformers library. To resolve this error, try using transformers version 4.42.4.</p><pre>pip install transformers==4.42.4</pre><p>After this, you should be able to resolve the AttributeError and continue working with your transformer model without issues.</p><p>Remember to test your code thoroughly after making any version changes to ensure everything works as expected.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c001aec2461" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>