How to use custom data with GPT3 without fine tuning

I was looking for a simple way to use custom data to prompt into GPT3 by using just the Embeddings API and Completion API.
So far I think the combination of spreadsheet with custom functions works really well!
It’s free to use and download and modify, let me know how it works for you.

6 Likes

hey => i have a interesting use case => how do i consume this data ? can i call open AI APIs to search in this XLS => ? My problem : i have a data set with maps and lat and long points => Prompt : give me the route map for cycling trails in bangalore for colonial era with points of interest and trail map ?This should give the column data in GOEJSON format saved in the column and i can modify this accordingly - previously i had to put this in DB and search for the same ! pls help me !

I don’t think you should do spatial routings with embeddings. The data for that is well structured already. Pure SQL is the pretty easy solution here.

Let’s say you have a mail with someone asking for a good cycling track like this:

I want to go on a cycling track next wednesday. Should be around 50km and I would like to see that specific point of interest. Want to start at 8 am and around 1pm I want to eat something in a restaurant.

Then you extract the important data from it like:

prompt: This is a mail of a guy who wants me to find him a cycling track from our database.

Please give them to me in following json format:

Then you take that json and call an API which builds an SQL and returns the GEOJSON.

Or have a look into functions to call the API directly…

Hi Murali,

Welcome to the community and thanks for sharing your project.
If I understand your objective clearly, you are looking for a solution to take a question from a user and recommend one a location and provide other artifacts such as a map and nearby interests.
It also seems like you have a database of places with GeoLocation and other text information about these places. If that is the case I think this is what you will need…

Validate the Question
The first thing we need to do is to understand the question from the user and find out if the question is related a location search. You can do this by taking the question of the user and ask the model the following…

Prompt: User is asking “What is a good hiking trail in the north part of Bangalore”. Is the user looking for a hiking trail. Reply only YES or NO.

YES

Most likely the model will reply either YES or NO if you use this prompt and give it only a max length under 3. If the answer is Yes, then you can continue, else you can ask the user to provide a question for hiking trail only and provide an example on how to ask the question.

Parse the Location
Once you have validated the question, you will need to parse the location of the user is looking for and you can do that by asking the model this question.

Prompt: User is asking “What is a good hiking trail in the north part of Bangalore”. Provide the geo location the user is looking to go in with latitude and longitude in JSON format only

{ “latitude”: -34.397, “longitude”: 150.644 }

Most likely you will get back an answer with the geo location with latitude or longitude only

Parse the activity
Once you have parsed the geolocation, you will want to find out what type of activities the user is interested in, I am assuming you are looking to serve users with other interest more than just hiking.

Prompt: User is asking “What is a good hiking trail in the north part of Bangalore”. Provide category of activity in one word

Hiking

Search With GeoLocation
Now that you have the geo location of the user, you can do a geo search in you Database to find all the locations within a certain distance

Filter the Results With Semantic Search
Just because you have all the locations nearby, it doesn’t mean you have the places of interests.
To find the place of interest you can take the response from the model, and include the nearby locations that are similar to Hiking

search_embedding = encode_embedding("Hiking")
place_embeddings = encode_embedding(nearby_location_descriptions)
best_nearby_places = semantic_search([search_embedding], place_embeddings)

It will come down to three lines of code with custom functions that you can build using OpenAI API, or using this spreadsheet.

Let me know if you have any questions and feel free to PM directly or at connect with me at https://www.linkedin.com/in/nelsonchu247

Depending on which model you are using, some of the prompts might need to be modify, but I have tested using our own model and it seems to be fine.

Asking for a json that includes assumed start and end location and activity will perfectly work in one prompt.
Routings and geolocations can be taken from the database. I am pretty sure the model won’t be able to provide the geojson since locations constantly change.
Streetnames, city names, etc…