AI Troubleshooting: Solving Long Inputs & Output Issues

AI Troubleshooting: Solving Long Inputs & Output Issues Hi there. Rajesh just started with AI at Make, and he is finding it challenging to understand some of his common errors. That's why in this video, we will be addressing some of the common issues and helping you and Rajesh understand how these can be solved..

AI Troubleshooting: Solving Long Inputs & Output Issues

Here are the two challenges we will be addressing. First, we'll address the issue of input data being too long for the AI. Then, we'll show you how to ensure you always get great output data that you can work with and make. Let's log in to Make and open our scenario so we can start working on the first problem.

Of long inputs. It's common to receive lengthy text, like from emails filled with HTML tags or irrelevant data. We will show you a simple way to shorten this content so you can use it even with AI that cannot process long prompts..

Let's take an example of text from this web page, which we will store in a variable. In Make tools, you can search for the action "set a variable," which allows you to store values. A good thing about this module is that it also allows you to perform functions on the values stored in that variable, which is what we will do in our case..

We will use the substring inline function. If you need a reminder about functions, there's a corresponding course available in the Intermediate Course at Make Academy, so feel free to pause here and refresh. But back to our substring function. This function returns a portion of a text string between the start position and the.

End position. So, to use it properly, you will need to specify the beginning and the end as arguments. In our case, we start at zero, which is the first argument, and the first letter of the text. As our end, we will put the maximum context window of our AI model..

As a refresher, context window is basically how long your prompt can be so your AI model doesn't reject it. This number differs across providers, and it is often 4,096 tokens for most. Some OpenAI models, such as GPT-3.5, offer longer contexts of up to 16,000 tokens. We will use the 3.5 model, so let's set our limit in the function to 16,000..

Let's now set up our second module where we will create a completion with OpenAI. Since we have trimmed our input, we can now pass it into the AI. Let's configure it together. When choosing a model, we will use the 16k context ChatGPT as we already mentioned. Then, we will add our message, where we will pass the text we stored in our previous variable..

It doesn't really matter which role we choose here because we are not doing anything with our data, so into our prompt, I will just write something like "What is this website about?" and then pass the text from the variable. Then, I'll specify the max number of tokens. Great..

That's it for the first one. We can give it a try and run the scenario. Now, let's tackle the second issue—ensuring the AI returns proper output data. The solution might sound simple, but we will need a JSON string to be returned. Here is a simple example of a JSON we expected, but that did not work inside Make..

Let's explore why. You can see here that the JSON we got back from our Anthropic module has text before and after, so it's not really something we can parse and use at the moment. We'll explore now two solutions, starting with the most common one. It's all about using examp ex or few shots, as we call them..

Provide the AI with examples of the JSON structure you want, like seen here—clear key and values. Another important aspect is to add clear rules such as "Do not add any other characters before or after the JSON. The JSON must be pure and parsable." You'll see that the AI responds with a great JSON output..

Posts Related:

    Now, for those using GPT-4, you can take this even further by directly requesting a JSON

    From the AI. In the advanced options of the OpenAI module, you can find these. Remember, it's still helpful to provide an example. And there you have it..

    Two simple solutions to common AI errors. We hope that this short tutorial brought you and Rajesh closer to using AI for your daily tasks without having to think twice about solving common errors like the limited context windows or outputs that are difficult to work with. With these two hacks, your AI-driven workflows will be unstoppable..

    DISCLAIMER: In this description contains affiliate links, which means that if you click on one of the product links, I'll receive a small commission. This helps support the channel and allows us to continuetomake videos like this. All Content Responsibility lies with the Channel Producer. For Download, see The Author's channel. The content of this Post was transcribed from the Channel: https://www.youtube.com/watch?v=dt-YY3xNLmM
Previous Post Next Post