Skip to main content

Posts

Showing posts with the label YouTube

Tips To Improve LLM-Based Applications

Large Language Models (LLMs) are powerful AI systems that can understand and generate natural language. They have many applications in various domains, such as natural language processing, machine translation, and healthcare. However, building LLM-based applications is not a trivial task. It requires careful consideration of several factors, such as the choice of the LLM, the data quality, the evaluation metrics, and the ethical implications.  In this blog post, I will share some tips to solve most common problems. How to extract correct content from LLM Problem says that, although the answer is present in the content, but model fails to extract that.  Here are the quick tips to resolve this problem: Prompt compression Remove irrelevant data Rectify typos and grammatical errors Remove duplicate data Use data cleaning libraries Problem of missing top ranked documents Problem states that correct document was not rankled while ranking the documents. Here are the few suggestions, which can

How To Hide Sensitive Data Before Passing To LLM-OpenAI

In my previous article “ Passing An Audio File To LLM ”, I explained how one can pass an audio file to LLM. In continuation to that, I’m extending this article by adding more value to it by addressing the use case of sensitive information. Let’s say, an audio file contains information about your bank account number, your secure id, your pin, your passcode, your date of birth, or any such information which has to be kept secured. You will find this kind of information if you are dealing with customer facing audio calls, specifically in finance sector. As these details, which are also known as PII (Personal Identifiable Information), are very sensitive and it is not at all safe to keep them only on any server. Hence, one should be very careful while dealing with such kind of data. Now, when it comes to using PII with generative AI based application, we need a way wherein we can just remove such information from data before passing that to LLM and that’s what this article is all about. In

Get Answers From Audio Without Listening

In this article, I’ll explain about how we can pass an audio file to LLM and I’m taking OpenAI as our LLM . There are many people who prefer audio and video tutorials over reading along with our podcast lovers as listening seems to be more effective for them as compared to reading a book, an e-book or an article, and it is quite common that after a certain period of time, we may forget some of the portions of our tutorial. Now, in order to get the insights again, re-watching or re-listening is the only option, which could be very time-consuming. So, the best solution is to come up with a small AI-based application by writing just a few lines of code which can analyze the audio and respond to all the questions that are asked by the user. Here, utilizing generative AI could be the best option, but the problem is, we can’t pass audio directly as it is text-based. Let’s deep dive into this article, to understand how we can make this work in a step-by-step fashion. If this is what that int

Integrating ChatGPT With Google Docs

In this article, I’ll explain how you can integrate ChatGPT inside Google docs and utilize the capabilities of any text based OpenAI model of your choice. If you are not aware what Google docs is — it is an offering by Google, where in you can create and collaborate documents online. Setting Up Google Docs You can go to https://docs.google.com/, login with your Gmail id and you are all set. If you have already created any document, you can open that otherwise you can go ahead and open a new document. New document will look something like this: In the above window, click on Extensions button and select Apps Script: On click of Apps Script will open up an editor wherein we will write our code. If you're looking for complete source code and explanation, then feel free to check out my article on Medium . Alternatively you can watch the video here .

Tips To Get Started With Azure OpenAI

If you want to explore Azure OpenAI but not sure how to get started, then you are at the right place. I've created a video, which explains everything about get your journey started. Have a look:

Use Your Own Data To Get Response From GPT like ChatGPT | Python

In this article, I’ll show you how you can use your locally stored text files to get response using GPT-3 . You can ask questions and get response like ChatGPT . On technology front, we will be using: OpenAI  Langchain Python Input files You can take bunch of text files and store them in a directory on your local machine. I’ve grabbed input data from here and created 5 text files. My files are all about ‘ Cause And Effect Of Homelessness ’ and are placed in a directory named Store. Import Required Packages As we are using Python , let’s go ahead and import the required packages. If you do not have above packages installed on your machine, then please go ahead and install these packages before importing. Once required packages are imported, we need to get OpenAI API key. Get OpenAI API Key To get the OpenAI key, you need to go to https://openai.com/, login and then grab the keys using highlighted way: Once you got the key, set that inside an environment variable(I’m using Windows). Load

Create Chatbot Based Using GPT-Index/LlamaIndex | OpenAI | Python

In this article, I’ll show you how can you create a basic chat bot which utilizes the data provided by you. Here we will be using GPT-Index/LlamaIndex, OpenAI and Pytho n. Let’s get started by installing the required Python module. Install modules/packages We need to install, two packages named  llama-index and langchain and this can be done using below lines: pip install llama-index pip install langchain Importing packages Next, we need to import those packages so that we can use them: from llama_index import SimpleDirectoryReader , GPTListIndex , GPTVectorStoreIndex , LLMPredictor , PromptHelper , ServiceContext , StorageContext ,load_index_from_storage from langchain import OpenAI import sys import os Please note that, here, we don’t need an GPU because we are not doing anything local. All we are doing is using OpenAI server. Grab OpenAI Key To grab the OpenAI key, you need to go to https://openai.com/, login and then grab the keys using highlighted way: Once you got the key

Are Your Intellisense Working In Jupyter Notebook?

