<?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 Tezan Sahu on Medium]]></title>
        <description><![CDATA[Stories by Tezan Sahu on Medium]]></description>
        <link>https://medium.com/@tezansahu?source=rss-99aa33de20e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5jFxsshc-YIUsY-xw0zyZw.png</url>
            <title>Stories by Tezan Sahu on Medium</title>
            <link>https://medium.com/@tezansahu?source=rss-99aa33de20e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:58:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tezansahu/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 Interactive AI Agents: A Complete Guide to Integrating AutoGen 0.4+ with Streamlit UI]]></title>
            <link>https://generativeai.pub/building-interactive-ai-agents-a-complete-guide-to-integrating-autogen-0-4-with-streamlit-ui-d5e9e6bd1b2c?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5e9e6bd1b2c</guid>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[autogen]]></category>
            <category><![CDATA[autogen-agents]]></category>
            <category><![CDATA[ai-agent-tutorial]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Mon, 09 Jun 2025 07:32:03 GMT</pubDate>
            <atom:updated>2025-06-09T07:32:03.030Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Complete Hands-On Tutorial: Learn how to hook up modern Autogen AgentChat agents with a slick Streamlit UI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9axtLE9R-kBCXTuvdpE3qA.png" /><figcaption>Build Interactive Autogen 0.4+ Agents with Streamlit: A Complete Hands-On Tutorial (Source: Created by author using AI)</figcaption></figure><p><strong><em>Have you ever built an amazing AI agent only to realise it’s trapped in your terminal, unable to shine in front of real users? You’re not alone.</em></strong></p><p>Microsoft’s Autogen 0.4 brought a breath of fresh air to building agents, with modular abstractions beautifully packaged under the high-levelAgentChat API to offer task-driven development for agentic applications. They also had a <a href="https://microsoft.github.io/autogen/dev/user-guide/agentchat-user-guide/migration-guide.html">fairly detailed guide</a> to migrate away from AutoGen v0.2.</p><p>Picture this: You’re all set to build something amazing using Autogen AgentChat. But then reality hits — you want to create a beautiful web interface with Streamlit, and suddenly you’re stuck.</p><p>That’s exactly what happened with me!</p><p>Despite AutoGen 0.4 being around since January 2025 (with even newer versions like 0.6 rolling out), I couldn’t find any tutorial or GitHub repo showing how to properly integrate AutoGen v0.4+ with Streamlit. Sure, there are plenty of tutorials for the old v0.2, but the breaking changes between versions make them practically useless for modern development using autogen-agentchat.</p><p>I spent countless hours digging through documentation &amp; tinkering with code. Finally, while working on a <a href="https://data-analyst-agent.streamlit.app/">Data Analyst Multi-Agent system</a> (a hobby project), I cracked the code for creating a clean, functional &amp; extensible integration between AutoGen AgentChat and Streamlit.</p><p>Today, I’m sharing that solution with you through a practical example: building a Career Mentor Agent with web search capabilities.</p><p>Let’s dive in and build something incredible together!</p><h3>So, what are we building?</h3><p>By the end of this tutorial, you’ll have a fully working Career Mentor Agent created using Autogen AgentChat, embedded into a Streamlit app, with:</p><p>🔁 User &amp; Agent messages rendered in dedicated Streamlit chat widgets<br>🛠️ Tool invocations rendered in the UI with parameters<br>🔐 LLMs accessed via <a href="https://github.com/marketplace/models-github">GitHub Models</a><br>🌐 Access to real-time web search via <a href="https://serper.dev/">SERPER API</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*4o5XLMNTYqUFOxsDD-5SXw.gif" /><figcaption>The end result — a Career Mentor Agent with Web Search capabilities, powered by GitHub Models</figcaption></figure><h3>Prerequisites &amp; Setup</h3><p>Before we start building, make sure you have:</p><ul><li>Python 3.10 or higher</li><li>uv package manager — <a href="https://docs.astral.sh/uv/getting-started/installation/">here’s how</a> <em>(trust me, you’ll thank me later for asking you to us this as your Python package manager)</em></li><li>A GitHub Personal Access Token (PAT) for accessing GitHub Models (<a href="https://gist.github.com/tezansahu/dc86fe0f0de02b2e6038e792747a91a2">here’s a detailed guide to get your GitHub PAT</a>)</li><li>Optional: <a href="https://serper.dev/">SERPER API key</a> for web search capabilities</li></ul><p>Let’s set up our project:</p><pre>mkdir streamlit-autogen-04<br>cd streamlit-autogen-04<br>uv venv<br>source .venv/bin/activate  # On Windows: .venv\Scripts\activate</pre><p>Create a pyproject.toml file with our dependencies:</p><pre>[project]<br>dependencies = [<br>    &quot;autogen-agentchat&gt;=0.6.1&quot;,<br>    &quot;autogen-ext[azure,openai]&gt;=0.6.1&quot;, <br>    &quot;streamlit&gt;=1.45.1&quot;,<br>    &quot;aiohttp&gt;=3.12.11&quot;,<br>    &quot;python-dotenv&gt;=0.9.9&quot;,<br>    &quot;requests&gt;=2.31.0&quot;<br>]</pre><p>Notice that we’re using AutoGen v0.6 (which is the most stable version as of writing this tutorial)</p><p>Install the dependencies:</p><pre>uv pip install -e .</pre><h3>Step 1: Building the Streamlit Interface Foundation</h3><p>Let’s start by creating our main file career-mentor-agent.py and setting up the basic Streamlit interface:</p><pre>import asyncio<br>from autogen_agentchat.agents import AssistantAgent<br>from autogen_agentchat.base import Response<br>from autogen_agentchat.conditions import TextMentionTermination<br>from autogen_agentchat.messages import AgentEvent, ChatMessage, TextMessage, ToolCallRequestEvent<br>from autogen_agentchat.teams import RoundRobinGroupChat<br>from autogen_core import CancellationToken<br>from autogen_ext.models.azure import AzureAIChatCompletionClient<br>from azure.core.credentials import AzureKeyCredential<br>import json<br>import requests<br>import streamlit as st<br>import sys<br>from typing import AsyncGenerator, Sequence<br><br># Create the Streamlit Interface<br>st.header(&quot;Autogen AgentChat Agent with Streamlit UI&quot;)</pre><p>This foundation imports all the essential components we’ll need from AutoGen v0.4+. Notice how we’re using autogen_agentchat — this is the new streamlined API that makes building agents much more intuitive than the older 0.2 version.</p><h3>Step 2: The Secret Sauce — Custom Trackable Agent Class</h3><p>Here’s where the real innovation happens. The biggest challenge with integrating AutoGen 0.4+ with Streamlit is capturing and displaying agent responses in real-time.</p><p>Our custom TrackableAssistantAgent solves this elegantly:</p><pre>class TrackableAssistantAgent(AssistantAgent):<br>    &quot;&quot;&quot;<br>    A specialized assistant agent that tracks and displays responses on Streamlit <br>    while processing messages. This class extends the functionality of the <br>    `AssistantAgent` by adding methods to handle and visualize responses, including <br>    tool call requests, text messages, and responses containing image references.<br>    &quot;&quot;&quot;<br>    async def on_messages_stream(<br>        self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken<br>    ) -&gt; AsyncGenerator[AgentEvent | ChatMessage | Response, None]:<br>         async for msg in super().on_messages_stream(<br>            messages=messages,<br>            cancellation_token=cancellation_token,<br>         ):<br>            self._track_response_on_streamlit(msg)<br>            <br>            # Yield the item (modified or unmodified)<br>            yield msg<br><br>    def _track_response_on_streamlit(self, msg):<br>        if isinstance(msg, ToolCallRequestEvent):<br>            content = f&quot;**[{msg.source}] Tool calls requested:**\n- &quot; + &quot;\n- &quot;.join(f&quot;`{tool.name}` with arguments `{tool.arguments})`&quot; for tool in msg.content)<br>            st.session_state[&quot;messages&quot;].append(<br>                {&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: content}<br>            )<br>            with st.chat_message(&quot;assistant&quot;, avatar=&quot;🛠️&quot;):<br>                st.markdown(content)<br>        <br>        elif (isinstance(msg, TextMessage)) and msg.source != &quot;user&quot;:<br>            self._handle_text_message(msg)<br><br>        elif isinstance(msg, Response):<br>            if isinstance(msg.chat_message, TextMessage):<br>                self._handle_text_message(msg.chat_message)<br>        else:<br>            pass<br><br>    def _handle_text_message(self, msg: TextMessage) -&gt; None:<br>        msg_content = f&quot;**[{msg.source}]**\n{msg.content.replace(&#39;TERMINATE&#39;, &#39;&#39;).strip()}&quot;<br>        st.session_state[&quot;messages&quot;].append(<br>            {&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: msg_content}<br>        )<br>        with st.chat_message(&quot;assistant&quot;):<br>            st.markdown(msg_content)</pre><p>This class is the heart of our integration. It:</p><ul><li>Extends AutoGen’s AssistantAgent</li><li>Intercepts message streams using on_messages_stream</li><li>Displays tool calls with a special 🛠️ avatar</li><li>Handles text messages with proper formatting</li><li>Maintains chat history in Streamlit’s session state</li></ul><p>The magic happens in on_messages_stream — We&#39;re essentially tapping into AutoGen&#39;s message pipeline and injecting our Streamlit rendering logic.</p><h3>Step 3: Building the Configuration Sidebar</h3><p>Every good Streamlit app needs a clean configuration interface. Let’s create a sidebar for our settings:</p><pre>async def reset_chat():<br>    &quot;&quot;&quot;Clear the chat history.&quot;&quot;&quot;<br>    if &quot;messages&quot; in st.session_state:<br>        st.session_state[&quot;messages&quot;] = []<br>    if &quot;agent&quot; in st.session_state:<br>        await st.session_state[&quot;agent&quot;].reset()<br><br>gh_pat = None<br>model = None<br><br>with st.sidebar:<br>    st.header(&quot;Configuration&quot;)<br>    gh_pat = st.text_input(<br>        &quot;GitHub Personal Access Token (PAT)&quot;,<br>        placeholder=&quot;Enter your GitHub PAT here&quot;,<br>        type=&quot;password&quot;<br>    )<br>    model = st.selectbox(<br>        &quot;Select a model&quot;,<br>        options=[&quot;gpt-4o-mini&quot;, &quot;gpt-4o&quot;, &quot;o1-mini&quot;, &quot;o1&quot;],<br>        index=0<br>    )<br><br>    st.text_input(<br>        &quot;Serper API Key&quot;,<br>        placeholder=&quot;Enter your Serper API key here&quot;,<br>        type=&quot;password&quot;,<br>        key=&quot;serper_api_key&quot;<br>    )<br>    st.info(&quot;The SERPER API key is needed for the agent to perform web searches.&quot;)<br><br>    st.button(<br>        &quot;New Chat&quot;,<br>        on_click=lambda: asyncio.run(reset_chat()),<br>        type=&quot;secondary&quot;,<br>        use_container_width=True<br>    )</pre><p>This sidebar provides an interface for users to enter the following:</p><ul><li>GitHub PAT input for authenticating with GitHub Models</li><li>The GitHub Model of choice, using the selection dropdown</li><li>Serper API key for web search functionality</li><li>A “New Chat” button to reset conversations</li></ul><h3>Step 4: Handling Async Operations in Streamlit</h3><p>One of the trickiest parts of this integration is handling asyncio properly in Streamlit. AutoGen 0.4+ relies heavily on async operations, which require careful event loop management. Here’s how we set it up:</p><pre># Initialize chat history<br>if &quot;messages&quot; not in st.session_state:<br>    st.session_state[&quot;messages&quot;] = []<br><br># Solution for Windows users<br>if sys.platform == &quot;win32&quot;:<br>    asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())<br><br># Ensure the event loop is created only once<br>if &quot;event_loop&quot; not in st.session_state:<br>    st.session_state[&quot;event_loop&quot;] = asyncio.new_event_loop()<br>    asyncio.set_event_loop(st.session_state[&quot;event_loop&quot;])</pre><p>This code handles a crucial aspect of Streamlit integration:</p><ul><li><strong>Session state management</strong> for persistent chat history</li><li><strong>Windows compatibility</strong> with the ProactorEventLoopPolicy</li><li><strong>Event loop persistence</strong> across Streamlit reruns</li></ul><p>Without this setup, you’d encounter various async-related errors when running on different platforms.</p><h3>Step 5: Adding Web Search Capabilities</h3><p>Our Career Mentor Agent may need to occasionally browse the web to access real-time information about job markets, company insights, and industry trends.</p><p>To give it the power of web search, let’s define a web search tool (powered by Serper) that it will use:</p><pre>def serper_web_search(query: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    Perform a web search using the Serper API and return the results.<br>    &quot;&quot;&quot;<br>    url = &quot;https://google.serper.dev/search&quot;<br>    payload = json.dumps({<br>        &quot;q&quot;: query,<br>        &quot;gl&quot;: &quot;in&quot;<br>    })<br>    headers = {<br>        &#39;X-API-KEY&#39;: st.session_state[&quot;serper_api_key&quot;],<br>        &#39;Content-Type&#39;: &#39;application/json&#39;<br>    }<br>    response = requests.request(&quot;POST&quot;, url, headers=headers, data=payload)<br>    if response.status_code != 200:<br>        return f&quot;Error: {response.status_code} - {response.text}&quot;<br>    return response.text</pre><p>While a Career Mentor Agent could have actually existed without web search capabilities, I added this tool to this agent just to demonstrate how a tool invocations (apart from usual agent messages) can be rendered in Streamlit.</p><h3>Step 6: Initialising the Agent</h3><p>Now let’s create our career mentor agent with all the bells and whistles:</p><pre>def initialize_agent(gh_pat: str, model: str):<br>    model_client = AzureAIChatCompletionClient(<br>        model=model,<br>        endpoint=&quot;https://models.inference.ai.azure.com&quot;,<br>        credential=AzureKeyCredential(gh_pat),<br>        model_info={<br>            &quot;json_output&quot;: True,<br>            &quot;function_calling&quot;: True,<br>            &quot;vision&quot;: True,<br>            &quot;family&quot;: &quot;unknown&quot;,<br>        },<br>    )<br><br>    career_mentor_agent = TrackableAssistantAgent(<br>        name=&quot;CareerMentorAgent&quot;,<br>        description=&quot;An agent that provides career advice and mentorship.&quot;,<br>        model_client=model_client,<br>        tools=[serper_web_search] if st.session_state.get(&quot;serper_api_key&quot;) else [],<br>        system_message=&quot;You are a Career Mentor Agent with deep expertise in career development, professional growth, and industry trends. Your goal is to provide thoughtful, strategic, and actionable advice to help users navigate career challenges, make informed decisions, and achieve long-term success. Use the tools at your disposal whenever required. Offer clear, empathetic guidance based on your knowledge, considering the user&#39;s background and goals. If the question is outside the domain of career development, politely redirect the user to a more appropriate topic. You must end with the word &#39;TERMINATE&#39; only at the end of your final response.&quot;<br>    )<br><br>    termination_condition = TextMentionTermination(&quot;TERMINATE&quot;)<br>    return RoundRobinGroupChat([career_mentor_agent], termination_condition)</pre><p>This initialisation:</p><ul><li>Sets up the Azure AI client using GitHub Models</li><li>Creates our custom trackable agent with career mentorship expertise</li><li>Conditionally adds web search tools based on API key availability</li><li>Defines clear termination conditions</li></ul><p>Wait, you might be scratching your head right now — why are we using RoundRobinGroupChat for what&#39;s clearly a single agent? Great question!</p><p>Here’s the thing: AutoGen’s AssistantAgent is designed to be methodical. It executes one step at a time – makes a model call, performs any necessary tool calls (sometimes in parallel), maybe does some reflection, and then... stops. It&#39;s like having a brilliant assistant who completes one task perfectly but then waits for your next instruction.</p><p>But we want our Career Mentor Agent to be more autonomous, right? To achieve this continuous operation until a termination condition is met (like when it decides it’s provided a complete answer), AutoGen requires us to wrap our single agent in what they call a <em>Single Agent Team</em>.</p><blockquote>This pattern might seem a bit quirky at first, but it’s actually quite elegant — it means the same architecture scales beautifully when you’re ready to add more agents to your team.</blockquote><h3>Step 7: Bringing It All Together — The Chat Interface</h3><p>Finally, let’s implement the main chat functionality:</p><pre>if not (gh_pat and model):<br>    st.warning(&quot;Please enter your GitHub PAT and select a model to continue.&quot;)<br>else:<br>    # Initialize the agent with the provided GitHub PAT and model<br>    st.session_state[&quot;agent&quot;] = initialize_agent(gh_pat, model)<br><br>    # Display chat history messages<br>    for message in st.session_state[&quot;messages&quot;]:<br>        with st.chat_message(message[&quot;role&quot;]):<br>            st.markdown(message[&quot;content&quot;])<br>    <br>    user_query = st.chat_input(&quot;How can I help you with your career?&quot;)<br><br>    if user_query:<br>        if user_query.strip() == &quot;&quot;:<br>            st.warning(&quot;Please enter a query.&quot;)<br>        else:<br>            st.session_state[&quot;messages&quot;].append({&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: user_query})<br>            <br>            with st.chat_message(&quot;user&quot;):<br>                st.markdown(user_query)<br><br>            async def initiate_chat():<br>                await st.session_state[&quot;agent&quot;].run(<br>                    task=[TextMessage(content=user_query, source=&quot;user&quot;)],<br>                    cancellation_token=CancellationToken(),<br>                )<br>                st.stop()<br><br>            st.session_state[&quot;event_loop&quot;].run_until_complete(initiate_chat())</pre><p>This section orchestrates the entire user interaction:</p><ol><li><strong>Validates credentials</strong> before allowing chat</li><li><strong>Initialises the agent</strong> using the GitHub PAT &amp; selected Model</li><li><strong>Displays chat history</strong> on each page load</li><li><strong>Handles user input</strong> with proper validation</li><li><strong>Runs the async agent</strong> within our managed event loop</li></ol><h3>Taking Your Career Mentor for a Spin</h3><p>Now it’s time to test your creation! Run the application:</p><pre>streamlit run career-mentor-agent.py</pre><p>Try asking questions like:</p><ul><li><em>“I’m a software engineer with 3 years of experience. Should I switch to AI/ML?”</em></li><li><em>“What’s a fresher’s salary in 2025 at companies like Google, Microsoft &amp; Amazon in India?”</em></li><li><em>“What are the current job market trends for data scientists?”</em></li><li><em>“How can I negotiate a better salary in my next role?”</em></li></ul><p>Watch as your agent searches the web for current information and provides personalised, actionable advice!</p><p>Meanwhile, I’ve already deployed this agent to Streamlit cloud — so you can try it out 👇</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fcareer-mentor-agent.streamlit.app%2F%3Fembed%3Dtrue&amp;display_name=Streamlit&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fcareer-mentor-agent.streamlit.app%2F&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fstorage.googleapis.com%2Fs4a-prod-share-preview%2Fdefault%2Fst_app_fallback_image.png&amp;type=text%2Fhtml&amp;schema=streamlit" width="560" height="630" frameborder="0" scrolling="no"><a href="https://medium.com/media/01b2d90793bd789b02c46cf6bc27677e/href">https://medium.com/media/01b2d90793bd789b02c46cf6bc27677e/href</a></iframe><p>The entire project, including setup instructions and additional examples, is available in my GitHub repository 👇</p><p><a href="https://github.com/tezansahu/streamlit-ui-for-autogen-agentchat">GitHub - tezansahu/streamlit-ui-for-autogen-agentchat: Integrating Streamlit UI for Agents created using AutoGen AgentChat (v0.4+)</a></p><p>Feel free to clone it, experiment with it, and make it your own!</p><h3>Extending and Customising Your Agent</h3><p>The beauty of this architecture lies in its extensibility. You can easily:</p><h4>Add More Tools</h4><pre>def linkedin_scraper(...):<br>    # Implementation...<br><br>def resume_analyzer(...):<br>    # Implementation...<br><br>career_mentor_agent = TrackableAssistantAgent(<br>    ...<br>    tools=[serper_web_search, linkedin_scraper, resume_analyzer],<br>    ...<br>)</pre><h4>Create Multi-Agent Teams</h4><pre>career_mentor = TrackableAssistantAgent(...)<br>industry_researcher = TrackableAssistantAgent(...)<br>interview_coach = TrackableAssistantAgent(...)<br><br>team = RoundRobinGroupChat([career_mentor, industry_researcher, interview_coach])</pre><h4><strong>Customise the UI</strong></h4><ul><li>Add file upload for resume analysis</li><li>Include data visualisation for market trends</li><li>Implement conversation export features</li></ul><p>Congratulations! You’ve just built a sophisticated AI agent with a beautiful web interface using the latest AutoGen 0.4+ and Streamlit. This isn’t just a tutorial project — it’s a robust blueprint that you can adapt for countless applications.</p><p>The TrackableAssistantAgent class you&#39;ve created serves as a powerful blueprint for future projects. You can use it as-is for your projects or modify it to suit specific needs.</p><p>Want to see it in action with a different use case? Check out my <a href="https://github.com/tezansahu/ai-garage/tree/master/data-analyst-agent-autogen">Data Analyst Agent project</a>, where I’ve applied similar principles to create a multi-agent data analysis system.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fembed%2FaVxbSUrsEq4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fwww.youtube.com%2Fwatch%3Fv%3DaVxbSUrsEq4&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.ytimg.com%2Fvi%2FaVxbSUrsEq4%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddedb0e5d030fa0e178dadb0c3c9dd72/href">https://medium.com/media/ddedb0e5d030fa0e178dadb0c3c9dd72/href</a></iframe><p>You can try it out here 👇</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fdata-analyst-agent.streamlit.app%2F%3Fembed%3Dtrue&amp;display_name=Streamlit&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fdata-analyst-agent.streamlit.app&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fstorage.googleapis.com%2Fs4a-prod-share-preview%2Fdefault%2Fst_app_screenshot_image%2F7d25108f-1d22-4867-9479-ea3dfcf2e02a%2FHome_Page.png&amp;type=text%2Fhtml&amp;schema=streamlit" width="560" height="630" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8f7382f5ef82c245f745f19ec2ca97/href">https://medium.com/media/9c8f7382f5ef82c245f745f19ec2ca97/href</a></iframe><p>The era of clunky command-line AI agents is over. With this integration pattern, you’re equipped to build professional-grade AI applications that users will love to interact with. The combination of AutoGen’s powerful agent framework with Streamlit’s elegant UI capabilities opens up endless possibilities for creating intelligent, user-friendly applications.</p><p>Now go forth and build something amazing! The AI agent revolution is just getting started, and you’re now equipped with the tools to be part of it.</p><h3>About the Author</h3><p>Hey folks! 👋🏼</p><p>I’m <strong>Tezan Sahu</strong>, a Software Engineer 2 (&amp; Ex-Data &amp; Applied Scientist 2) at <strong>Microsoft</strong>, an <strong><em>Amazon #1 Bestselling Author</em></strong> (for the book “<a href="https://www.amazon.in/Beyond-Code-Strategies-Technical-Scientists-ebook/dp/B0BW8MJW6G/"><strong>Beyond Code</strong></a>”), and co-author of “<a href="https://the-vision-debugged.beehiiv.com/"><strong>The Vision, Debugged</strong></a>” AI newsletter.</p><p>I am passionate about helping aspiring data scientists &amp; software developers kickstart their careers, deliver consistent impact &amp; become differentiated professionals in the field of AI &amp; Data Science.</p><p>If you are interested in learning more about how to stay ahead of the curve in the data science industry and boost your results with actionable tips in leadership &amp; mindset, <a href="https://www.linkedin.com/in/tezan-sahu/">connect with me on LinkedIn</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PVYmw8cXPNQXEtZu.png" /></figure><p>This story is published on <a href="https://generativeai.pub/">Generative AI</a>. Connect with us on <a href="https://www.linkedin.com/company/generative-ai-publication">LinkedIn</a>.</p><p>Subscribe to our <a href="https://www.generativeaipub.com/">newsletter</a> and <a href="https://www.youtube.com/@generativeaipub">YouTube</a> channel to stay updated with the latest news and updates on generative AI. Let’s shape the future of AI together!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*JC-LbpNBuhLdwt7a.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5e9e6bd1b2c" width="1" height="1" alt=""><hr><p><a href="https://generativeai.pub/building-interactive-ai-agents-a-complete-guide-to-integrating-autogen-0-4-with-streamlit-ui-d5e9e6bd1b2c">Building Interactive AI Agents: A Complete Guide to Integrating AutoGen 0.4+ with Streamlit UI</a> was originally published in <a href="https://generativeai.pub">Generative AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Turned IPL Stats into a Mesmerizing Bar Chart Race]]></title>
            <link>https://medium.com/data-science/how-i-turned-ipl-stats-into-a-mesmerizing-bar-chart-race-9ba48084b0c0?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ba48084b0c0</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[bar-chart-race]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-storytelling]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 07:02:08 GMT</pubDate>
            <atom:updated>2024-10-10T01:04:04.204Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide to creating captivating animated visualizations for data storytelling</h4><p><strong><em>Have you ever scrolled through social media, mesmerized by those animated charts showing the rise and fall of populations, companies, or even meme stocks?</em></strong></p><p>I know I have — like many of you, I’ve always been fascinated by those animated visualizations that pop up on my social media feeds. You know the ones — mesmerizing <strong><em>bar chart races</em></strong> showing population growth, or <strong><em>moving bubble charts</em></strong> illustrating how people spend their time throughout the day. I’d watch them on repeat, marvelling at the stories they told without a single word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kXE5BMmUPt_2ZrBo.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a8nK5bVzCNq2-8DL.gif" /><figcaption>Examples of animated charts — Bar Chart Race (left) &amp; Moving Bubble Chart (right)</figcaption></figure><p>So, I thought to myself: <em>“Let’s try creating one! And even better is we could do so in a low-code fashion!”</em></p><p><em>Here’s a confession: Although I’ve been a data &amp; applied scientist for a while now, I did not know that such charts were called “animated charts”, or that these specific types of charts were called “bar chart race”, etc. until recently.</em></p><p>In this post, I share how I took the plunge &amp; went about creating my first stunning animated visualization. This is a glimpse of the final output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*UIdx2hd5dCaLYH1ehwpMBA.gif" /><figcaption>A portion (2020–24) of the final visualization (created by author)</figcaption></figure><h3>Why animated visualizations?</h3><p>In our fast-paced digital world, capturing and maintaining audience attention is more challenging than ever. This is where animated visualizations shine. They can:</p><ol><li>Convey complex trends over time in an easily digestible format</li><li>Engage viewers emotionally, making data more memorable</li><li>Encourage exploration and discovery within datasets</li><li>Simplify the communication of key insights to non-technical audiences</li></ol><p>As data professionals, it’s crucial we stay abreast of these powerful storytelling tools. Let’s dive into how we can leverage them effectively.</p><h3>So, where do I start?</h3><p>As an avid cricket enthusiast, I knew I wanted to do something related to the <strong><em>Indian Premier League (IPL)</em></strong>. But I didn’t want to create just another run-of-the-mill visualization. No, I wanted something that would make even the most casual cricket fan sit up and take notice.</p><p>That’s when it hit me: <em>what if I could show the number of wins for each IPL team over time? </em>It would be like watching the entire history of the IPL unfold before your eyes!</p><p>A quick search on Kaggle led me to a goldmine — <a href="https://www.kaggle.com/datasets/patrickb1912/ipl-complete-dataset-20082020?select=matches.csv">a comprehensive IPL dataset containing match results from 2008 to 2024</a>. I downloaded it faster than Jasprit Bumrah’s yorker and saved it as ipl_matches_2008-2024.csv.</p><p><a href="https://www.kaggle.com/datasets/patrickb1912/ipl-complete-dataset-20082020?select=matches.csv">IPL Complete Dataset (2008-2024)</a></p><p>Now armed with my dataset, I faced the daunting question: <em>how on earth do I turn this into one of those fancy animated charts?</em></p><p>While I’m comfortable with coding visualizations from scratch using Python, I was intrigued by the potential efficiency of low-code tools. Enter <a href="https://flourish.studio/visualisations/bar-chart-race/"><strong>Flourish</strong></a><strong> </strong>— a tool I stumbled upon that promised to help create stunning visualizations without coding — how cool is that!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*iX30i7Vr4wGam6TXz1bqIQ.png" /><figcaption>Stumbled upon “Flourish” while searching for a tool to create the animated visualization</figcaption></figure><p>The range of options for visualisations provided by Flourish is great (even for free-tier usage). On selecting the “Bar chart race” option, followed by clicking the “Data” toggle, I was quickly able to understand the data requirements for Flourish to generate a bar chart race visualization for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xhmZxytvpUNHeOSd5nyP8g.png" /><figcaption>Understanding the data requirements in Flourish</figcaption></figure><h3>The Data Wrangling</h3><p>Of course, the raw IPL dataset was nowhere close to this format, which means I got the opportunity to leverage the power of GitHub Copilot to massage the data &amp; bring it into the required format.</p><p>Here’s the sequence of interactions I had with GitHub Copilot to help me convert the raw IPL data into the desired format (with a bunch of interesting IPL-related nuances):</p><p>As a first step, I broadly explained the format that the dataset was originally in, and how I wanted the final representation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10bf85c077f967702f82b8e57767d9c0/href">https://medium.com/media/10bf85c077f967702f82b8e57767d9c0/href</a></iframe><p>Here’s the result returned by GitHub Copilot:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03946ac4034fb074b126ccc3c474c9f4/href">https://medium.com/media/03946ac4034fb074b126ccc3c474c9f4/href</a></iframe><p>I was pleasantly surprised to find that this piece of code was <em>almost </em>correct in the first go itself! The process shown is simple:</p><p>After extracting the unique dates of each match &amp; the unique teams, initialize a data frame with teams as rows &amp; dates as columns. Now, iterate through each date &amp; do the following:</p><ol><li>Filter matches up to the current date</li><li>Calculate the cumulative wins for each team</li><li>Update the DataFrame with the cumulative wins</li></ol><p>The only hiccup here was this extra piece of code — removing which, did the trick for me:</p><pre># Ensure cumulative sum<br>if date != unique_dates[0]:<br>    cumulative_wins.at[team, date] += cumulative_wins.at[team, unique_dates[unique_dates.index(date) - 1]]</pre><p>cumulative_wins.head() resulted in the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k9w1BQi9KRUgCq62qopomA.png" /></figure><p>But wait, there’s more! The IPL, like any good drama, has its own twists and turns…</p><h3>Dealing with the Nuances of IPL</h3><p>Although this data, by itself, is <em>sufficient </em>to be visualized in Flourish as a bar chart race, I decided to address some of the nuances of IPL that will give the visualization a more realistic feel.</p><h4>Team Renaming</h4><p>Throughout the IPL history, there have been multiple occasions where franchise owners changed, leading to the rebranding of the teams <em>Remember when </em><strong><em>Deccan Chargers </em></strong><em>transformed into </em><strong><em>Sunrisers Hyderabad</em></strong><em>?</em></p><p>In the dataset, these are considered separate teams in separate rows, where post renaming, the old team continues to stay with the cumulative number of wins until that year, while the new team starts afresh with 0 wins.</p><p>To change this, I tried out the following prompts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/691201b6de70f65bea23417463f25381/href">https://medium.com/media/691201b6de70f65bea23417463f25381/href</a></iframe><p>With a couple of minor fixes, this is what the resulting code looked like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/064c75adac1a5d929ba714c2c1baf77b/href">https://medium.com/media/064c75adac1a5d929ba714c2c1baf77b/href</a></iframe><p>Now, to generalize this &amp; apply it across the various changes, I tried converting his into a function &amp; used Bing to figure out the years of these major team changes, before applying the function to them:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0aa81aa6486f959f94c0586d92603c2a/href">https://medium.com/media/0aa81aa6486f959f94c0586d92603c2a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85b3edb6940c891dec12bb293cf36f59/href">https://medium.com/media/85b3edb6940c891dec12bb293cf36f59/href</a></iframe><p>Awesome! I was able to account for all the franchise changes that happened over the years. Still, one thing bothered me…</p><h4>Defunct Teams</h4><p>A bunch of teams in the IPL appeared in just a couple of editions &amp; then faded away. Their presence in the final visualisation after them being made defunct seemed unnecessary.</p><p>So, I tried to have them removed after their final appearance using the following prompt:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f143347758722d32c1565be783b44c7/href">https://medium.com/media/7f143347758722d32c1565be783b44c7/href</a></iframe><p>This gave me another neat function, which I could apply to the teams that went defunct over the years (again, I found this data from Bing).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70d6bb2a354f87fdb9d5efdd4e689821/href">https://medium.com/media/70d6bb2a354f87fdb9d5efdd4e689821/href</a></iframe><h4>Team Logos</h4><p>In the demo data in Flourish, I observed that one column contained links to images that could be used for each bar in the bar chart race.</p><p>To make my visualization pop out, I wished to do something similar. So, I found the images for the logos for each of the unique teams in our dataset &amp; added them to a new column:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18cefcdde87107402e1dd768e0768f37/href">https://medium.com/media/18cefcdde87107402e1dd768e0768f37/href</a></iframe><p>This small touch significantly enhances the viewer’s ability to track teams throughout the animation</p><p>And now, I was all set to create the visualization!</p><h3>Bringing It All Together</h3><p>With our data primed and polished, it was time for the main event!</p><p>Uploading to Flourish was a piece of cake —it was automatically able to identify the <strong><em>Label</em></strong>, <strong><em>Values </em></strong>&amp; <strong><em>Image </em></strong>columns correctly.</p><p>Switching to the <strong><em>Preview </em></strong>toggle, I had something that almost resembled what I had envisioned — a couple of setting changes here &amp; there, and we were done.</p><p>Following are the changes I made:</p><ul><li>Used “<strong><em>Labels on bars (images in axis)</em></strong>” as the “<strong><em>Labels mode</em></strong>” under <strong><em>Labels</em></strong> for a sleek look</li><li>Set image <strong><em>sizing </em></strong>to &quot;<strong><em>Fit</em></strong>&quot; and <strong><em>shape </em></strong>to &quot;<strong><em>Rectangle</em></strong>&quot; for crisp logos</li><li>Reduced the <strong><em>Size %</em></strong> of the <strong><em>Current Time Counter</em></strong> &amp; <strong><em>Totalizer </em></strong>under <strong><em>Counter &amp; Totalizer</em></strong> for balance</li></ul><p>And there you have it — from a simple CSV file to a dynamic, engaging visualization that tells the story of IPL team performances over the years — with just a dash of creativity and a sprinkle of data magic. 🎉</p><p><strong>Here’s the final output👇🏼</strong></p><iframe src="https://flo.uri.sh/visualisation/19680784/embed" width="700" height="575" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2effadd35f0eed29f0da9e200184cdb/href">https://medium.com/media/b2effadd35f0eed29f0da9e200184cdb/href</a></iframe><h3>Key Takeaways for Data Professionals</h3><p>This simple-yet-engaging project holds several valuable insights for data scientists and analysts looking to enhance their storytelling toolkit:</p><ol><li><strong>Low-Code Doesn’t Mean Low-Quality: </strong>Tools like Flourish can produce sophisticated visualizations that rival custom-coded solutions.</li><li><strong>Data Prep Remains Critical: </strong>Our data science skills are invaluable in preparing and structuring data for effective visualization.</li><li><strong>Efficiency Gains:</strong> For certain projects, low-code tools can significantly reduce time-to-insight without sacrificing quality.</li><li><strong>Accessibility: </strong>These tools can help bridge the gap between data teams and non-technical stakeholders, facilitating better communication of insights.</li></ol><p>As data professionals, it’s easy to get caught up in the power of our coding skills. However, it is essential to remember the importance of staying open to new tools and approaches. Low-code visualization platforms like Flourish don’t replace our expertise — they enhance it, allowing us to create compelling data stories more efficiently.</p><p>By combining our deep understanding of data manipulation and statistical analysis with the rapid prototyping capabilities of these new tools, we can elevate our data storytelling to new heights. Whether you’re presenting to executives, creating content for social media, or exploring data for your own insights, consider adding low-code visualization tools to your repertoire.</p><p>The future of data science isn’t just about crunching numbers — it’s about telling stories that resonate. By embracing tools that amplify our ability to create engaging visualizations, we can ensure that our insights don’t just inform, but inspire and drive action.</p><h3>About the Author</h3><p>Hey folks! 👋🏼</p><p>I’m <strong>Tezan Sahu</strong>, a Software Engineer 2 (&amp; Ex-Data &amp; Applied Scientist 2) at <strong>Microsoft</strong>, an <strong><em>Amazon #1 Bestselling Author</em></strong> (for the book “<a href="https://www.amazon.in/Beyond-Code-Strategies-Technical-Scientists-ebook/dp/B0BW8MJW6G/"><strong>Beyond Code</strong></a>”), and co-author of “<a href="https://the-vision-debugged.beehiiv.com/"><strong>The Vision, Debugged</strong></a>” AI newsletter.</p><p>I am passionate about helping aspiring data scientists &amp; software developers kickstart their careers, deliver consistent impact &amp; become differentiated professionals in the field of AI &amp; Data Science.</p><p>If you are interested in learning more about how to stay ahead of the curve in the data science industry and boost your results with actionable tips in leadership &amp; mindset, <a href="https://www.linkedin.com/in/tezan-sahu/">connect with me on LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba48084b0c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-i-turned-ipl-stats-into-a-mesmerizing-bar-chart-race-9ba48084b0c0">How I Turned IPL Stats into a Mesmerizing Bar Chart Race</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Cricket: The Leadership Secrets Behind India’s T20 World Cup Victory]]></title>
            <link>https://tezansahu.medium.com/beyond-cricket-the-leadership-secrets-behind-indias-t20-world-cup-victory-50f66c83c024?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/50f66c83c024</guid>
            <category><![CDATA[team-india]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[t20-world-cup]]></category>
            <category><![CDATA[winner-mindset]]></category>
            <category><![CDATA[leadership-lessons]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Sun, 30 Jun 2024 09:38:31 GMT</pubDate>
            <atom:updated>2024-06-30T09:38:31.300Z</atom:updated>
            <content:encoded><![CDATA[<h4>6 Timeless Lessons from the Men in Blue’s Triumphant Journey</h4><p>Witnessing India break their ICC T20 World Cup trophy drought by defeating South Africa in a thrilling final was nothing short of spectacular! 🤩🏆</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*53Zxi79ntF84C_X7" /><figcaption>Team India — Champions of the ICC T20 World Cup 2024 (source: MSN)</figcaption></figure><p>A match that wasn’t just about cricket but about overcoming past failures, defying odds, and rewriting history. The air was electric with excitement, memes, and high-stakes drama as the “Generational chokers” <em>(South Africa, who historically faltered in semi-finals)</em> faced off against the “Chokers of the Decade”<em> (India, known for their near-misses in finals)</em>.</p><p>With both sides unbeaten in this tournament, the tension was palpable, and the stakes couldn’t have been higher. This wasn’t just a cricket match; it was a riveting lesson in leadership, resilience, and mindset that transcends the sport.</p><p><strong>Here are some of my favourite life lessons from this unforgettable victory…</strong></p><blockquote><strong>“The greatest glory in living lies not in never falling, but in rising every time we fall” </strong>— Nelson Mandela</blockquote><p>Indian Cricket fans will hardly ever forget the date “<em>19th November 2023</em>” — that heartbreak was real. Virat Kohli and Rohit Sharma, arguably the two best batsmen of this generation, had come agonizingly close to a World Cup trophy yet again. The gut-wrenching defeat stung, for them and for millions of fans who’d been yearning for this moment for ages.</p><p>Just 7 months later, our Men in Blue defied the odds, defeating every opposition in their way (while also avenging the previous defeats at the hands of Australia &amp; England) &amp; finally lifting the ICC T20 World Cup.</p><p>Talk about picking yourself up, dusting yourself off, and reminding everyone why they’re the best in the business!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*MTmG9cSNhRjJScefrL2nHA.png" /><figcaption>From the disappointment of losing the WC 2023 finals to the exhilaration of winning the T20 WC in 2024 (source: sportstiger.com)</figcaption></figure><p>This win wasn’t just a trophy — it was a masterclass in resilience. Indeed, this was the last T20 World Cup for this legendary duo (and for Rahul Dravid as well, as coach of the Indian team), and they ensured that they got the farewell they deserved!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*bRpuygkozO9zsd3Rk6kpAA.png" /><figcaption>The happy faces of Virat Kohli (left), Rahul Dravid (centre) &amp; Rohit Sharma (right) after the T20 WC victory (source: indiatimes.com)</figcaption></figure><blockquote>“It is during our darkest moments that we must focus to see the light” — Aristotle</blockquote><p>Even the best folks have their bad days. As a leader, it’s your responsibility to recognize rough patches that your key team members might be undergoing &amp; back them up at critical moments, instilling the lost confidence.</p><p>Backing the mighty Virat Kohli after the string of low scores in this tournament, Rohit Sharma proclaimed in the post-match presentation after the Semi-Final win (against England) that perhaps Virat is saving the best for the Finals — and boy did prove his skipper true!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*XTlJpIkTC8hCvNdlI0YIkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*LUnNzqEjAWl2eVHit0XVlA.png" /><figcaption>Rohit Sharma backing Virat Kohli, and then Virat showing why he is considered the “King” of Cricket (source: espncricinfo.com)</figcaption></figure><p>Despite a slow start, his 76 off 59 balls was instrumental in stabilizing the Indian innings after early wickets. He also won the “Player of the Match” award for this sublime innings.</p><blockquote>“Peace is not the absence of noise, but the ability to be still in the presence of it.” — Wayne Dyer (American writer)</blockquote><p>Hardik Pandya had been caught up amidst a bunch of drama of late—he was trolled during the IPL, there were some serious rumours around his personal life, and even his inclusion in the World Cup squad was questioned by critics.</p><p>Despite of all this noise around him, he managed to deliver throughout this campaign as an impactful all-rounder, taking a total of 11 wickets &amp; scoring crucial runs on several occasions. On the big stage too, he kept himself calm &amp; composed, focused well on his strategies, &amp; nailed the final over — scalping 2 critical wickets and defending 16 runs to ensure India’s triumph.</p><p>His emotional statement after winning the cup, truly showcases what this win meant to him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*u8N2zTkm3CdmRh-uGKbP_A.png" /><figcaption>Hardik Pandya’s interview statement after the win (source: instagram.com)</figcaption></figure><p>This entire episode does strike a chord with the dialogue from the movie 1983, where Ranveer Singh <em>(playing Kapil Dev) </em>tells Ammy Virk <em>(playing Balwinder Sandhu)</em>:</p><blockquote><em>“Ground Ke Bahar Hamare Life Mein Kuch Bhi Ho Raha Ho Jab Hum Yeh Uniform Pehenkar Ground Mein Utarte Hain Toh Humara Ek Hi Maqsad Hota Hai — Jaan Lagake Desh Ke Liye Khelna.”</em></blockquote><blockquote>(Translation: No matter what’s happening in our lives outside the ground, when we don this uniform and step onto the field, we have only one goal — to play with all our might for the country.)</blockquote><blockquote>“Be so good they can’t ignore you.” — Steve Martin (American actor)</blockquote><p>The magic wielded by Jasprit Bumrah with the ball throughout the tournament made him the trump card for India &amp; a nightmare for any batter. The fear of his lethal array of tactics stifled many a team, leaving them with the only option to respect his spell &amp; see through his 4 overs rather carefully (which is exemplified by his <em>unreal </em>economy of 4.17 runs/over &amp; 18 wickets during this World Cup campaign).</p><p>In the Finals too, he was instrumental in providing early breakthroughs, setting the tone of the match &amp; keeping the team’s morale high. No wonder, he was the recipient of the “Player of the Tournament”!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*ot3mz9DZRqNEfGao_5eoGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*V_44vQztmbQ_i5lo_APThA.png" /><figcaption>Jasprit Bumrah — the pillar of the Indian bowling unit, working his magic once again for the team to deliver when required (source: BCCI.tv)</figcaption></figure><blockquote>“No one can whistle a symphony. It takes a whole orchestra to play it.” — H.E. Luccock (American Methodist minister)</blockquote><p>This has been the story of this Indian team — every match had its moments &amp; heroes. From the fierce batting to clinical bowling &amp; some stunning fielding, every player played their part.</p><p>Whether it was the blistering start by Rohit against Australia, the heroics of Rishabh Pant against Pakistan, or the spin wizardry by Axar Patel &amp; Kuldeep Yadav in the Semi-Final vs England — on every occasion, there was someone to save the day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*cVRzoS6jmaxbfXE6.jpg" /><figcaption>Everyone in the team stepped up &amp; played their part when called upon (source: MSN)</figcaption></figure><p>In the Finals too, the partnership by Virat &amp; Axar, the critical wickets of Klaasen taken by Hardik, and the stunner of David Miller’s catch taken by Suryakumar Yadav — these were all major moments in the match that led to this victory, and it wouldn’t have been possible without the unflinching contributions of the entire team.</p><blockquote>It ain’t over till it’s over — Yogi Berra (baseball player and manager)</blockquote><p>Clinching this victory from the jaws of defeat was nothing short of a spectacle! At one stage, the Proteas needed just 30 runs off 30 balls, with the “win predictor” predicting less than a 5% chance of India’s win.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qc-Az7D-whXhWKa4" /><figcaption>Win predictor throughout the T20 WC Finals b/w India &amp; South Africa (source: Twitter)</figcaption></figure><p>Believe you can and you’re halfway there — this Indian side fought till the end with unwavering faith, ensuring victory although the odds were stacked against them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*eH3REQ0Ex9ll_9-TozXhSg.png" /><figcaption>The Men in Blue celebrating after winning the ICC T20 World Cup 2024 (source: Instagram)</figcaption></figure><p>As we celebrate this historic triumph, it’s clear that this Indian team embodied more than just cricketing prowess — they showcased the essence of resilience, teamwork, and unwavering belief. This 2024 T20 World Cup will forever be etched in our memories, not just as a glorious victory, but as an enduring reminder that with grit, heart, and a bit of magic, even the most daunting challenges can be overcome.</p><p>Hats off to the Indian team, the coaches, and the support staff for giving us moments we’ll cherish forever. Here’s to celebrating this monumental win and carrying forward these timeless lessons in our own lives!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*-W8xnHd3xPdrzn76ZF97vA.png" /><figcaption>Team India — Champions of the ICC T20 World Cup 2024 (source: BCCI.TV)</figcaption></figure><p><em>PS: Kudos to the Proteas as well for breaking the semi-final ‘jinx’ this year &amp; playing some fantastic cricket in the finals — they did keep us at the edge of our seats &amp; ensured that this was a nail-biting match to watch.</em></p><h3>About the Author</h3><p>Hey folks! 👋🏼</p><p>I’m <strong>Tezan Sahu</strong>, an Applied Scientist at Microsoft, an Amazon #1 Bestselling Author (for the book “<a href="https://www.amazon.in/Beyond-Code-Strategies-Technical-Scientists-ebook/dp/B0BW8MJW6G/">Beyond Code: A Practical Guide for Data Scientists, Analysts &amp; Engineers</a>”), and co-author of “The Vision, Debugged” newsletter.</p><p>I am passionate about helping aspiring data scientists &amp; software developers kickstart their careers, deliver consistent impact &amp; become differentiated professionals in the field of AI &amp; Data Science.</p><p>If you are interested in learning more about how to stay ahead of the curve and boost your results with actionable tips in leadership &amp; mindset, <a href="https://www.linkedin.com/in/tezan-sahu/">connect with me on LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50f66c83c024" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use AI to Create Awesome Brand Images in Minutes]]></title>
            <link>https://generativeai.pub/how-to-use-ai-to-create-awesome-brand-images-in-minutes-7916d9e47595?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7916d9e47595</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[ai-use-cases]]></category>
            <category><![CDATA[branding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-marketing]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Sat, 09 Sep 2023 05:53:24 GMT</pubDate>
            <atom:updated>2024-04-08T05:36:42.508Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Step-by-Step Guide to Design Captivating Brand Identity for your Business effortlessly, using 6 Amazing AI Tools</h4><figure><img alt="AI-Generated Image of a cute robot holding a board with “Branding” written on it (generated by the author using Ideogram.AI)" src="https://cdn-images-1.medium.com/max/1024/1*VZxLGxcDqCWro6l3HwWDYQ.png" /><figcaption>AI-Generated Image of a cute robot holding a board with “Branding” written on it (generated by the author using Ideogram.AI)</figcaption></figure><p>What if I told you that <strong>you can create a stunning brand image for your business in minutes</strong>, using just six AI tools?</p><p>Sounds too good to be true, right?</p><p>Well, it’s not.</p><p>AI has revolutionized the way we do branding. AI Tools have made it 10x easier, faster, and cheaper to create a unique and memorable brand identity that resonates with your target audience.</p><p>Whether you need a catchy name and tagline, a logo that stands out, or a professional-grade branding photoshoot, AI can help you achieve it in a matter of minutes.</p><p>Don’t believe me?</p><p>Let me show you how I did it for a ‘hypothetical’ luxury chocolate brand.</p><p>It took me less than <strong><em>20 minutes</em></strong>…and this was the result!</p><figure><img alt="Final Result of the Branding Image of my hypothetical luxury chocolate brand, generated using AI Tools" src="https://cdn-images-1.medium.com/max/1024/1*80L5M_GGa5Wj1om_xL6uOQ.png" /><figcaption>Final Result of the Branding Image of my hypothetical luxury chocolate brand, generated using AI Tools</figcaption></figure><p>Pretty impressive, huh?</p><p>And the best part is, you can do it too! All you need are these six AI tools:</p><ul><li>ChatGPT <strong><em>[FREE]</em></strong></li><li>Midjourney <strong><em>[Paid, but stick till the end for a bonus tip! </em>🤩<em>]</em></strong></li><li>LunaPic <strong><em>[FREE]</em></strong></li><li>Remove.bg <strong><em>[FREE]</em></strong></li><li>Adobe Firefly <strong><em>[FREE]</em></strong></li><li>Canva<strong><em> [FREE]</em></strong></li></ul><p>Ready to create your next brand image with AI?</p><p><strong><em>Let’s get started!</em></strong></p><h3>Step 1: Craft a Memorable Name and Tagline with ChatGPT</h3><p>The first step to creating a stunning brand image is to come up with a memorable name and tagline for your business. You want your name and tagline to be catchy, unique, and relevant to your niche and audience.</p><p>But how do you come up with such brilliant ideas?</p><p>That’s where <a href="https://openai.com/chatgpt"><strong><em>ChatGPT</em></strong></a> comes in handy.</p><p>ChatGPT is an AI-powered chatbot that can generate creative suggestions for anything you ask.</p><p>For my hypothetical chocolate brand, I used ChatGPT to suggest some cool names and taglines, using simple prompts. For example, to generate 25 attention-grabbing and classy names for my luxury chocolate brand, I used this prompt:</p><blockquote><strong><em>“Suggest 25 attention-grabbing and classy names for a new luxury chocolate brand. The names can contain words in languages other than English.”</em></strong></blockquote><p><em>You can change the </em><strong><em>number of suggestions</em></strong><em> and the </em><strong><em>brand description</em></strong><em> based on your use case.</em></p><p>Here are some of the names ChatGPT came up with:</p><figure><img alt="Results obtained from ChatGPT on asking it suggestions for the name of my luxury chocolate brand" src="https://cdn-images-1.medium.com/max/1024/1*azHqsEN_ivY87qAVMc0Bcw.png" /><figcaption>Results obtained from ChatGPT on asking it suggestions for the name of my luxury chocolate brand</figcaption></figure><p>I loved the name <strong><em>“Amour Doux”</em></strong>. It sounds elegant and sophisticated, don’t you think?</p><p>Having selected the name for my luxury chocolate brand, I needed the perfect tagline to go with it. Again, I used ChatGPT for some suggestions, by prompting:</p><blockquote>“I like the name ‘Amour Doux’. Now give me 10 options for a tagline for this chocolate brand.”</blockquote><p><em>You can mention the </em><strong><em>name you chose</em></strong><em> and </em><strong><em>update the remaining portion</em></strong><em> of the prompt based on your requirements.</em></p><p>Here are some of the taglines ChatGPT suggested:</p><figure><img alt="Results obtained from ChatGPT on asking it suggestions for a memorable tagline for my luxury chocolate brand" src="https://cdn-images-1.medium.com/max/1024/1*lq7dUBJ6ixRRO6Hls9p-fw.png" /><figcaption>Results obtained from ChatGPT on asking it suggestions for a memorable tagline for my luxury chocolate brand</figcaption></figure><p>They all sound pretty good, but I decided to go with <strong><em>“A Symphony of Sweet Delights”</em></strong>. It captures the essence of my brand and appeals to the senses of my audience.</p><p>And just like that, I had my brand name and tagline ready in a few minutes.</p><p>Now, let’s move on to the visuals…</p><h3>Step 2: Design a Logo That Stands Out with Midjourney and LunaPic</h3><p>The next step to creating a stunning brand image is to design a logo that stands out from the crowd. Your logo is one of the most important visual elements of your brand identity. It represents your brand’s personality, values, and message.</p><p>But how do you design a logo that is unique, attractive, and relevant to your niche and audience?</p><p>That’s where <a href="https://www.midjourney.com/home/"><strong><em>Midjourney</em></strong></a><strong><em> </em></strong>and <a href="https://www2.lunapic.com/editor/?action=replace-color"><strong><em>LunaPic</em></strong></a><strong><em> </em></strong>come in handy.</p><ul><li>Midjourney is an AI-powered text-to-image generator that can create amazing images from any description you give.</li><li>LunaPic is an online photo editor that can help you edit and enhance your images with various effects and tools.</li></ul><p>For my hypothetical chocolate brand, I used Midjourney to create a flat vector logo of a truffle as a black line drawing on a white background using this prompt:</p><blockquote>“truffle flat vector logo, elegant, black, line drawing, white background”</blockquote><p><em>You can be creative and describe the subject and type of your logo in the prompt. Just make sure that the logo is </em><strong><em>monochromatic</em></strong><em>, so that you can change its color based on your requirements later.</em></p><p>Here are some of the logos Midjourney generated:</p><figure><img alt="Results obtained from Midjourney while designing the logo of my luxury chocolate brand" src="https://cdn-images-1.medium.com/max/1024/1*UO763c7wtx67uToQLN2pZg.png" /><figcaption>Results obtained from Midjourney while designing the logo of my luxury chocolate brand</figcaption></figure><p>The fourth image looked very similar to something I had in mind, so I clicked “U4” to upscale it…</p><figure><img alt="Upscaled image logo (finalized) for my chocolate brand, generated using Midjourney" src="https://cdn-images-1.medium.com/max/927/1*r_7VXdyIszAEwXXAUnQcDA.png" /><figcaption>Upscaled image logo (finalized) for my chocolate brand, generated using Midjourney</figcaption></figure><p>I had my basic logo ready. Now, I needed to think about the color themes for my brand.</p><p>I had envisioned the covers of my luxury chocolate brand to be a combination of <strong><em>dark cerulean blue</em></strong> and <strong><em>chrome yellow</em></strong>. Hence, I wanted to have my logos also in these primary colors.</p><p><em>Feel free to choose your own color schemes.</em></p><p>Having chosen the color schemes, I headed over to the <strong><em>Replace Color</em></strong> tool of <strong><em>LunaPic</em></strong>. I followed the following steps:</p><ul><li>Uploaded the upscaled logo</li><li>Set the new color as the hex value of chosen color(s)</li><li>Click on the black portion in the uploaded image</li></ul><p>And voila! Within seconds, your flat black logo is converted to the color of your choice.</p><figure><img alt="Interface of the “Replace Color” tool of LunaPic, that I used to convert the black monochromatic logo image into the colors for my chocolate brand" src="https://cdn-images-1.medium.com/max/1024/1*vT8B3KjSfC2bV0l36Mzjjg.png" /><figcaption>Interface of the “Replace Color” tool of LunaPic, that I used to convert the black monochromatic logo image into the colors for my chocolate brand</figcaption></figure><p>These were the results of the transformation…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*GSgFzEX31ZfWdgDSrshErg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*AMRbCaOyw6jrF7lWuCHmWw.png" /><figcaption>Results obtained by converting the black logo image to the branding colors of my chocolate brand (dark cerulean blue &amp; chrome yellow)</figcaption></figure><blockquote><strong>Note:</strong> You may have to play around a little with the “color threshold” slider to get the best result</blockquote><h3>Step 3: Combine Your Logo, Name, and Tagline with Canva and Remove.bg</h3><p>Now that you have your logo ready in different colors, you need to combine it with your name and tagline to form the complete logo.</p><p>For this, you need two more AI tools: <a href="https://www.canva.com/"><strong><em>Canva</em></strong></a><strong><em> </em></strong>and <a href="https://www.remove.bg/"><strong><em>Remove.bg</em></strong></a>.</p><ul><li>Canva is an online graphic design platform that lets you create stunning visuals for your brand with ease.</li><li>Remove.bg is an online background remover that can erase any unwanted background from your images with a single click.</li></ul><p>For my hypothetical chocolate brand, I used Canva to create a new square design. I created two pages, one for each colored logo, uploaded the images, selected some elegant fonts, and added the name and tagline of the chocolate brand.</p><p>But there was a problem — if I downloaded these images as they were from Canva, they would have a white background <em>(downloading with a transparent background requires Canva Pro)</em>.</p><p>So, I copied the images downloaded from Canva and pasted them in Remove.bg.</p><p>Remove.bg automatically detected and removed the white background from my images, leaving me with transparent logos.</p><figure><img alt="Background removal for the full brand logo using Remove.BG, another cool AI Tool" src="https://cdn-images-1.medium.com/max/1024/1*iBvuUC4-Uc-lzHgWcYUVTA.png" /><figcaption>Background removal for the full brand logo using Remove.BG, another cool AI Tool</figcaption></figure><p>Once the background was removed, I downloaded the images. This is what my final logos looked like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*lhU2HbXZqudFvOGPAaZWOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*8nIT7X5vluIKAlk1R8w8eQ.png" /><figcaption>Final combination mark logo for my chocolate brand, with the name &amp; tagline</figcaption></figure><p>They look pretty awesome, right?</p><p>But we are not done yet. We still need to use our logo on our branding image.</p><p>Let’s see how we can do that.</p><h3>Step 4: Generate a Professional Branding Image with Midjourney</h3><p>We have our logo ready, but where do we use it?</p><p>Well, now it’s time to come up with the actual image that you will use for your branding — something that will showcase your logo and name of your product or company.</p><p>But how do you create such a professional branding image without hiring a photographer or a designer?</p><p>That’s where <strong><em>Midjourney </em></strong>comes in handy again.</p><p>Midjourney can generate photorealistic images from any description you give. It can create amazing product photography for your brand in minutes.</p><p>For my hypothetical chocolate brand, I envisioned a flatlay type photoshoot with a bunch of chocolate packs on display. I generated the image using this prompt:</p><blockquote>“luxury chocolate branding flatlay photoshoot, with dark cerulean blue and chrome yellow tone, bird’s eye view perspective”</blockquote><p><em>You can modify the </em><strong><em>product description</em></strong><em>, the </em><strong><em>photoshoot type</em></strong><em>, and </em><strong><em>color tones </em></strong><em>in this prompt to generate a captivating branding image for yourself.</em></p><p>Here are some of the images Midjourney generated:</p><figure><img alt="Results obtained while generating the Professional Branding Image for my luxury chocolate brand using Midjourney" src="https://cdn-images-1.medium.com/max/1024/1*ByT_W4CbaS1qGl3yPrUk7g.png" /><figcaption>Results obtained while generating the Professional Branding Image for my luxury chocolate brand using Midjourney</figcaption></figure><p>The results from Midjourney were insane! I really liked the first image and upscaled it by clicking “U1”.</p><figure><img alt="Upscaled branding image for my chocolate brand, generated using Midjourney" src="https://cdn-images-1.medium.com/max/927/1*XElyW8eeLtV_MlIHH4pOEA.png" /><figcaption>Upscaled branding image for my chocolate brand, generated using Midjourney</figcaption></figure><p>This image looks great, but it also has some gibberish text on every box…</p><p>How do we get rid of it and introduce our own logo?</p><p>Let’s find out in the next step.</p><h3><strong>Step 5: Make It “Your” Branding Image with Adobe Firefly</strong></h3><p>We are almost there!</p><p>We have our base image ready, but we need to replace the gibberish text with our own logo. But how do we do that without messing up the image quality or realism?</p><p>That’s where <a href="https://firefly.adobe.com/"><strong><em>Adobe Firefly</em></strong></a> comes in handy.</p><p>Adobe Firefly is an AI-powered photo editing tool that can help you modify your images with natural language commands. For example, you can use Adobe Firefly to remove unwanted objects, change colors, add filters, and more.</p><p>For my hypothetical chocolate brand, I used Adobe Firefly to remove all the gibberish text from my base image using its Generative Fill feature.</p><figure><img alt="Removal of unwanted &amp; gibberish text from the branding image generated by Midjourney using Adobe Firefly" src="https://cdn-images-1.medium.com/max/1024/1*KEfL5KmsCffq_96BQjDsSA.png" /><figcaption>Removal of unwanted &amp; gibberish text from the branding image generated by Midjourney using Adobe Firefly</figcaption></figure><p>I followed these steps:</p><ul><li>Uploaded the upscaled image from Midjourney into Adobe Firefly</li><li>Clicked on “Add” and started selecting all the portions in the image containing gibberish text — basically the text at the center of each chocolate box</li><li>After selecting all of them, I simply wrote “remove text” as the prompt and hit “Continue”</li></ul><p>And within seconds, Adobe Firefly produced the resulting image — the same beautiful image, but now with all the unnecessary text removed!</p><figure><img alt="Final result obtained after using Adobe Firefly to remove text from the Midjourney-generated branding image" src="https://cdn-images-1.medium.com/max/1024/1*lOtm5fpkpaPqry_qV7l55g.png" /><figcaption>Final result obtained after using Adobe Firefly to remove text from the Midjourney-generated branding image</figcaption></figure><p>Lovely! Now this base image is fully ready for our branding.</p><p>I uploaded the cleaned base image onto Canva and then started copy-pasting the colored logos (with transparent background) onto this base image.</p><p>For my chocolate brand, I pasted contrasting logos onto each box, carefully orienting and resizing them to look absolutely realistic!</p><p>And here’s the final result!</p><figure><img alt="Final Result of the Branding Image of my hypothetical luxury chocolate brand, generated using AI Tools" src="https://cdn-images-1.medium.com/max/1024/1*80L5M_GGa5Wj1om_xL6uOQ.png" /><figcaption>Final Result of the Branding Image of my hypothetical luxury chocolate brand, generated using AI Tools</figcaption></figure><p>An absolutely gorgeous branding image for a hypothetical luxury chocolate brand, created fully using AI tools! How cool is that?</p><h3>Bonus Tip</h3><p>You might be wondering how much these AI tools cost and whether you can afford them.</p><p>Well, the good news is that most of these AI tools are FREE or have a free trial option. The only exception is <strong><em>Midjourney</em></strong>, which has a nominal monthly subscription fee.</p><p>But don’t worry, I have a solution for that too!</p><p>If you don’t want to spend any money on these AI tools, you can still use <a href="https://playgroundai.com/"><strong><em>Playground AI</em></strong></a><strong><em> </em></strong>for similar image generation capabilities.</p><p>Playground AI is a FREE online platform that lets you create amazing images from any text you type. It allows you to generate up to 1000 free images per day!</p><p>Of course, you might have to compromise on the quality and variety of the images compared to Midjourney, but hey, it’s still a great deal!</p><h3>Concluding Remarks</h3><p>You have just learned how to use AI to create a stunning brand image for your business in minutes. You have seen how AI can help you craft a memorable name and tagline, design a logo that stands out, generate a professional branding image, and make it your own with simple edits.</p><p>You have also discovered six amazing AI tools that can help you achieve all this and more:</p><ul><li><a href="https://openai.com/chatgpt">ChatGPT</a></li><li><a href="https://www.midjourney.com/home/">Midjourney</a></li><li><a href="https://www2.lunapic.com/editor">LunaPic</a></li><li><a href="https://www.remove.bg/">Remove.bg</a></li><li><a href="https://firefly.adobe.com/">Adobe Firefly</a></li><li><a href="https://www.canva.com/">Canva</a></li></ul><p>AI has not only made branding easier, faster, and cheaper than ever before, but it has also made it more fun, creative, and exciting.</p><p><strong>So, what are you waiting for? Start creating your stunning brand image with AI today!</strong></p><p>And do share your experience with me in the comments below 👇</p><p>I’d love to know more about your journey, see what you create &amp; help you out wherever required.</p><p>If you enjoyed this article, I’m certain that you’d love my brand-new <em>FREE </em>AI Products &amp; Research newsletter, <strong>“The Vision, Debugged”.</strong></p><p><a href="https://the-vision-debugged.beehiiv.com/subscribe?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how-to-use-ai-to-create-awesome-brand-images-in-minutes">The Vision Debugged</a></p><p>Subscribe &amp; join the bandwagon of enthusiastic readers across top companies like Microsoft, Google, Walmart, Deloitte &amp; more to get <strong><em>cool AI products &amp; research insights</em></strong>, <strong><em>cheat sheets </em></strong>&amp; <strong><em>resources.</em></strong></p><p>About the Author</p><p>Hey folks!</p><p>I’m <strong>Tezan Sahu</strong>, an Applied Scientist at Microsoft, an Amazon #1 Bestselling Author (for the book “<a href="https://www.amazon.in/Beyond-Code-Strategies-Technical-Scientists-ebook/dp/B0BW8MJW6G/">Beyond Code: A Practical Guide for Data Scientists, Analysts &amp; Engineers</a>”), and co-author of “The Vision, Debugged” newsletter.</p><p>I am passionate about helping aspiring data scientists &amp; software developers kickstart their careers, deliver consistent impact &amp; become differentiated professionals in the field of AI &amp; Data Science.</p><p>If you are interested in learning more about how you can leverage AI to stay ahead of the curve and boost your results, <a href="https://www.linkedin.com/in/tezan-sahu/">connect with me on LinkedIn</a> &amp;<a href="https://the-vision-debugged.beehiiv.com/subscribe?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how-to-use-ai-to-create-awesome-brand-images-in-minutes"> subscribe to my newsletter</a>.</p><figure><img alt="AI-generated avatar of the author (Tezan Sahu) generated using Midjourney &amp; InsightFaceSwap" src="https://cdn-images-1.medium.com/max/1024/1*hPBGFzteI0S5MxFHfw0cLw.jpeg" /><figcaption>AI-generated avatar of the author (Tezan Sahu) generated using Midjourney &amp; InsightFaceSwap</figcaption></figure><p>Check out <a href="https://tezansahu.com/?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how_to_use_ai_to_create_awesome_brand_images_in_minutes%F0%9F%94%A5">my website</a> &amp; follow me on <a href="https://www.linkedin.com/in/tezan-sahu/">LinkedIn</a>, <a href="https://www.instagram.com/tezan_sahu/">Instagram</a> &amp; <a href="https://twitter.com/SahuTezan">Twitter</a> for interesting content on Al, data science, marketing, leadership, and mindset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*uuNi-4fXCH-gRsnX.png" /></figure><p><strong>This story is published on </strong><a href="https://generativeai.pub/"><strong>Generative AI</strong></a><strong>. Connect with us on </strong><a href="https://www.linkedin.com/company/generative-ai-publication"><strong>LinkedIn</strong></a><strong> to get the latest AI stories and insights right in your feed. Let’s shape the future of AI together!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*wAZSovRsnN20uUDS.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7916d9e47595" width="1" height="1" alt=""><hr><p><a href="https://generativeai.pub/how-to-use-ai-to-create-awesome-brand-images-in-minutes-7916d9e47595">How to Use AI to Create Awesome Brand Images in Minutes🔥</a> was originally published in <a href="https://generativeai.pub">Generative AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Stunning Photorealistic Images with Midjourney]]></title>
            <link>https://generativeai.pub/how-to-create-stunning-photorealistic-images-with-midjourney-f81dd7e60d9f?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f81dd7e60d9f</guid>
            <category><![CDATA[photorealistic]]></category>
            <category><![CDATA[midjourney-how-to]]></category>
            <category><![CDATA[midjourney-prompts]]></category>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[ai-art]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Sun, 06 Aug 2023 18:44:20 GMT</pubDate>
            <atom:updated>2024-04-08T05:36:50.184Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Comprehensive Guide with 175 Keywords to Master Midjourney Photorealism<em> (along with a Primer on Photography)</em></h4><figure><img alt="A collection of photorealistic images generated by the author (Tezan Sahu) using Midjourney" src="https://cdn-images-1.medium.com/max/1024/1*QQYcl1A_V1Ln7-YnKLwUgw.png" /><figcaption>A collection of photorealistic images across various genres, generated by the author (Tezan Sahu) using Midjourney</figcaption></figure><p><em>Given below are two images (A) &amp; (B).</em></p><p><em>Which of them was generated by AI &amp; which was clicked by a human?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KAJMbay1520RxBwmgQ0CVA.png" /><figcaption>(A) An Indian woman drinking coffee in a cozy café (B) The Majestic Himalayas, including snow-capped peaks</figcaption></figure><p><strong><em>Surprise! Surprise! Both of them were generated by AI (using Midjourney)</em>.</strong></p><p>Mind-boggling, isn’t it? AI-powered image generation has certainly reached a new level of realism and creativity. You can now create stunning images of anything you can imagine, just by typing <em>the right set of words</em>.</p><p><em>In my </em><a href="https://tezansahu.medium.com/how-to-use-midjourney-for-marketing-a-complete-guide-to-creating-stunning-visuals-with-ai-65c6df4b4eba"><em>previous blog</em></a><em>, I showed you how to use Midjourney, one of the most popular and powerful AI image generators, to create stunning visuals for your marketing campaigns.</em></p><p><a href="https://tezansahu.medium.com/how-to-use-midjourney-for-marketing-a-complete-guide-to-creating-stunning-visuals-with-ai-65c6df4b4eba">How to Use Midjourney for Marketing: A Complete Guide to Creating Stunning Visuals with AI</a></p><p>In this blog, I want to take you to the next level of AI image generation: <strong><em>photorealism</em></strong>. Photorealism is the ability to create images that look so realistic that they could be mistaken for photographs. This is not only impressive, but also useful for many purposes, such as creating realistic mockups, prototypes, simulations, illustrations, and more.</p><p>In this article, we’ll explore how to create stunning photorealistic images with Midjourney:</p><ul><li>I will explain the <strong>significance </strong>of understanding how to generate photorealistic images using AI</li><li>I’ll outline some of the <strong>common mistakes</strong> that lead to sub-par quality of images, and ways to avoid them</li><li>We’ll then dive deep into <strong>keywords</strong> for constructing <strong>effective prompts</strong> that enable the generation of high-quality, photorealistic images.<br><strong><em>I’ll also try to explain some of the key terms &amp; concepts related to photography so that you can choose the ones relevant to the type of image you intend to generate.</em></strong></li></ul><p>I will also provide you with <strong><em>a template for writing photorealistic image prompts</em></strong> and show you some examples of the amazing results you can achieve.</p><p>Are you ready? Let’s get started!</p><figure><img alt="Difference in quality of the photorealistic images obtained by supplying Midjourney with Simple Prompts vs Highly Detailed Prompts" src="https://cdn-images-1.medium.com/max/1024/1*BE8Z1SfEdTdA7qIa3wOPvQ.png" /><figcaption>Difference in quality of the photorealistic images obtained by supplying Midjourney with Simple Prompts (artifacts such as hair through the raincoat, blurred hands, lack of depth) vs Highly Detailed Prompts</figcaption></figure><h3>What are Photorealistic Images and Why Do You Need Them?</h3><p>Photorealistic images are images that look so realistic that they could be mistaken for photographs. They have a high level of detail, accuracy, and consistency, and they capture the nuances of light, shadow, color, texture, and perspective. Photorealistic images are not just ordinary images; they are images that evoke emotions, tell stories, and inspire actions.</p><figure><img alt="Editorial photography of a high-quality DSLR kept on a sturdy rock, lush green vegetation in the background, set in the golden hour, dramatic atmosphere, emulating a Leica M10-R camera with a polarizing filter, f/8 aperture, 1/1000 shutter speed, ISO 200, studio lighting, composed with a low angle perspective." src="https://cdn-images-1.medium.com/max/1024/0*w83hOOk9wFSPYxSN" /><figcaption>A high-quality DSLR kept on a sturdy rock amidst green vegetation (generated by the author using Midjourney)</figcaption></figure><p>But why do you need photorealistic images? What are the benefits of using them for your marketing campaigns, projects, or personal use? Here are some of the reasons why photorealistic images are valuable and useful:</p><ul><li><strong>Attract attention and engagement: </strong>Photorealistic images are eye-catching and captivating, making the audience curious and interested in your message. They also encourage your audience to interact with your content, such as liking, commenting, sharing, or clicking on your call-to-action.</li><li><strong>Enhance credibility and trust:</strong> Photorealistic images are convincing and persuasive. They show your audience that you are professional, reliable, and authentic while demonstrating your expertise, quality, and value.</li><li><strong>Save time and money:</strong> Photorealistic images are convenient and cost-effective because they eliminate the need for hiring photographers, designers, or artists. They also reduce the time and effort required for creating, editing, or modifying images.</li></ul><p>As you can see, photorealistic images have many advantages and benefits for your marketing campaigns, projects, or personal use.</p><h3>3 Common Mistakes to Avoid When Creating Photorealistic Images with Midjourney</h3><p>Image generation in Midjourney is more like a game of words — you just type a few words in the form of a prompt &amp; the AI tool magically generates something based on your prompt. However, blindly doing this will never get you to unleash the full potential of Midjourney &amp; you will end up generating mediocre images.</p><p>Here are three common mistakes that you should avoid while trying to generate captivating photorealistic images, and how to fix them:</p><h4>Mistake #1: Using short, vague or ambiguous prompts</h4><p>A vague or ambiguous prompt can confuse Midjourney and make it generate images that have nothing to do with what you want. For example, “<em>a beautiful landscape</em>” can mean anything from mountains to oceans.</p><figure><img alt="Results generated by Midjourney for the prompt “a beautiful landscape”" src="https://cdn-images-1.medium.com/max/1024/0*V2O6wXcOPyrhdELd" /><figcaption>Results generated by Midjourney for the prompt “<strong>a beautiful landscape</strong>” — the images are surely <strong><em>beautiful</em></strong>, but they are definitely <strong>not photorealistic</strong>! In fact, they are all over the place, and very ‘artistic’ in nature.</figcaption></figure><p>To fix this mistake, use specific and descriptive prompts that tell Midjourney exactly what you want, such as “<em>a photorealistic image of a snowy mountain range at sunrise with a clear blue sky</em>”.</p><figure><img alt="Results generated by Midjourney for the prompt “a photorealistic image of a snowy mountain range at sunrise with a clear blue sky”" src="https://cdn-images-1.medium.com/max/1024/0*E3u1HdSsXKjAAiXV.png" /><figcaption>Result generated by Midjourney for the prompt “<strong><em>a photorealistic image of a snowy mountain range at sunrise with a clear blue sky</em></strong><em>” — much more realistic in nature</em></figcaption></figure><h4>Mistake #2: Using inappropriate or conflicting keywords</h4><p>An inappropriate or conflicting keyword can mislead Midjourney and make it generate images that look unnatural or distorted. For example, “cartoon” is not a good keyword for a photorealistic image prompt, nor are “dark” and “bright” for the same prompt.</p><p>To address this, use appropriate and compatible keywords that match your photorealistic image prompts, such as “photorealistic”, “realistic”, “cinematic”, “unsplash”, “stock photography”, “national geographic photo”, etc.</p><p><strong><em>“But how do I know which keywords to use?”</em></strong><em><br></em>Don’t worry! I’ve got you covered…the next section is exactly going to be about these, so stick around.</p><h4>Mistake #3: Using default settings or parameters</h4><p>A default setting or parameter can limit Midjourney and make it generate images that are low quality, blurry, pixelated, or unrealistic. For example, the 1:1 aspect ratio may not be suitable for a photorealistic image subject, and standard mode may be too artistic for a photorealistic image style.</p><figure><img alt="Difference in photorealism &amp; quality of generation on adding the “ — style raw” parameter in Midjourney (using example of a tulip garden)" src="https://cdn-images-1.medium.com/max/1024/1*1gYZ0aIE2b7WIAMPrvEjSw.png" /><figcaption>Difference in photorealism &amp; quality of generation on adding the “ <strong>— style raw</strong>” &amp; “ <strong>— ar 16:9</strong>” parameters in Midjourney</figcaption></figure><p>To fix this, use custom settings or parameters that optimize your photorealistic image prompts, such as changing the <strong><em>aspect ratio</em></strong> to 16:9, or changing the <strong><em>style </em></strong>to “raw”. <br><em>(More about these in a future post…stay tuned!)</em></p><p>As you see, when it comes to prompting in Midjourney, it is evident that <strong><em>“more the details, better the prompt &amp; more powerful the image!”</em></strong></p><p>Without details, your short prompts will be vague and ambiguous, and your images will be generic, unrealistic and all over the place. But with details, your prompts will be clear, specific and descriptive, empowering you to control your image and get closer to your vision.</p><h3>Essential Elements of Photorealistic Image Prompt</h3><p><em>“How can you write effective prompts that tell Midjourney exactly what you want to create, and how to create it?”<br>“What are the details that you need to include in your prompts to make them specific and descriptive?”</em></p><p>In this section, I will answer these questions and show you the most crucial elements of crafting photorealistic image prompts. These elements are the building blocks of a photorealism, and will help you communicate your vision and expectations to Midjourney.</p><p>The elements that we’ll explore are:</p><ul><li>Scene Descriptors</li><li>Time &amp; Weather Conditions</li><li>Mood or Atmosphere</li><li>Camera Selection</li><li>Lens Filters</li><li>Camera Settings</li><li>Lighting</li><li>Perspective</li></ul><p>Let’s take a look at each of these elements in detail and see how they work.</p><h4>Scene Descriptors</h4><p>Scene descriptors are words or phrases that describe the main subject or object of your image and form the core of your prompt. They define the type of image being generated, and hence should be clear and specific.</p><p>Following is a list of keywords that you can use as scene descriptors, typically for photorealistic images. They usually set the context &amp; genre of the image to be generated.</p><figure><img alt="22 Scene descriptor keywords for Midjourney Prompts" src="https://cdn-images-1.medium.com/max/1024/1*p8-27UfmJ81PSqE_GljRTQ.png" /><figcaption><strong>22 Scene descriptor keywords</strong> for Midjourney Prompts</figcaption></figure><p>Let’s try to spice up some of the simplistic subjects with these descriptors, to craft prompts that start unleashing Midjourney’s magic.</p><figure><img alt="Wildlife photography of a Royal Bengal tiger walking in a forest in the Sundarbans delta (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*6AuSwojfBqmq3r1y.png" /><figcaption><strong>Wildlife photography</strong> of a Royal Bengal tiger walking in the Sundarbans Forests (generated by the author using Midjourney)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*4tx8v1hCA5HFtMQd" /><figcaption><strong>Closeup shot</strong> of a female sunglass model, <strong>fashion photography</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="Product photography of a bottle of luxury perfume coming out of a splashing pool of liquid, with a dark floral background (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/927/0*nC0BsbLauVabEazj" /><figcaption><strong>Product photography</strong> of a bottle of luxury perfume coming out of a splashing pool of liquid, with a dark floral background (generated by the author using Midjourney)</figcaption></figure><h4>Time &amp; Weather Conditions</h4><p>These words or phrases describes the time when your image takes place, as well as the weather or climate of your image. Keywords indicating time affect the color, brightness, contrast, and tone of your image, while those specific to weather affect the visibility, texture, reflection, and mood of your image.</p><p>Here are a bunch of keywords that you can experiment with and see the difference.</p><figure><img alt="22 Scene descriptor keywords for Midjourney Prompts" src="https://cdn-images-1.medium.com/max/1024/1*muB0VpisykonTE0dLudbaw.png" /><figcaption><strong>22 Keywords</strong> for Midjourney Prompts to describe <strong>Time of the Day</strong> &amp; <strong>Weather Conditions</strong></figcaption></figure><p>Here are some examples of how adding details about the time &amp; weather conditions can significantly alter the final image quality.</p><figure><img alt="Difference between photos of a blue Kawasaki Ninja 1000 bike clicked during a rainy night and during the golden hour (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*2Gvx3ftsgbufpMLfpuxOUg.png" /><figcaption>Difference b/w photos of a blue Kawasaki Ninja 1000 bike clicked during a <strong>rainy night</strong> and during the<strong> golden hour </strong>(generated by the author using Midjourney)</figcaption></figure><figure><img alt="Difference between photos of a luxurious villa in a valley, clicked during the golden hour, with thin mist and the blue hour in snowstorm (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*v9XABByZQYOg-JrM3nQHGQ.png" /><figcaption>Difference b/w photos of a luxurious villa in a valley, clicked during <strong>the golden hour, with thin mist</strong> and during <strong>the blue hour in snowstorm </strong>(generated by the author using Midjourney)</figcaption></figure><h4>Mood or Atmosphere</h4><p>These keywords capture the essence of the emotions being conveyed through the image. It tells Midjourney what kind of mood or atmosphere you want to create your image with, such as happy, sad, angry, calm, tense, romantic, scary, or mysterious. Specifying the mood explicitly can add to the overall impact created by your generated image.</p><p>Some examples of keywords for describing the overall mood or atmosphere of your image:</p><figure><img alt="33 Keywords for Midjourney Prompts to describe the Mood conveyed by the image" src="https://cdn-images-1.medium.com/max/1024/1*1-OJokTxumbXQGFSRjoNXA.png" /><figcaption><strong>33 Keywords</strong> for Midjourney Prompts to describe the <strong>Mood </strong>conveyed by the image</figcaption></figure><p>Let’s now visualize how these <em>mood </em>keywords affect the quality &amp; impact created by the Midjourney-generated images.</p><figure><img alt="A software developer working on his laptop in a tense environment (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*4uSqPc4ybPIGgx2Z.png" /><figcaption>A software developer working on his laptop in a <strong>tense </strong>environment (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A young Indian man overwhelmed with the technology, in a gloomy &amp; dystopian atmosphere (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*pa7qBdlYqd1ZpNeY" /><figcaption>A young Indian man overwhelmed with the technology, in a <strong>gloomy </strong>&amp; <strong>dystopian </strong>atmosphere (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A woman in a Parisian café, with a warm, cozy &amp; nostalgic atmosphere (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/741/0*JoyH5yLlqCSzvLLE" /><figcaption>A woman in a Parisian café, with a <strong>warm</strong>, <strong>cozy </strong>&amp; <strong>nostalgic </strong>atmosphere (generated by the author using Midjourney)</figcaption></figure><figure><img alt="Lone figure near a stormy beach with crashing waves, atmosphere of drama, anger (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*2swAeHNMGSVqVD1nK3q7SQ.png" /><figcaption>Lone figure near a stormy beach with crashing waves, atmosphere of <strong>drama</strong>, <strong>anger </strong>(generated by the author using Midjourney)</figcaption></figure><h4>Camera Selection</h4><p>Now, we start getting more into the ‘<em>real’ </em>of photorealism. Since Midjourney model has been trained on a plethora of images clicked by a variety of cameras, with different lenses, it can emulate these to a great extent — but only if you specify it explicitly!</p><p>Here is a list of High-Quality &amp; Creative options for Cameras, along with the best use-cases for them. You may need to experiment with these iteratively to achieve the most compelling results.</p><figure><img alt="A collection of 10 high-quality cameras &amp; 10 creative cameras to choose for your prompt" src="https://cdn-images-1.medium.com/max/1024/1*L6Ltb3jAPoW77--lqBLV9Q.png" /><figcaption>A collection of <strong>10 high-quality</strong> <strong>cameras </strong>&amp; <strong>10 creative cameras</strong> to choose for your prompt</figcaption></figure><p>Mentioning the camera can significantly elevate the photorealism in the results generated by Midjourney. Below are some images that I’ve generated using some of the above mentioned high-quality &amp; creative cameras.</p><figure><img alt="A Jamaican athlete, running a 100 m race, shot using Sony A1 camera (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/927/0*ZTxIXa3zZKj4zVeR" /><figcaption>A Jamaican athlete, running a 100 m race, shot using <strong>Sony A1 camera</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A scientist working in a chemistry lab, clicked using Night Vision camera (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/927/0*cTS04EFtRa1iaicb" /><figcaption>A scientist working in a chemistry lab, clicked using <strong>Night Vision camera</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A polar bear in the Arctic next to a camera on a tripod, clicked using an Infrared Camera (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*kSYKJmMM_BN-B8JZ" /><figcaption>A polar bear in the Arctic next to a camera on a tripod, clicked using an <strong>Infrared Camera</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A Gothic-style fountain in a European garden clicked using Leica M10-R camera (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/741/0*ufFTeAgb_k2V3O27" /><figcaption>A Gothic-style fountain in a European garden clicked using <strong>Leica M10-R camera</strong> (generated by the author using Midjourney)</figcaption></figure><p><em>I personally love the photorealism in the images generated </em><strong><em>Leica M10-R </em></strong><em>camera, for its versatility across multiple genres of photography.</em></p><h4>Lens Filters</h4><p>These keywords in your prompt indicate Midjourney as to what kind of color, contrast, brightness, or tone adjustments you want to make to your image, such as warm, cool, sepia, black and white, or vintage. Lens filters affect the mood, atmosphere, and style of your image. For example:</p><ul><li>If you want to create a photorealistic image of a sunset over the ocean with a warm and nostalgic feel, you should use a lens filter like “warm filter” or “vintage filter”.</li><li>But if you want to create a photorealistic image of a snowy mountain range with a cold and crisp feel, you should use a lens filter like “cool filter” or “black and white filter”.</li></ul><p>Following are some professional grade lens filters that can enhance the photorealistic images generated by Midjourney according to your mood.</p><figure><img alt="12 Lens filter keywords to include in prompts to enhance the mood of generated images" src="https://cdn-images-1.medium.com/max/1024/1*KJ2Ca8zrHiHjR-D9e5GsAA.png" /><figcaption><strong>12 Lens filter keywords </strong>to include in prompts to enhance the mood of generated images</figcaption></figure><p>Using lens filters is totally optional — usually you may not require them, however they can give stunning results when you wish to reflect a certain kind of mood or vibrance in your images<em> (and using simple mood keywords is not providing satisfactory results)</em></p><figure><img alt="Old bungalow in the meadows of Scotland, shot using Fujifilm Instax camera with a vintage lens filter (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*wlLKhLvuZFoZlaYK" /><figcaption>Old bungalow in the meadows of Scotland, shot using Fujifilm Instax camera with a <strong>vintage lens filter</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A large spicy chicken burger with extra veggies, shot using Leica M10-R camera with a polarizing lens filter (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/927/0*zZL382BPekKXDOKp" /><figcaption>A large spicy chicken burger with extra veggies, shot using Leica M10-R camera with a <strong>polarizing lens filter</strong> (generated by the author using Midjourney)</figcaption></figure><h4>Camera Settings</h4><p>Camera settings are words or phrases that describe the settings of the camera that you want to use to create your image. They tell Midjourney what kind of aperture, focus, exposure, or shutter speed you want to apply to your image (such as f/1.8, f/16, auto focus, manual focus, overexposed, underexposed, fast shutter, or slow shutter). Camera settings affect the depth of field, blur, brightness, and motion of your image.</p><p><strong><em>In the short section below, I try to explain the key settings of cameras. It can help you pick &amp; choose the right settings for the most impactful images once you develop a deeper understanding of these. However, if you are simply interested in using the keywords, feel free to skip this section.</em></strong></p><p>There are a few major camera settings that you need to know, so that you can get the most out of Midjourney while trying to emulate the high-quality cameras mentioned previously:</p><ul><li><strong>Aperture: </strong>It controls how much light enters the camera (bigger the aperture, more the incoming light). Aperture is measured by a number called <strong><em>f-stop</em></strong>. The smaller the f-stop number, the bigger the aperture (for example, f/2.8 is a big aperture while f/16 is small). Aperture also affects how much of your picture is in focus (<strong><em>depth of field</em></strong>). The bigger the aperture, the smaller the depth of field. Thus, if you want to take a picture of a flower and make the background blurry, you can use a big aperture like f/2.8.</li></ul><figure><img alt="Variation in Midjourney-generated images of a toucan in a rainforest, for apertures f/2.8 &amp; f/8" src="https://cdn-images-1.medium.com/max/1024/1*TPz7wj_K2dxG_xpbWXGjKA.png" /><figcaption>Variation in Midjourney-generated images of a toucan in a rainforest, for apertures <strong>f/2.8</strong> &amp; <strong>f/8</strong></figcaption></figure><ul><li><strong>Shutter Speed:</strong> It controls how long the light enters the camera sensor. The faster the shutter speed, the shorter the time that light comes in. It is measured by seconds or fractions of seconds. The faster the shutter speed, the more frozen or still your picture will be. The slower the shutter speed, the more blurred or moving your picture will be. For example, if you want to take a picture of a car racing by, you can use a fast shutter speed like 1/1000 to freeze its motion and make it sharp and clear. If you want to take a picture of water flowing in a river, you can use a slow shutter speed like 1/4 to blur its motion and make it smooth and silky.</li></ul><figure><img alt="Variation in Midjourney-generated images of a Moto GP Rider, for shutter speeds 1/1000 s &amp; 1 s" src="https://cdn-images-1.medium.com/max/1024/1*VLK1BkmW-tcV8aDLrehLcA.png" /><figcaption>Variation in Midjourney-generated images of a Moto GP Rider, for shutter speeds <strong>1/1000 s</strong> &amp; <strong>1 s</strong></figcaption></figure><ul><li><strong>ISO:</strong> This is a camera setting that helps you take good pictures in different kinds of light. If you use a low ISO, your picture will be very dark. If you use a high ISO, although your image will become very bright, but it will make your image look grainy or fuzzy. It is best to use the lowest ISO possible that still gives you a clear picture.</li><li><strong>Exposure: </strong>It is like the brightness of your picture. It is determined by the 3 settings discussed above — aperture, ISO &amp; shutter speed. The following “exposure triangle” explain this well.</li></ul><figure><img alt="Exposure Triangle Diagram" src="https://cdn-images-1.medium.com/max/1024/0*YA63ppPq9jMUOcUi.png" /><figcaption>Exposure Triangle Diagram in Photography</figcaption></figure><ul><li><strong>Focus: </strong>It determines how sharp or blurry your picture is. Focus is important because it helps you to draw attention to what you want to show in your picture.</li></ul><p>That concludes our brief digression into photography. Hope you will now understand the keywords mentioned below better and choose them appropriately in your own prompts.</p><p>Back to our keywords, here is a curated list of camera settings that you can add to your prompts to generate professional quality photorealistic images.</p><figure><img alt="24 camera settings to be included in Midjourney prompts for impactful photorealistic images" src="https://cdn-images-1.medium.com/max/1024/1*CgXlUEkrhBXr1fUMNvfwig.png" /><figcaption><strong>24 camera settings</strong> to be included in Midjourney prompts for impactful photorealistic images</figcaption></figure><p>We can use various permutations of these camera settings while crafting our Midjourney prompts to obtain the most appropriate visualization of the concept in our minds. Following are some examples that I generated using some <em>extreme </em>camera settings:</p><figure><img alt="Formula One racing car speeding through the Moroccan Grand Prix track, clicked using a GoPro Hero11 camera with a graduated neutral filter, f/8 aperture, 1/4000 shutter speed, ISO 100, short exposure (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*0VkGQaPBKvLnwB_f" /><figcaption>Formula One racing car speeding through the Moroccan Grand Prix track, clicked using a GoPro Hero11 camera with a graduated neutral filter, <strong>f/8 aperture</strong>, <strong>1/4000 shutter speed</strong>, <strong>ISO 100</strong>, <strong>short exposure </strong>(generated by the author using Midjourney)</figcaption></figure><figure><img alt="Trailing lights of cars on a winding ghat road on a hill, shot using a Sony Alpha a17 III mirrorless camera, with color-gel lens, aperture f/1.4, shutter speed 5, long exposure, ISO 1600 (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*iNqWBKciFIK4f7Me" /><figcaption>Trailing lights of cars on a winding ghat road on a hill, shot using a Sony Alpha a17 III mirrorless camera, with color-gel lens, <strong>aperture f/1.4</strong>,<strong> shutter speed 5</strong>, <strong>long exposure</strong>, <strong>ISO 1600</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="Double exposure bison with the great grass plains (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*ipDJJ00q2r88nMi7q-3dyA.png" /><figcaption><strong>Double exposure</strong> bison with the great grass plains (generated by the author using Midjourney)</figcaption></figure><h4>Lighting</h4><p>These keywords in your prompt tell Midjourney how to illuminate your subject. They affect the shadow, highlight, contrast, depth, and realism of your image.</p><p>Here are some examples of lighting keywords to be included in your prompt, that can elevate the look &amp; feel of your images.</p><figure><img alt="20 Professional lighting conditions to include in your Midjourney prompts to make your images stand out" src="https://cdn-images-1.medium.com/max/1024/1*mJQYXXMa-4_s5kYrRqEKrg.png" /><figcaption><strong>20 Professional lighting conditions</strong> to include in your Midjourney prompts to make your images stand out</figcaption></figure><p>Let’s apply this learning to our Midjourney prompts to understand how to make the best use of some of these professional lighting keywords.</p><figure><img alt="Variations of fashion photography of an Indian couple, in blue &amp; black tones, with different lighting conditions (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*PTkikEgvuNxDIJpgmyTdsg.png" /><figcaption>Variations of fashion photography of an Indian couple, in blue &amp; black tones, with different lighting conditions (generated by the author using Midjourney)</figcaption></figure><figure><img alt="Scuba diver near the great barrier reef, shot using Nikon Z9 camera with cool filter lens, with underwater lighting (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*p4N-kKOC2fyIv9RB" /><figcaption>Scuba diver near the great barrier reef, shot using Nikon Z9 camera with cool filter lens, with<strong> underwater lighting</strong> (generated by the author using Midjourney)</figcaption></figure><figure><img alt="Light painting of a circle made by a young Indian girl holding a firecracker during Diwali (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/927/0*XUHIYnKAQSt63MLo" /><figcaption><strong>Light painting</strong> of a circle made by a young Indian girl holding a firecracker during Diwali (generated by the author using Midjourney)</figcaption></figure><h4>Perspective &amp; Composition</h4><p>These keywords serve as guidelines for Midjourney to position the subject of your image. They affect the depth, angles, composition and point of view of the generated image, which may result in varied perceptions of the photorealistic image.</p><p>Given below is a list of some interesting perspectives &amp; composition guidelines to try out in your next image.</p><figure><img alt="11 Perspective &amp; 11 Composition keywords to bring a sense of depth into your photorealistic generated images" src="https://cdn-images-1.medium.com/max/1024/1*OgwGH_N161XJ-xiPJ_IOPQ.png" /><figcaption><strong>11 Perspective </strong>&amp; <strong>11 Composition keywords</strong> to bring a sense of depth into your photorealistic generated images</figcaption></figure><p>Here are a few examples of how adding guidelines for perspective &amp; composition can generate awe-inspiring images.</p><figure><img alt="Variations in image of a cup of Cappuccino placed next to a piece of cake in a cafe, with different perspectives (generated using Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*b2xYLwXxHaRhqshW3_CYAg.png" /><figcaption>Variations in image of a cup of Cappuccino placed next to a piece of cake in a cafe, with different perspectives (generated by the author using Midjourney)</figcaption></figure><figure><img alt="A single baobab tree in a large expanse of the Savannah grasslands, composed using negative space (generated using Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*s_MV5sGjC3xeO_W2" /><figcaption>A single Baobab tree in a large expanse of the Savannah grasslands, composed using <strong>negative space</strong> (generated by the author using Midjourney)</figcaption></figure><h3>The Ultimate Photorealistic Image Prompt Template</h3><p>Now, it’s time to put all these learnings into practice and create stunning photorealistic images with Midjourney.</p><p>How can you do that? Don’t worry, I have got you covered. Given below, I’ve shared the ultimate photorealistic image prompt template for Midjourney:</p><blockquote><em>“</em><strong><em>[Style Descriptor]</em></strong><em> of </em><strong><em>[Subject]</em></strong><em>, set in a </em><strong><em>[environment — time, weather, etc.]</em></strong><em> with a </em><strong><em>[mood/atmosphere]</em></strong><em>. Include [</em><strong><em>additional details/modifiers]</em></strong><em>, emulate a </em><strong><em>[specific camera]</em></strong><em> with a </em><strong><em>[lens filter]</em></strong><em> and </em><strong><em>[camera settings]</em></strong><em>, use </em><strong><em>[lighting conditions]</em></strong><em>, and compose with </em><strong><em>[perspective/composition guidelines]</em></strong><em>.”</em></blockquote><p>This template is a simple and powerful formula that will help you write effective prompts that tell Midjourney exactly what you want to create, and how to create it. Just plug in your choice of keywords from among the <strong>175 options</strong> that I’ve shared above, to see your imagination brought to life by Midjourney!</p><p><strong><em>Note: </em></strong><em>You need not fill in all the placeholders for every photo. Experiment with what works best for your creatives. Also, feel free to reposition the placeholders within your prompt — Midjourney pays more attention to the words &amp; phrases appearing early on in the prompt.</em></p><p>Let’s look at some images that I created by plugging keywords into this exact template to craft my prompt for photorealistic images…</p><figure><img alt="Cinematic shot of an Indian woman through a glass window, the woman is in casual clothes, smiling and sipping coffee (generated using Midjourney)" src="https://cdn-images-1.medium.com/max/895/0*QqrBgE9RDnLLSf_-.png" /><figcaption><strong>Prompt: </strong>Cinematic shot of an Indian woman through a glass window, the woman is in casual clothes, smiling and sipping coffee, photorealistic, 4k, set in a cozy cafe with a peaceful, warm, and positive atmosphere. Emulate a Hasselblad X2D 100C camera with a Fujifilm GF 110mm f/2 R LM WR lens. Use softbox lighting, and compose with a frame-in-a-frame perspective</figcaption></figure><figure><img alt="Editorial product photography of a modern headphone kept on a minimalistic table next to a window (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*8moFBEfrBgFg85zl" /><figcaption><strong>Prompt: </strong>Editorial product photography of a modern headphone kept on a minimalistic table next to a window, during sunset, dramatic &amp; confident atmosphere, clicked using Leica M10-R camera with polarizing lens filter, aperture f/2.8, shutter speed 1/100s, rack focus, gobo lighting from the window, composed using eye-level perspective</figcaption></figure><figure><img alt="Photorealistic image of a detective solving a mystery case in streets of Kolkata (generated by Midjourney)" src="https://cdn-images-1.medium.com/max/1024/1*WUnVzacJGRFhHkt1EHQeiA.png" /><figcaption><strong>Prompt: </strong>Photorealistic image of a detective solving a mystery case in streets of Kolkata, set in a crowded market with colorful stalls, rickshaws, and people, with a mysterious and suspenseful mood, emulate a Nikon Z9 with a Petzval 58 Bokeh Control Art Lens, with a sepia filter, f/2.8 aperture, use natural light from the late afternoon sun, compose with a low-angle perspective and leading lines.</figcaption></figure><figure><img alt="Food photography of a hot plate of chicken sizzler (generated using Midjourney)" src="https://cdn-images-1.medium.com/max/1024/0*JPaYj0twJ2rwFgEh" /><figcaption><strong>Prompt:</strong> Food photography of a hot plate of chicken sizzler, shot using Lomography Lomo’ Instant Wide camera with color-gel lens filter, f/5.6 aperture, 1/60 shutter speed, 800 ISO, bokeh lighting, composed using a low-angle view, dark background</figcaption></figure><p>Whoa! Now that’s really cool!</p><p>Now, let’s see if we can ask Midjourney to imagine certain concepts, and make it look as photorealistic as possible…</p><p>Here’s how Midjourney imagined <em>Sheldon Cooper (from ‘The Big Bang Theory’), in a crowded India market buying vegetables</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O08XInsopMpK1IS5" /><figcaption><strong>Prompt:</strong> full body shot of Sheldon Cooper wearing a kurta and pyjama, in a crowded Indian market buying vegetables, detailed, shot on Fujifilm Pro 400H, rim lighting</figcaption></figure><p>Okay, I don’t know why I did that 😂, but the generated image does look really awesome!</p><p>One last attempt — this time, I’ve asked Midjourney to imagine the <em>photoshoot of a futuristic sports car</em>, and here’s the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J2e5Ks_unc2OvlDQ" /><figcaption><strong>Prompt:</strong> an award-winning photograph of a futuristic sports car designed by Bugatti standing on a deserted road in the Red Rock Valley of Mojave Desert of Nevada, fluidic &amp; futuristic design, clicked during a bright sunny day, in a warm atmosphere, clicked using Holga 120N camera with a warm lens filter, aperture f/16, shutter speed 1/500 s, ISO 100, natural lighting, composed using a low-angle perspective with leading lines</figcaption></figure><p>Amazing! So now I’ve also shown you how to use the ultimate photorealistic image prompt template to unleash your creativity and generate mind-boggling images of any genre with Midjourney.</p><h3>Concluding Remarks</h3><p>Congratulations! You’ve made it to the end! With that, I believe you have learned how to create stunning photorealistic images with Midjourney, using the ultimate photorealistic image prompt template and the essential elements of a photorealistic image prompt.</p><p>Throughout this article, I’ve shown you how you can generate stunning photorealistic images across multiple genres of photography — <em>wildlife</em>, <em>nature</em>, <em>product</em>, <em>portrait</em>, <em>fashion</em>, <em>food</em>, <em>editorial</em>, <em>architectural</em>, <em>sports</em>, <em>action</em>, and so much more — using the right keywords in your Midjourney prompts.</p><p>You now also know how to avoid the common mistakes that can ruin your photorealistic image generation experience and result in low quality, unrealistic, or irrelevant images.</p><p>I hope you enjoyed this blog and found it useful and informative. I encourage you to try out Midjourney and experiment with different prompts, keywords, settings, and parameters, and unleash your creativity and imagination with Midjourney’s amazing photorealism capabilities.</p><p>If you enjoyed this article, I’m certain that you’d love my brand-new <em>FREE </em>AI Products &amp; Research newsletter, <strong>“The Vision, Debugged”.</strong></p><p><a href="https://the-vision-debugged.beehiiv.com/subscribe?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how-to-create-stunning-photorealistic-images-with-midjourney">The Vision Debugged</a></p><p>Subscribe &amp; join the bandwagon of enthusiastic readers across top companies like Microsoft, Google, Walmart, Deloitte &amp; more to get <strong><em>cool AI products &amp; research insights</em></strong>, <strong><em>cheat sheets </em></strong>&amp; <strong><em>resources.</em></strong></p><h3>References</h3><ul><li><a href="https://www.midjourney.com/home/">Midjourney</a></li><li><a href="https://roryflynn.gumroad.com/l/PhotorealisticMijourneyCheatSheet?layout=profile&amp;recommended_by=library">Create Photorealistic Images in Midjourney (Cheat Sheet) by Rory Flynn</a></li><li><a href="https://bootcamp.uxdesign.cc/50-midjourney-prompts-to-create-photorealistic-images-advanced-2e233463bccf">50+ Midjourney Prompts to Create Photorealistic Images (Advanced)</a></li><li><a href="https://bing.com/search/?q=Bing%20AI&amp;showconv=1">Bing Chat (for research)</a></li></ul><h3>About the Author</h3><p>Hey folks!</p><p>I’m <strong>Tezan Sahu</strong>, an Applied Scientist at Microsoft, an Amazon #1 Bestselling Author (for the book “<a href="https://www.amazon.in/Beyond-Code-Strategies-Technical-Scientists-ebook/dp/B0BW8MJW6G/">Beyond Code: A Practical Guide for Data Scientists, Analysts &amp; Engineers</a>”), and co-author of “The Vision, Debugged” newsletter.</p><p>I am passionate about helping aspiring data scientists &amp; software developers kickstart their careers, deliver consistent impact &amp; become differentiated professionals in the field of AI &amp; Data Science.</p><p>If you are interested in learning more about how you can leverage AI to stay ahead of the curve and boost your results, <a href="https://www.linkedin.com/in/tezan-sahu/">connect with me on LinkedI</a>n &amp; <a href="https://the-vision-debugged.beehiiv.com/subscribe?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how-to-create-stunning-photorealistic-images-with-midjourney">subscribe to my newsletter</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*aj9e_GTA4K7eEIdL" /><figcaption>AI-generated avatar of the author (Tezan Sahu) generated using Midjourney &amp; InsightFaceSwap</figcaption></figure><p>Check out <a href="https://tezansahu.com/?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how_to_create_stunning_photorealistic_images_with_midjourney">my website</a> &amp; follow me on <a href="https://www.linkedin.com/in/tezan-sahu/">LinkedIn</a>, <a href="https://www.instagram.com/tezan_sahu/">Instagram</a> &amp; <a href="https://twitter.com/SahuTezan">Twitter</a> for interesting content on Al, data science, marketing, leadership, and mindset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*v7EcMIsJSKZVIHY-.png" /></figure><p><strong>This story is published on </strong><a href="https://generativeai.pub/"><strong>Generative AI</strong></a><strong>. Connect with us on </strong><a href="https://www.linkedin.com/company/generative-ai-publication"><strong>LinkedIn</strong></a><strong> to get the latest AI stories and insights right in your feed. Let’s shape the future of AI together!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dcVXdK6E3wlObGlw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f81dd7e60d9f" width="1" height="1" alt=""><hr><p><a href="https://generativeai.pub/how-to-create-stunning-photorealistic-images-with-midjourney-f81dd7e60d9f">How to Create Stunning Photorealistic Images with Midjourney</a> was originally published in <a href="https://generativeai.pub">Generative AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use Midjourney for Marketing: A Complete Guide to Creating Stunning Visuals with AI]]></title>
            <link>https://generativeai.pub/how-to-use-midjourney-for-marketing-a-complete-guide-to-creating-stunning-visuals-with-ai-65c6df4b4eba?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/65c6df4b4eba</guid>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[ai-art]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[ai-marketing]]></category>
            <category><![CDATA[graphics]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Sun, 09 Jul 2023 06:20:59 GMT</pubDate>
            <atom:updated>2024-04-08T05:36:33.060Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to use Midjourney, an AI image generator from text, to create eye-catching graphics, logos, avatars, and more for your marketing content. Plus, discover some ethical and legal considerations, as well as some best practices to optimize your images for SEO.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lp9FVPI4oHbBSz0DOe8yA.png" /><figcaption>A marketing executive using Midjourney on their laptop with a coffee mug next to them, fantasy, surreal, dreamlike, vibrant, highly detailed, 8k</figcaption></figure><p>⚡Are you looking for a way to spice up your marketing content with eye-catching visuals? 🤩<br>⚡Do you want to save time and money on hiring designers or buying stock images? ⌚💵<br>⚡Do you want to unleash your creativity and generate unique graphics that match your brand and vision? 🧠</p><p>If you answered yes to any of these questions, then you need to check out <a href="https://www.midjourney.com/"><strong><em>Midjourney</em></strong></a>. Midjourney is an AI image generator from text that can create beautiful, brilliant illustrations for many purposes. Hobbyists love it for its expressiveness and ease of use, while digital marketers recognize its potential as a design tool.</p><p>In this article, we will show you how to use Midjourney for marketing and create stunning visuals for your content. We will also cover some ethical and legal considerations when using Midjourney, as well as some best practices to optimize your images for SEO.</p><h3>What is Midjourney and how does it work?</h3><p>Midjourney is an AI-powered image generator that works through the popular messaging app Discord. Users request images by writing text commands (called <strong><em>prompts</em></strong>) that tell the AI what to create. Prompts can be short and simple or long and highly descriptive. Many serious users develop their own unique prompting styles over time.</p><p>For example, if you want to create an image of a woman wearing a red dress and holding a rose, you can simply type:</p><p>/imagine prompt: a woman wearing a red dress and holding a rose</p><p>And Midjourney will generate four images based on your request. You can then request variations on any of the images, or isolate and upscale any of them at any point in the process. You can also save the images to your personal device or post them to your gallery.</p><figure><img alt="Midjourney’s response to thee prompt “a woman wearing a red dress and holding a rose”" src="https://cdn-images-1.medium.com/max/845/1*5X7sDjBuQ_T6_PVdVVqCxg.png" /><figcaption>Midjourney’s response to thee prompt “<strong>a woman wearing a red dress and holding a rose</strong>”</figcaption></figure><p>Midjourney uses a deep learning model that work together to encode text prompts into visual features and generate realistic images that match the prompts. It can create images of almost anything you can imagine, from animals and landscapes to logos and abstract art. It can also blend images and text, add effects and filters, and adjust the aspect ratio and quality of the images. Learning additional commands will give you more control and flexibility over the image generation process.</p><h3>Why is Midjourney a powerful tool for marketers and content creators?</h3><p>As a marketer or a content creator, you know how important visuals are for attracting and engaging your audience. Visuals can help you convey your message, evoke emotions, increase recall, and boost conversions. However, creating visuals can also be time-consuming, expensive, and challenging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFaNf_KHomTI1gSxaQ62Hw.png" /><figcaption>Upscaled image, generated using the prompt “<strong>artificial intelligence working on laptop to create logos, posters and visuals for brands, time and money, highly detailed, cinematic, soft studio lighting, backlighting, dark background, 8k — ar 16:9”</strong></figcaption></figure><p>That’s where Midjourney comes in handy. With Midjourney, you can:</p><ul><li>Create <strong>eye-catching graphics</strong> for your blog posts, social media, newsletters, eBooks, and more in minutes.</li><li>Generate <strong>logos</strong>, <strong>icons</strong>, <strong>branding elements</strong>, banners, flyers, posters, and other marketing materials for your business or clients.</li><li>Design appealing <strong>visuals for your ads</strong>, l<strong>anding pages</strong>, webinars, presentations, and other <strong>conversion-focused content</strong>.</li><li>Inspire your creativity and <strong>brainstorm new ideas </strong>with Midjourney’s endless possibilities.</li><li>Create unique <strong>AI avatars</strong> and videos for your <strong>ads and campaigns</strong>.</li></ul><p>Using Midjourney for marketing can help you <strong>save time and money</strong> on hiring designers or buying stock images. It can also help you stand out from the crowd with original and customized visuals that match your brand and vision.</p><h3>What are some ethical and legal considerations when using Midjourney?</h3><figure><img alt="Upscaled image, generated using the prompt “confusion with legal documents, intellectual property and offensive content, Kurzgesagt — ar 16:9”" src="https://cdn-images-1.medium.com/max/1024/1*Xtt4oaIwoQYHtv7teP0gFQ.png" /><figcaption>Upscaled image, generated using the prompt “<strong>confusion with legal documents, intellectual property and offensive content, Kurzgesagt — ar 16:9</strong>”</figcaption></figure><p>While Midjourney is an amazing tool for creating visuals, it also comes with some ethical and legal implications that you need to be aware of. Here are some of the main issues to consider:</p><ul><li><strong>Whether AI devalues human creativity:</strong> Many artists and designers are embracing Midjourney as a tool to enhance their workflows. Others are concerned that such programs devalue the effort and years of training behind human-created material. For example, when a state fair blue ribbon for “digital art” went to a Midjourney-created piece, thousands of artists expressed their outrage online.</li><li><strong>Whether AI infringes on intellectual property rights:</strong> Midjourney creates its images by drawing from a large database of existing images on the internet. This raises the question of whether it violates the intellectual property rights of the original creators or owners of those images. For example, if you use Midjourney to create an image of Mickey Mouse or Harry Potter, are you infringing on Disney’s or Warner Bros.’ trademarks?</li><li><strong>Whether AI generates harmful or offensive content: </strong>Midjourney can create images of anything you can imagine, including things that are harmful or offensive to some people. For example, if you use Midjourney to create an image of violence, nudity, racism, or hate speech, are you responsible for the consequences of your actions? How can you ensure that your images are appropriate and respectful for your audience and context?</li></ul><p>These are some of the questions that need to be answered as AI-powered image generation becomes more widespread and accessible. As a marketer or a content creator, you need to be mindful of the ethical and legal implications of using Midjourney for your purposes. You also need to follow some best practices to ensure that your images are not only stunning but also safe and compliant.</p><h3>How to Use Midjourney for Marketing: 5 Practical Examples</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdmf-Zu-NXYAAYCYOPCxZQ.png" /><figcaption>Upscaled image, generated using the prompt “<strong>knolling of various equipment used by marketing professionals for creative tasks like photography, podcasts, visuals, posters, branding, surveys, etc., 8k, photorealistic, highly detailed, — ar 16:9</strong>”</figcaption></figure><p>Now that you know what Midjourney is and why it is a powerful tool for marketers and content creators, let’s see some practical examples of how to use it for your marketing purposes. Here are five ways you can use Midjourney to create stunning visuals for your content.</p><h4>1. Create eye-catching graphics for your blog posts, social media, and newsletters</h4><p>One of the most common ways to use Midjourney for marketing is to create eye-catching graphics for your blog posts, social media, and newsletters. These graphics can help you attract more attention, drive more traffic, and increase engagement with your content.</p><p>For example, if you want to create a graphic for a blog post titled “How to Start a Podcast in 2022”, you can simply type:</p><p>/imagine prompt: a graphic for a blog post titled &quot;How to Start a Podcast in 2022&quot;, colorful, modern, catchy, photorealistic, 8k, --ar 3:2</p><p>And Midjourney will generate four images based on your prompt.</p><figure><img alt="Midjourney’s response to the prompt “a graphic for a blog post titled “How to Start a Podcast in 2022”, colorful, modern, catchy, photorealistic, 8k, — ar 3:2&quot;" src="https://cdn-images-1.medium.com/max/1024/1*7uqH48cBuGQJ-hM7UubzVA.png" /><figcaption>Midjourney’s response to the prompt “<strong>a graphic for a blog post titled “How to Start a Podcast in 2022”, colorful, modern, catchy, photorealistic, 8k, — ar 3:2</strong>&quot;</figcaption></figure><p>You can then choose the one you like best, or request variations or modifications until you get the perfect graphic for your blog post. I like the first one, so I’ll click the <strong>U1 </strong>button to upscale the first image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IP7QSZ6jdS4lMVr_jz3esw.png" /><figcaption>Upscaled image, generated by the prompt “<strong>a graphic for a blog post titled “How to Start a Podcast in 2022”, colorful, modern, catchy, photorealistic, 8k, — ar 3:2</strong>&quot;</figcaption></figure><p>You can use the same process to create graphics for your social media posts and newsletters. Just make sure to adjust the aspect ratio and size of your images to fit the platform and format you are using. For example, if you want to create a graphic for an Instagram post, you can use the square image which appears by default, while for LinkedIn, you can use the parameter --ar 4:5 to generate an image in the required portrait format.</p><h4>2. Generate logos, icons, and branding elements for your business or clients</h4><p>Another way to use Midjourney for marketing is to generate logos, icons, and branding elements for your business or clients. These elements can help you establish your identity, differentiate yourself from competitors, and build trust and loyalty with your audience.</p><p>For example, if you want to create a logo for a business called “Green Planet”, you can simply type:</p><p>/imagine prompt: a logo for a business called &quot;Green Planet&quot;, eco-friendly, simple, elegant, green, circular, photorealistic</p><p>And Midjourney will generate four logos based on your prompt. You can then choose the one you like best, or request variations or modifications until you get the perfect logo for your business.</p><figure><img alt="Midjourney’s response to the prompt “a logo for a business called “Green Planet”, eco-friendly, simple, elegant, green, circular, photorealistic”" src="https://cdn-images-1.medium.com/max/1024/1*7de9L8WJu1uGAg1JNaUflA.png" /><figcaption>Midjourney’s response to the prompt “<strong>a logo for a business called “Green Planet”, eco-friendly, simple, elegant, green, circular, photorealistic</strong>”</figcaption></figure><p>Logos can be of various types — <em>vector</em>, <em>letter mark</em>, <em>abstract</em>, <em>geometrical</em>, <em>emblem</em>, <em>mascot</em>, etc. These can be incorporated into the prompt to generate the respective type of logo for your business. For example, for the same business “Green Planet”, I generated the following logos with minor variations in the prompts:</p><figure><img alt="Examples of various types of logos generated by Midjourney for the same company “Green Planet”, just by tweaking the prompt slightly" src="https://cdn-images-1.medium.com/max/1024/1*sSYmWjrajkMKJ9DtJhaoyg.png" /><figcaption>Examples of various types of logos generated by Midjourney for the same company “Green Planet”, just by tweaking the prompt slightly</figcaption></figure><p>You can use the same process to create icons and other branding elements for your business or clients. Just make sure to use relevant keywords and colors that match your brand and vision.</p><h4>3. Design appealing visuals for your ads and landing pages</h4><p>A third way to use Midjourney for marketing is to design appealing visuals for your ads and landing pages. These visuals can help you capture attention, generate interest, and persuade action from your potential customers.</p><p>For example, if you want to create a visual for a Facebook or Instagram ad promoting a free trial of a software product called “ChatGPT”, you can simply type:</p><p>/imagine prompt: a visual for an ad promoting a free trial of a software product called &quot;ChatGPT&quot;, conversational AI, chatbot, friendly, smart, blue, photorealistic</p><p>And Midjourney will generate four visuals based on your prompt. You can then choose the one you like best, or request variations or modifications until you get the perfect visual for your ad.</p><figure><img alt="Midjourney’s response to the prompt “a visual for an ad promoting a free trial of a software product called “ChatGPT”, conversational AI, chatbot, friendly, smart, blue, photorealistic”" src="https://cdn-images-1.medium.com/max/1024/1*Eh5mnOLtlAigtXxSnxdK8w.png" /><figcaption>Midjourney’s response to the prompt “<strong>a visual for an ad promoting a free trial of a software product called “ChatGPT”, conversational AI, chatbot, friendly, smart, blue, photorealistic</strong>”</figcaption></figure><p>You may notice that the text inside any image generated by Midjourney is usually gibberish. This is because there is no concept of a “word” or “character” explicitly represented in the model, it’s all inferred from the relationships between the pixels. To fix this, you can do the following:</p><ol><li>Upscale the selected image</li><li>Use any text removal tool (like <a href="https://clipdrop.co/text-remover">ClipDrop Text Remover</a>) to get rid of the text.</li><li>Use a tool like Canva or Photoshop to add the appropriate text in the appropriate font style &amp; size to this image.</li></ol><p>I liked the last image from among the four images generated above, so performing the above mentioned steps resulted in:</p><figure><img alt="Final image obtained after overlaying required text onto the text-removed version of the original image generated by Midjourney" src="https://cdn-images-1.medium.com/max/606/1*dF4ZT4V4A823oVX7oYRylQ.png" /><figcaption>Final image obtained after overlaying required text onto the text-removed version of the original image generated by Midjourney</figcaption></figure><p>You can use the same process to create visuals for your landing pages and other conversion-focused content. Just make sure to use clear and compelling messages that match your visuals and call to action.</p><h4>4. Inspire your creativity and brainstorm new ideas with Midjourney</h4><p>A fourth way to use Midjourney for marketing is to inspire your creativity and brainstorm new ideas with Midjourney. Midjourney can help you overcome creative blocks, explore new possibilities, and discover new angles for your content.</p><p>For example, if you want to create a blog post about “10 Ways to Use Midjourney for Marketing”, but you are stuck on what to write about, you can simply type:</p><p>/imagine prompt: 10 ways to use Midjourney for marketing</p><p>And Midjourney will generate four images based on your prompt. You can then use these images as inspiration or starting points for your blog post.</p><figure><img alt="Midjourney’s response to the prompt: “10 ways to use Midjourney for marketing”" src="https://cdn-images-1.medium.com/max/719/1*T7xdgn2Bo1jtKHH7uyab4Q.png" /><figcaption>Midjourney’s response to the prompt: “<strong>10 ways to use Midjourney for marketing</strong>”</figcaption></figure><p>For instance, the fourth image shows a person using Midjourney on their laptop with a coffee mug next to them. You can then write about how Midjourney can help marketers work from anywhere and save time on creating visuals.</p><p>You can use the same process to inspire your creativity and brainstorm new ideas for any type of content. Just make sure to keep an open mind and experiment with different prompts and variations.</p><h4>5. Create unique AI avatars and videos for your ads and campaigns</h4><p>A fifth way to use Midjourney for marketing is to create unique AI avatars and videos for your ads and campaigns. These avatars can help you showcase your brand personality, connect with your target audience, and stand out from the competition.</p><p>For example, if you want to create an AI avatar of a celebrity (say, Virat Kohli) who is the brand ambassador of your perfume company, you can simply type:</p><p>imagine prompt: virat kohli holding a bottle of luxury perfume, smiling, front face, in the style of disney pixar, k fantasy background with splashes --ar 4:5</p><p>And Midjourney will generate four avatars based on your prompt. You can then choose the one you like best, or request variations or modifications until you get the perfect avatar for your brand.</p><figure><img alt="Midjourney’s response to the prompt “virat kohli holding a bottle of luxury perfume, smiling, front face, in the style of disney pixar, k fantasy background with splashes — ar 4:5”" src="https://cdn-images-1.medium.com/max/1024/1*dPyJvZeReDRJd38EcamW0Q.png" /><figcaption>Midjourney’s response to the prompt “<strong>virat kohli holding a bottle of luxury perfume, smiling, front face, in the style of disney pixar, k fantasy background with splashes — ar 4:5</strong>”</figcaption></figure><p>I like the first one best, so I’ll upscale it. Notice that this image still may not capture the features of your celebrity (here, Virat Kohli) correctly. In that case you can rely on using tools like <a href="https://github.com/deepinsight/insightface/tree/master/web-demos/swapping_discord">InsightFaceSwap</a> on Discord to get a more accurate representation.</p><p>Here’s the final image I generated:</p><figure><img alt="Final upscaled AI Avatar of Virat Kohli, after applying InsightFaceSwap" src="https://cdn-images-1.medium.com/max/741/0*f1h3SyO3ksA27Cy8" /><figcaption>Final upscaled AI Avatar of Virat Kohli, after applying InsightFaceSwap</figcaption></figure><p>You can use the same process to create AI avatars of any person or character you want, such as influencers, fictional characters, or even yourself. You can also customize their appearance, clothing, accessories, and expressions.</p><p>Once you have your AI avatar, you can use it to create AI-generated videos for your ads and campaigns. You can use <a href="https://www.d-id.com/">D-ID Labs</a> to make your avatar talk using text-to-speech technology. You can also add backgrounds, music, effects, and subtitles to your videos.</p><blockquote><strong>Stay tuned for a detailed step-by-step tutorial on creating Video Ads using Creative AI Avatars!</strong></blockquote><p>Using AI avatars and videos for marketing can help you create captivating and personalized content that resonates with your audience. You can also save time and money on hiring actors or video production teams.</p><p>As you can see, using Midjourney for marketing can help you create unique AI avatars and videos that can boost your brand awareness, engagement, and conversions. Just make sure to use them ethically and legally, and respect the rights and preferences of the people or characters you are using.</p><h3>How to Optimize Your Midjourney Images for SEO: 4 Best Practices</h3><figure><img alt="Upscaled image, generated using the prompt “cinematic shot of an SEO expert optimizing content and images on a computer, at High Noon, shot on instax camera using Dichroic-filter, deep focus, Shutter Speed 1/1000, F/22, 32k, Super-Resolution — ar 2:1”" src="https://cdn-images-1.medium.com/max/1024/1*YgBvYhZlloHz1ZOyV9Ousw.png" /><figcaption>Upscaled image, generated using the prompt “<strong>cinematic shot of an SEO expert optimizing content and images on a computer, at High Noon, shot on instax camera using Dichroic-filter, deep focus, Shutter Speed 1/1000, F/22, 32k, Super-Resolution — ar 2:1</strong>”</figcaption></figure><p>Creating stunning visuals with Midjourney is not enough to make your content rank well on search engines. You also need to optimize your images for SEO, so that they can help you drive more organic traffic, improve user experience, and increase conversions. Here are four best practices to optimize your Midjourney images for SEO.</p><h4>1. Use relevant keywords and synonyms in your prompts and image descriptions</h4><p>One of the easiest ways to optimize your Midjourney images for SEO is to use relevant keywords and synonyms in your prompts and image descriptions. Keywords are the words and phrases that users type into search engines to find what they are looking for. Synonyms are words that have the same or similar meaning as your keywords.</p><p>Using keywords and synonyms in your prompts and image descriptions can help you:</p><ul><li>Create images that match the search intent and expectations of your audience</li><li>Make your images more relevant and descriptive for search engines and users</li><li>Increase the chances of your images appearing in image search results and featured snippets</li></ul><p>For example, if you want to create an image for a blog post titled “How to Use Midjourney for Marketing”, you can use keywords and synonyms like:</p><p>/imagine prompt: an image for a blog post titled &quot;How to Use Midjourney for Marketing&quot;, AI image generator, marketing content, visuals, graphics, colorful, modern, catchy, photorealistic</p><p>These keywords and synonyms can help you create an image that reflects the topic and purpose of your blog post, as well as attract the attention of your potential readers.</p><figure><img alt="Midjourney’s response to the prompt “an image for a blog post titled “How to Use Midjourney for Marketing”, AI image generator, marketing content, visuals, graphics, colorful, modern, catchy, photorealistic”" src="https://cdn-images-1.medium.com/max/1024/1*wkpUgtzmj2705KDSoUQO7Q.png" /><figcaption>Midjourney’s response to the prompt “<strong>an image for a blog post titled “How to Use Midjourney for Marketing”, AI image generator, marketing content, visuals, graphics, colorful, modern, catchy, photorealistic</strong>”</figcaption></figure><p><em>Well, now you know how the cover image for this blog was generated! </em>😁</p><h4>2. Adjust the aspect ratio, quality, and size of your images to fit your platform and purpose</h4><p>Another way to optimize your Midjourney images for SEO is to adjust the aspect ratio, quality, and size of your images to fit your platform and purpose. Aspect ratio is the ratio of the width to the height of an image. Quality is the level of detail and clarity of an image. Size is the amount of space an image occupies on a device or a server.</p><p>Adjusting the aspect ratio, quality, and size of your images can help you:</p><ul><li>Create images that look good and fit well on different devices and platforms</li><li>Improve the loading speed and performance of your website or app</li><li>Reduce the bandwidth and storage costs of your images</li></ul><p>For example, if you want to create an image for a Facebook post, you can use the command --a 16:9 to get a landscape type image that fits the platform’s format. You can also use the command --q 0.25 to increase the speed of generation of your image, while compromising slightly on the quality.</p><figure><img alt="Table showing a comparison of the images generated by Midjourney for the same prompt “mc donalds mc spicy chicken burger, scale model, miniature representation, detailed replica, scaled-down, 3D model” using different values of quality ( — q) &amp; aspect ratio ( — ar)" src="https://cdn-images-1.medium.com/max/828/1*d3kF1FGaTFOipvRf69NCvw.png" /><figcaption>Comparison of the images generated by Midjourney for the same prompt <strong>“mc donalds mc spicy chicken burger, scale model, miniature representation, detailed replica, scaled-down, 3D model</strong>” using different values of quality ( — q) &amp; aspect ratio ( — ar)</figcaption></figure><p>These commands can help you create an image that looks sharp and clear on social media like Instagram &amp; Facebook, without compromising the loading speed or taking up too much space.</p><h4>3. Use ASCII art or other effects to create a digitized or computer-centric look for your images</h4><p>A third way to optimize your Midjourney images for SEO is to use ASCII art or other effects to create a digitized or computer-centric look for your images. ASCII art is a type of art that uses characters from the ASCII standard to create images. Other effects are filters or modifications that alter the appearance of an image.</p><p>Using ASCII art or other effects to create a digitized or computer-centric look for your images can help you:</p><ul><li>Create images that stand out from the crowd and catch the eye of your audience</li><li>Showcase your creativity and innovation with unique and original visuals</li><li>Enhance the theme and message of your content with relevant and appropriate effects</li></ul><p>For example, if you want to create an image of a roaring lion with a digitized or computer-centric look, you can use the prompt term ASCII art or other effects like glitch or 16-bit. You can also combine different effects to create more complex and interesting visuals.</p><figure><img alt="Examples of various effects applied to image subjects to create a digitized, nostalgic or futuristic look." src="https://cdn-images-1.medium.com/max/1024/1*FJBV8USCWy8k6LIfEX65yQ.png" /><figcaption>Examples of various effects applied to image subjects to create a digitized, nostalgic or futuristic look.</figcaption></figure><p>These effects can help you create an image that looks nostalgic, or cool and futuristic, as well as convey a sense of technology and power.</p><h4>4. Add alt text, captions, and metadata to your images to make them accessible and searchable</h4><figure><img alt="Upscaled image, generated using the prompt “magnifying glass on a pile of photographs, duotone, purple, cyan — ar 2:1”" src="https://cdn-images-1.medium.com/max/1024/1*1hxdEMcfDww55xDSuG3GMQ.png" /><figcaption>Upscaled image, generated using the prompt “<strong>magnifying glass on a pile of photographs, duotone, purple, cyan — ar 2:1</strong>”</figcaption></figure><p>A fourth way to optimize your Midjourney images for SEO is to add <strong>alt text</strong>, <strong>captions</strong>, and <strong>metadata </strong>to your images to make them accessible and searchable. Alt text is a short description of an image that appears when the image cannot be displayed or accessed. Captions are text that accompanies an image to provide additional information or context. Metadata are data that describe other data, such as title, author, date, location, etc.</p><p>Adding alt text, captions, and metadata to your images can help you:</p><ul><li>Make your images accessible and understandable for people with visual impairments or disabilities</li><li>Make your images searchable and indexable for search engines and users</li><li>Make your images more informative and engaging for your audience</li></ul><h3>Conclusion</h3><p>In this article, you have learned how to use Midjourney for marketing and create stunning visuals with AI. You have seen some practical examples of how to use Midjourney to create graphics, logos, avatars, videos, and more for your marketing content. You have also learned some ethical and legal considerations when using Midjourney, as well as some best practices to optimize your images for SEO.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KAGZbxsJxSdSxW4IoAHJrg.png" /><figcaption>Upscaled image, generated using the prompt “<strong>royal lion as a suited marketing executive — ar 16:9</strong>”</figcaption></figure><p>We hope this article has helped you get started with Midjourney and inspired you to create amazing visuals for your marketing content. <strong><em>If you want to learn more about Midjourney and other AI tools, stay tuned for a series of guides and tutorials that I am in the process of writing and will soon be published.</em></strong></p><p>Before you go, we would love to hear from you: <strong>What are some of the ways you would use Midjourney for marketing?</strong></p><p>Please share your thoughts and ideas in the comment section below.</p><p>Thank you for reading!</p><p>If you enjoyed this article, I’m certain that you’d love my brand-new <em>FREE </em>AI Products &amp; Research newsletter, <strong>“The Vision, Debugged”.</strong></p><p><a href="https://the-vision-debugged.beehiiv.com/subscribe?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how-to-use-midjourney-for-marketing">The Vision Debugged</a></p><p>Subscribe &amp; join the bandwagon of enthusiastic readers across top companies like Microsoft, Google, Walmart, Deloitte &amp; more to get <strong><em>cool AI products &amp; research insights</em></strong>, <strong><em>cheat sheets </em></strong>&amp; <strong><em>resources.</em></strong></p><h3>About the Author</h3><p>Hey folks! I’m <strong>Tezan Sahu</strong>, an Applied Scientist at Microsoft, an Amazon #1 Bestselling Author (for the book “<a href="https://www.amazon.in/Beyond-Code-Strategies-Technical-Scientists-ebook/dp/B0BW8MJW6G/">Beyond Code: A Practical Guide for Data Scientists, Analysts &amp; Engineers</a>”), and co-author of “The Vision, Debugged” newsletter.</p><p>I am passionate about helping aspiring data scientists &amp; software developers kickstart their careers, deliver consistent impact &amp; become differentiated professionals in the field of AI &amp; Data Science.</p><p>If you are interested in learning more about how you can leverage AI to stay ahead of the curve and boost your results, <a href="https://www.linkedin.com/in/tezan-sahu/">connect with me on LinkedIn</a> &amp; <a href="https://the-vision-debugged.beehiiv.com/subscribe?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how-to-use-midjourney-for-marketing">subscribe to my newsletter</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*qqGAresJcxwQ1TZE" /><figcaption>AI-generated avatar of the author (Tezan Sahu) generated using Midjourney &amp; InsightFaceSwap</figcaption></figure><p>Check out <a href="https://tezansahu.com/?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=how_to_use_midjourney_for_marketing">my website</a> &amp; follow me on <a href="https://www.linkedin.com/in/tezan-sahu/">LinkedIn</a>, <a href="https://www.instagram.com/tezan_sahu/">Instagram</a> &amp; <a href="https://twitter.com/SahuTezan">Twitter</a> for interesting content on Al, data science, marketing, leadership, and mindset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*v7EcMIsJSKZVIHY-.png" /></figure><p><strong>This story is published on </strong><a href="https://generativeai.pub/"><strong>Generative AI</strong></a><strong>. Connect with us on </strong><a href="https://www.linkedin.com/company/generative-ai-publication"><strong>LinkedIn</strong></a><strong> to get the latest AI stories and insights right in your feed. Let’s shape the future of AI together!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*dcVXdK6E3wlObGlw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65c6df4b4eba" width="1" height="1" alt=""><hr><p><a href="https://generativeai.pub/how-to-use-midjourney-for-marketing-a-complete-guide-to-creating-stunning-visuals-with-ai-65c6df4b4eba">How to Use Midjourney for Marketing: A Complete Guide to Creating Stunning Visuals with AI</a> was originally published in <a href="https://generativeai.pub">Generative AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developing Microsoft Edge extensions powered by SoTA NLP models]]></title>
            <link>https://medium.com/data-science-at-microsoft/developing-microsoft-edge-extensions-powered-by-sota-nlp-models-f3991f18daa4?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3991f18daa4</guid>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[extension]]></category>
            <category><![CDATA[paraphrasing]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[edge-extensions]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Tue, 10 May 2022 07:17:24 GMT</pubDate>
            <atom:updated>2022-05-10T07:17:24.048Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step tutorial on building a Microsoft Edge extension for text paraphrasing using PEGASUS, KeyBERT, and WordNet</h4><p>A Microsoft Edge extension is a small program that allows developers to modify or “extend<em>”</em> certain functionality in Microsoft Edge. It enhances the browsing experience of a specific target audience by usually performing a niche function. Information aggregation, web content enrichment, ad blocking, memory optimization, and password management are just <em>some </em>examples of the plethora of functionality these extensions enable.</p><p>Developing an extension for Edge is not very complicated. Such extensions are built on web technologies like HTML, JavaScript, and CSS. Based on the functionality that they are designed to provide, these extensions may also require a server with API endpoints exposed that the user interface can interact with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JAS7S3fELyenpUSo5zc0FA.png" /><figcaption><strong>Source:</strong> Image created by the author.</figcaption></figure><p>In this article, I present a detailed overview of how to get started creating your very own Edge extensions that leverage state-of-the-art NLP techniques. I show this with an extension I’ve created to be an AI-powered text paraphraser and synonym finder for keywords in text. I use the <a href="https://huggingface.co/docs/transformers/model_doc/pegasus"><strong>PEGASUS transformer model</strong></a><strong><em> </em></strong>from HuggingFace for paraphrasing, along with the <a href="https://maartengr.github.io/KeyBERT/index.html"><strong>KeyBERT model</strong></a> for keyword extraction, and <a href="https://www.nltk.org/howto/wordnet.html"><strong>WordNet</strong></a><strong><em> </em></strong>to find synonyms. Such an extension might come in handy for numerous purposes, including rewriting a block of sentences in an article, post, or email.</p><p>So, let’s get started!</p><blockquote><strong>Tl;dr: </strong><a href="https://github.com/tezansahu/Janus-AI">This repository</a> contains all the code mentioned in this article. Although GitHub gists are used as code snippets throughout this article, if copied directly, they may not work as intended. In case you face such issues, please refer to <a href="https://github.com/tezansahu/Janus-AI">the repository</a> for the exact directory structure and code that goes into each file.</blockquote><h3><strong>Bird’s-eye view of how the extension works</strong></h3><p>Let’s start by giving the extension a name. I will call it <strong><em>Janus AI: Smart Paraphrasing Solution</em></strong> (According to Roman mythology, <a href="https://en.wikipedia.org/wiki/Janus">Janus</a> is the god of change and transitions, and the idea of paraphrasing is to “change” the expression of some text for better clarity).</p><p>The user interface of the extension is to be a popup (like most other extensions) that allows users to input text for paraphrasing in two ways:</p><ul><li>The user can type or paste textual content into the input box.</li><li>The user can select a piece of text from any tab in the browser and click the extension to automatically populate the input box.</li></ul><p>When the user clicks the “Rephrase” button, the extension sends the text to the API server, which performs the paraphrasing using PEGASUS, keyword extraction using KeyBERT, and then finds synonyms for these keywords using WordNet. When the result is returned to the extension, the paraphrased text, along with the keywords and their synonyms, is displayed on the popup.</p><p>The user can then copy the paraphrased text just as it is or modify it with the synonyms of the keywords identified and then copy the text for further use.</p><h3>Developing the RESTful API server</h3><p>Janus AI requires a <a href="https://www.techtarget.com/searchapparchitecture/definition/RESTful-API">RESTful API</a> server for the extension to send the user’s input text and receive the paraphrased text along with the keywords and their synonyms. I spin up this server using <a href="https://fastapi.tiangolo.com/"><strong>FastAPI</strong></a> as it is extremely powerful yet very simple to use and has pretty good documentation. The API endpoints of this server use the modules for paraphrasing, keyword extraction, and synonym finding.</p><h4>Preliminaries</h4><p>First, I create a folder called server/ for the API server, which contains two files: main.py and paraphrasingModule.py. Then I install the following packages in a virtual environment:</p><pre>fastapi==0.75.2<br>keybert==0.5.1<br>nltk==3.7                 <em># To leverage WordNet for finding synonyms</em> <br>sentence-splitter==1.4    <em># To split sentences from input text</em><br>sentencepiece==0.1.96     <em># Required by PEGASUS paraphraser model</em><br>torch==1.11.0<br>transformers==4.18.0<br>uvicorn==0.17.6           <em># Lightweight server to run FastAPI code</em></pre><p>These packages are found in the server/requirements.txt file.</p><h4>Module for paraphrasing, keyword extraction and synonym finding</h4><p>The server/paraphrasingModule.py file contains the PEGASUS paraphraser, KeyBERT keyword extractor, and synonym finder.</p><p><strong>PEGASUS for paraphrasing:</strong> PEGASUS stands for <em>Pre-training with Extracted Gap-sentences for Abstractive SUmmarization Sequence-to-sequence models</em>. Developed by Google Research, it is fine-tuned for text paraphrasing and is <a href="https://huggingface.co/tuner007/pegasus_paraphrase">available on HuggingFace</a>. This model and its tokenizer are loaded when the PegasusParaphraser class is instantiated. Because the user input can contain multiple sentences, SentenceSplitter() is used to split the paragraph into individual sentences and pass them as batch input to the tokenizer and model. The model requires the following hyperparameters to be set:</p><ul><li>num_return_sequences is set to 1 to return only one paraphrase per sentence</li><li>num_beams is set to 10 to allow 10 beams during <a href="https://towardsdatascience.com/foundations-of-nlp-explained-visually-beam-search-how-it-works-1586b9849a24">beam search</a> for selecting alternatives of the input sequence</li><li>max_length is set to 100 to allow the generation of a maximum of 100 tokens per paraphrased sentence</li><li>temperature is set to 1.5 to generate more diverse outputs (temperature controls prediction randomness)</li></ul><p>The output from the model is a List of paraphrased sentences, which are then concatenated and returned.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7811244d5fde245876223ad76e907c99/href">https://medium.com/media/7811244d5fde245876223ad76e907c99/href</a></iframe><p><strong>Keyword extraction and prefix finding using KeyBERT and WordNet: </strong>KeyBERT is a minimal keyword extraction technique that uses BERT-embeddings and cosine similarity to find the sub-phrases in a piece of text that are the most similar to the overall text itself. The model is loaded when the KeywordSynonyms class is instantiated. The extract_keywords() function of KeyBERT extracts and returns a List of the keywords and their similarity scores.</p><p>Once the keywords are extracted, the WordNet corpus reader in nltk is used to obtain synonyms for them. WordNet is a huge lexical database of English where words are grouped into sets of cognitive synonyms (<em>synsets</em>), each expressing a distinct concept. These synsets are used to obtain relevant synonyms for any word.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f9b494f6f8cb3c17533be6f9066cf68/href">https://medium.com/media/0f9b494f6f8cb3c17533be6f9066cf68/href</a></iframe><h4>RESTful API server with FastAPI</h4><p>With this, we are set to write the code in the server/main.py file, which loads our paraphrasing, keyword extraction, and synonym finding modules, and serves them as an API endpoint using FastAPI. Basically, we spin up a server and offer the endpoint POST /paraphrase for our extension to send the user’s text input. It returns a JSON object containing the paraphrased text and the synonyms of the extracted keywords from the text as a response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/680b0b18a498b0521b4f2d1feceecfaa/href">https://medium.com/media/680b0b18a498b0521b4f2d1feceecfaa/href</a></iframe><p>Now, on running uvicorn main:app --host=0.0.0.0 --port=8000, the server starts running on <a href="http://0.0.0.0:8000">http://0.0.0.0:8000</a> after downloading (if not already present) and loading the models. 0.0.0.0 indicates that the server can be accessed by the loopback address 127.0.0.1, as well as through the IP address of the machine that the server is started on.</p><p>To test the endpoint, visit the interactive documentation (created automatically by FastAPI) at http://127.0.0.1:8000/docs to find the POST /predict endpoint. This can be tested by expanding the section &amp; clicking on “<em>Try it now”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQQOeVMFEAKUz7dN65nKWA.png" /><figcaption>Testing of the POST /paraphrase endpoint in the RESTful API server by going to <a href="http://localhost:8000/docs">http://localhost:8000/docs</a></figcaption></figure><p>Having set up the API server, I proceed to build the actual extension with which the user interacts.</p><h3>Developing the Edge extension</h3><p>Microsoft Edge is built on Chromium. Hence, most of the stable chrome APIs (used for developing Chrome extensions) can also be used for developing Edge extensions. <a href="https://docs.microsoft.com/en-us/microsoft-edge/extensions-chromium/developer-guide/api-support">The complete list of supported APIs can be found in this documentation.</a></p><p>The overall structure of an extension is similar to that of a regular web app. The basic components that it should include are:</p><ul><li>An app <strong><em>manifest JSON</em></strong> containing the configuration of the extension</li><li><strong><em>HTML (and CSS) file(s)</em></strong> defining the user interface</li><li><strong><em>JavaScript file(s)</em></strong> defining the functionality</li><li>Icon for the extension and other images as required by the extension</li></ul><h4>Preliminaries</h4><p>To start, I create a new directory extension/ to maintain the files required by the extension. This folder shall contain the following:</p><pre>extension/<br>├── assets/           <em># Folder to contain icons and other images</em><br>│   └── icons/        <em># Folder to contain all the icons</em><br>│       └── icon.png<br>├── popup/<br>│   ├── popup.html    <em># Code for the popup UI</em><br>│   └── popup.js      <em># Code for logic layer in the popup</em><br>└── manifest.json     <em># App manifest file</em></pre><p>For this extension, I used an <a href="https://www.freelogoservices.com/">online logo generator</a> to create a single icon for Janus AI and saved it as extension/assets/icons/icon.png. However, one can also choose to save multiple variations of the icon based on different sizes.</p><h4>Setting up the manifest</h4><p>Development of extensions usually starts by creating a manifest.json file that contains all the configurations of the extension. A basic manifest file contains the name, description, version (i.e., the version of the extension), and manifest_version.</p><blockquote><strong>Note: </strong>With the adoption of Manifest V3, Manifest V2 is progressively being phased out. Manifest V3 and its feature-set offer greater privacy, security, and performance. Hence, the manifest_version is set to 3 for Janus AI.</blockquote><p>Following is the manifest.json file for Janus AI:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44a27ce36be2d20ed6fae8fb3efeb5d6/href">https://medium.com/media/44a27ce36be2d20ed6fae8fb3efeb5d6/href</a></iframe><p>Based on the functionality of Janus AI, several other parameters need to be present in the manifest file:</p><ul><li>permissions: Specify the optional permissions based on the chrome APIs necessary to implement the extension’s functionality. For Janus AI, the chrome.tabs and chrome.scripting APIs are required.</li><li>host_permissions: Because our extension should be able to identify selected text from any active tab in the browser, it should discover all hosts at runtime. Thus, &quot;https://*/&quot; should be included in the host permissions.</li><li>action: This is used to control the behavior of the extension in the Edge toolbar. Within this, default_title specifies what is shown in the tooltip, default_icon specifies the path to the icon to be displayed on the Edge toolbar, and default_popup specifies the HTML file defining the UI of the popup that appears on clicking the extension.</li><li>icons: These specify the paths to various sizes of the extension’s icon.</li></ul><p><a href="https://developer.chrome.com/docs/extensions/mv3/manifest/">Here is the full list of parameters supported by Manifest V3.</a></p><h4>Creating the user interface</h4><p>In the manifest file, the default_popup in action is set to popup/popup.html, which defines what the UI of the popup for Janus AI looks like. Below is an outline of what the UI looks like and how it behaves.</p><p>When the extension is clicked, the popup should contain:</p><ul><li>An input box (or textarea) for the user to input the text to be paraphrased (either by typing or by selecting text on a tab and clicking the extension)</li><li>A “Rephrase” button, which when clicked, sends the input to the API server for paraphrasing</li></ul><p>While the extension receives a response from the server, a <em>spinner </em>can be shown to depict that the result is loading. Once the response is received, the paraphrased text should be populated and displayed in a textarea so that it can be edited if needed. The keywords and their synonyms should also be populated and displayed to the user.</p><p>To facilitate the efficient and elegant design of the UI, <strong>Bootstrap v5.1</strong> is used as it provides several customizable off-the-shelf UI components, without the need to write explicit CSS code.</p><p>This is what the extension/popup/popup.html file looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ee97a59e6fc35a3e098c130919963e4/href">https://medium.com/media/5ee97a59e6fc35a3e098c130919963e4/href</a></iframe><p>Toward the end, we include the popup.js file, which implements the actual functionality of the extension.</p><h4>Leveraging Chrome APIs to select text in the active tab</h4><p>The first of the two broad categories that the functionality of Janus AI is divided into involves obtaining the text selected by the user in the browser’s active tab and populating the input textarea. This is achieved by adding the following code in the extension/popup/popup.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fb06c9b887696af75963cbffa8081f4/href">https://medium.com/media/4fb06c9b887696af75963cbffa8081f4/href</a></iframe><p>This code adds an event listener that triggers the function to get selected text from the active browser tab when the DOM content of extension is loaded upon being clicked. This is accomplished programmatically by injecting the _getSelectedTextFromTab() function <em>(using the </em><em>chrome.scripting API)</em> into the active tab <em>(obtained using the </em><em>chrome.tabs API).</em></p><h4>Adding functionality to interact with the API server</h4><p>The second category of functionality implemented in the popup.js file involves interacting with the API server to fetch the paraphrased text and synonyms and display the results to the user. The following code implements this functionality:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34acab540225330a1a8efd79526f4565/href">https://medium.com/media/34acab540225330a1a8efd79526f4565/href</a></iframe><p>This adds a click event listener that issues a POST request to the API server for non-empty user input when the “Rephrase” button is clicked. Once the response is received by the extension, the paraphrased text is placed in the output textarea while the synonyms are dynamically displayed in a tabular format.</p><p>The extension is now fully functional and can be loaded into Microsoft Edge for testing.</p><h3>Using the extension on Microsoft Edge</h3><p>To load the extension into Microsoft Edge, go to the <strong>Manage extensions</strong> menu using edge://extensions/, enable the <strong>Developer mode</strong>, and select the extension/ folder after clicking on <strong>Load Unpacked</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WlIGDVqmmnAedv2m6uXofA.png" /></figure><p>Once loaded, the icon for Janus AI appears on the Edge toolbar. After ensuring that the API server is up and running at <a href="http://localhost:8000,">http://localhost:8000</a>, you can use the extension by selecting some text on any browser tab and clicking the extension icon on the toolbar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9UFl-zkPxOO5-eRrbRYjQ.gif" /><figcaption>Working demo of Janus AI extension on Microsoft Edge</figcaption></figure><h3>Distribution of the extension for public use</h3><p>Once the extension has been developed and tested, it is ready for distribution. Before this, however, the server must be hosted online. Although it’s possible to use platforms like Heroku or set up an Azure Compute instance to host the server, I explore a more scalable and hassle-free approach that uses <strong>Docker<em> </em></strong>and <strong>Azure Container Service</strong> instances.</p><h4>Containerizing and hosting the server using Azure Container Service</h4><blockquote><strong>Note: </strong>This section assumes that you have Docker and Azure CLI installed already. If not, they can be installed using the installation docs for <a href="https://docs.docker.com/engine/install/">Docker</a> and <a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli">Azure CLI</a>.</blockquote><p>Containerization refers to the packaging of software code with just the OS libraries and dependencies required to run the code into a single lightweight executable — called a <em>container</em> — that runs consistently on any infrastructure.</p><p>I use Docker to containerize the API server before hosting it using Azure Container Service. To build a Docker image of the server, I create a Dockerfile in the server/ directory with the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a18d3399ba8be15824dc690be045d6/href">https://medium.com/media/96a18d3399ba8be15824dc690be045d6/href</a></iframe><p>After creating the Dockerfile, the Docker image for the server is built by issuing the docker build -t janus_ai . from within the server/ folder. The image created is tagged with the name janus_ai.</p><p>To run this image in a container on Azure, we need to create a <strong>container registry</strong> on Azure. Using Azure CLI, this can be done as follows:</p><pre><em># Log into Azure CLI<br></em>az login</pre><pre><em># Create a resource group (calling it &#39;janus&#39;)</em><br>az group create --name janus --location eastus</pre><pre><em># Create a container registry (calling it &#39;janus_cr&#39;)</em><br>az acr create --resource-group janus --name janus_cr --sku Basic</pre><p>When the registry is created, a JSON output is obtained that contains the loginServer. This value should replace the &lt;login-server&gt; when the image is pushed to this registry:</p><pre><em># Log into the registry</em><br>az acr login --name janus_cr</pre><pre><em># Tag the image with the name of the login server of the registry</em><br>docker tag janus_ai &lt;login-server&gt;/janus_ai</pre><pre><em># Push the image to the registry</em><br>docker push &lt;login-server&gt;/janus_ai</pre><p>With this, we now deploy this image to an Azure Container Service instance:</p><pre><em># Create a container instance</em><br>az container --resource-group janus --name janus_ai --image &lt;login-server&gt;/janus_ai --dns-name-label janus_ai --ports 8000</pre><blockquote><strong>Note:</strong> The dns-name-label should be unique within the Azure region where the instance is created.</blockquote><p>The deployment shall complete in a few moments, and the <strong>fully qualified domain name (FQDN)</strong> of the container can be found using az container show --resource-group janus --name janus_ai --out table --query “{FQDN:ipAddress.fqdn}}”.</p><p>Finally, the base_url in the extension/popup/popup.js file must be changed to the FQDN returned by the previous command.</p><h4>Publish the extension on Microsoft Edge Add-ons website</h4><p>Having deployed the server, the extension can be published on the <a href="https://microsoftedge.microsoft.com/addons/Microsoft-Edge-Extensions-Home">Microsoft Edge Add-ons website</a> to increase its reach and make it available to other Microsoft Edge users. The detailed steps to do so are described in <a href="https://docs.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/publish-extension">this documentation</a>.</p><h3>Concluding remarks</h3><p>In this article, I have illustrated how to develop a text paraphrasing extension for Microsoft Edge that is powered by state-of-the-art NLP models. I start by creating the API server with the modules for paraphrasing, keyword extraction, and synonym finding, followed by building the UI and functionality of the extension from scratch. Toward the end, I also discuss how to containerize the server to deploy it using Azure Container Services and publish the extension on the Microsoft Edge Add-ons website.</p><p>Hopefully, this article has given you a good understanding of how to leverage NLP solutions in building your own extensions for Microsoft Edge.</p><blockquote>All the code mentioned in this article is available in <a href="https://github.com/tezansahu/Janus-AI">this repository</a>.</blockquote><p><em>Tezan Sahu is on </em><a href="https://www.linkedin.com/in/tezan-sahu/"><em>LinkedIn</em></a><em> and </em><a href="https://github.com/tezansahu"><em>GitHub</em></a><em>.</em></p><h3>References</h3><ol><li><a href="https://analyticsindiamag.com/how-to-paraphrase-text-using-pegasus-transformer/">How To Paraphrase Text Using PEGASUS Transformer</a></li><li><a href="https://maartengr.github.io/KeyBERT/index.html">KeyBERT Documentation</a></li><li><a href="https://www.nltk.org/howto/wordnet.html">NLTK :: Sample usage for wordnet</a></li><li><a href="https://docs.microsoft.com/en-us/microsoft-edge/extensions-chromium/">Overview of Microsoft Edge extensions — Microsoft Edge Development | Microsoft Docs</a></li><li><a href="https://developer.chrome.com/docs/extensions/">Extensions — Chrome Developers</a></li><li><a href="https://docs.microsoft.com/en-us/azure/container-registry/container-registry-quickstart-task-cli">Quickstart — Build a container image on-demand in Azure — Azure Container Registry | Microsoft Docs</a></li><li><a href="https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quickstart">Quickstart — Deploy Docker container to container instance — Azure CLI — Azure Container Instances | Microsoft Docs</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3991f18daa4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-at-microsoft/developing-microsoft-edge-extensions-powered-by-sota-nlp-models-f3991f18daa4">Developing Microsoft Edge extensions powered by SoTA NLP models</a> was originally published in <a href="https://medium.com/data-science-at-microsoft">Data Science + AI at Microsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tracking and Monitoring Transformers with MLFoundry]]></title>
            <link>https://medium.com/analytics-vidhya/tracking-and-monitoring-transformers-with-mlfoundry-460a3b860600?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/460a3b860600</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[mlfoundry]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Mon, 21 Mar 2022 11:20:34 GMT</pubDate>
            <atom:updated>2022-03-21T11:20:34.430Z</atom:updated>
            <content:encoded><![CDATA[<h4>Efficient tracking and monitoring of Transformer models for Financial Sentiment Analysis using MLFoundry, by TrueFoundry</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rV5vZWZGW5xiqp70" /><figcaption>Source: <a href="https://www.catchpoint.com/blog/digital-monitoring-offer">Catchpoint Digital Monitoring: Offering lowest cost options without compromising quality</a></figcaption></figure><p>Natural language processing (NLP) has become increasingly popular in financial applications in recent years. Stock/forex market forecasting, volatility modeling, asset allocation, business taxonomy construction, credit scoring, initial public offering (IPO) valuation, and other applications are among them. One common task (or rather subtask, which can provide <em>features </em>for some tasks mentioned previously) in this financial domain is <strong><em>Financial Sentiment Analysis (FSA)</em></strong><em>.</em> The goal of FSA is to classify financial text as expressing bullish or bearish opinions on specific arguments.</p><p>In this new era of NLP, tasks like FSA have also been impacted by the dominance of transformers. Models like <a href="https://arxiv.org/pdf/1908.10063.pdf"><em>FinBERT</em></a> perform significantly better compared to previous approaches.</p><p>In this tutorial, we will explore how to easily fine-tune any pretrained transformer for the FSA task using the <a href="https://simpletransformers.ai/docs/usage/"><strong><em>Simple Transformers</em></strong></a> library. Then, we will experiment iteratively by changing parameters and base models and tracking the relevant information using <a href="https://truefoundry.gitbook.io/mlfoundry/"><strong><em>MLFoundry</em></strong></a>. We will create a custom demo of our model using the MLFoundry Web App, which could be shared with others or showcased to users.</p><p>So, let’s dive in!</p><p><strong><em>Tl;dr: </em></strong><em>If you wish to see only the working implementation of all that we cover in this article, please refer to </em><a href="https://gist.github.com/tezansahu/a22dd2e4d880d4fc2e308e36795219a2"><em>this notebook</em></a><em>. Although GitHub gists are used as code snippets throughout this article, if copied directly, they may not work as intended. Feel free to refer to the </em><a href="https://gist.github.com/tezansahu/a22dd2e4d880d4fc2e308e36795219a2"><em>mentioned notebook</em></a><em> in case you face such issues.</em></p><h3>Preliminaries</h3><p>We first create a virtual environment for this project and install the necessary libraries:</p><pre>matplotlib==3.5.1<br>mlfoundry==0.2.7<br>mlfoundry-ui==0.1.4<br>numpy==1.21.5<br>pandas==1.4.1<br>scikit-learn==0.24.2<br>simpletransformers==0.63.4<br>torch==1.10.2</pre><blockquote><strong>Note:</strong> It is advisable to have some GPU access to train the transformer models because they are large and require considerable time for training otherwise. Using Google Colab can be a viable solution.</blockquote><p>Next, we need to create an IPython notebook and import the required libraries. Optionally, we can also clear the cache in CUDA.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80761654c515a1ceeed21fd1969c0e9b/href">https://medium.com/media/80761654c515a1ceeed21fd1969c0e9b/href</a></iframe><p>We do not need to set the device in PyTorch explicitly because simpletransformers library automatically takes care of that and uses GPU by default.</p><h3>Sentiment Analysis for Financial News using Simple Transformers</h3><h4>Exploring &amp; Processing the Dataset</h4><p>For this tutorial, we use the processed <a href="https://www.kaggle.com/ankurzing/sentiment-analysis-for-financial-news"><em>FinancialPhraseBank</em> data available from Kaggle</a>. This dataset contains sentiments for financial news headlines as seen through the eyes of a retail investor. The all-data.csv file contains two columns, <em>Sentiment</em> and <em>News Headline</em>. The sentiment can be negative, neutral, or positive. Thus, the FSA task is treated as a multi-class classification problem.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa8180d59dbb7c5761005d187cb388c3/href">https://medium.com/media/fa8180d59dbb7c5761005d187cb388c3/href</a></iframe><p>Since the Simple Transformers library requires data to be in Pandas DataFrames with at least two columns, named text (of type str) and labels (of type int), we do the required processing before splitting the data into training &amp; evaluation sets.</p><h4>Training a BERT Model for FSA</h4><p>We define a simple training function that takes in the specifications of the model to create a ClassificationModel, along with the training hyperparameters to perform the training loop. We also evaluate the model using <em>Micro-F1</em> and <em>Accuracy</em> scores by leveraging scikit-learn.</p><p>As a wrapper around the Hugging Face library, Simple Transformers makes it extremely simple to do all this by abstracting away the heavy-lifting required. Thus, we can create, train &amp; evaluate our transformer with just 3–4 statements.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/467ac55162eafcc1b310b67e1adb5728/href">https://medium.com/media/467ac55162eafcc1b310b67e1adb5728/href</a></iframe><p>In the constructor of ClassificationModel, the first parameter is the <em>model_type, </em>the second is the <em>model_name</em>, and the third is the number of labels in the data (set to 3 because we have three sentiments). Currently, Simple Transformers supports one of <a href="https://simpletransformers.ai/docs/classification-specifics/#supported-model-types">the available types</a> as the <em>model_type. </em>The <em>model_name </em>can be from among any of the models available on <a href="https://huggingface.co/models">Hugging Face</a>.</p><p>After training the model, we evaluate it using eval_model(). This function returns the following:</p><ul><li>A dict containing the performance metrics on the evaluation dataset (Matthews correlation coefficient and loss by default, along with micro-F1 and accuracy defined by us)</li><li>A list of model outputs for each evaluation instance</li><li>A list of inputs for which the model predicts incorrectly</li></ul><p>The trained model checkpoints are stored in training_args[&#39;output_dir&#39;].</p><p><em>There are many hyperparameters that you can change based on your requirement. The full list with their default values can be found below:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e920771b9a1b4d90e56c3d920413b096/href">https://medium.com/media/e920771b9a1b4d90e56c3d920413b096/href</a></iframe><p>Before actually supplying the trainModel() function with the required parameters, we will introduce MLFoundry to set up the tracking required for our experimentation.</p><h3>Introducing MLFoundry for Tracking and Monitoring</h3><p>MLFoundry is the ML Monitoring &amp; Experiment Tracking solution created by <a href="https://truefoundry.com/"><strong><em>TrueFoundry</em></strong></a>, that allows users to track their experiments, models, metrics, data &amp; features. Each experiment, with a unique combination of parameters, dataset, and metrics is considered a <strong><em>run</em></strong>, and multiple such runs can be grouped logically as a <strong><em>project</em></strong>. Each run has a unique <strong><em>run_id</em></strong>, but can also be given a <strong><em>run_name </em></strong>for easier referencing. Later, these runs can be inspected and compared using an interactive dashboard.</p><h4>Logging Experiment Details with MLFoundry</h4><p>First, we import MLFoundry and initialize the API. Then, we create our project (called financial-sentiment-analysis) with our first run named bert_3epochs. This experiment will involve fine-tuning a BERT model for three epochs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/773313ba96cfc2a86dec757cee18164e/href">https://medium.com/media/773313ba96cfc2a86dec757cee18164e/href</a></iframe><p>This creates a mlf/ folder in the project directory that will contain all the information across the various runs logged by MLFoundry.</p><p>Now, we modify our trainModel() function to accept a run as input and log all the required information (parameters, dataset, metrics, and dataset stats).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbf764e285ca005b222eea2d4392fa7e/href">https://medium.com/media/fbf764e285ca005b222eea2d4392fa7e/href</a></iframe><ul><li>To log the <strong><em>training &amp; evaluation datasets</em></strong>, we use <a href="https://truefoundry.gitbook.io/mlfoundry/api-doc/mlfoundry/mlfoundryrun/log_dataset">log_dataset()</a></li><li>We log the <strong><em>model specification</em></strong>s (type and name), along with the <strong><em>hyperparameters </em></strong>as a dictionary using l<a href="https://truefoundry.gitbook.io/mlfoundry/api-doc/mlfoundry/mlfoundryrun/log_params">og_params()</a></li><li>The dictionary containing the <strong><em>performance metrics</em></strong> on our evaluation set (accuracy and micro-f1) is logged using <a href="https://truefoundry.gitbook.io/mlfoundry/api-doc/mlfoundry/mlfoundryrun/log_metrics">log_metrics()</a>.</li><li>Various <strong><em>metrics related to our datase</em></strong>t, along with <strong><em>statistics </em></strong>like counters, summaries, histograms, and most frequent values are estimated using <a href="https://docs.whylabs.ai/docs/">whylogs</a> automatically when logged using <a href="https://truefoundry.gitbook.io/mlfoundry/api-doc/mlfoundry/mlfoundryrun/log_dataset_stats">log_dataset_stats()</a>.</li></ul><p>Now, we set the hyperparameters in the form of a dictionary along with the model specifications and call the trainModel() function for the run that we defined previously.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a41958e9dcb33011b9f2dab84bee4d32/href">https://medium.com/media/a41958e9dcb33011b9f2dab84bee4d32/href</a></iframe><p>This loads weights from the pre-trained bert-base-uncased model and fine-tunes it based on the supplied hyperparameters for three epochs.</p><h4>Navigating around the MLFoundry Dashboard</h4><p>Once the training is complete, we can view all the logged information in the <a href="https://truefoundry.gitbook.io/mlfoundry/mlfoundry-dashboard">MLFoundry Dashboard</a> by running the command mlfoundry ui from within the project folder (containing the mlf/ folder). This starts the dashboard on localhost:4200 by default (we can change the port by running export STREAMLIT_SERVER_PORT=&lt;your-preferred-port&gt;).</p><p>Under the<strong><em> Single Run View</em></strong>, select financial-sentiment-analysis as the <strong><em>Project Name</em></strong> and bert_3epochs as the <strong><em>Run Name</em></strong>. Now, we can inspect all the information about that specific run that has been tracked, using the different tabs:</p><ul><li>The <strong><em>Model Health</em></strong> section shows the performance metrics of the current model on the evaluation dataset. These include a confusion matrix (since this is a multiclass classification task) along with other relevant plots.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MTPNRBmfHIGOD8TEFFS64Q.png" /><figcaption>Model Health section showing the various user-generated and auto-generated metrics for bert_3epochs run</figcaption></figure><ul><li>The <strong><em>Data Health</em></strong> section contains various stats related to our dataset, which can be used to understand the data quality and compare it against other datasets if there is a data change later.</li><li>The <strong><em>Feature Health</em></strong> section shows the numerical distribution of labels and predicted values based on input features. For our case, there is only one input feature named <em>headline</em>, containing the financial news headline.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SYd8DLi11btmv-qovBAWKQ.png" /><figcaption>Feature Health section showing the numerical feature distribution of classes for the labels and predictions for bert_3epochs run</figcaption></figure><ul><li>The <strong><em>Run Details</em></strong> section displays all the parameters and metrics logged for the run and also allows users to view the datasets and other artifacts related to the run that were tracked.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*KIML3cpmmmgd0V43HgRP9Q.png" /></figure><p>We see that after three epochs of training, our fine-tuned BERT model can achieve an <strong><em>accuracy of 0.82</em></strong> and <strong><em>micro-F1 score of 0.82</em></strong>.</p><h3>Efficient Tracking and Comparison of Multiple Experiments with MLFoundry</h3><p>Now, we will see how easy it is to experiment with different models and parameters for a specific task while being able to track all the relevant information for reference by creating different runs within the same project.</p><p>To demonstrate experimentation by changing hyperparameters, we create a new run called bert_5epochs and pass it to the trainModel() function along with the training_args dictionary (this time, the value of num_train_epochs in this dictionary is set to 5 instead of 3) and model_params (no change).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1333e1a29f8787a0c01fa1c504f4405e/href">https://medium.com/media/1333e1a29f8787a0c01fa1c504f4405e/href</a></iframe><p>To illustrate the use of different transformer architectures for experimentation, we create a new run called roberta. This time, we keep the training_args unchanged from the previous run (with 5 epochs) and change the model_params to use the weights of pre-trained RoBERTa instead of BERT.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/680c2ea09b8a7c9fc65d57a9e1969bb4/href">https://medium.com/media/680c2ea09b8a7c9fc65d57a9e1969bb4/href</a></iframe><p>Once the training of these models completes, we again go to the MLFoundry Dashboard to inspect the tracked information by selecting the specific <em>run_name </em>under <em>Single Run View</em>. Now that we have more than one run, we can also compare them under <strong><em>Run Comparison</em></strong>.</p><p>The runs to be compared can be selected either using their <em>run_id</em> or <em>run_name</em>, the latter being more comfortable<em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVTbLBP20RN5Pgvc-_SFpg.png" /></figure><ul><li>When trained for more epochs, the BERT model showed better accuracy</li><li>The <strong><em>RoBERTa </em></strong>model gives the <strong><em>best accuracy</em></strong> of <strong><em>0.866</em></strong></li></ul><p>Scrolling below, we can also see the consolidated plot of all the performance metrics tracked for each run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGhYMXSlDJVWLUYAsM6BzA.png" /></figure><h3>Model Demo using MLFoundry Web App</h3><p>Having understood the process of iterative experimentation, tracking, and comparison of transformer models with MLFoundry, we now wish to demonstrate the performance of our best model (i.e. RoBERTa) to a broader audience. This is where the <strong><em>MLFoundry Web App</em></strong> comes in handy.</p><p>For this, we can create a standalone web app file that will be registered with the appropriate run using log_webapp_file(). Since we want to make the demo for our RoBERTa model, we name this file streamlit_roberta.py (it could be named anything else as well). In this file, we first need to write a function that can load a saved Simple Transformer model and predict the sentiment using the loaded model for an input financial news headline. Then, we need to initialize the MLFoundry client, create a run, and call webapp() from the run by supplying it with the prediction function, type(s) of inputs and outputs (here, we have just one input and one output, each of type text). This defines a model demo interface on the dashboard.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bcd4a12ad82332e5f3bdee1ac2b44709/href">https://medium.com/media/bcd4a12ad82332e5f3bdee1ac2b44709/href</a></iframe><p>Back in our notebook where we trained our models, we can register this file with mlf_run_3, which tracks all the information for our RoBERTa-based experiment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/785a7735bfac8a19f672e00d03443f08/href">https://medium.com/media/785a7735bfac8a19f672e00d03443f08/href</a></iframe><p>In the dashboard, when we can select the roberta run and open the <strong><em>Model Demo</em></strong> section, we see an interactive demo (similar to the <em>Model Card</em> in Hugging Face) that leverages our saved RoBERTa checkpoint to predict the sentiment of a financial news headline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Y0R5TUKHg3uBv-ilRqzeQ.png" /><figcaption>Example of a financial news headline being classified correctly as ‘positive’ by our fine-tuned RoBERTa model as seen in the MLFoundry Web App for the run named ‘roberta’</figcaption></figure><p><em>Since this web app is built using </em><a href="https://streamlit.io/"><em>Streamlit</em></a><em>, we can import </em><em>streamlit into the </em><em>streamlit_roberta.py file and use it to add other elements (for example, to add explainability, etc.) to this model demo dashboard as well for customization.</em></p><h3>Concluding Remarks</h3><p>In this tutorial, we initially saw how to easily train transformer models for an NLP task like Financial Sentiment Analysis using Simple Transformers. Later, we used MLFoundry to track the parameters, metrics, datasets, and stats for the different experiments that we performed by varying some hyperparameters and the model architecture. In the end, we also created a web app to demonstrate the working of our trained model to predict the sentiments of financial news headlines.</p><p>Feel free to check out the References section below for more details regarding the documentation of the libraries mentioned in this tutorial. Please leave any feedback or suggestions in the comments section below.</p><p><a href="http://truefoundry.com/"><em>TrueFoundry</em></a><em> is building one of the fastest framework for ML Pipelines that relies on Open standards, </em><strong><em>saving 30–40% of a Data Science team’s time </em></strong><em>through their automated post-model pipeline. Feel free to </em><a href="https://truefoundry.com/contact"><em>sign up for early access to TrueFoundry’s ML monitoring and auto-scaling solution</em></a><em>!</em></p><p><em>Tezan Sahu is on </em><a href="https://www.linkedin.com/in/tezan-sahu/"><em>LinkedIn</em></a><em> and </em><a href="https://github.com/tezansahu"><em>GitHub</em></a><em>.</em></p><h3>References</h3><ol><li><a href="https://aclanthology.org/2020.coling-main.85.pdf">Financial Sentiment Analysis: An Investigation into Common Mistakes and Silver Bullets | aclanthology.org</a></li><li><a href="https://simpletransformers.ai/">Simple Transformers</a></li><li><a href="https://medium.com/swlh/simple-transformers-multi-class-text-classification-with-bert-roberta-xlnet-xlm-and-8b585000ce3a">Simple Transformers — Multi-Class Text Classification with BERT, RoBERTa, XLNet, XLM, and DistilBERT | by Thilina Rajapakse | The Startup | Medium</a></li><li><a href="https://truefoundry.gitbook.io/mlfoundry/">MLFoundry | gitbook.io</a></li><li><a href="https://medium.com/@nikunjbajaj/truefoundrys-ml-monitoring-experiment-tracking-solution-ba5ad9c6cbe6">TrueFoundry’s ML Monitoring &amp; Experiment Tracking Solution | by Nikunj Bajaj | Medium</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=460a3b860600" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/tracking-and-monitoring-transformers-with-mlfoundry-460a3b860600">Tracking and Monitoring Transformers with MLFoundry</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visual question answering with multimodal transformers]]></title>
            <link>https://medium.com/data-science-at-microsoft/visual-question-answering-with-multimodal-transformers-d4f57950c867?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4f57950c867</guid>
            <category><![CDATA[multimodality]]></category>
            <category><![CDATA[visual-question-answering]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Tue, 08 Mar 2022 08:16:05 GMT</pubDate>
            <atom:updated>2022-03-08T08:16:05.921Z</atom:updated>
            <content:encoded><![CDATA[<h4>PyTorch implementation of VQA models using text and image transformers from Hugging Face</h4><p>Recent years have seen significant advancements not only in the respective domains of Natural Language Processing (NLP) and Computer Vision (CV) but also in tasks involving multiple modalities (text + image features) such as image captioning, visual question answering (VQA), cross-modal retrieval, visual common-sense reasoning, and more. Among these, VQA has particularly drawn the interest of several researchers.</p><h3>What is VQA?</h3><p>VQA is a multimodal task wherein, given an image and a natural language question related to the image, the objective is to produce a natural language answer correctly as output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*gHyln1I0Q6s67oWo5tpWOg.png" /><figcaption><strong>Source: </strong><a href="https://arxiv.org/pdf/1906.00067.pdf">OK-VQA: A Visual Question Answering Benchmark Requiring External Knowledge</a> on arxiv.org.</figcaption></figure><p>It involves understanding the content of the image and correlating it with the context of the question asked. Because we need to compare the semantics of information present in both of the modalities — the image and natural language question related to it — VQA entails a wide range of sub-problems in both CV and NLP (such as object detection and recognition, scene classification, counting, and so on). Thus, it is considered an <a href="https://en.wikipedia.org/wiki/AI-complete">AI-complete</a> task.</p><h3>VQA with multimodal fusion models</h3><p>Multimodal models can be of various forms to capture information from the text and image modalities, along with some cross-modal interaction as well. In <strong><em>fusion models</em></strong>, the<strong><em> </em></strong>information from the text and image encoders are fused into a combined representation to perform the downstream task.</p><p>A typical fusion model for a VQA system involves the following steps:</p><ul><li><strong>Featurization of image and question:</strong> We need to extract features from the image and obtain the embeddings of the question after tokenization. The question can be featurized using simple embeddings (like GLoVe), Seq2Seq models (like LSTMs), or transformers. Similarly, the image features can be extracted using simple CNNs (convolutional neural networks), early layers of object detection or image classification models, or image transformers.</li><li><strong>Feature fusion: </strong>Since VQA involves a comparison of the semantic information present in the image and the question, there is a need to jointly represent the features from both modalities. This is usually accomplished through a <em>fusion layer </em>that allows cross-modal interaction between image and text features to generate a fused multimodal representation.</li><li><strong>Answer generation:</strong> Depending on the modelling of the VQA task, the correct answers could either be generated purely using natural language generation (for longish or descriptive answers) or using a simple classifier model (for one-word/phrase answers present in a fixed <em>answer space</em>).</li></ul><p>Following are some methods used to perform the individual feature extraction and feature fusion steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hKAhlRBsuqenD2G-Mu6PWg.png" /><figcaption>Types of multimodal data fusion. Image created by the author.</figcaption></figure><p>In this article, I explore the idea of<strong><em> late fusion</em></strong> by fine-tuning pretrained text and image transformer models, as they are simpler to train.</p><p>With this background in place, it’s time to delve into the code and implement our multimodal model for VQA. First, we process the <a href="https://www.mpi-inf.mpg.de/departments/computer-vision-and-machine-learning/research/vision-and-language/visual-turing-challenge/"><strong><em>DAQUAR dataset</em></strong></a>. Because all the questions have single word/phrase-type answers, we consider the entire vocabulary of answers available (<em>answer space</em>) and treat them as labels. This converts visual question answering into a multiclass classification problem. We then train our multimodal transformer model and evaluate it using some established metrics for VQA. Toward the end, we compare and explain the results for various combinations of textual and image transformers used for featurization.</p><p><strong><em>Tl;dr: </em></strong><a href="https://github.com/tezansahu/VQA-With-Multimodal-Transformers"><em>This repository</em></a><em> contains all the code mentioned in this article. Although GitHub gists are used as code snippets throughout this article, if copied directly, they may not work as intended. Please refer to </em><a href="https://github.com/tezansahu/VQA-With-Multimodal-Transformers/blob/main/notebooks/VisualQuestionAnsweringWithTransformers.ipynb"><em>this notebook</em></a><em> present in the repository for working implementations.</em></p><h3>Preliminaries</h3><h4>Installing required packages</h4><p>We need to create a virtual environment and install the required packages:</p><pre>datasets==1.17.0<br>nltk==3.5<br>pandas==1.3.5<br>Pillow==9.0.0<br>scikit-learn==0.23.2<br>torch==1.8.2+cu111<br>transformers==4.14.0</pre><blockquote><strong>Note:</strong> It is advisable to have some GPU access to train the multimodal models because they are large and require considerable time for training otherwise.</blockquote><h4>Setting up the environment</h4><p>To set up the environment for training our multimodal VQA model, we need to import the required modules and set the appropriate device for PyTorch.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63c68563982dbb38ba20db9893976925/href">https://medium.com/media/63c68563982dbb38ba20db9893976925/href</a></iframe><h3>Data preparation</h3><p>For the VQA model training, we use the full <a href="https://www.mpi-inf.mpg.de/departments/computer-vision-and-machine-learning/research/vision-and-language/visual-turing-challenge/"><strong><em>DAtaset for QUestion Answering on Real-world images (DAQUAR)</em></strong></a> dataset, which contains approximately 12,500 question-answer pairs based on images from the <a href="https://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html">NYU-Depth V2 Dataset</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*mIpI4IcS2DBtUH4HQn7dRA.png" /><figcaption>Sample images, questions, and answers from the DAQUAR Dataset. <strong>Source:</strong> <a href="http://datasets.d2.mpi-inf.mpg.de/mateusz15neural_qa/ask_your_neurons-poster.pdf">Ask Your Neurons: A Neural-based Approach to Answering Questions about Images. ICCV’15 (Poster).</a></figcaption></figure><h4>Preprocessing the dataset</h4><p>The raw dataset contains the actual images separately in the images/ directory. All the question-answer pairs are present on consecutive lines in a .txtfile as shown below:</p><pre>what is on the desk and behind the black cup in the image4 ?<br>bottle<br>what is in front of the monitor in the image6 ?<br>keyboard<br>...</pre><p>We run the following script to pre-process these question-answer pairs. It normalizes the questions by removing the image IDs present in the question. The questions and answers, along with the corresponding image IDs extracted during normalization, are stored in a tabular (CSV) format. Moreover, because the original DAQUAR dataset provides only about 54 percent of the question-answer pairs for training (this amounts to only around 6700 samples, which is very less for training), we produce our custom split (80 percent training and 20 percent evaluation) from the overall data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/784905e9463bb25cf5abbae60bb5c1f7/href">https://medium.com/media/784905e9463bb25cf5abbae60bb5c1f7/href</a></iframe><p>This script produces data_train.csv and data_eval.csv files, along with answer_space.txt, containing a vocabulary of all the answers.</p><blockquote>These files are already available in the dataset/ folder of the repository for direct consumption and <a href="https://www.kaggle.com/tezansahu/processed-daquar-dataset">can also be found on Kaggle</a>.</blockquote><h4>Loading the data</h4><p>Now we are set to load this data using this processed dataset. For this, we use the datasets library from Hugging Face. Since we model this task as a multiclass classification task, we should assign labels to every answer. These labels are derived from the indices of the answers in the <em>answer space</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae91c5702b95be26855017d53b788862/href">https://medium.com/media/ae91c5702b95be26855017d53b788862/href</a></iframe><p>We can also inspect entries present in our training or evaluation dataset (specific or random) using Jupyter notebook:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49f5256272dfcd0d60f06d2b8924e1cf/href">https://medium.com/media/49f5256272dfcd0d60f06d2b8924e1cf/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*edcTE1GyopnNwlMQ052Kqw.png" /><figcaption>A random entry from the training dataset after loading and creating labels from the answer-space.</figcaption></figure><h4>Defining a multimodal collator for data</h4><p>Up to this point, we have just loaded the questions, answers, and corresponding image IDs, along with the labels. To feed the information about the question and actual images batchwise into our multimodal model, we need to define a data collator.</p><p>This collator will process the <strong>question (text)</strong> and the <strong>image</strong> and return the <strong>tokenized text (with attention masks)</strong> along with the <strong>featurized image</strong> (basically, the <strong>pixel values</strong>). These will be fed into our multimodal transformer model for question answering.</p><p>We use AutoTokenizer and AutoFeatureExtractor from Hugging Face transformers to convert the raw images and questions into inputs for featurization using the respective image and text transformers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31d45a17ec0778c59af6691a146b51aa/href">https://medium.com/media/31d45a17ec0778c59af6691a146b51aa/href</a></iframe><h3>Defining the multimodal VQA model architecture</h3><p>As mentioned previously, we use the idea of <em>late fusion</em> to define our multimodal model comprising:</p><ul><li>A <strong>text transforme</strong>r to encode the question and generate embeddings</li><li>An <strong>image transformer</strong> to encode the image and generate features</li><li>A reasonably <strong>simple fusion layer</strong> that concatenates the textual and image features and passes them through a linear layer to generate an intermediate output</li><li>A <strong>classifier</strong>, which is a fully connected network with output having the dimensions equal to that of the answer-space</li></ul><p>We model VQA as a multiclass classification task. Thus, c<em>ross-entropy loss </em>becomes a natural choice for the <strong>loss function </strong>to be minimized.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30f205857b0cb74856a639f0f07423c9/href">https://medium.com/media/30f205857b0cb74856a639f0f07423c9/href</a></iframe><p>Besides training a particular VQA model with multimodal transformers, we intend to experiment with various pre-trained model combinations and evaluate their performance on the DAQUAR dataset.</p><h4>Pretrained models for textual encoding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0oUat45J9X3U2n482nqGKg.png" /><figcaption>Pretrained text transformers for experimentation to provide textual features.</figcaption></figure><h4>Pretrained models for image encoding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhHZBVHjTNR80cGEaphQEA.png" /><figcaption>Pretrained image transformers for experimentation to provide visual features.</figcaption></figure><h3>Creating the collator and multimodal model</h3><p>Because we aim to experiment with multiple combinations of text and image transformers, it is reasonable to implement a function for creating the corresponding collators with the respective models.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9781e2ca7693124fd8fcd63726b4fa57/href">https://medium.com/media/9781e2ca7693124fd8fcd63726b4fa57/href</a></iframe><p>For demonstration in this article, we will create the collator and model using the tokenizer, feature extractor, and models from pretrained <strong><em>BERT </em></strong>and <strong><em>ViT</em></strong>.</p><h3>Evaluation metrics</h3><p>We approach the VQA task as a multiclass classification problem in this article. Hence, <strong><em>accuracy </em></strong>and <strong><em>macro F1 score</em></strong> are straightforward choices as metrics for evaluating the performance of our model. However, because these metrics may often be too restrictive, penalizing <em>almost </em>correct answers (‘tree’ versus ‘plant’) as heavily as incorrect answers (‘tree’ versus ‘table’), we select a metric like <strong><em>WUPS </em></strong>as our primary evaluation metric. Such a metric considers the semantic similarity between the predicted answer and the ground truth.</p><h4>Wu and Palmer Similarity (WUPS) Score</h4><p>One option to evaluate open-ended natural language answers is to perform exact string matching. However, it is too stringent and cannot capture the semantic relatedness between the predicted answer and the ground truth. This prompts the use of other metrics that capture the semantic similarity of strings effectively. One such commonly used metric is the <em>Wu and Palmer Similarity (WUPS) Score</em>.</p><p>WUPS computes the semantic similarity between two words or phrases based on their longest common subsequence in the taxonomy tree. This score works well for single-word answers (hence, we use it for our task), but may not work for phrases or sentences.</p><p>Although nltk has an implementation of the WUPS based on the <em>WordNet taxonomy,</em> for our experimentation, we use the <a href="https://datasets.d2.mpi-inf.mpg.de/mateusz14visual-turing/calculate_wups.py">implementation of Wu and Palmer similarity as defined along with the DAQUAR dataset</a> through the wup_measure(...) function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac31802b47376e0350b48fe76e12a9a4/href">https://medium.com/media/ac31802b47376e0350b48fe76e12a9a4/href</a></iframe><h3>Training the multimodal VQA model</h3><p>We finally come to the part where we use the previously defined functions to initialize our multimodal model and train it using the Trainer from Hugging Face to abstract away most of the code required for setting up a PyTorch training loop. The hyperparameters such as <em>training epochs</em>, <em>batch siz</em>e, and so on, are passed to the Trainer by setting the corresponding values in the TrainingArguments.</p><p>For this article, we use the following hyperparameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oKA2EGhLN4to95qSAmbSg.png" /><figcaption>Hyperparameters used for training the multimodal model.</figcaption></figure><p>The training of this BERT + ViT model (and all other combinations of transformers) was carried out on an <a href="https://www.techpowerup.com/gpu-specs/a100-sxm4-40-gb.c3506">NVIDIA A100 SXM4 40 GB</a> GPU.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af8808915d600972099808b8ec46b5d7/href">https://medium.com/media/af8808915d600972099808b8ec46b5d7/href</a></iframe><p>The model checkpoints are saved periodically in the indicated output directory based on the information provided in the TrainingArguments.</p><h3>Making inferences using trained model</h3><p>To use any of the saved model checkpoints for inferencing, the question must be tokenized, and image features must be extracted appropriately (as done in the collator). These would serve as input to the model, with weights loaded from the trained checkpoint. The label predicted by the model is then mapped to the index of the actual answer in the answer space.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a94a26b79ed15eeeeba45a9209632d7f/href">https://medium.com/media/a94a26b79ed15eeeeba45a9209632d7f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZX8P5ZO7kULmL0QMZ38_w.png" /><figcaption>Examples of answers predicted by our multimodal VQA model on certain evaluation instances.</figcaption></figure><h3>Comparing the performance of various models</h3><p>A similar approach is followed to train VQA models with various combinations of text and image transformers by changing the text and image arguments while calling the createMultimodalVQACollatorAndModel(...) function.</p><p>The table below summarizes the performance of these different models. These details can also be found on <a href="https://studio.iterative.ai/user/tezansahu/views/VQA-With-Multimodal-Transformers-nq8zlqu0p5">this DVC Studio dashboard</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*waQyZGOJIsMkiwYV7vPbbQ.png" /></figure><ul><li><strong><em>RoBERTa + BEiT</em></strong> performs the best in terms of both WUPS and accuracy.</li><li>RoBERTa-based models generally perform better than the rest. This can be attributed to the larger number of trainable parameters and the embeddings generated through more robust pre-training.</li><li>ALBERT-based models are expected to have lower performance because ALBERT is much smaller compared to BERT and RoBERTa. Yet, the <strong><em>ALBERT + ViT</em></strong> model can achieve scores comparable to the BERT + ViT model, despite having only around half the number of parameters.</li><li>For BERT and RoBERTa-based text transformers, the best results are achieved using <strong><em>BEiT </em></strong>as the image transformer. However, it does not perform up to the mark with ALBERT. This could indicate that higher quality textual embeddings are required to complement the image embeddings generated by BEiT.</li></ul><h3>Concluding remarks</h3><p>In summary, we successfully implemented, trained, and evaluated a <em>late fusion</em> <em>type of multimodal transformer model</em> in PyTorch for visual question answering using the DAQUAR dataset. We also learned how to use the model weights from a trained checkpoint to answer questions related to an image. Last, we compared the performance of several models using different text and image transformers to featurize the question and image before performing fusion.</p><p>I hope this article has given you a good overview of some of the concepts involved in visual question answering and helped you understand the nuances of training multimodal transformer models in PyTorch for such a task. Feel free to check out the References section below for more details regarding concepts and terms that I might have breezed through in this article. Please leave any feedback or suggestions in the comments section below.</p><blockquote>All the code mentioned in this article is available in <a href="https://github.com/tezansahu/VQA-With-Multimodal-Transformers">this repository</a>. The performance metrics for different combinations of transformers can be found on <a href="https://studio.iterative.ai/user/tezansahu/views/VQA-With-Multimodal-Transformers-nq8zlqu0p5">this dashboard</a>. Feel free to clone the repository, follow the steps mentioned in the README.md and tweak the params.yaml file to experiment with different model architectures for the VQA task.</blockquote><p><em>Tezan Sahu is on </em><a href="https://www.linkedin.com/in/tezan-sahu/"><em>LinkedIn</em></a><em> and </em><a href="https://github.com/tezansahu"><em>GitHub</em></a><em>.</em></p><h3>References</h3><ol><li><a href="https://tryolabs.com/blog/2018/03/01/introduction-to-visual-question-answering">Introduction to Visual Question Answering: Datasets, Approaches and Evaluation | Tryolabs</a></li><li><a href="https://avisingh599.github.io/deeplearning/visual-qa/">Deep Learning for Visual Question Answering</a></li><li><a href="https://medium.com/@nithinraok_/visual-question-answering-attention-and-fusion-based-approaches-ebef62fa55aa">Visual Question Answering — Attention and Fusion based approaches | by Nithin Rao | Medium</a></li><li><a href="https://medium.com/haileleol-tibebu/data-fusion-78e68e65b2d1">Multimodal Data Fusion | by Haylat T | Medium</a></li><li><a href="https://blog.paperspace.com/vision-transformers/">Vision Transformers Explained | Paperspace Blog</a></li><li><a href="https://www.mpi-inf.mpg.de/departments/computer-vision-and-machine-learning/research/vision-and-language/visual-turing-challenge/">DAQUAR Dataset Homepage</a></li><li><a href="https://youtu.be/2sQp7jJJmeg">Wu and Palmer Similarity (WUPS) Score</a></li><li><a href="https://huggingface.co/docs/transformers/v4.15.0/en/index">Hugging Face </a><a href="https://huggingface.co/docs/transformers/v4.15.0/en/index">transformers (v4.15.0) Documentation</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4f57950c867" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-at-microsoft/visual-question-answering-with-multimodal-transformers-d4f57950c867">Visual question answering with multimodal transformers</a> was originally published in <a href="https://medium.com/data-science-at-microsoft">Data Science + AI at Microsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Autosuggestion services in web search]]></title>
            <link>https://medium.com/data-science-at-microsoft/autosuggestion-services-in-web-search-9d4f71c662c6?source=rss-99aa33de20e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d4f71c662c6</guid>
            <category><![CDATA[autocomplete]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[web-search-engine]]></category>
            <category><![CDATA[personalization]]></category>
            <category><![CDATA[auto-suggest]]></category>
            <dc:creator><![CDATA[Tezan Sahu]]></dc:creator>
            <pubDate>Tue, 08 Feb 2022 08:18:54 GMT</pubDate>
            <atom:updated>2022-02-08T08:18:54.945Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Autosuggestion</em>, also known as <em>query autocompletion (QAC)</em>, <em>predictive search,</em> and <em>type-ahead</em>, is a key search-assist feature that has become indispensable in modern information retrieval for enhancing search experience. The goal of autosuggestion is to predict relevant query completions for incomplete prefix inputs so that users reach their search intent with fewer keystrokes, saving their time and effort.</p><p>Being a <strong><em>low-latency</em></strong> (matching the user’s typing speed to predict new suggestions at every keystroke)<em>, </em><strong><em>high-throughput</em></strong> (catering to millions of requests made per second on the search engine)<em> </em>service, robustness and adherence to a strict online latency budget are a must during the design of QAC services. <a href="https://en.wikipedia.org/wiki/Trie"><em>Tries</em></a><em> </em>and <a href="https://en.wikipedia.org/wiki/Inverted_index"><em>inverted indexes</em></a><em> </em>are some favorites for choosing efficient data structures for the storage and lookup of suggestions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ou9a-Pd_Um1zkZjgwjFY9w.png" /><figcaption>Illustration of a basic autosuggestion framework (adapted from <em>[1]).</em></figcaption></figure><h3>A brief history of autosuggestion services</h3><p>The core idea behind autosuggestion dates to the 1960s <em>[1]</em> with methods describing ways to reduce the number of keystrokes that developers needed to complete keywords and identifiers. Through the 1980s and ’90s, there was some additional research around developing similar assistive technologies. In 2000, <a href="https://patents.google.com/patent/US6564213B1/en">Amazon filed a patent</a> describing a technology to suggest query autocompletions during the query entry process, based on specific attributes of the database access system being searched. Later in 2004, Google Labs piloted its QAC service named <a href="https://googleblog.blogspot.com/2008/08/at-loss-for-words.html"><em>Google Suggest</em></a><em>, </em>which was formally integrated into Google’s homepage in 2008. In 2009 Bing was released, having the autosuggest feature implemented on its homepage. In recent times, almost every search box on the web has some form of autosuggest mechanism implemented to aid the user.</p><p>Initially, the suggested completions were based purely on popularity (i.e., frequency in the query logs). As time passed, plenty of augmentations were introduced beyond simple prefix-based lookup to enhance the quality of suggestions. This involved the use of n-grams <em>[2]</em>, intent identification <em>[3]</em>, and personalization <em>[4]</em>, among others, to cater to specific requirements of different users. Later, with advanced NLP and Deep Learning, the context of a prefix could be captured more effectively. This enabled QAC to extend and include purely “generative” suggestions <em>[14]</em>, which improved the coverage as well as the relevance of autosuggestions by predicting <em>unseen </em>suggestions.</p><p>As it is usually the first point of contact for a user with information needs on a search engine, providing a great QAC experience is imperative. There have been several approaches developed to advance QAC services with <em>better </em>and <em>more </em>suggestions <em>[5]</em> while staying within the latency bounds. These broadly fall under the umbrellas of <strong><em>relevance </em></strong>and <strong><em>coverage</em></strong>.</p><h3>Improving the relevance of autosuggestion services</h3><p>Conceptually, an ideal autosuggestion service could predict the exact query that a user has in mind as the user starts typing with a single character (“<em>psychic</em>” QAC). Because that may not be possible, QAC services strive to provide users with the most relevant suggestions for every keystroke.</p><p>Early QAC services suggested query completions based on the popularity of queries available in their logs. However, this did not work well because users come to a search engine with differing intent. Today, such services go far beyond simply providing users with the most popular suggestions. Literature in this domain describes several methods used by QAC frameworks to address relevance. Some of the broad classes of such methods are <em>personalization</em>, <em>diversity</em>, and <em>freshness</em>.</p><h4>Personalization</h4><p>Personalization has become an increasingly popular concept in web search. There are several levels at which personalization is introduced in QAC to improve users’ experience by providing relevant suggestions based on their preferences.</p><ul><li><strong>Language-specific: </strong>Global search engines like Bing and Google allow users to search in a variety of languages. Thus, it makes more sense to show suggestions related to the user’s specified language <em>[6] </em>(or probable location where the language is dominant). As an example, for the prefix <em>“a” </em>it might be useful to show <em>“aadhar card”</em> (specific to India) as a suggestion when Hindi is selected as the language, but not when Korean is selected. Automatic <a href="https://en.wikipedia.org/wiki/Transliteration">transliteration</a> may also be performed if necessary for languages with completely different scripts.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sT6olBQjN-HQjTmdRle82A.png" /><figcaption>Based on the language preference of the user, search engines like Google provide slightly different query completions. The suggestions marked with red boxes indicate those that have special relevance to the language set by the user.</figcaption></figure><ul><li><strong>Time-sensitive: </strong>Several events (sports, political, festivals, and others) occur at more or less fixed intervals of time. This periodicity is leveraged by QAC services to anticipate temporal trends and suggest appropriate completions when prefixes are queried during the optimal time window <em>[7]</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVVGKqpLQT57rMmutbJbqQ.png" /><figcaption>The plot shows relative query popularity for “christmas” (blue) and “fifa world cup” (red) over time. While the query “christmas” is issued yearly, “fifa world cup” presents peaks roughly once in four years. These temporal trends can be featurized and infused into the ranker function to improve overall suggestion quality.</figcaption></figure><ul><li><strong>Based on user behavior and search history: </strong>Although widely debated, insights drawn from users’ session information can result in a significantly better search experience. As an example, for a user whose search history contains <em>“avengers”</em>, <em>“captain america”,</em> and <em>“iron man”</em>, it may be better to display <strong><em>“mark ruffalo”</em></strong> as the topmost suggestion for the prefix <strong><em>“mark ” </em></strong>instead of <em>“mark zuckerberg”</em>. Extensive research is being carried out in this area to come up with end-to-end personalized neural language models <em>[8]</em> to encode user representations through long/short-term search history and other signals. Query reformulation patterns by users have also been explored to improve personalization models <em>[9]</em>. In 2017, Google filed a patent describing a technique where search systems can improve query completions by considering information about the user <em>[18].</em></li></ul><h4>Diversity</h4><p>The aim of QAC is to assist users in reaching their search goals quickly. During the initial few keystrokes, the search intent may seem ambiguous, but as the user inputs more characters, the intent becomes clearer and suggestions become more precise. Thus, it is reasonable to avoid redundancy in suggestion intents typically only for shorter prefixes. The goal of QAC diversification is to return the correct query early in the suggestions list and reduce redundancy among QAC candidates <em>[10]</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oyMBJtClbl4X9raibk6mKQ.png" /><figcaption>For the short prefix “aa”, the suggestions in (a) cover only three broad intents (as shown by the colored boxes), while the suggestions in (b) cover five broad intents. Hence, (b) is more diverse as it does a much better job of seeking to overcome ambiguity about the user’s actual information needs.</figcaption></figure><p>Most literature on QAC diversification proposes <em>greedy methods</em> of deduplication <em>[10], </em>while a few discuss algorithms based on <em>dynamic programming</em> and <em>A* search</em> <em>[11]</em> as well. Some also attempt to model intents based on users’ interaction with documents displayed as previous search results <em>[12]</em> and use these to avoid seemingly redundant suggestions.</p><h4><strong>Freshness</strong></h4><p>Earlier, there was some discussion about time-sensitive personalization for periodic trends. Keeping these aside, several search queries gain rapid popularity in certain parts of the world because of some trigger (such as news, forecasts, sentiments becoming viral, and so on). Such recent trends also need to be picked up consistently and displayed by QAC pipelines to allow users to keep up with the latest information. For example, when the prices of cryptocurrencies rallied upward at the start of 2021, most search engines displayed <em>“bitcoin”</em>, <em>“cryptocurrency”</em> and <em>“dogecoin”</em> as top suggestions for prefixes <em>“b”</em>, <em>“c”</em> and <em>“d”</em>. As the trends started fading away, these suggestions started appearing in their usual positions as before.</p><h3>Coverage improvement in QAC services</h3><p>Different search engines show a different number of maximum suggestions for any prefix: for Google it is ten, while for Bing it is eight. However, there are situations (especially for longer prefixes, or prefixes with spelling errors) where suggestion blocks actually contain fewer suggestions. This is primarily due to the unavailability of relevant completions to be displayed and may negatively affect the search experience. Search engines employ several clever techniques to overcome these <em>coverage </em>issues. Some of them are as follows.</p><h4><strong>Scalable hosting of more suggestions</strong></h4><p>The most intuitive approach to improve coverage is to start hosting more suggestions in the trie powering the autosuggestion service. But this may cause <em>memory outage</em> as well as <em>latency increase</em>. Hence, effective ways of <strong><em>partitioning the trie </em></strong>of logged queries <em>[5]</em> have been proposed to host more suggestions in a scalable way.</p><h4><strong>Non-prefix matching</strong></h4><p>Looking up suggestions from the trie based on the user-entered prefix, followed by their ranking, forms the majority portion of a web-scale QAC service. However, certain coverage issues arise due to misspellings or malformed prefixes. In such situations, QAC services may be better off suggesting completions that do not exactly match the user’s prefix. These are non-prefix matches and are triggered using language-specific <strong><em>spell correction</em></strong> mechanisms or some <strong><em>inverted index</em></strong> maintained by the QAC pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XhR8Bx6sRF4ZsCHx1ftriQ.png" /><figcaption>Different types of non-prefix matching in Bing Autosuggest.</figcaption></figure><h4><strong>Approaches based on language modeling</strong></h4><p>In the past, natural language models have been proposed that utilize the context of prefixes to generate suffixes for QAC <em>[15]. </em>Such models can exploit sub-word–level information as well <em>[16]</em>. Interesting deep learning techniques have also been explored that use language models to predict suggestions beyond those present in the trie <em>[14]</em>. Results from such techniques can also populate the suggestion box in low coverage cases.</p><h3><strong>Blocking and filtering</strong></h3><p>Search engines like Bing and Google have autosuggestions that are used across the globe and must adhere to certain policies as mandated by the various governments <em>[19]</em>. Thus, although blocking and filtering of certain content may lead to loss of coverage, it is a crucial aspect of any QAC pipeline. Suggestions may be blocked based on one or more of the following reasons (non-exhaustive list):</p><ul><li>Hate/violence-related suggestions</li><li>Adult/offensive content–related suggestions</li><li>Piracy-related suggestions</li><li>Suggestions related to sensitive or controversial information</li><li>Gibberish or defective suggestions</li></ul><p>Apart from the filtering done by the pipeline, search engines offer provisions to request the blocking of certain suggestions subject to scrutinization.</p><h3><strong>Interesting features in modern QAC services</strong></h3><p>With time, there have been interesting modifications to the UI/UX of autosuggestion services to enhance the productivity of users. I list some of my personal favorites below.</p><h4><strong>Rich entity information</strong></h4><p>Today, just as SERP goes beyond text and simple multimedia to show information in entity panes and carousels, among others, modern autosuggestions have also gone beyond simple textual suggestions. One often finds thumbnails and some auxiliary information about <em>entity-type</em> suggestions (personalities, places, organizations, books, movies, and so on) for easier disambiguation and quicker satisfaction of the users’ information needs.</p><h4><strong>Factual answers in suggestion box</strong></h4><p>Another interesting feature that search engines like Google have implemented is for suggestions demanding an answer in the form of a small calculation or lookup. Instead of ghosting, the actual answer is displayed prominently in the suggestion box itself. These answers currently cover a small range of topics and may be extended to cover more scenarios in the future.</p><h4><strong>Ghosting</strong></h4><p>While ranking suggestions are displayed in the block for a given prefix, autosuggest algorithms also calculate the likelihood of the first suggestion being clicked by the user. If this likelihood is greater than some threshold, the search box automatically gets pre-populated with this likely suggestion. This is known as <em>ghosting</em>. Implemented in Bing, Google, and elsewhere, such a feature can significantly increase the speed at which users can express their intent <em>[17]</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I2E0KoTEieqkiXaMR0-4yg.png" /><figcaption>Some of the interesting features of modern QAC services implemented to increase user engagement; (a) and (b) are from Google, while (c) is from Bing.</figcaption></figure><h4>Zero-input scenario</h4><p>This is the case when a user has just clicked the search box but has not typed anything yet. Instead of showing no suggestions, autosuggestion services use different techniques to engage users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R1hcozYzww-V_toe9HEKSg.png" /><figcaption>For a zero-input scenario, (a) Yahoo shows history search queries, (b) Bing shows region-wise trending queries, and (c) Google shows queries related to the previous search result.</figcaption></figure><h3>Evaluation of QAC Techniques</h3><p>We have looked at several approaches developed to allow autosuggestion services to satisfy users’ query intent. To assess the effectiveness of such techniques, several metrics have been devised and tested, some of which include the following.</p><h4>Mean reciprocal rank (MRR)</h4><p>MRR <em>[13]</em> is calculated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*qeKRGd2GLf46Tj2q1DpzIw.png" /></figure><p>where <strong><em>Q</em></strong> is the set of all <em>user-issued queries (</em><strong><em>q</em></strong><em>) </em>in the evaluation set and <strong><em>rank_q</em></strong> is the rank that query <strong><em>q</em></strong> appears in the suggestion box. It is one of the most popular metrics to evaluate QAC methods and gives more credit if <strong><em>q</em></strong> is placed at the top of the suggestion block.</p><h4>Success rate at top K (SR@K)</h4><p>SR@K <em>[13]</em> computes the average ratio of queries that satisfy the user’s search intent and are located within the top <strong><em>K </em></strong>positions of the suggestion list. It is usually used when there is only one ground truth among all suggestions in the block.</p><h4>Minimum keystroke length (MKS)</h4><p>This <em>user-assist metric</em> <em>[13] </em>records the number of actions that a user must take before issuing a target query. If, for a prefix of length <strong><em>i</em></strong>, the target query appears in the block at position <strong><em>j</em></strong>, then the number of actions is calculated as <strong>(<em>i + j)</em></strong>. Now, the smallest value of <strong>(<em>i + j) </em></strong>is chosen as the MKS for that query.</p><h4>e-Saved</h4><p>“Effort saved” <em>[13] </em>is another <em>user-assist metric</em> that calculates the expected ratio of characters that a user can skip inputting until the query is submitted. It can be calculated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*Hf6UeS8G3QwlRCQEtXk2cw.png" /></figure><p>where <strong><em>|q| </em></strong>is the length of the user-issued query <strong><em>q</em></strong>, <strong><em>i</em></strong> refers to the keystroke until which the query is typed, <strong><em>j </em></strong>refers to the position of the query in the suggestion box and <strong><em>P(Sᵢⱼ = 1)</em></strong> is the probability that the user clicks on the suggestion when it appears at the <strong><em>iᵗʰ</em></strong> keystroke in the<strong><em> jᵗʰ</em></strong> position.</p><p>This formulation prefers the improvements in the query suggestions for longer queries in particular.</p><h4>Mean Recoverable Length (MRL)</h4><p>When all characters of a target query (of length <strong><em>L</em></strong>) are known, it can be readily suggested. If we delete characters from right to left one-by-one, at some point (prefix length <strong><em>l</em></strong>), the target query will disappear from the list. Recoverable length <em>[16] </em>for the query is defined as <strong><em>L - l + 1</em></strong>. MRL is an average of the recoverable lengths for all queries in the evaluation set, and is more useful for systems that suggest one word at a time compared to full query completion.</p><h4><strong>α-nDCG</strong></h4><p>This is an extension to the normalized discounted cumulative gain (nDCG), which also takes into account <em>aspect-specific rankings </em>in the form of α <em>[10]</em>. This is used to evaluate the ranking while applying diversification approaches to QAC, but also requires manual judgments to assign intent-specific scores (in this context, <em>intents </em>become the <em>aspects</em>) to each of the suggestions.</p><p>In this article, I first reviewed the fundamentals of autosuggestion services implemented in search engines. Then, I delved into some of the key aspects of modern QAC services, such as relevance and coverage, by discussing various techniques that have been used to improve the UX of these services. I concluded by discussing some of the performance metrics to evaluate the effectiveness of autosuggestions.</p><p>I hope you found this article useful. Feel free to leave your feedback or comments in the section below.</p><p><em>Tezan Sahu is on </em><a href="https://www.linkedin.com/in/tezan-sahu/"><em>LinkedIn</em></a><em>.</em></p><h3>References</h3><ol><li><a href="https://www.nowpublishers.com/article/Details/INR-055">Fei Cai; Maarten de Rijke. (2016). <em>A Survey of Query Auto Completion in Information Retrieval. ACM Transactions on Information Systems</em></a></li><li><a href="https://dl.acm.org/doi/pdf/10.1145/3437963.3441725">Young Mo Kang, Wenhao Liu, and Yingbo Zhou<em>. </em>(2021)<em>. QueryBlazer: Efficient Query Autocompletion Framework. </em>WSDM</a></li><li><a href="https://jyunyu.csie.org/docs/pubs/ictir2016paper.pdf">Jiang, Jyun-Yu, and Pu-Jen Cheng. (2016). <em>Classifying user search intents for query auto-completion. </em>ICTIR.</a></li><li><a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2013/01/SIGIR2013-Shokouhi-PersonalizedQAC.pdf">Shokouhi, Milad. (2013) <em>Learning to personalize query auto-completion.</em> SIGIR</a></li><li><a href="http://users.ics.forth.gr/~tzitzik/publications/Tzitzikas_2010_ICWE.pdf">Kastrinakis, D. &amp; Tzitzikas, Y. (2010). <em>Advancing Search Query Autocompletion Services with More and Better Suggestions. </em>ICWE<em>.</em></a></li><li><a href="https://www.unicodeconference.org/presentations/S11T3-Provalov.pdf">Netflix: Autocomplete Multi-Language Search Using Solr</a></li><li><a href="https://dl.acm.org/doi/pdf/10.1145/2661829.2661921">Cai, Fei, Shangsong Liang, and Maarten De Rijke. (2014). <em>Time-sensitive personalized query auto-completion.</em> CIKM</a></li><li><a href="https://arxiv.org/pdf/1804.06439.pdf">Fiorini, Nicolas, and Zhiyong Lu. (2018). <em>Personalized neural language models for real-world query auto completion.</em> NAACL-HLT</a></li><li><a href="https://dl.acm.org/doi/pdf/10.1145/2600428.2609614">Jiang, Jyun-Yu, Yen-Yu Ke, Pao-Yu Chien, and Pu-Jen Cheng. (2014). <em>Learning user reformulation behavior for query auto-completion.</em> SIGIR.</a></li><li><a href="https://dl.acm.org/doi/pdf/10.1145/2910579">Fei Cai; Ridho Reinand; Maarten de Rijke. (2016) <em>Diversifying Query Auto-Completion.</em></a></li><li><a href="https://arxiv.org/pdf/1208.0076.pdf">Qin, Yu &amp; Chang. (2012). <em>Diversifying top-k results.</em> VLDB.</a></li><li><a href="https://dl.acm.org/doi/pdf/10.1145/2505515.2505661">Kharitonov, Macdonald, Serdyukov, and Ounis. (2013) <em>Intent models for contextualising and diversifying query suggestions.</em> CIKM.</a></li><li><a href="https://link.springer.com/chapter/10.1007/978-3-030-58334-7_1">Chang, Y., &amp; Deng, H. (Eds.). (2020). <em>Query Understanding for Search Engines. The Information Retrieval Series.</em></a></li><li><a href="https://dl.acm.org/doi/pdf/10.1145/3340531.3412701">Wan, Guo &amp; Long. (2020). <em>Efficient Neural Query Auto Completion. CIKM</em></a></li><li><a href="https://ra.ethz.ch/cdstore/www2011/proceedings/p107.pdf">Ziv Bar-Yossef and Naama Kraus. (2011<em>). Context-sensitive query auto-completion.</em> WWW.</a></li><li><a href="https://aclanthology.org/D19-1507.pdf">Gyuwan Kim. (2019). <em>Subword Language Model for Query Auto-Completion.</em> EMNLP</a></li><li><a href="https://blogs.bing.com/search/2013/02/20/a-look-at-autosuggest/">A Look at Autosuggest | Bing Search Blog</a></li><li><a href="https://www.searchenginejournal.com/google-query-completions-patent/420520/#close">How Autocomplete Works: The Patent Behind Google’s Query Completions</a></li><li><a href="https://searchengineland.com/how-google-instant-autocomplete-suggestions-work-62592">How Google Instant’s Autocomplete Suggestions Work</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d4f71c662c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-at-microsoft/autosuggestion-services-in-web-search-9d4f71c662c6">Autosuggestion services in web search</a> was originally published in <a href="https://medium.com/data-science-at-microsoft">Data Science + AI at Microsoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>