<?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 Adarsh Ajay on Medium]]></title>
        <description><![CDATA[Stories by Adarsh Ajay on Medium]]></description>
        <link>https://medium.com/@adarsh.ajay?source=rss-a275cc2f19e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DDgA87ZfErcacdfg</url>
            <title>Stories by Adarsh Ajay on Medium</title>
            <link>https://medium.com/@adarsh.ajay?source=rss-a275cc2f19e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:43:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adarsh.ajay/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[Unleashing the Power of Google Gemini with Python: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@adarsh.ajay/unleashing-the-power-of-google-gemini-with-python-a-step-by-step-guide-ed5e2ea1818f?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed5e2ea1818f</guid>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[multimodal-ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-gemini]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Tue, 17 Dec 2024 06:42:55 GMT</pubDate>
            <atom:updated>2024-12-17T06:42:55.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*au_-vZkNPp0BqBWphhZEww.jpeg" /></figure><p>Generative AI models have taken the tech world by storm, and Google’s <strong>Gemini</strong> series represents one of the most robust tools available for text, image, audio, and video processing. In this guide, we’ll explore practical Python scripts for using Gemini models efficiently, from basic text generation to advanced multimedia tasks like extracting content from images, summarizing videos, and fine-tuning custom models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yiLNpiexmH3kkJoDhrQ7dQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkJNwHEgJsjLvFX8a3My3g.png" /></figure><h3>1. Setting Up Your Environment</h3><p>To get started, you need access to the google-generativeai library. Install it using:</p><pre>pip install -q -U google-generativeai</pre><p>Next, import the required libraries and configure your API key:</p><pre>import google.generativeai as genai<br><br># Configure your API key<br>genai.configure(api_key=&quot;YOUR_API_KEY_HERE&quot;)</pre><h3>2. Text Generation with Gemini</h3><p>Let’s start with a simple example: generating content with <strong>Gemini Flash</strong>.</p><pre>model = genai.GenerativeModel(&quot;gemini-1.5-flash&quot;)<br>response = model.generate_content(&quot;Explain how AI works&quot;)<br>print(response.text)</pre><p>This basic example showcases how Gemini generates natural and coherent responses to any query.</p><h3>3. Extracting Content from Images</h3><p>Gemini also supports multimodal tasks, such as image content extraction. Here’s how you can upload and process images:</p><pre>from PIL import Image<br># Load images<br>image_path_1 = &quot;/content/B.png&quot;  # Replace with actual path<br>image_path_2 = &quot;/content/G.png&quot;<br>sample_file_1 = Image.open(image_path_1)<br>sample_file_2 = Image.open(image_path_2)<br># Generate content<br>model = genai.GenerativeModel(model_name=&quot;gemini-1.5-pro&quot;)<br>response = model.generate_content([&quot;Extract all content from it&quot;, sample_file_1, sample_file_2])<br>print(response.text)</pre><pre>prompt = &quot;Return bounding boxes for objects in this image in [ymin, xmin, ymax, xmax] format.&quot;<br>response = model.generate_content([sample_file_1, prompt])<br>print(response.text)</pre><h3>4. Video Summarization and Quiz Generation</h3><p>Gemini models can process video files, summarize content, and even create quizzes. Here’s an example:</p><ol><li><strong>Download and upload a video</strong>:</li></ol><pre>!wget https://storage.googleapis.com/generativeai-downloads/images/GreatRedSpot.mp4</pre><ol><li><strong>Upload and summarize</strong>:</li></ol><pre>video_file_name = &quot;GreatRedSpot.mp4&quot;<br>video_file = genai.upload_file(path=video_file_name)<br><br>prompt = &quot;Summarize this video and create a quiz with an answer key.&quot;<br>response = model.generate_content([video_file, prompt], request_options={&quot;timeout&quot;: 600})<br>print(response.text)</pre><h3>5. Handling Audio Files</h3><p>Here’s how you can analyze audio files using Gemini Flash:</p><pre>myfile = genai.upload_file(&quot;/content/audio_sample.wav&quot;)<br>model = genai.GenerativeModel(&quot;gemini-1.5-flash&quot;)<br>response = model.generate_content([myfile, &quot;Describe this audio clip&quot;])<br>print(response.text)</pre><h3>6. Fine-Tuning Gemini Models</h3><p>Gemini allows for fine-tuning models with specific datasets. Below is an example for an increment function:</p><h3>Define Training Data:</h3><pre>training_data = [<br>  {&quot;text_input&quot;: &quot;1&quot;, &quot;output&quot;: &quot;2&quot;},<br>  {&quot;text_input&quot;: &quot;three&quot;, &quot;output&quot;: &quot;four&quot;},<br>  {&quot;text_input&quot;: &quot;ten&quot;, &quot;output&quot;: &quot;eleven&quot;},<br>]</pre><h3>Fine-Tune the Model:</h3><pre>operation = genai.create_tuned_model(<br>    display_name=&quot;increment_model&quot;,<br>    source_model=&quot;models/gemini-1.5-flash-001&quot;,<br>    epoch_count=5,<br>    batch_size=4,<br>    learning_rate=0.001,<br>    training_data=training_data,<br>)<br>for status in operation.wait_bar():<br>    time.sleep(1)<br>result = operation.result()<br>print(result)</pre><h3>7. Text Embeddings and Search Retrieval</h3><p>Generate text embeddings for downstream tasks:</p><pre>result = genai.embed_content(model=&quot;models/text-embedding-004&quot;, content=&quot;What is the meaning of AI?&quot;)<br>print(result[&#39;embedding&#39;])</pre><h3>8. Image Generation with Gemini</h3><p>Leverage <strong>Imagen</strong> to create images:</p><pre>pip install -U git+https://github.com/google-gemini/generative-ai-python@imagen</pre><pre>imagen = genai.ImageGenerationModel(&quot;imagen-3.0-generate-001&quot;)<br>result = imagen.generate_images(prompt=&quot;Fuzzy bunnies in my kitchen&quot;, number_of_images=4)<br><br>for image in result.images:<br>    image._pil_image.show()</pre><h3>9. List Available Models</h3><p>You can list and explore available Gemini models:</p><pre>for model_info in genai.list_models():<br>    print(model_info.name)</pre><h3>Conclusion</h3><p>This guide showcased how to harness the full potential of Google Gemini models for text, image, audio, and video tasks. Whether you’re summarizing videos, fine-tuning models, or generating images, Gemini offers robust tools for developers and researchers alike.</p><p>Start experimenting today and explore how generative AI can unlock new possibilities in your projects.</p><p><strong>Happy coding!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed5e2ea1818f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using PyMuPDF as Data Feeder in LLM / RAG Applications]]></title>
            <link>https://medium.com/@adarsh.ajay/using-pymupdf-as-data-feeder-in-llm-rag-applications-97a4d76c25f8?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/97a4d76c25f8</guid>
            <category><![CDATA[rag-application]]></category>
            <category><![CDATA[pdf-converter]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 03:31:12 GMT</pubDate>
            <atom:updated>2024-12-02T03:32:44.411Z</atom:updated>
            <content:encoded><![CDATA[<p>In the rapidly evolving landscape of Large Language Models (LLMs) and Retrieval-Augmented Generation (RAG) applications, efficient document processing is crucial. PyMuPDF4LLM emerges as a powerful tool that simplifies PDF text extraction, offering sophisticated markdown conversion capabilities that are particularly valuable for AI-driven document analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UXpDgGe-IIfUbBjX3q-_Q.png" /></figure><h3>Introduction to PyMuPDF4LLM</h3><p>PyMuPDF4LLM is a Python library designed to transform PDF documents into clean, structured markdown text. This tool goes beyond simple text extraction, providing intelligent parsing that preserves document structure, formatting, and layout.</p><h3>Key Features</h3><h3>Intelligent Text Extraction</h3><p>The library offers remarkable capabilities for extracting text from complex PDF layouts:</p><ul><li>Handles multiple text columns with precision</li><li>Detects and preserves document structure</li><li>Identifies headers based on font size</li><li>Automatically applies appropriate markdown formatting</li></ul><h3>Markdown Conversion</h3><p>Text is converted to GitHub-compatible markdown, including:</p><ul><li>Automatic header identification</li><li>Formatting for:</li><li>Bold text</li><li>Italic text</li><li>Monospaced text</li><li>Code blocks</li><li>Ordered and unordered list detection</li></ul><h3>Installation and Basic Usage</h3><p>Install the package using pip:</p><pre>pip install -U pymupdf4llm</pre><p>A simple implementation looks like this:</p><pre>import pymupdf4llm<br><br># Convert PDF to markdown<br>md_text = pymupdf4llm.to_markdown(&quot;input.pdf&quot;)<br># Optional: Save to file<br>import pathlib<br>pathlib.Path(&quot;output.md&quot;).write_bytes(md_text.encode())</pre><h3>Advanced Features</h3><h3>Image and Graphics Extraction</h3><p>PyMuPDF4LLM offers robust image extraction capabilities:</p><pre># Extract images with custom settings<br>md_text = pymupdf4llm.to_markdown(<br>    &quot;input.pdf&quot;, <br>    write_images=True,  # Enable image extraction<br>    dpi=150,            # Set resolution<br>    force_text=True     # Include text from images<br>)</pre><h3>Page-based Processing</h3><p>You can process specific pages or chunk the document:</p><pre># Process only selected pages<br>md_text = pymupdf4llm.to_markdown(<br>    &quot;input.pdf&quot;, <br>    pages=[0, 2, 3]  # Process only specified pages<br>)<br><br># Generate page-wise chunks<br>data = pymupdf4llm.to_markdown(<br>    &quot;input.pdf&quot;, <br>    page_chunks=True  # Returns list of page dictionaries<br>)</pre><h3>LlamaIndex Integration</h3><p>Seamless integration with LlamaIndex makes it ideal for RAG applications:</p><pre>import pymupdf4llm<br><br># Create LlamaIndex documents<br>md_reader = pymupdf4llm.LlamaMarkdownReader()<br>data = md_reader.load_data(&quot;input.pdf&quot;)<br># Access page-level markdown and metadata<br>first_page_text = data[0].to_dict()[&quot;text&quot;]<br>Best Practices</pre><ol><li>Ensure PyMuPDF and required dependencies are installed</li><li>Handle large documents in chunks to manage memory</li><li>Validate extracted text for accuracy</li><li>Preprocess complex PDFs if needed</li></ol><h3>Conclusion</h3><p>PyMuPDF4LLM represents a significant advancement in PDF text extraction for LLM and RAG applications. Its intelligent parsing, markdown conversion, and flexible processing make it an essential tool for developers working with document-based AI systems.</p><h3>Additional Resources</h3><ul><li><a href="https://github.com/pymupdf/PyMuPDF">PyMuPDF GitHub Repository</a></li><li><a href="https://docs.llamaindex.ai/">LlamaIndex Documentation</a></li></ul><p><strong>Note:</strong> Always test the library with your specific document types to ensure optimal performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97a4d76c25f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build an AI-Powered Telegram Bot with Groq’s Models]]></title>
            <link>https://medium.com/@adarsh.ajay/build-an-ai-powered-telegram-bot-with-groqs-models-d9b85cb7e3f5?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9b85cb7e3f5</guid>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[groq-ai]]></category>
            <category><![CDATA[telegram-bot]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[whisper]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 10:00:05 GMT</pubDate>
            <atom:updated>2024-11-21T10:00:07.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OJvXMvrpyB5R3bitOrZWKw.png" /></figure><p>Telegram bots have transformed how we interact with automated services, blending convenience with powerful functionality. This article walks you through a <strong>Telegram AI Bot</strong> built using Python and Groq’s AI models. This bot can handle natural language processing, image analysis, and audio transcription, making it a versatile assistant for a variety of tasks.</p><h3>What Can the Bot Do?</h3><p>This bot leverages Groq’s cutting-edge AI models to deliver these key features:</p><ul><li><strong>Text Queries</strong>: Ask questions and receive AI-driven responses.</li><li><strong>Image Analysis</strong>: Upload an image for detailed analysis and answers to questions about it.</li><li><strong>Audio Transcription</strong>: Send a voice message for accurate transcription and an intelligent response.</li><li><strong>Groq API Integration</strong>: The bot seamlessly integrates with Groq’s AI capabilities for advanced processing.</li></ul><h3>Getting Started</h3><h3>Prerequisites</h3><p>Before you dive in, ensure you have the following:</p><ul><li><strong>Python 3.11+</strong>: The bot relies on Python for scripting and execution.</li><li><strong>Docker</strong>: Optional, for containerized deployment.</li><li><strong>Telegram Bot Token</strong>: Register your bot with Telegram to get this.</li><li><strong>Groq API Key</strong>: Required for accessing Groq’s AI features.</li></ul><h3>Setting Up the Bot</h3><h3>Step 1: Clone the Repository</h3><p>Start by cloning the repository to your local machine:</p><pre>git clone https://github.com/achuajays/telegram_multi_fuction_chatbot.git<br>cd telegram-ai-bot</pre><h3>Step 2: Configure Environment Variables</h3><p>Create a .env file in the project&#39;s root directory with the following content:</p><pre>TELEGRAM_BOT_TOKEN=your_telegram_bot_token<br>GROQ_API_KEY=your_groq_api_key</pre><p>Replace your_telegram_bot_token and your_groq_api_key with your actual credentials.</p><h3>Step 3: Install Dependencies</h3><p>Set up a Python virtual environment and install the required libraries:</p><pre>python -m venv venv<br>source venv/bin/activate  # On Windows, use `venv\Scripts\activate`<br>pip install -r requirements.txt</pre><h3>Running the Bot</h3><h3>Option 1: Run Locally</h3><p>Launch the bot with:</p><pre>python telegram_aibot.py</pre><h3>Option 2: Deploy with Docker (Optional)</h3><p>For containerized deployment, follow these steps:</p><ol><li><strong>Build the Docker Image</strong>:</li></ol><pre>docker build -t telegram-ai-bot .</pre><pre>docker run --env-file .env -p 8080:8080 telegram-ai-bot</pre><p><strong>2. Run the Docker Container</strong>:</p><p>This will run the bot in a Docker container using the environment variables from the .env file.</p><h3>Interacting with the Bot</h3><p>Once the bot is running, you can interact with it directly in Telegram. Test its key functionalities:</p><ul><li><strong>Text Queries</strong>: Ask a question and get a Groq-powered response.</li><li><strong>Image Analysis</strong>: Send an image to receive a detailed analysis.</li><li><strong>Audio Transcription</strong>: Send a voice message and get a transcription along with a response.</li></ul><h3>Advanced: Customize the Dockerfile</h3><p>The project includes a Dockerfile for seamless deployment. Below is a sample configuration:</p><pre>FROM python:3.11-slim<br><br>WORKDIR /app<br>COPY requirements.txt .<br>RUN pip install --no-cache-dir -r requirements.txt<br>COPY . .<br>EXPOSE 8080<br>CMD [&quot;python&quot;, &quot;telegram_aibot.py&quot;]</pre><p>This setup ensures a lightweight containerized environment, ready to deploy.</p><h3>Debugging and Logs</h3><p>If you encounter issues, check these areas:</p><ol><li><strong>Environment Configuration</strong>: Ensure your .env file has the correct credentials.</li><li><strong>Dependencies</strong>: Verify all dependencies are installed.</li><li><strong>Network Access</strong>: Ensure the bot has access to Telegram servers and Groq’s API.</li></ol><p>For Docker deployments, access logs with:</p><pre>docker logs -f &lt;container_id&gt;</pre><p>Use docker ps to find the container ID.</p><h3>Contributing to the Project</h3><p>We welcome contributions! Fork the repository, make your changes, and submit a pull request. Please ensure your code adheres to best practices and includes adequate testing.</p><p>This <strong>Telegram AI Bot</strong> combines Python programming with Groq’s advanced AI models to create a versatile tool for communication and analysis. Whether you’re deploying locally or in a Docker container, the bot is designed for ease of use and functionality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9b85cb7e3f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Telegram Bot with Python: Integrating OpenAI and Groq for Real-Time Assistance]]></title>
            <link>https://medium.com/@adarsh.ajay/building-a-telegram-bot-with-python-integrating-openai-and-groq-for-real-time-assistance-6529ca20a50a?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6529ca20a50a</guid>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[clash-of-clans]]></category>
            <category><![CDATA[groq]]></category>
            <category><![CDATA[telegram-bot]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 03:58:27 GMT</pubDate>
            <atom:updated>2024-11-20T04:01:49.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tKRpL-wOudQacfbfsl66Bg.png" /></figure><p>In this article, we’ll explore how to create a Telegram bot using Python that leverages OpenAI’s and Groq’s powerful APIs to provide intelligent, real-time assistance. We’ll go through the implementation, explaining each component step by step.</p><h3>Introduction</h3><p>With advancements in AI, integrating intelligent bots into messaging platforms like Telegram has become easier than ever. This project combines:</p><ul><li><strong>Python</strong> for the bot’s backend.</li><li><strong>Groq’s API</strong> for generating responses.</li><li><strong>Telegram Bot API</strong> for user interaction.</li><li><strong>Dotenv</strong> to manage environment variables securely.</li></ul><p>Our use case? A Clash of Clans assistant bot that provides insightful responses about the game.</p><h3>Prerequisites</h3><ol><li><strong>Python Installed</strong>: Ensure Python 3.9+ is installed.</li><li><strong>Telegram Bot Token</strong>: Create a bot on Telegram via BotFather and get your API token.</li><li><strong>Groq API Key</strong>: Sign up at <a href="https://groq.com/">Groq</a> and obtain an API key.</li><li><strong>Dependencies</strong>: Install necessary Python packages:</li></ol><pre>pip install python-telegram-bot groq python-dotenv</pre><h3>Setting Up the Environment</h3><p>We’ll use a .env file to store sensitive information securely. Create a .env file in your project directory:</p><pre>TELEGRAM_BOT_TOKEN=&lt;your-telegram-bot-token&gt;<br>GROQ_API_KEY=&lt;your-groq-api-key&gt;</pre><p>Load the environment variables using dotenv:</p><pre>from dotenv import load_dotenv<br>import os<br><br>load_dotenv()<br>TELEGRAM_BOT_TOKEN = os.getenv(&quot;TELEGRAM_BOT_TOKEN&quot;)<br>GROQ_API_KEY = os.getenv(&quot;GROQ_API_KEY&quot;)</pre><h3>Integrating Groq for AI Responses</h3><p>Groq provides AI models that can generate human-like responses. Here’s</p><pre>from groq import Groq<br><br>client = Groq(api_key=GROQ_API_KEY)<br>async def get_openai_response(user_query):<br>    try:<br>        chat_completion = client.chat.completions.create(<br>            messages=[<br>                {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;You are a helpful assistant.&quot;},<br>                {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: f&quot;Explain the query about Clash of Clans: {user_query}&quot;}<br>            ],<br>            model=&quot;llama3-8b-8192&quot;,<br>        )<br>        return chat_completion.choices[0].message.content<br>    except Exception as e:<br>        print(f&quot;OpenAI API error: {e}&quot;)<br>        return &quot;Sorry, I couldn&#39;t process that. Please try again later.&quot;</pre><h3>Setting Up Telegram Command Handlers</h3><p>Using python-telegram-bot, we handle user commands and messages. Here’s the breakdown:</p><h3>Start Command</h3><p>The /start command introduces the bot to the user:</p><pre>async def start(update, context):<br>    await update.message.reply_text(&quot;Hello! I am your real-time Clash of Clans assistant. How can I help?&quot;)</pre><h3>Help Command</h3><p>The /help command provides usage instructions:</p><pre>async def help_command(update, context):<br>    await update.message.reply_text(&quot;To use this bot, simply type your question or topic, and I&#39;ll assist you!&quot;)</pre><h3>Message Handler</h3><p>Handle text messages by passing them to Groq for a response:</p><pre>async def handle_message(update, context):<br>    user_query = update.message.text<br>    await update.message.reply_chat_action(action=&quot;typing&quot;)<br>    response = await get_openai_response(user_query)<br>    await update.message.reply_text(response)</pre><h3>Bringing It All Together</h3><p>Finally, we set up the bot, register the handlers, and run the polling loop:</p><pre>from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters<br><br>def main():<br>    application = ApplicationBuilder().token(TELEGRAM_BOT_TOKEN).build()<br>    # Register command handlers<br>    application.add_handler(CommandHandler(&quot;start&quot;, start))<br>    application.add_handler(CommandHandler(&quot;help&quot;, help_command))<br>    application.add_handler(MessageHandler(filters.TEXT &amp; ~filters.COMMAND, handle_message))<br>    print(&quot;Bot is running...&quot;)<br>    application.run_polling()<br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><h3>Testing Your Bot</h3><ol><li><strong>Run the Script</strong>: Execute your script using:</li></ol><pre>python telegram_aibot.py</pre><p><strong>2. Interact with the Bot</strong>: Open Telegram, find your bot, and start chatting.</p><h3>Conclusion</h3><p>You’ve successfully created a Telegram bot powered by Groq’s AI. This bot can assist with queries related to Clash of Clans — or any topic you program it to handle. Extend this bot further by integrating other APIs or enhancing the AI model’s context for richer responses.</p><p>Github Link https://github.com/achuajays/clashofclans_telegram_bot</p><p>With minimal effort, you’ve unlocked a world of possibilities in conversational AI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6529ca20a50a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-Tuning Qwen-2.5 for More Accurate Code Generation]]></title>
            <link>https://medium.com/@adarsh.ajay/fine-tuning-qwen-2-5-for-more-accurate-code-generation-127afa2aa73e?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/127afa2aa73e</guid>
            <category><![CDATA[qwen2-5]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 09:58:59 GMT</pubDate>
            <atom:updated>2024-11-18T09:58:59.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LMfgewfnAVW_WKLlJz0P1A.png" /><figcaption><strong>Fine-Tuning Qwen-2.5 for More Accurate Code Generation</strong></figcaption></figure><p><em>Introduction</em><br>As large language models continue to redefine the landscape of artificial intelligence, their ability to understand and generate code has opened up new avenues for developers and organizations. Among these models, <strong>Qwen-2.5</strong>, a cutting-edge model known for its language comprehension and coding capabilities, has shown promise in generating high-quality code snippets and handling complex programming tasks. However, like any general-purpose model, fine-tuning Qwen-2.5 can significantly enhance its accuracy and domain-specific performance for specialized coding tasks. This article will guide you through the process of fine-tuning Qwen-2.5 for more precise code generation.</p><h3>Why Fine-Tune Qwen-2.5?</h3><p>While Qwen-2.5 is pre-trained on a large corpus encompassing a wide range of topics, it may not fully align with the specific needs of certain coding tasks or niche programming challenges. Fine-tuning can help:</p><ul><li><strong>Improve domain-specific knowledge</strong>: Align the model with particular frameworks, libraries, or coding standards.</li><li><strong>Reduce errors</strong>: Minimize logical and syntactic mistakes in code generation.</li><li><strong>Enhance consistency</strong>: Improve code structure and adherence to best practices.</li></ul><h3>Preparing for Fine-Tuning</h3><p>Before fine-tuning, it is essential to have:</p><ol><li><strong>A dataset of high-quality code samples</strong>: The dataset should reflect the desired output, including code structures, function definitions, and specific libraries.</li><li><strong>Access to a robust computing environment</strong>: Ensure you have enough computational resources, such as GPUs or TPUs, for training the model efficiently.</li><li><strong>Familiarity with fine-tuning frameworks</strong>: Libraries such as Hugging Face’s transformers, DeepSpeed, or PEFT (Parameter-Efficient Fine-Tuning) can be invaluable.</li></ol><h3>Step-by-Step Guide to Fine-Tuning Qwen-2.5</h3><h4>1. Setting Up the Environment</h4><p>Start by setting up your environment with the necessary libraries:</p><pre>pip install transformers torch datasets</pre><p>Ensure your environment supports GPU acceleration (e.g., via CUDA).</p><h4>2. Load the Pre-Trained Qwen-2.5 Model</h4><pre>from transformers import AutoModelForCausalLM, AutoTokenizer<br><br># Load the model and tokenizer<br>model_name = &quot;Qwen/Qwen/Qwen2.5-Coder-32B-Instruct&quot;<br>tokenizer = AutoTokenizer.from_pretrained(model_name)<br>model = AutoModelForCausalLM.from_pretrained(model_name)</pre><h4>3. Preparing the Dataset</h4><p>Format your code dataset to match the input-output structure required for the model. Using datasets, load and preprocess your data:</p><pre>from datasets import load_dataset<br><br># Load your dataset (replace &#39;path/to/dataset&#39; with your actual data path)<br>dataset = load_dataset(&#39;path/to/dataset&#39;)<br># Tokenize the dataset<br>def tokenize_function(examples):<br>    return tokenizer(examples[&#39;code&#39;], truncation=True, padding=True)<br>tokenized_dataset = dataset.map(tokenize_function, batched=True)</pre><p>Ensure that the dataset is split into training and validation sets to monitor overfitting during training.</p><h4>4. Fine-Tuning with Trainer API</h4><p>Leverage Hugging Face’s Trainer API for straightforward training:</p><pre>from transformers import Trainer, TrainingArguments<br><br>training_args = TrainingArguments(<br>    output_dir=&quot;./results&quot;,<br>    evaluation_strategy=&quot;epoch&quot;,<br>    learning_rate=2e-5,<br>    per_device_train_batch_size=4,<br>    per_device_eval_batch_size=4,<br>    num_train_epochs=3,<br>    weight_decay=0.01,<br>    save_total_limit=2,<br>)<br>trainer = Trainer(<br>    model=model,<br>    args=training_args,<br>    train_dataset=tokenized_dataset[&#39;train&#39;],<br>    eval_dataset=tokenized_dataset[&#39;validation&#39;],<br>)<br>trainer.train()</pre><h4>5. Monitoring Performance</h4><p>Track performance using metrics such as perplexity and BLEU scores. Integrating additional custom metrics specific to coding accuracy, like syntactic correctness, can further guide training adjustments.</p><h3>Best Practices for Fine-Tuning</h3><ol><li><strong>Incremental Learning</strong>: Start with a smaller learning rate and scale up if necessary. This helps preserve the pre-trained knowledge while adapting to the new task.</li><li><strong>Regular Validation</strong>: Validate your model frequently to avoid overfitting.</li><li><strong>Use Parameter-Efficient Techniques</strong>: Techniques like LoRA (Low-Rank Adaptation) or adapters can reduce memory requirements and training time.</li></ol><h3>Post-Tuning Consideration</h3><ul><li><strong>Code Review and Testing</strong>: Use tools like pylint or custom test scripts to validate the quality and functionality of generated code.</li><li><strong>Iterative Improvements</strong>: Continue to fine-tune with new data or adjust hyperparameters for more refined results.</li><li><strong>Deployment</strong>: Optimize your model for inference using libraries like ONNX Runtime or TorchScript for faster response times in production.</li></ul><h3>Conclusion</h3><p>Fine-tuning Qwen-2.5 can lead to significant improvements in code generation by aligning the model more closely with specific coding practices and requirements. By following these steps, you can create a powerful AI coding assistant tailored to your unique needs, enhancing productivity and code quality across your projects.</p><p><em>With tailored fine-tuning, Qwen-2.5 can become an even more effective partner in tackling complex coding challenges, empowering developers and teams to push the boundaries of what’s possible in software engineering.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=127afa2aa73e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up PostgreSQL with pgvector in Docker: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@adarsh.ajay/setting-up-postgresql-with-pgvector-in-docker-a-step-by-step-guide-d4203f6456bd?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4203f6456bd</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[pgvector]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Fri, 08 Nov 2024 08:28:06 GMT</pubDate>
            <atom:updated>2024-11-08T08:32:20.571Z</atom:updated>
            <content:encoded><![CDATA[<p>Vector embeddings have become increasingly important in modern applications, from semantic search to AI-powered recommendations. In this guide, I’ll walk you through setting up PostgreSQL with pgvector in Docker, enabling you to store and query vector data efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtg89-qh_II0HSqn36aa2A.jpeg" /></figure><h3>What is pgvector?</h3><p>pgvector is a powerful PostgreSQL extension that adds vector similarity search capabilities to your database. It’s particularly useful for applications involving machine learning, natural language processing, and image similarity search.</p><h3>Prerequisites</h3><ul><li>Docker installed on your machine</li><li>Basic familiarity with PostgreSQL</li><li>Terminal or command prompt access</li></ul><h3>Step 1: Pulling the Docker Image</h3><p>We’ll use the ankane/pgvector image, which comes with PostgreSQL and pgvector pre-installed. Open your terminal and run:</p><pre>docker pull ankane/pgvector</pre><h3>Step 2: Running the PostgreSQL Container</h3><p>Now, let’s start a PostgreSQL container with pgvector enabled:</p><pre>docker run -e POSTGRES_USER=myuser \<br>           -e POSTGRES_PASSWORD=mypassword \<br>           -e POSTGRES_DB=mydatabase \<br>           --name my_postgres \<br>           -p 5432:5432 \<br>           -d ankane/pgvector</pre><p>Let’s break down these parameters:</p><ul><li>-e POSTGRES_USER=myuser: Creates a database user</li><li>-e POSTGRES_PASSWORD=mypassword: Sets the user&#39;s password</li><li>-e POSTGRES_DB=mydatabase: Creates a new database</li><li>--name my_postgres: Names your container</li><li>-p 5432:5432: Maps the container&#39;s PostgreSQL port to your host</li><li>-d: Runs the container in detached mode</li></ul><h3>Step 3: Connecting to Your Database</h3><p>You can connect to your newly created database using the psql command-line tool</p><pre>psql -h localhost -U myuser -d mydatabase -p 5432</pre><p>You’ll be prompted for the password you set earlier.</p><h3>Step 4: Enabling pgvector</h3><p>Once connected to your database, enable the pgvector extension by running:</p><pre>CREATE EXTENSION vector;</pre><h3>Step 5: Verifying the Installation</h3><p>To ensure pgvector is properly installed, run:</p><pre>SELECT * FROM pg_extension;</pre><p>You should see vector listed among the installed extensions.</p><h3>Using pgvector with Python</h3><p>To interact with your vector-enabled database from Python, first install the PostgreSQL adapter:</p><pre>pip install psycopg2-binary</pre><p>Here’s a simple example of how to use it:</p><pre>import psycopg2<br>import numpy as np<br><br># Connect to your database<br>conn = psycopg2.connect(<br>    dbname=&quot;mydatabase&quot;,<br>    user=&quot;myuser&quot;,<br>    password=&quot;mypassword&quot;,<br>    host=&quot;localhost&quot;<br>)<br># Create a table with a vector column<br>with conn.cursor() as cur:<br>    cur.execute(&quot;&quot;&quot;<br>        CREATE TABLE items (<br>            id serial PRIMARY KEY,<br>            embedding vector(3)<br>        );<br>    &quot;&quot;&quot;)<br>    conn.commit()</pre><h3>Common Issues and Troubleshooting</h3><ol><li><strong>Connection refused errors</strong>: Make sure the Docker container is running:</li></ol><pre>docker ps | grep my_postgres</pre><p><strong>2 . Permission denied</strong>: Verify your username and password are correct</p><p><strong>3 . Extension creation fails</strong>: Ensure you’re connected as a user with sufficient privileges</p><h3>Next Steps</h3><p>Now that you have PostgreSQL with pgvector running in Docker, you can:</p><ul><li>Start storing vector embeddings from your machine learning models</li><li>Implement semantic search in your applications</li><li>Build AI-powered recommendation systems</li><li>Experiment with similarity searches</li></ul><h3>Conclusion</h3><p>Setting up PostgreSQL with pgvector in Docker provides a powerful foundation for building vector-based applications. This containerized setup ensures consistency across different environments and makes it easy to get started with vector similarity search in your projects.</p><p>Remember to secure your database properly before deploying to production, and consider your specific use case when configuring PostgreSQL parameters for optimal performance.</p><p><em>Happy coding! If you found this guide helpful, feel free to share it with others who might benefit from it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4203f6456bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-Tuning Mistral 7B: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@adarsh.ajay/fine-tuning-mistral-7b-a-step-by-step-guide-aaca135a18de?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaca135a18de</guid>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Tue, 24 Sep 2024 09:09:27 GMT</pubDate>
            <atom:updated>2024-09-24T09:09:27.071Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fx4SqJcj7fQjL3COidiucg.png" /></figure><p>Fine-tuning a large language model like Mistral 7B can greatly enhance its performance on specific tasks by adapting it to new datasets or domains. This article walks through the fine-tuning process for Mistral 7B using Hugging Face’s Transformers library and efficient 4-bit quantization, which makes it possible to run the model on consumer-grade GPUs.</p><h3>Prerequisites</h3><p>Before you begin, ensure that you have the following installed:</p><ul><li>Python 3.x</li><li>Hugging Face Transformers (pip install transformers)</li><li>BitsAndBytes for quantization (pip install bitsandbytes)</li><li>Accelerate library for optimization (pip install accelerate)</li></ul><h3>Step 1: Setting Up the Environment</h3><p>First, update and install all necessary libraries to ensure compatibility with Mistral 7B:</p><pre>pip install -q -U transformers accelerate bitsandbytes</pre><h3>Step 2: Loading the Mistral 7B Model</h3><p>Mistral 7B can be accessed via platforms like <strong>Hugging Face</strong>, <strong>Kaggle</strong>, or <strong>Google Colab</strong>. Here, we demonstrate how to load the model with 4-bit quantization to optimize for GPU memory:</p><pre>from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig</pre><pre>bnb_config = BitsAndBytesConfig(<br>    load_in_4bit=True,<br>    bnb_4bit_quant_type=&quot;nf4&quot;,<br>    bnb_4bit_use_double_quant=True<br>)<br>model_name = &quot;mistral-7b-v0.1&quot;<br>tokenizer = AutoTokenizer.from_pretrained(model_name)<br>model = AutoModelForCausalLM.from_pretrained(<br>    model_name,<br>    load_in_4bit=True,<br>    quantization_config=bnb_config,<br>    torch_dtype=torch.bfloat16,<br>    device_map=&quot;auto&quot;<br>)</pre><h3>Step 3: Preparing the Dataset</h3><p>For fine-tuning, you’ll need a dataset that matches the kind of task you’re targeting. For example, if you’re customizing Mistral for chatbot conversations, you might use datasets like <strong>guanaco-llama2–1k</strong>. Fine-tuning typically involves supervised training using labels, so make sure your dataset is properly preprocessed and tokenized.</p><p>You can use Hugging Face Datasets to load your dataset:</p><pre>from datasets import load_dataset<br></pre><pre>dataset = load_dataset(&quot;your_dataset&quot;)</pre><h3>Step 4: Fine-Tuning with PEFT and QLoRA</h3><p>To make fine-tuning efficient, especially on resource-limited GPUs, you can utilize Parameter-Efficient Fine-Tuning (PEFT) techniques such as <strong>QLoRA</strong>. PEFT allows you to fine-tune the model on a small number of parameters without retraining the entire model.</p><p>Install the PEFT library:</p><pre>pip install peft</pre><p>Then, apply QLoRA for low-rank adaptation of the model:</p><pre>from peft import prepare_model_for_int8_training<br></pre><pre>model = prepare_model_for_int8_training(model)</pre><p>Fine-tune the model with appropriate hyperparameters such as learning rate, batch size, and epochs, as per your use case.</p><h3>Step 5: Evaluating the Fine-Tuned Model</h3><p>Once fine-tuning is complete, you can evaluate your model using test data. Use metrics like perplexity or accuracy, depending on the task (e.g., text generation, classification).</p><pre>from transformers import pipeline<br></pre><pre>pipe = pipeline(<br>    &quot;text-generation&quot;,<br>    model=model,<br>    tokenizer=tokenizer,<br>    torch_dtype=torch.bfloat16,<br>    device_map=&quot;auto&quot;<br>)<br>prompt = &quot;Explain the concept of regularization in machine learning.&quot;<br>sequences = pipe(prompt, max_new_tokens=100, temperature=0.7)<br>print(sequences[0][&#39;generated_text&#39;])</pre><h3>Conclusion</h3><p>Fine-tuning Mistral 7B with 4-bit quantization and PEFT ensures that even large models can be adapted efficiently to new tasks on limited hardware. By following these steps, you can customize Mistral 7B for domain-specific applications, enhancing its usability and performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaca135a18de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fine-Tune LLaMA 3.1 Locally: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@adarsh.ajay/how-to-fine-tune-llama-3-1-locally-a-step-by-step-guide-341de509d64f?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/341de509d64f</guid>
            <category><![CDATA[training]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Tue, 24 Sep 2024 08:59:09 GMT</pubDate>
            <atom:updated>2024-09-24T08:59:09.412Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*qLu2wXOHZnuUeQNU-EClwA.jpeg" /></figure><p>Fine-tuning large language models like Meta’s LLaMA 3.1 is a powerful way to adapt these models for specialized tasks. Whether you’re looking to build a custom chatbot, improve a recommendation system, or enhance language translation, fine-tuning can optimize LLaMA to suit your needs. This guide outlines the process of fine-tuning LLaMA 3.1 locally using Python, Hugging Face, and quantization methods for efficient deployment.</p><h4>Prerequisites</h4><p>Before you start, ensure you have the following in place:</p><ul><li>Python environment with necessary libraries (transformers, datasets, accelerate, etc.)</li><li>Access to Hugging Face for downloading the base model</li><li>Sufficient hardware (GPU is recommended for faster training)</li></ul><h4>Step 1: Setting Up Your Environment</h4><p>First, set up your Python environment and install the required packages:</p><pre>pip install transformers datasets accelerate</pre><p>You’ll also need the base LLaMA model from Hugging Face:</p><pre>from transformers import AutoModelForCausalLM, AutoTokenizer<br>model_name = &quot;meta-llama/LLaMA-3.1-8b&quot;<br>model = AutoModelForCausalLM.from_pretrained(model_name)<br>tokenizer = AutoTokenizer.from_pretrained(model_name)</pre><h4>Step 2: Preparing Your Dataset</h4><p>Fine-tuning requires a specific dataset that matches the task you want the model to learn. Ensure your data is cleaned and tokenized to match the format required by LLaMA.</p><p>Here’s an example of loading and tokenizing a dataset using Hugging Face’s datasets library:</p><pre>from datasets import load_dataset<br>dataset = load_dataset(&quot;your_dataset_name&quot;)<br>tokenized_dataset = dataset.map(lambda x: tokenizer(x[&#39;text&#39;]), batched=True)</pre><h4>Step 3: Fine-Tuning the Model</h4><p>Now you can start fine-tuning the model. Use the Trainer API from Hugging Face to handle the training process:</p><pre>from transformers import Trainer, TrainingArguments<br><br><br>training_args = TrainingArguments(<br>    output_dir=&quot;./results&quot;,<br>    evaluation_strategy=&quot;steps&quot;,<br>    per_device_train_batch_size=2,<br>    num_train_epochs=3,<br>    logging_dir=&#39;./logs&#39;,<br>)<br>trainer = Trainer(<br>    model=model,<br>    args=training_args,<br>    train_dataset=tokenized_dataset[&quot;train&quot;],<br>    eval_dataset=tokenized_dataset[&quot;test&quot;],<br>)<br>trainer.train()</pre><h4>Step 4: Quantization and Model Optimization</h4><p>For efficient local use, you’ll want to quantize the model to reduce its size and resource usage. This involves converting the model into a format like GGUF, which works well with local applications such as Jan AI or LLaMA.cpp.</p><p>You can quantize the model as follows:</p><pre>python llama_quantize.py --input_model ./results --output_format GGUF</pre><h4>Step 5: Running the Fine-Tuned Model Locally</h4><p>Once your model is fine-tuned and quantized, you can load it into local applications. For instance, using the Jan AI application:</p><ol><li>Download and install Jan AI.</li><li>Import the quantized GGUF model file.</li><li>Set the prompt template and inference parameters to optimize response generation.</li></ol><p>For usage in other frameworks like LLaMA.cpp or GPT4ALL, simply import the model following similar steps.</p><h4>Conclusion</h4><p>Fine-tuning LLaMA 3.1 locally enables you to create custom AI solutions without relying on external cloud-based APIs. By following these steps — setting up your environment, preparing the dataset, fine-tuning the model, and optimizing it through quantization — you can unlock the potential of LLaMA 3.1 for various specialized tasks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=341de509d64f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Distributed Training: Fine-Tuning a Donut Transformer with Ray]]></title>
            <link>https://medium.com/@adarsh.ajay/understanding-distributed-training-fine-tuning-a-donut-transformer-with-ray-1eafa8b737c7?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1eafa8b737c7</guid>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Thu, 22 Aug 2024 04:46:49 GMT</pubDate>
            <atom:updated>2024-08-22T04:50:03.767Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of machine learning, fine-tuning models is a crucial step to ensure they perform well on specific tasks. However, as models grow larger and more complex, the need for efficient training methods becomes increasingly important. In this post, we’ll explore the differences between regular fine-tuning and distributed training using the Ray framework, all explained in a way that’s easy to understand — imagine it as a fun coloring project!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTB9B43cRsW1BKrGjSlu4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*jGBseS8d_LxR63KGB7T-VA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EHzsjCOjSt7veqNRaSeVA.png" /></figure><h3>What is Fine-Tuning?</h3><h3>Regular Fine-Tuning</h3><p>Think of a pre-trained model like a big box of crayons. This box contains a wide variety of colors that can be used for different drawings. When you want to color a specific picture, you need to pick just the right colors to make it look great. This process of selecting and adjusting the model to fit a specific task is called fine-tuning.In traditional fine-tuning:</p><ul><li>Single Crayon Box: You typically use one computer (like one crayon box) to handle all the training work.</li><li>Slow Process: If the picture is large or complicated, it might take a long time to finish because you’re doing everything by yourself.</li></ul><h3>Fine-Tuning with Ray (Distributed Training)</h3><p>Now, imagine you have a big group of friends, and each friend has their own crayon box filled with colors. Instead of one person doing all the coloring, everyone works together to complete the same picture. This collaborative effort is what distributed training with Ray is all about!In distributed fine-tuning:</p><ul><li>Many Crayon Boxes: You use several computers (like many crayon boxes) simultaneously.</li><li>Faster Process: Each computer can handle a different part of the training, allowing you to finish much faster because everyone is pitching in.</li></ul><h3>How Does Ray Help?</h3><h3>Teamwork</h3><p>Ray is a powerful framework that enables many computers to work together as a cohesive team. Each computer can tackle a specific piece of the training process, just like your friends each coloring a different section of the picture.</p><h3>Sharing the Load</h3><p>By distributing the workload among multiple computers, Ray ensures that no single machine becomes overwhelmed. This means that the training process runs smoothly and efficiently, without one computer getting too tired or slow.</p><h3>Making It Easier</h3><p>Setting up this collaborative training is made simple with Ray. It acts like a good leader, ensuring that everyone knows their role and when to execute tasks. This streamlined approach allows you to focus more on the model and less on the technical details of managing multiple systems.</p><h3>Summary</h3><p>In conclusion, the difference between regular fine-tuning and distributed training using Ray can be likened to a coloring project:</p><ul><li>Regular Fine-Tuning: One computer does all the work alone, which can be time-consuming and labor-intensive.</li><li>Fine-Tuning with Ray: Many computers collaborate, sharing the workload to finish faster and more efficiently.</li></ul><p>This teamwork approach is especially beneficial when training large models like the Donut transformer. By leveraging distributed training, you can significantly reduce training time and improve performance, making it an essential tool in the machine learning toolkit.By embracing distributed training with frameworks like Ray, you can unlock the full potential of your models and tackle even the most complex tasks with ease. Happy training!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1eafa8b737c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resume CrewAI framework]]></title>
            <link>https://medium.com/@adarsh.ajay/resume-crewai-framework-b207131f8e87?source=rss-a275cc2f19e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b207131f8e87</guid>
            <dc:creator><![CDATA[Adarsh Ajay]]></dc:creator>
            <pubDate>Tue, 06 Aug 2024 06:22:13 GMT</pubDate>
            <atom:updated>2024-08-06T06:22:13.244Z</atom:updated>
            <content:encoded><![CDATA[<h4>The CrewAI framework provides a robust solution for automating the process of job research and resume writing through the collaboration of specialized AI agents. Below is an overview of how to set up and utilize the CrewAI Resume Builder, highlighting its features, usage, and customization options.</h4><h3>Features</h3><ol><li>Job Research: The Research Specialist agent collects detailed information about job skills, projects, and requirements tailored to the specified job title, location, and education.</li><li>Resume Writing: The Resume Writer agent creates a customized resume using the research findings along with the employee’s name, job title, location, and education.</li><li>Output: The final resume is generated and saved in Markdown format as resume.md.</li></ol><h3>Usage</h3><p>To utilize the CrewAI Resume Builder, follow these steps:</p><ol><li>Install Required Dependencies:</li></ol><ul><li>Install the necessary libraries:</li></ul><pre>pip install crewai langchain_groq langchain.tools</pre><p>Set API Key: Configure your API key for the language model (e.g., ChatGroq).</p><ol><li>Customize Job and Employee Information: Adjust the job details and employee information in the code snippet below:</li></ol><pre>result = resume_crew.kickoff({     &#39;job_title&#39;: &#39;Software Engineer&#39;,     &#39;name&#39;: &#39;John Doe&#39;,     &#39;location&#39;: &#39;San Francisco, CA&#39;,     &#39;education&#39;: &#39;University of California, Berkeley&#39; })</pre><ol><li>Run the Code: Execute the script to generate the resume.</li><li>Output File: The generated resume will be saved in the resume.md file.</li></ol><h3>Customization Options</h3><p>The behavior of the agents can be tailored by modifying the following parameters:</p><ul><li>role: Define the specific role of the agent.</li><li>goal: Set the primary objective or purpose of the agent.</li><li>backstory: Provide context or background for the agent.</li><li>verbose: Control the level of detail in the agent’s output.</li><li>allow_delegation: Determine if the agent can delegate tasks to others.</li><li>tools: Specify the tools available for the agent’s tasks.</li><li>llm: Choose the language model utilized by the agent.</li><li>output_file: Designate the file for saving the agent’s output.</li></ul><p>These parameters allow for a high degree of flexibility, enabling users to adapt the agents’ tasks and expected outcomes to meet specific needs.</p><h3>Conclusion</h3><p>The CrewAI Resume Builder effectively combines AI-driven research and writing capabilities, streamlining the process of creating tailored resumes. By leveraging customizable agents, users can enhance their job application materials to better align with job requirements, ultimately improving their chances of success in the job market.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b207131f8e87" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>