Can you imagine a life of a programmer using an editor having no intellisense support? In today’s era where most of us are working in many programming languages at the same time, it is very difficult to remember the syntax of all the programming languages? The one thing which is most important is the underlying concept of any programming language and if you are good in those fundamentals, there are various ways to get help in writing code. It could be by using a search engine, by going through some book, by lending fellow coder’s hand, by using editor’s or IDEs capabilities, etc. My personal favorite way is by taking the help of IDE. I prefer the IDE which provides very good support for syntax and coding guidelines. In today’s article, I’m focusing on Jupyter notebook inside VS Code, which is a very common IDE these days when you are coding in Python . By default, syntax support or say intellisense support is not enabled in Jupyter Notebook in VS Code and hence we need to enable it us

How To Simplify IF In Python

Using conditionals or say IF-ELSE statement is quite common when developing any application and based on the programming language, the syntax to handle such conditionals varies but the underline concept remains the same. In this article, I’ll show you how to write an IF statement in Python to check if a given item is present in the collection or not. Have a look at the traditional way to achieve the same: fruits = [‘apple’,’orange’,’banana’,’mango’] fruit = ‘mango’ if (fruit==’apple’ or fruit==’orange’ or fruit==’banana’ or fruit==’mango’): print (‘Found the fruit’) In the above snippet, we have a collection holding multiple fruits and a variable holding one fruit. The idea here is to check whether the given fruit exists in the collection or not.  There is no problem with the above code but we do have a way to optimize it and by optimizing the code, we can achieve the below benefits: less number of lines of code less error prone no need to change code, if more items are added

Generate Pivot Table Using Python

Python is nowadays a very common language to use, especially when you want to automate something. Hence, we will go with Python to automate our today’s flow wherein we will generate a pivot table using Python and then we will save it back to Microsoft Excel. Input Data I’m considering CSV file as an input, which holds multiple columns as shown in the below sample: Scenario Let’s consider a scenario, wherein we want to generate a pivot table which depicts the interest of students based on the residence. For example, say you want to know how many students are falling under Uncertain category from Rural, then pivot table should be able to provide us with this data. Generating Pivot Table The very first thing we need to do is to grab the CSV data and bring it into the memory, so that we can perform operations on it. Yes, you guessed it right. We can go for a pandas data frame. Once data is available in a data frame, we can filter out the required columns and start our pivoting process.  He

How To Schedule A Python Script On Windows

Whenever we think about automating something, there are many questions which come to our mind. Like, How will we schedule it? How many times we want to execute it? Is it possible to automate this scheduling part? Well, in this article I’m going to walk you through all those various steps which are required to schedule a Python script on Windows. Step 1: Prepare The Python script Automation begins with the piece of code which will automate something. So, the first step here is to get ready with a Python script which must be in working condition. There is no constraint on how big or small a script has to be, but we need to make sure that the script is doing what it is intended to do. Step 2: Create An Executable Once the script is verified, we need to create an executable or EXE file as this executable file we are going to schedule in our next step. In order to create an executable in Python, we need to install a package named pyinstaller using pip: pip install pyinstaller Once the packa

How To Print Calendar Using Python

In this article, I’ll show you those two lines of Python code, using which you can print calendar of any year. Required Package The pre-requisite to generate calendar is to import the required package named calendar as shown below: from calendar import * Generate Calendar Now to generate a calendar, we need to call constructor and pass in four parameters as shown below: print(calendar(2018,2,1,4)) Here, 2018 is the year for which calendar will be printed 2 signifies width of each character 1 signifies number of lines per week 4 signifies column separation value You can adjust the last three parameters for better spacing in between the text. Output This is how the calendar looks like: I hope you enjoyed generating a calendar of your choice. Make sure to check out my recording explaining each and every parameter discussed in this article:

Sort A Python Dictionary By Value

It is quite common to sort a Python dictionary based on key. But what if you want to perform sorting on the value? In this article, I’m going to show you multiple ways to sort dictionary value and then return the resultant dictionary. Method 1: Using operator The very first method to sort dictionary value is by using sorted(…) function along with operator. So, let’s go ahead and do it as shown below: import operator students = {‘Shweta’:25,’Andy’:30,’Maddy’:3} students = sorted(students.items(), key=operator.itemgetter(1)) print (students) Method 2: Using lambda The second method to sort dictionary value is by using sorted(…) function along with lambda and the code looks as shown below: : import operator students = {‘Shweta’:25,’Andy’:30,’Maddy’:3} students = sorted(students.items(), key=lambda stud:stud[1]) print (students) Output On execution of above two methods, you will get exactly same output. I hope you enjoyed sorting your dictionary values in Python. If you have reached t

What Is REDUCE In Python

Before jumping on to what is reduce, let’s have a quick look at the lines  below :  import operator sum = 0 for n in [1,2,3]: sum = sum + n print ( sum ) You got it right. Here we are taking a collection having three numbers and summing them up. As such, there is nothing wrong with this code but, of course there is a big room for optimization with respect to the number of lines of code we have written, just go get summation. Now the question is, how can we optimize? How can we reduce the number of lines and achieve the same result? Well, the answer is reduce function. What is reduce? Reduce is a function in Python provided by functools . This function takes a collection of values, performs some operation by calling a function and then returns a single value as an output. For example, you can give multiple values as input and perform mathematical calculations on them, you can perform operations on multiple strings, etc. Ways to use reduce There are two ways you can use reduce: Way 1