<?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 Tamilselvan Arjunan on Medium]]></title>
        <description><![CDATA[Stories by Tamilselvan Arjunan on Medium]]></description>
        <link>https://medium.com/@arjunantamilselvan1?source=rss-f6d48b017e79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EyGhRB9UkCtNHlKKSZwLzg.jpeg</url>
            <title>Stories by Tamilselvan Arjunan on Medium</title>
            <link>https://medium.com/@arjunantamilselvan1?source=rss-f6d48b017e79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 09:43:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arjunantamilselvan1/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[Building Your First Flask Application: A Beginner’s Guide]]></title>
            <link>https://medium.com/@arjunantamilselvan1/building-your-first-flask-application-a-beginners-guide-49743cd676ad?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/49743cd676ad</guid>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 22:07:55 GMT</pubDate>
            <atom:updated>2024-04-09T22:07:55.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*OqMCdLPT3k_ZKKN1OGPYSg.png" /></figure><p>Flask is a lightweight and flexible web framework for Python. It’s an excellent choice for building web applications, APIs, and prototypes due to its simplicity and ease of use. In this article, we’ll guide you through the process of creating your first Flask application step by step.</p><h3>Setting Up Your Environment</h3><p>Before we begin, make sure you have Python and pip installed on your machine. You can check by running the following commands in your terminal or command prompt:</p><pre>python --version</pre><pre>pip --version</pre><p>If Python and pip are installed, let’s create a virtual environment for our Flask project. Navigate to your project directory and run the following commands:</p><pre>mkdir my_flask_app</pre><pre>cd my_flask_app</pre><pre>python -m venv venv</pre><p>Next, activate the virtual environment:</p><ul><li>On macOS/Linux:</li></ul><pre>source venv/bin/activate</pre><ul><li>On Windows:</li></ul><pre>venv\Scripts\activate</pre><h3>Installing Flask</h3><p>With the virtual environment activated, let’s install Flask using pip:</p><pre>pip install Flask</pre><h3>Creating Your Flask Application</h3><p>Now that we have Flask installed, let’s create our Flask application. Inside your project directory, create a new Python file named app.py and open it in your favorite text editor.</p><pre>from flask import Flask<br><br># Create an instance of the Flask class<br>app = Flask(__name__)<br><br># Define a route for the homepage<br>@app.route(&#39;/&#39;)<br>def hello_world():<br>    return &#39;Hello, World!&#39;<br><br># Run the application if this script is executed<br>if __name__ == &#39;__main__&#39;:<br>    app.run(debug=True)</pre><h3>Running Your Flask Application</h3><p>To run your Flask application, make sure you’re still in the virtual environment and execute the following command in your terminal or command prompt:</p><pre>python app.py</pre><p>You should see output similar to the following:</p><ul><li>Running on <a href="http://127.0.0.1:5000/">http://127.0.0.1:5000/</a> (Press CTRL+C to quit)</li></ul><p>Open your web browser and navigate to http://127.0.0.1:5000/. You should see the message &quot;Hello, World!&quot; displayed in your browser.</p><p>Congratulations! You’ve successfully created and run your first Flask application. From here, you can explore more features of Flask, such as creating multiple routes, rendering templates, handling form submissions, and interacting with databases.</p><h3>Conclusion</h3><p>Flask provides a simple yet powerful framework for building web applications with Python. In this guide, we’ve covered the basics of setting up a Flask project, installing Flask, creating routes, and running the application. With this foundation, you can now start building more complex web applications and APIs using Flask.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49743cd676ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Django: Top 5 Tips and Tricks for Efficient Web Development]]></title>
            <link>https://medium.com/@arjunantamilselvan1/mastering-django-top-5-tips-and-tricks-for-efficient-web-development-a744316de0a6?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/a744316de0a6</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[django-admin]]></category>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 11:01:29 GMT</pubDate>
            <atom:updated>2024-04-07T11:06:57.584Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R8uJ39r-ylvmPnsy" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Django is a powerful web framework for building robust and scalable web applications. Whether you’re a beginner or an experienced developer, mastering Django can significantly enhance your productivity and code quality. In this article, we’ll explore five Django tips and tricks that can take your Django skills to the next level.</h4><h3>1. Class-Based Views (CBVs) for Structured Development</h3><p>Django provides both function-based views (FBVs) and class-based views (CBVs). While FBVs are straightforward, CBVs offer more structure and reusability, making them ideal for complex views. For example, using CBVs for common patterns like CRUD operations can lead to cleaner and more maintainable code.</p><pre>from django.views.generic import ListView, DetailView<br>from .models import YourModel<br><br>class YourModelListView(ListView):<br>    model = YourModel<br>    template_name = &#39;your_template.html&#39;<br>    context_object_name = &#39;your_model_list&#39;<br><br>class YourModelDetailView(DetailView):<br>    model = YourModel<br>    template_name = &#39;your_detail_template.html&#39;<br>    context_object_name = &#39;your_model&#39;</pre><h3>2. Custom Template Tags and Filters for Flexible Templates</h3><p>Extend Django’s template engine with custom template tags and filters to handle complex logic or formatting tasks directly in your templates. This approach enhances template readability and reduces redundancy in your HTML code.</p><pre># custom_tags.py<br>from django import template<br><br>register = template.Library()<br><br>@register.filter<br>def truncate(value, length):<br>    if len(value) &gt; length:<br>        return value[:length] + &#39;...&#39;<br>    return value</pre><p>In the html template:</p><pre>{% load custom_tags %}<br>{{ text_to_truncate|truncate:50 }}</pre><h3>3. Middleware for Global Request/Response Processing</h3><p>Django middleware allows you to modify request and response objects globally. Use middleware for tasks like authentication, CORS handling, or logging. This enables centralized processing of common tasks across your application.</p><pre># custom_middleware.py<br>class CustomMiddleware:<br>    def __init__(self, get_response):<br>        self.get_response = get_response<br><br>    def __call__(self, request):<br>        # Do something before the view is called<br>        response = self.get_response(request)<br>        # Do something after the view is called<br>        return response</pre><h3>4. Database Optimization Techniques</h3><p>Optimize database queries using Django’s ORM features such as select_related, prefetch_related, and only methods. These methods minimize database hits and improve performance, especially when dealing with complex data relationships.</p><pre># Example using select_related<br>from .models import Author, Book<br><br>books = Book.objects.select_related(&#39;author&#39;).all()</pre><h3>5. Django Forms for Easy Data Handling</h3><p>Leverage Django’s form capabilities for data validation and processing. Customize forms using widgets, validators, and formsets to handle complex form scenarios efficiently. This simplifies data handling and ensures data integrity in your application.</p><pre>from django import forms<br>from .models import YourModel<br><br>class YourModelForm(forms.ModelForm):<br>    class Meta:<br>        model = YourModel<br>        fields = [&#39;field1&#39;, &#39;field2&#39;]</pre><p>By incorporating these Django tips and tricks into your development workflow, you can write cleaner, more efficient code and build Django applications that are scalable, maintainable, and performant. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a744316de0a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Tips and Tricks for Efficient Coding]]></title>
            <link>https://medium.com/@arjunantamilselvan1/python-tips-and-tricks-for-efficient-coding-5ccd3d1d2ba0?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ccd3d1d2ba0</guid>
            <category><![CDATA[python-web-developer]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 11:48:20 GMT</pubDate>
            <atom:updated>2024-04-07T11:05:22.580Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJX39_djRXMMTYGRxB7h4w.jpeg" /></figure><p>Python, with its simplicity and versatility, is a favorite among developers. In this guide, we’ll explore some tips and tricks to boost your Python coding efficiency. Follow along for practical insights and step-by-step examples.</p><h3>Prerequisites</h3><p>Before we dive into the tips and tricks, ensure you have Python installed on your system. Additionally, some examples may require specific packages. You can install them using:</p><pre>pip install package-name</pre><p>Now, let’s enhance your Python coding skills!</p><h3>Tip 1: Virtual Environments</h3><p>Set up virtual environments to isolate project dependencies. It keeps your project’s dependencies separate from the system-wide ones, ensuring a clean and reproducible environment.</p><pre># Create a virtual environment<br>python -m venv myenv<br><br># Activate the virtual environment<br>source myenv/bin/activate  # On Unix or MacOS<br>myenv\Scripts\activate  # On Windows</pre><h3>Tip 2: List Comprehensions</h3><p>Use list comprehensions for concise and readable code. They’re a powerful tool to create lists in a single line.</p><pre># Traditional approach<br>squared_numbers = []<br>for num in range(1, 6):<br>    squared_numbers.append(num ** 2)<br><br># Using list comprehension<br>squared_numbers = [num ** 2 for num in range(1, 6)]</pre><h3>Tip 3: Unpacking</h3><p>Leverage tuple unpacking to simplify variable assignments.</p><pre># Without unpacking<br>coordinates = (3, 4)<br>x = coordinates[0]<br>y = coordinates[1]<br><br># With unpacking<br>x, y = coordinates</pre><h3>Tip 4: f-strings</h3><p>Embrace f-strings for string formatting. They are concise and provide a clear syntax.</p><pre>name = &quot;John&quot;<br>age = 30<br><br># Traditional formatting<br>message = &quot;My name is {} and I&#39;m {} years old.&quot;.format(name, age)<br><br># Using f-string<br>message = f&quot;My name is {name} and I&#39;m {age} years old.&quot;python</pre><h3>Tip 5: Context Managers</h3><p>Utilize context managers (with statements) to handle resource management efficiently.</p><pre># Without context manager<br>file = open(&quot;example.txt&quot;, &quot;r&quot;)<br>content = file.read()<br>file.close()<br><br># With context manager<br>with open(&quot;example.txt&quot;, &quot;r&quot;) as file:<br>    content = file.read()</pre><h3>Conclusion</h3><p>These Python tips and tricks can significantly enhance your coding efficiency. Whether you’re a beginner or an experienced developer, incorporating these practices into your workflow can make your code more readable and maintainable.</p><p>Keep exploring the vast Python ecosystem, stay curious, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ccd3d1d2ba0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python List Comprehensions Unveiled: A Visual and Practical Guide]]></title>
            <link>https://medium.com/@arjunantamilselvan1/python-list-comprehensions-unveiled-a-visual-and-practical-guide-fda9f803b1b5?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/fda9f803b1b5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 11:37:56 GMT</pubDate>
            <atom:updated>2024-02-24T11:37:56.914Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EX8xBkcgLstncTFn9hKfpg.jpeg" /></figure><p>Introduction: Python’s list comprehensions are a concise and powerful feature that often mystifies newcomers but becomes a favorite tool for experienced developers. In this 3-minute read, we’ll unravel the magic behind list comprehensions step by step, using code snippets and visual aids. Let’s dive into the world of Python list comprehensions.</p><h3>Step 1: Installation</h3><p>Ensure you have Python installed on your machine. You can check by running python --version. If not, download and install Python from <a href="https://www.python.org/">python.org</a>.</p><h3>Step 2: Understanding the Basics</h3><p>List comprehensions provide a concise way to create lists in Python. The basic syntax is:</p><pre>new_list = [expression for item in iterable]</pre><p>For example, to create a list of squares from 0 to 9:</p><pre>squares = [x**2 for x in range(10)]</pre><h3>Step 3: Filtering with Conditionals</h3><p>List comprehensions can include conditionals to filter elements:</p><pre>even_squares = [x**2 for x in range(10) if x % 2 == 0]</pre><p>This generates a list of squared numbers only for even values of x.</p><h3>Step 4: Nested List Comprehensions</h3><p>List comprehensions can be nested for more complex constructions:</p><pre>matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]<br>flattened = [num if num % 2 == 0 else &#39;Odd&#39; for row in matrix for num in row]</pre><p>This example flattens a matrix into a single list, replacing odd numbers with the string ‘Odd’.</p><h3>Step 5: Visualizing List Comprehensions</h3><p>Visualize the transformation with diagrams or illustrations. For instance, showcase the evolution of a list through each step of a comprehension.</p><h3>Step 6: Real-world Examples</h3><p>Explore real-world scenarios where list comprehensions shine, such as processing data, filtering, or transforming elements.</p><pre># Example: Extracting vowels from a string<br>text = &quot;Hello, Medium!&quot;<br>vowels = [char for char in text if char.lower() in &#39;aeiou&#39;]</pre><h3>Conclusion:</h3><p>List comprehensions epitomize Python’s readability and simplicity. They condense multiple lines of code into a single, expressive line. As you master this Pythonic tool, your code will become more concise and elegant.</p><p>With list comprehensions, Python offers a succinct way to create, filter, and transform lists. Embrace this elegant feature, and let your code flourish with brevity and clarity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fda9f803b1b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unveiling Sora: Pioneering the Future of Text-to-Video Technology by ChatGPT]]></title>
            <link>https://medium.com/@arjunantamilselvan1/unveiling-sora-pioneering-the-future-of-text-to-video-technology-by-chatgpt-6b8c90835181?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b8c90835181</guid>
            <category><![CDATA[sora]]></category>
            <category><![CDATA[chartgpt]]></category>
            <category><![CDATA[chatgpt3]]></category>
            <category><![CDATA[chatgpt4]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 10:56:50 GMT</pubDate>
            <atom:updated>2024-02-24T10:56:50.781Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5jIMm12kzM9gToIWrLVuvw.png" /></figure><p>In the realm of artificial intelligence, OpenAI is at the forefront, teaching AI to comprehend and simulate the dynamic physical world. Our goal? Empowering models to assist users in solving real-world problems that demand an understanding of motion and interaction.</p><h3>Meet Sora: Transforming Text into Dynamic Videos</h3><p>In our pursuit of innovation, we are excited to introduce Sora, our state-of-the-art text-to-video model. Sora is not just a tool; it’s a leap forward in bridging the gap between textual descriptions and captivating visual content.</p><h3>The Power of Sora</h3><h3>Understanding the Physical World</h3><p>Sora represents a significant step in training AI models to understand and simulate the intricacies of the physical world in motion. Whether it’s the dance of leaves in the wind or the bustling energy of a city street, Sora comprehends and translates these dynamics into engaging visual narratives.</p><h3>Realizing the Vision</h3><p>Generating videos up to a minute long, Sora maintains unparalleled visual quality and adheres closely to the user’s prompt. This capability enables users to articulate their creative vision through text, and Sora brings it to life on the screen with stunning realism.</p><h3>How Sora Works</h3><p>Sora leverages advanced deep learning techniques to analyze textual prompts and generate corresponding videos. Its training involves exposure to diverse scenarios, allowing it to understand the nuances of movement, context, and visual aesthetics.</p><p>Sample Prompt: <em>“Several giant woolly mammoths approach, treading through a snowy meadow. Their long, woolly fur lightly blows in the wind as they walk. Snow-covered trees and dramatic snow-capped mountains in the distance, mid-afternoon light with wispy clouds, and a sun high in the distance creates a warm glow. The low camera view is stunning, capturing the large furry mammals with beautiful photography and depth of field.”</em></p><h3>Video Showcase</h3><p>Now, let’s witness the magic of Sora! Below is a video generated by Sora based on the provided prompt. Enjoy the mesmerizing scene come to life.</p><p><a href="https://cdn.openai.com/sora/videos/wooly-mammoth.mp4">https://cdn.openai.com/sora/videos/wooly-mammoth.mp4</a></p><h3>The Future of Text-to-Video Technology</h3><p>Sora isn’t just a tool; it’s a glimpse into the future of text-to-video technology. As we refine and enhance Sora, we envision a world where creative expressions seamlessly transition from text to immersive visual experiences.</p><h3>Conclusion</h3><p>Sora is more than a model; it’s a testament to the boundless possibilities that emerge when AI understands and interprets the physical world in motion. Join us on this exciting journey as we continue to push the boundaries of text-to-video technology with Sora.</p><p>Ready to embark on a visual storytelling adventure? Explore the capabilities of Sora and witness your textual visions come to life on the screen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b8c90835181" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Dynamic Conversations with ChatGPT]]></title>
            <link>https://medium.com/@arjunantamilselvan1/creating-dynamic-conversations-with-chatgpt-7f658a3053a1?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f658a3053a1</guid>
            <category><![CDATA[chatgpt-chatbot]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatgpt3]]></category>
            <category><![CDATA[chatgpt4]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 10:34:46 GMT</pubDate>
            <atom:updated>2024-02-24T10:34:46.959Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B04m6_qGjCC4tKFBITluyA.jpeg" /></figure><h3>Introduction</h3><p>ChatGPT, powered by OpenAI’s GPT-3.5 architecture, allows you to create dynamic and interactive conversations by sending a series of messages as input. In this quick guide, we’ll walk through the steps to achieve this, covering the necessary installations and providing code examples.</p><h3>Prerequisites</h3><p>Before getting started, ensure you have Python installed on your system. Additionally, you’ll need to install the OpenAI Python package. Run the following command in your terminal:</p><pre>pip install openai</pre><h3>Setting Up the Conversation</h3><p>To initiate a dynamic conversation with ChatGPT, you send a list of messages as input, where each message has a ‘role’ (‘system’, ‘user’, or ‘assistant’) and ‘content’ (the text of the message).</p><p>Let’s create a basic conversation using Python:</p><pre>import openai<br><br>conversation = [<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;: &quot;Who won the world series in 2020?&quot;},<br>    {&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: &quot;The Los Angeles Dodgers won the World Series in 2020.&quot;},<br>    {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Where was it played?&quot;}<br>]<br><br>response = openai.Completion.create(<br>    engine=&quot;text-davinci-002&quot;,<br>    messages=conversation<br>)<br><br>print(response[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;])</pre><p>In this example, we’ve set up a conversation where the user asks about the World Series, and the assistant responds accordingly.</p><h3>Adding Dynamism to the Conversation</h3><p>To make the conversation dynamic, you can extend it by adding more messages based on previous responses. Let’s continue the conversation:</p><pre>conversation.append({&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: &quot;The 2020 World Series was played in Arlington, Texas.&quot;})<br>conversation.append({&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Tell me more about Arlington.&quot;})<br><br>response = openai.Completion.create(<br>    engine=&quot;text-davinci-002&quot;,<br>    messages=conversation<br>)<br><br>print(response[&#39;choices&#39;][0][&#39;message&#39;][&#39;content&#39;])</pre><p>In this extension, the user asks for more information about Arlington after receiving the initial response.</p><h3>Conclusion</h3><p>Creating dynamic conversations with ChatGPT opens up exciting possibilities for interactive applications. Experiment with different message formats, ask follow-up questions, and guide the conversation flow to suit your needs.</p><p>Remember to refer to the OpenAI documentation for additional details and explore the full potential of dynamic interactions with ChatGPT.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f658a3053a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Full Potential of ChatGPT: A Guide to Temperature and Max Tokens]]></title>
            <link>https://medium.com/@arjunantamilselvan1/unlocking-the-full-potential-of-chatgpt-a-guide-to-temperature-and-max-tokens-4eb1d4c2a65c?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/4eb1d4c2a65c</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[chatgpt3]]></category>
            <category><![CDATA[chatgpt-chatbot]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatgpt4]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 10:20:04 GMT</pubDate>
            <atom:updated>2024-02-24T10:20:04.693Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKf4WJ90CSxn-EWTtyyZbQ.jpeg" /><figcaption>ChatGPT</figcaption></figure><p>ChatGPT, powered by OpenAI’s GPT-3.5 architecture, is a powerful language model that can generate human-like text. However, to make the most out of your interactions with ChatGPT, it’s crucial to understand and leverage the parameters that control its output.</p><p>In this guide, we’ll explore two key parameters: <strong>temperature</strong> and <strong>max tokens</strong>. These parameters play a crucial role in shaping the responses generated by ChatGPT, allowing you to tailor the model’s behavior to suit your specific needs.</p><h3>Prerequisites</h3><p>Before diving into using ChatGPT, make sure you have Python installed on your system. You’ll also need to install the OpenAI Python package. You can do this by running:</p><pre>pip install openai</pre><h3><strong>Understanding Temperature</strong></h3><p>The <strong>temperature</strong> parameter influences the randomness of the model’s output. It essentially controls the level of creativity in the responses. A higher temperature (e.g., 0.8) results in more diverse and creative responses, while a lower temperature (e.g., 0.2) makes the output more deterministic and focused.</p><p>Let’s take a look at an example:</p><pre>import openai<br><br>openai.Completion.create(<br>  engine=&quot;text-davinci-002&quot;,<br>  prompt=&quot;Tell me about the benefits of artificial intelligence.&quot;,<br>  temperature=0.2<br>)</pre><p>In this example, setting the temperature to 0.2 would lead to more focused and deterministic responses about the benefits of artificial intelligence.</p><h3>Controlling Output Length with Max Tokens</h3><p>The max tokens parameter allows you to limit the length of the generated response. This is useful when you want to control the verbosity of ChatGPT’s output.</p><pre>import openai<br><br>openai.Completion.create(<br>  engine=&quot;text-davinci-002&quot;,<br>  prompt=&quot;Explain the concept of quantum entanglement.&quot;,<br>  max_tokens=50<br>)</pre><p>By setting max_tokens to 50, you ensure that the response is concise and doesn&#39;t exceed a specified length.</p><h3>Finding the Right Balance</h3><p>Achieving the perfect output often involves finding the right balance between temperature and max tokens. Experiment with different values to strike the ideal balance for your use case.</p><p>In the graph above, we can see how adjusting temperature and max tokens impacts the output. As temperature increases, the responses become more diverse, while reducing max tokens results in shorter responses.</p><h3>Practical Examples</h3><h3>Example 1: Creative Writing</h3><p>If you’re using ChatGPT for creative writing, a higher temperature (e.g., 0.8) can lead to more imaginative and diverse storylines.</p><pre>openai.Completion.create(<br>  engine=&quot;text-davinci-002&quot;,<br>  prompt=&quot;Write a short story about a futuristic city.&quot;,<br>  temperature=0.8<br>)</pre><h3>Example 2: Code Generation</h3><p>For generating code snippets, you might prefer a lower temperature (e.g., 0.2) to ensure precise and deterministic code.</p><pre>openai.Completion.create(<br>  engine=&quot;code-davinci-002&quot;,<br>  prompt=&quot;Create a Python function to calculate Fibonacci sequence.&quot;,<br>  temperature=0.2<br>)</pre><h3>Conclusion</h3><p>Understanding and effectively using temperature and max tokens empower you to customize ChatGPT’s behavior for diverse applications. Experiment, iterate, and fine-tune these parameters based on your specific requirements to unlock the full potential of ChatGPT.</p><p>Remember to refer to the OpenAI documentation for the latest updates and additional details on these parameters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4eb1d4c2a65c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Whisper API for Real-Time Transcription Services in Your App]]></title>
            <link>https://medium.com/@arjunantamilselvan1/implementing-whisper-api-for-real-time-transcription-services-in-your-app-36977a6896a6?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/36977a6896a6</guid>
            <category><![CDATA[transcription]]></category>
            <category><![CDATA[whisper]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 07:27:19 GMT</pubDate>
            <atom:updated>2024-02-24T11:03:13.206Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uRBatNFip60SqL5Muuv4JQ.png" /></figure><p>ChatGPT, DALL.E, Stable Diffusion, Perplexity AI, etc. There are various models and tools for text and image generation. However, the market seems to be up for grabs when it comes to speech to text models and tools. One such tool is OpenAI’s Whisper.</p><p>Here are a few pointers about why you should use it in your next app.</p><ul><li>It can be used for almost any major language in the world, ranging from English to Hindi to Spanish to German and even more.</li><li>Speech to text tools like Dragon are good but there is no way to add that tool if you want to use it in either your desktop or web app. Whisper is better in that regard as it allows seamless integration within your app, and it is platform agnostic.</li><li>It can be used for transcription as well as translation. However, the translation can only be done to English at the time of writing.</li><li>Though file uploads are currently limited to 25MB, it allows most of the supported formats such as mp3 , mp4 ,mpeg ,m4a ,wav , and webm.</li></ul><p>In this article, we will focusing on transcribing from a given audio.</p><p>Firstly, we will need to install a couple of relevant packages.</p><p>Before we start with the main part of the integration, we need to create an enable a virtual environment in Python to install the relevant packages. Virtual environments allow us to keep the package versions in a project isolated from the global packages versions.</p><p>Create a virtual environment.</p><pre>python3 -m venv env</pre><ul><li>-m : This flag denotes that the file named venv will be run as a module in Python.</li><li>env : This is the name of the virtual environment.</li></ul><p>Basically, we are running the venv file as a module in Python so that it creates an environment named env for dealing with project level installations.</p><p>Now, activate the virtual environment after creating it.</p><pre>source env/bin/activate</pre><p>We need to install the OpenAI package to use it in Python. To install the package:</p><pre>pip install --upgrade openai</pre><p>Before using the OpenAI API, we need to generate an API key. Please follow <a href="https://platform.openai.com/docs/quickstart/step-2-set-up-your-api-key">these steps</a> to use the generated API key in your application.</p><p>Create main.py . Add the following lines:</p><pre>from openai import OpenAI<br>client = OpenAI()<br><br>audio_file= open(&quot;/path/to/file/audio.mp3&quot;, &quot;rb&quot;)<br>transcript = client.audio.transcriptions.create(<br>  model=&quot;whisper-1&quot;, <br>  file=audio_file<br>)</pre><p>The converted text will be available in transcript. By default, the response type will be json with the raw text included.</p><p>The Audio API also allows you to set additional parameters in a request. For example, if you want to set the response_format as text, your request would look like the following:</p><pre>from openai import OpenAI<br>client = OpenAI()<br><br>audio_file = open(&quot;speech.mp3&quot;, &quot;rb&quot;)<br>transcript = client.audio.transcriptions.create(<br>  model=&quot;whisper-1&quot;, <br>  file=audio_file, <br>  response_format=&quot;text&quot;<br>)</pre><p>There are other response formats available but for our use case and for better readability to non-programmers, getting the output as text will suffice for now.</p><p>temperature is another parameter that can be tweaked to get different types of responses.</p><pre>from openai import OpenAI<br>client = OpenAI()<br><br>audio_file = open(&quot;speech.mp3&quot;, &quot;rb&quot;)<br>transcript = client.audio.transcriptions.create(<br>  model=&quot;whisper-1&quot;, <br>  file=audio_file, <br>  response_format=&quot;text&quot;,<br>  temperature=0.8<br>)</pre><p>temperature can have values from 0 to 1. Higher values will make it more random whereas lower values will make it more deterministic.</p><p>So, this is how we can convert audio into text and use them in our application.</p><p>Stay tuned for articles related to deep learning and generative AI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36977a6896a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Creativity: Integrating DALL·E API for Dynamic Image Generation]]></title>
            <link>https://medium.com/@arjunantamilselvan1/unlocking-creativity-integrating-dall-e-api-for-dynamic-image-generation-90b739b51496?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/90b739b51496</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[dalle-2]]></category>
            <category><![CDATA[dalle-3]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 10:59:18 GMT</pubDate>
            <atom:updated>2024-02-22T11:02:41.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="An AI generated image of a robot sitting on a bench." src="https://cdn-images-1.medium.com/max/1024/0*dDw_m11CEqQMCgQo" /><figcaption>Photo by <a href="https://unsplash.com/@santesson89?utm_source=medium&amp;utm_medium=referral">Andrea De Santis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>DALL.E by OpenAI is one of the greatest technological breakthroughs in the field of generative AI in recent times. In addition to allowing the user to generate an image using a text prompt, it can also be used to generate variations of an uploaded image and do basic editing of the uploaded image without the use of a tool like Adobe Photoshop.</p><p>In this article, we will be focusing on the first use case, i.e., generating an image using a text prompt and also how you can incorporate that feature in your application.</p><p>Before we start with the main part of the integration, we need to create an enable a virtual environment in Python to install the relevant packages. Virtual environments allow us to keep the package versions in a project isolated from the global packages versions.</p><p>Create a virtual environment.</p><pre>python3 -m venv env</pre><ul><li>-m : This flag denotes that the file named venv will be run as a module in Python.</li><li>env : This is the name of the virtual environment.</li></ul><p>Basically, we are running the venv file as a module in Python so that it creates an environment named env for dealing with project level installations.</p><p>Now, activate the virtual environment after creating it.</p><pre>source env/bin/activate</pre><p>We need to install the OpenAI package to use it in Python. To install the package:</p><pre>pip install --upgrade openai</pre><p>Before using the OpenAI API, we need to generate an API key. Please follow <a href="https://platform.openai.com/docs/quickstart/step-2-set-up-your-api-key">these steps</a> to use the generated API key in your application.</p><p>Create main.py . Add the following lines:</p><pre>from openai import OpenAI<br><br>client = OpenAI()<br>model = int(input(<br>  &quot;Please select the model to be used (type a number and press enter.).<br>  1. dall-e-2.<br>  2. dall-e-3.<br>  &quot;<br>))<br>prompt = input(<br>  &quot;Please enter the description of <br>  the image that needs to be generated.&quot;<br>)<br>size = int(input(<br>  &quot;Please select the size of the image (type a number and press enter.).<br>  1. 1024x1024 pixels.<br>  2. 1024x1792 pixels. <br>  3. 1792x1024 pixels.<br>  &quot;<br>))<br>quality = int(input(<br>  &quot;Please enter the quality of the image (type a number and press enter.). <br>  1. standard.<br>  2. hd.<br>  &quot;<br>))<br>n = int(input(<br>  &quot;Please enter the number of images (1-10) to be generated.&quot;<br>))<br><br>if model == 1:<br>  model = &quot;dall-e-2&quot;<br>else:<br>  model = &quot;dall-e-2&quot;<br><br>if size == 1:<br>  size = &quot;1024x1024&quot;<br>elif size == 2:<br>  size = &quot;1024x1792&quot;<br>else:<br>  size = &quot;1792x1024&quot;<br><br>if quality == 1:<br>  quality = &quot;standard&quot;<br>else:<br>  quality = &quot;hd&quot;<br><br>response = client.images.generate(<br>  model=model,<br>  prompt=prompt,<br>  size=size,<br>  quality=quality,<br>  n=n,<br>)<br><br>image_url = response.data[0].url</pre><p>The arguments in the generate method are:</p><ul><li>model : You can choose DALL.E 2 or DALL.E 3. The latter one is a newer version so it has a bunch of new features such as support for more image sizes, ability to generate an HD image.</li><li>prompt : This is the text prompt that will be used by the model as a reference to generate the image.</li><li>size : This is the size of the generated image.</li><li>quality : This is the quality of the generated image. The image can be either of standard or HD quality.</li><li>n : The number of images to be generated in each API call. Currently, upto 10 images can be generated by DALL.E 2 and only 1 image by DALL.E 3. You can generate more images using DALL.E 3 by making parallel requests (covering this technique is out of the scope of this article.).</li><li>image : It contains a URL for the generated image(s).</li></ul><p>So, this is how we can generate images using a prompt and use them in our application.</p><p>Stay tuned for articles related to deep learning and generative AI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90b739b51496" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT Integration 101: Custom Data Queries in Your AI App — Part 3]]></title>
            <link>https://medium.com/@arjunantamilselvan1/chatgpt-integration-101-custom-data-queries-in-your-ai-app-part-3-aacb0bea3757?source=rss-f6d48b017e79------2</link>
            <guid isPermaLink="false">https://medium.com/p/aacb0bea3757</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Tamilselvan Arjunan]]></dc:creator>
            <pubDate>Tue, 20 Feb 2024 07:55:39 GMT</pubDate>
            <atom:updated>2024-02-20T07:55:39.639Z</atom:updated>
            <content:encoded><![CDATA[<h3>ChatGPT Integration 101: Custom Data Queries in Your AI App — Part 3</h3><figure><img alt="Open AI logo." src="https://cdn-images-1.medium.com/max/1024/0*3kSGh3IhWBMU8u3o" /><figcaption>Photo by <a href="https://unsplash.com/@boliviainteligente?utm_source=medium&amp;utm_medium=referral">BoliviaInteligente</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In <a href="https://medium.com/@arjunantamilselvan1/chatgpt-integration-101-custom-data-queries-in-your-ai-app-part-2-a937895858ce">part 2</a> of this tutorial series, we used langchain to get create a simple question answering bot for our custom data that we provided as an argument to the langchain API.</p><p>In this part, we will explore another method of using our own data corpus to answer the questions related to our data.</p><p><strong>-Option 2: Use a vector store and embedding to get the answer:</strong></p><p>A custom data source will be required to use embeddings. For the custom data source, some popular options are PDF, SQL tables, and .txt files. For the current tutorial, we will be using PDF and will extract the text to use it with our llm.</p><p>But before we move on, we need to know what exactly embeddings are and how these question-answer bots work at a high level. Whenever a question is asked to ChatGPT, it calculates a metric called a similarity index. Similarity index tells us how close a given piece of text is to another piece of text. So, when a question is asked, the model tries to locate the answer which contains text similar to the one present in the question. Now, one way to represent words and sentences to calculate similarity between them is in a form of vector.</p><p>So, embeddings are basically vector projections of words/sentences/paragraphs in an n-dimensional space and these embeddings are used to answer questions. The embeddings which is the closest in vector space to the question asked is usually the most similar and will be used to phrase the answer in a more human readable format.</p><p>Now, coming back to the program, we can use .txt files and load it into Python but most of the general real world use case will involve PDFs rather than plain .txt files. For example, suppose you want to find out the total profits from your sales report. It might be 80 pages long and to avoid searching for it manually, we can use this PDF and ask the question directly to llm.</p><p>Create a new file named file_conversion.py . This file will be used to extract the text of PDF files and use it for answering the question.</p><p>pdfminer is a popular python package that is used for extracting text from PDFs. To install it:</p><pre>pip install pdfminer.six</pre><p>Now, in file_conversion.py :</p><pre>from pdfminer.high_level import extract_text<br><br>folder_name = &#39;./assets/&#39;<br>file_name = &#39;sample research paper.pdf&#39;<br>pdf_location = folder_name + file_name<br><br>def convert_pdf_to_txt():<br>    text = extract_text(pdf_location)<br>    return text</pre><p>convert_pdf_to_txt() function will extract the text from the pdf and will store it in a variable named text . The PDF file used for this demo can be downloaded from <a href="https://pubs.acs.org/doi/pdf/10.1021/es703112w">this link</a>. Create a folder named assets and store the PDF file as sample research paper.pdf .</p><p>After the text has been extracted, the only thing left is to use this text to answer the question asked by the user. To do this, first we will use OpenAI embeddings to create embeddings for our text. We will use FAISS vector database to store our embeddings.</p><p>Once the embeddings are created, the model will calculate similarity index and will return the text closest to the question asked.</p><p>To install FAISS:</p><pre>pip install faiss-cpu</pre><p>In llm_tutorial.py :</p><pre>from langchain_openai import ChatOpenAI<br>from langchain_core.prompts import ChatPromptTemplate<br>from langchain_openai import OpenAIEmbeddings<br>from langchain_community.vectorstores import FAISS<br>from langchain.text_splitter import RecursiveCharacterTextSplitter<br>from langchain.chains.combine_documents import create_stuff_documents_chain<br>from langchain.chains import create_retrieval_chain<br><br>llm = ChatOpenAI(openai_api_key=&quot;...&quot;)<br>prompt = ChatPromptTemplate.from_template(&quot;&quot;&quot;Answer the following question based only on the provided context:<br><br>&lt;context&gt;<br>{context}<br>&lt;/context&gt;<br><br>Question: {input}&quot;&quot;&quot;)<br><br>def get_answers(text):<br>  embeddings = OpenAIEmbeddings()<br>  text_splitter = RecursiveCharacterTextSplitter()<br>  documents = text_splitter.split_documents(text)<br>  vector = FAISS.from_documents(documents, embeddings)<br>  document_chain = create_stuff_documents_chain(llm, prompt)<br>  retriever = vector.as_retriever()<br>  retrieval_chain = create_retrieval_chain(retriever, document_chain)<br>  response = retrieval_chain.invoke({&quot;input&quot;: &quot;How much emissions occured in 2023?&quot;})<br>  <br>  return response<br>    </pre><p>A couple of things have been added.</p><ul><li>text in get_answers function definition is the text that we extracted from the PDF.</li><li>prompt is used to structure our query.</li><li>text_splitter is used to split the text into chunks so that it is easier to populate the vector database.</li><li>vector creates embeddings from the text.</li><li>response gets the closest match to the question and passes it as context to the model and it then generates an answer in a human readable format.</li></ul><p>Using this method, we can use our own custom document to answer questions related to it.</p><p>This part concludes the tutorial series.</p><p>Stay tuned to my channel for articles related to generative AI and deep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aacb0bea3757" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>