<?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 Manas Bhalla on Medium]]></title>
        <description><![CDATA[Stories by Manas Bhalla on Medium]]></description>
        <link>https://medium.com/@bhallamanas?source=rss-188f6d4a4a2e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IiRsnVmFjeDuszOjp7es7A.jpeg</url>
            <title>Stories by Manas Bhalla on Medium</title>
            <link>https://medium.com/@bhallamanas?source=rss-188f6d4a4a2e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 04:02:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhallamanas/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[Why Generative AI Models fail to count ‘R’s’ in ‘strawberry’ — solving it through sequential…]]></title>
            <link>https://medium.com/@bhallamanas/why-generative-ai-models-fail-to-count-rs-in-strawberry-solving-it-through-sequential-29b5a8d9d414?source=rss-188f6d4a4a2e------2</link>
            <guid isPermaLink="false">https://medium.com/p/29b5a8d9d414</guid>
            <category><![CDATA[prompt]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <dc:creator><![CDATA[Manas Bhalla]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 16:57:47 GMT</pubDate>
            <atom:updated>2024-08-28T16:57:47.001Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Generative AI Models fail to count ‘R’s’ in ‘strawberry’ — solving it through sequential prompting</h3><p>‘AI is going to take over the world’, ‘We are only a few years away from AI replacing all developers’, ‘AI can do anything’ — these are all very common phrases we might have heard regarding AI in the past, and it is true Generative AI can change ALOT, definitely a lot more than the past models and AI breakthroughs that we have had.</p><p>However, the true value of Generative AI lies in the manner it is used. What this statement means is that while AI can do a lot, there is a lot that it cannot do. Now, let’s take a very simple example</p><p>Let’s take the question: ‘How many ‘R’s are there in strawberry’. This is a very simple question that humans can answer with relative ease, but Generative AI models are struggling with, look at the response generated by Gemini:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*kfVo96F1DbAtWgWf-e7b4Q.png" /></figure><p>Now, why is this the case? Well, it is because of the manner in which this question is actually understood by the Generative AI model. The model does not actually ever see the word ‘Strawberry’ but rather an ‘encoded’ word that means Strawberry. So these Generative AI models or Large Language models are actually built using the Transformer Architecture. This architecture, works by essentially breaking words into something called ‘Tokens’. Tokens can be of many types and sizes — i.e. sentences, words, sub-words or syllables and even letters. This broadly means that the model actually never sees the word ‘strawberry’ but rather the token that represents ‘strawberry’, so this also means that it never sees the letters in the word, which means that task of counting the number of letters is a bit difficult to do.</p><p>Now, that we understand why AI struggles with it, let’s go back to the statement — ‘The true value of Generative AI lies in the manner it is used’. Let’s use a slightly different prompting technique to get our desired result. Instead of using a single prompt, let’s use 2 prompts — First ask the model to ‘Spell the word ‘strawberry’ and then let’s get the model to use the produced answer to actually calculate the number of ‘R’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sEjekXNDl-FwBxNtNYLm9A.png" /><figcaption>=</figcaption></figure><p>This method is called ‘Sequential Prompting’ or ‘Question Prompting’. So how does this sequential prompting help? By using sequential prompting, we are essentially breaking the task into manageable and achievable tasks for the model. Simply put, the model is able to perform the first task of spelling the word ‘strawberry’, and the produced output, has the output generated with ‘-’ (dashes) that then model then encodes very differently to the entire word ‘strawberry’. We can assume that the each letter is essentially being encoded, this means that the model can now in theory see the different letters and therefore count the letters.</p><p>Now, trying to calculate the number of times a letter occurs is an extremely simple task that does not need Generative AI, however, sequential prompting is extremely beneficial for Chat-Bots, Answer Validation and much more. You can read up more about sequential prompting in my next blog!</p><p>Disclaimers:</p><ol><li>Will this exact prompt work every single time? No. This is because generative AI models are not 100% deterministic, which means that is always a chance for hallucinations</li><li>Is this the only approach? No, there are likely to be many prompts that could get you the same result.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29b5a8d9d414" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT: Jupyter Notebook Walkthrough using Haystack]]></title>
            <link>https://medium.com/@bhallamanas/chatgpt-jupyter-notebook-walkthrough-using-haystack-4147a1638d2?source=rss-188f6d4a4a2e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4147a1638d2</guid>
            <dc:creator><![CDATA[Manas Bhalla]]></dc:creator>
            <pubDate>Tue, 05 Sep 2023 10:22:22 GMT</pubDate>
            <atom:updated>2023-09-05T10:22:22.461Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will be going through how to create and set-up a simple Generative QA solution using Jupyter Notebooks, Azure OpenAl Subscriptions or an OpenAl Subscription, and Haystack.</p><p>In the past year, ChatGPT has demonstrated the power of generative Al, it is a model that is revolutionary in the manner in which NLG (Natural Language Generation) models are being used and their potential. OpenAl’s ChatGPT model has made it exceptionally easy to experiment with NLG models.</p><p>This is the first of a series of walkthroughs that use the OpenAl’s model for different cases. This walkthrough will look at how ChatGPT can be used in a lupyter Notebook for NLG offerings using a simple Haystack pipeline, and a couple of nom packages — all under 20 minutes!</p><p><strong>Setting up your OpenAl account or Azure OpenAl account</strong><br>The first step is to create your OpenAl or Azure OpenAl account (deploying your model). You can follow these links for reference:</p><ul><li>OpenAl: <a href="https://platform.openai.com/docs/guides/gpt">https://platform.openai.com/docs/guides/gpt</a> /chat-completions-api</li><li>Azure OpenAl:<a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/hov-to/create-resource?pivots=web">https://learn.microsoft.com/en-us/azure/ai-services/openai/hov-to/create-resource?pivots=web</a>-portal</li></ul><p>Once your account is set up and model is available for use, retrieve your API keys, and other details.</p><p>If you are using Azure OpenAl, you will need your deployment name, endpoint and API Keys. If you are using OpenAl, you will need your API key.</p><p><strong>Installing the essential packages</strong><br>This might be the most time consuming process of this entire walkthrough. In your Jupyter environment, you will need to install all the packages that are required by Haystack and OpenAl/Azure OpenAl to run.<br>*Please note that the dependencies are constantly changing, this means that you might have to install a couple more packages or fewer packages.</p><p>To install the packages you can just run the below commands:</p><blockquote>pip install -upgrade pip pip install farm-haystack[colab)<br>pip install datasets&gt;=2.6.1</blockquote><p><strong>Creating your pipeline</strong><br>The key components of your pipeline are:</p><ul><li>Pre Processor: This is a tool that Haystack provides to help clean and split the text into smaller units. This step is extremely important as it can help to improve the performance of the model and if Dense Passage Retrieval method is being used, it is mandatory.</li></ul><blockquote>From haystack.nodes import PreProcessor</blockquote><blockquote>preprocessor = PreProcessor(clean empty lines-True, clean_whitespace=True, clean_header_footer-False, split_by=”word”, split_length=100, split_overlap=3, split_respect_sentence_boundary=False)</blockquote><blockquote>processed docs = preprocessor.process(docs)</blockquote><ul><li>DocumentStore: The document store is a database that stores your texts and meta data. The document store will provide them to the retriever as query time.</li></ul><blockquote>from haystack. document_ stores import InMemoryDocumentStore<br>document_store = InMemoryDocumentStore(use_bm25-True)<br>from datasets import load dataset<br>dataset = load_dataset(“bilgevucel/seven-wonders”, split=”train”)<br>document_store.write_documents(dataset)</blockquote><ul><li>Retriever: This tool is responsible for preforming the ‘document retrieval at query time. The retriever will look through the document store and provide a set of ‘candidate documents that match the requirements best.</li></ul><blockquote>from haystack.nodes import BM25Retriever<br>retriever = BM25Retriever(document_ store=document_ store, top_k=2)</blockquote><ul><li>Generator: This is a LLM (Large Language Model) that has the ability to generate an text based on a set of instructions, ChatGPT is an LLM. In this particular walkthrough, we are using our Generative LLM to use a set of documents and generate an answer to a question.</li></ul><blockquote>from haystack.nodes import PromptNode, PromptTemplate, AnswerParser<br>rag.prompt = Prompt Template(<br>prompt=”’’’Synthesize a comprehensive answer from the following text for the given question.<br>Provide a clear and concise response that summarizes the key points and information presented in the documents. Your answer should be in your own words and be no longer than 50 words.<br>Related text: (join(documents)) \n Question: {query) \n Answer:’,<br>outout_parser=AnswerParser(),</blockquote><blockquote>prompt node = PromptNode(model name or path-”google/flan-+5-large”, default prompt template-rag, prompt)</blockquote><p>You can follow the code below to set up your pipeline.</p><blockquote>from havstack pipelines import Pipeline<br>pipe = Pipeline()<br>pipe.add node(component-retriever, name=”retriever”, inputs-(“Query”) pipe.add_node(component-prompt_node, name-”prompt node”, inputs-(“retriever”))</blockquote><p><strong>Running your pipeline</strong><br>The final step is to run your pipeline and ask a question!</p><blockquote>output = pipe.run(query-”What does Rhodes Statue look like?”)<br>print (output[answers[0].answer)</blockquote><p>As you embark on your journey, it is important to understand the ethical implications of using any Al and what are the best practices are, you can find some useful information here:</p><ul><li><a href="https://openai.com/blog/best-practices-for-deploying-language-models">https://openai.com/blog/best-practices-for-deploying-language-models</a></li><li><a href="https://openai.com/research/ai-safety-needs-social-scientists">https://openai.com/research/ai-safety-needs-social-scientists</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4147a1638d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Brief Introduction to Facial Recognition]]></title>
            <link>https://medium.com/@bhallamanas/a-brief-introduction-to-facial-recognition-f17b6a6b901?source=rss-188f6d4a4a2e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f17b6a6b901</guid>
            <dc:creator><![CDATA[Manas Bhalla]]></dc:creator>
            <pubDate>Fri, 01 Sep 2023 12:53:30 GMT</pubDate>
            <atom:updated>2023-09-01T12:53:30.038Z</atom:updated>
            <content:encoded><![CDATA[<p>Facial recognition software is not new or unknown to the world, it has been around since 1967 when Woodrow W. Bledsoe developed a system that would classify photos of faces through a RAND tablet.</p><p>However, in recent years the advances in machine learning models has made the use of facial recognition widespread, especially in the security industry — Police, Immigration, Private Home Security and more. While the use of facial recognition has been essential in assisting these forces, some activist argue that the machine learning models and the data that is used to train the models is flawed and has created several problems that need to be tackled.</p><p>So, what is facial recognition exactly and how does it work?</p><p>Facial recognition is a method of identifying and verifying the identity of an individual using their face. This is done through the use of computer algorithms that will analyse and identify specific and distinct details regarding an individual’s face. These features include but are not limited to a person’s eyes, nose, cheekbones or lips. The identified features are then converted into a mathematical representation — ‘face template’. This ‘face template’ is then typically used to compare it to other pictures to find matches or train a model. Facial recognition has actually made significant progress in terms of where it can be used. Earlier, facial recognition could only be used on photos, however, thanks to advances in computing power, database storage, machine learning models and more, facial recognition can now actually be used on videos, photos and even real-time streaming. While facial recognition has made significant progress, there are still several limitations and challenges that it faces, such as significantly reduced accuracy in poor lighting, low-quality image resolution, challenging or sub-optimal angles.</p><p>The investment and use of facial recognition has drastically increased in recent years — a report by Statista suggested that the facial recognition market size is likely to increase from USD 3.2 billion to USD 7 billion in 2024. Facial recognition’s increase has been in several areas such as our personal mobile devices and more recently supermarkets have begun using it as a ‘Know Your Customer’ initiative. However, the largest contributor has been law enforcement — through the use of surveillance, including live surveillance. Facial recognition has allowed for mass surveillance to take place — allowing authorities to track and identify individuals at unprecedented speeds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*0LOmlqhG14Z2Jd2q" /></figure><p>GlobeNewswire, 2022</p><p>The heavy use of facial recognition in law enforcement despite extreme flaws has led several activists to speak up. Activists warn of several issues from the use of ‘informed consent’ as an invasion of privacy, to questionable accuracy causing misidentified individuals and wrongful arrests. These issues are some of the issues that activists warn against. In an interview with ‘The Times’, the former Surveillance Camera Commissioner — Tony Porter, expressed his concerns regarding the regulatory framework and oversight with regards to the use of facial recognition technology in the UK. He even commented that in certain instances local councils and police forces are operating under less scrutiny than the MI5, with regards to facial recognition technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_4G2kAbxNdu8gB0A" /></figure><p>Gender Shades, 2018</p><p>In February 2018, Gender Shades published a report comparing the accuracy of various different facial recognition technologies. The report highlighted key issues that the technology faces — such as identifying individuals with darker skin and especially identifying women with darker skin. These inaccuracies have actually led to mistaken arrests. This issue of inaccuracy can actually be attributed to the dataset that is used to train the machine learning model and the model itself.</p><p>A machine learning model is trained on a ‘dataset’ consisting of a collection of videos and images. This dataset acts as an example to teach the machine learning algorithm how to make predictions. There multiple types of ‘datasets’ — text, video, numeric, audio.</p><p>The issue with a flawed dataset can arise due to multiple reasons and can result in a number of problems when training the actual machine learning model. The dataset that is used could be —</p><ul><li>Insufficient: Where the amount of data available is limited and therefore predictions cannot be made.</li><li>Non-Representative: Where the data being used may not be representative of the entire population, such as in the case of the facial recognition technologies</li><li>Poor Quality: Where the data quality is simply poor, inaccurate, noisy and is not clean.</li></ul><p>Many more issues can arise with the data, the above were just a few examples. With all of these major issues with the data used to train these models, the outcomes that are produced by these models are questionable.</p><p>In conclusion, it is important to understand that while the use of these models have helped facial recognition technology to become widely used, there are many issues that still remain unsolved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f17b6a6b901" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>