Large Language Models are heralding a new era in information technology. To better understand this revolution, it’s important to consider the historical context. The printing press significantly reduced the cost of reproducing information, while the internet cut out the middleman, making the distribution of information virtually free. In Aggregation Theory, Ben Thompson writes about how the free distribution of the internet allowed companies to modularize (or unbundle) services and focus on user experience. Ben states that “companies that win the user experience can generate a virtuous cycle where their ownership of consumers/users attracts suppliers which improves the user experience”.
Enter Large Language Models (LLMs), a world changing technology that enables transforming and generating information at incredible speeds and low cost. LLMs present the opportunity to expedite the virtuous cycle Aggregation Theory describes by commoditizing the human effort traditionally required to deliver great user experiences.
The internet cut out the newspaper, now content can be delivered directly to you. Now we are going a step further, modifying content itself based on your personal preferences! Not only are we able to bring content with a great UX to people, but now we can generate content, in real time, based on existing information in the database to create an ever better and more personalized experience!
In this article, we are going to illustrate the concept of Generative Feedback Loops with LLMs. Retrieving information from the Weaviate Vector Database to prompt Weaviate’s generative module and then vectorizing and saving these generations back into the database! Now we can semantically search through the generated content, as well as add symbolic metadata about it.
We will step into the shoes of AirBnB and implement a Generative Feedback Loop to process Listing
objects. This shows how LLMs let us supercharge user experience by creating custom advertisements based on user preferences. We retrieve information about users from the DB, give that + information about the Listing to the LLM, and save the resulting custom advertisement back to the database.
Here is a quick overview of the code snippets before diving in:
- Create a description for Listings based on x,y,z.
- Semantic Search through generated Listings with the Vector Database
- Generate Ads for these Listings and link them with cross-references.
- Write personalized Ads for Connor the dog owner and Bob the weightlifter
Part 1: AirBnB Listing Example
The GitHub repo with notebooks (using Weaviate embedded) can be found here.
In this example we will be using the OpenAI text-davinci-003
and the Cohere command-xlarge-nightly
LLMs to generate content, but this is also possible with other providers such as HuggingFace, Anthropic, and more. Set your OpenAI or Cohere key to use with Weaviate’s generate module using the following block of code:
import weaviate
client = weaviate.Client(embedded_options=weaviate.EmbeddedOptions(),
additional_headers = {
“X-OpenAI-Api-Key”: “<YOUR OPENAI KEY HERE>”
}) # if using Cohere, replace this with "X-Cohere-Api-Key"
client.get_meta() # see which modules are enabled in Weaviate Embedded
The table below illustrates the schema of the data we will use, please see the notebook for reference of the full json dictionary to create Weaviate schemas with configurations like this:
Property | Type | Vectorize? | AI Generated? | In import dataset? |
---|---|---|---|---|
name | text | ✅ | ❌ | ✅ |
description | text | ✅ | ✅ | ❌ |
host_name | text | ❌ | ❌ | ✅ |
neighbourhood | text | ❌ | ❌ | ✅ |
neighbourhood_group | text | ❌ | ❌ | ✅ |
latitude | number | ❌ | ❌ | ✅ |
longitude | number | ❌ | ❌ | ✅ |
room_type | text | ❌ | ❌ | ✅ |
price | number | ❌ | ❌ | ✅ |
minimum_nights | int | ❌ | ❌ | ✅ |
number_of_reviews | int | ❌ | ❌ | ✅ |
last_review | date | ❌ | ❌ | ✅ |
reviews_per_month | number | ❌ | ❌ | ✅ |
calculated_host_listings_count | int | ❌ | ❌ | ✅ |
availability_365 | int | ❌ | ❌ | ✅ |
hasAd | Ad | ❌ | ✅ | ❌ |
The schema can be found in this repository
Avoiding Hallucinations: Real-Time Data with LLM Capabilities
Utilizing prompt engineering tactics like “Please base your response only on the provided information”, we integrate data from the Listing database into the generative model. This allows us to draw from the provided information. By emphasizing the use of real-time information stored in Weaviate, we continuously update the language model with the latest data, bypassing the limitation of its encoded knowledge. Ultimately combining the peanut butter of factual information from the database with the jelly of LLM language understanding.
Generate a description for each Listing
- Python
- TypeScript
generatePrompt = """
Please write a description for the following AirBnb Listing in english:
Name: {name}
Neighbourhood: {neighbourhood}
Neighbourhood Group: {neighbourhood_group}
Latitude: {latitude}
Longitude: {longitude}
Room Type: {room_type}
Price: {price}
Minimum Nights: {minimum_nights}
Number of Reviews: {number_of_reviews}
Last Review: {last_review}
Reviews per Month: {reviews_per_month}
Calculated Host Listings Count: {calculated_host_listings_count}
Availability_365: {availability_365}
Please do not make up any information about the property in your description.
"""
generate_properties = ["name","neighbourhood","neighbourhood_group",
"latitude","longitude","room_type",
"price","minimum_nights","number_of_reviews",
"last_review","reviews_per_month",
"calculated_host_listings_count","availability_365"]
descriptions = client.query\
.get("Listing", generate_properties)\
.with_generate(single_prompt=generatePrompt)\
.with_additional(["id"])\
.with_limit(5)\
.do()["data"]["Get"]["Listing"]
for description in descriptions:
new_property = {
"description": description["_additional"]["generate"]["singleResult"]
}
id = description["_additional"]["id"]
client.data_object.update(
new_property,
class_name = "Listing",
uuid=id
)
const generate_prompt: string = 'Please write a description for the following AirBnB Listing in English. NAME: {name} HOST_NAME {host_name} NEIGHBOURHOOD {neighbourhood} NEIGHBOURHOOD_GROUP {neighbourhood_group} PRICE {price}. Please do not make up any information about the property in your description.';
const properties_str = 'name host_name neighbourhood neighbourhood_group price _additional{ id }';
client.graphql
.get()
.withClassName('Listing')
.withFields(properties_str)
.withGenerate({
singlePrompt: generate_prompt,
})
.withLimit(5)
.do()
.then(results => {
//loop through results to add to `generated_descriptions`
let generated_data = results["data"]["Get"]["Listing"];
for (let i = 0; i < 5; i++) {
let uuid = generated_data[i]["_additional"]["id"];
let generated_result = generated_data[i]["_additional"]["generate"]["singleResult"];
let new_description_property = {
"description": generated_result
};
console.log(new_description_property);
client.data
.getterById()
.withClassName('Listing')
.withId(uuid)
.do()
.then(res => {
client.data
.updater()
.withId(uuid)
.withClassName('Listing')
.withProperties(new_description_property)
.do();
})
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
}
})
.catch(err => {
console.error(err);
});
Now let's test a semantic search through the Listings, each vectorized with the respective LLM-generated description
:
- Python
- TypeScript
client.query.get("Listing", "description").with_near_text({
"concepts": ["AirBnB near a place to walk my dog"]
}).do()
client.graphql
.get()
.withClassName('Listing')
.withFields('description')
.withNearText({
concepts: ['AirBnB near a place to walk my dog']
})
.do()
OpenAI Generations
Rank | Result |
---|---|
1 | This private room in the Bedford-Stuyvesant neighbourhood of Brooklyn is the perfect spot for a long-term stay. The space is clean and quiet, providing a peaceful retreat from the hustle and bustle of the city. With a minimum stay of 60 nights, you'll have plenty of time to explore all that Brooklyn has to offer. The location is convenient, with easy access to public transportation and a variety of shops and restaurants nearby. Although there are no reviews yet, you can rest assured that the host is experienced and dedicated to providing a comfortable and enjoyable stay. With availability 365 days a year, this listing is a great option for anyone looking for a long-term stay in Brooklyn. |
2 | This spacious 2 bedroom apartment is located in the vibrant East Harlem neighbourhood of Manhattan, just a stone's throw away from Central Park. The entire home is available for rent, providing guests with ample space and privacy during their stay. With a minimum stay of 7 nights, this listing is perfect for those looking for a longer-term rental option. Although there are currently no reviews for this property, guests can rest assured that they will be staying in a well-maintained and comfortable space. The host has two listings on Airbnb and the availability for this property is 249 days out of the year. Book now to experience the excitement of New York City from the comfort of this spacious apartment. |
3 | This private room is located in the Flatbush neighborhood of Brooklyn, offering a unique country space in the heart of the city. The room is priced at $150 per night with a minimum stay of one night. Although there are currently no reviews for this listing, it is available for booking 365 days a year. The host has only one listing, ensuring a personalized and attentive experience for guests. The latitude and longitude coordinates for the property are 40.63702 and -73.96327, respectively. Book now for a peaceful and relaxing stay in the bustling city of Brooklyn. |
Cohere Generations
Rank | Result |
---|---|
1 | Welcome to your country space in the city! This beautiful, bright, and quiet 2 bedroom apartment has been completely renovated and features a private entrance, a large kitchen with brand new stainless steel appliances, two bedrooms each with queen size beds, and a full bathroom with a soaking tub. There is also a washer and dryer in the unit as well as a dishwasher. The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park. |
2 | THE VILLAGE OF HARLEM....NEW YORK !\n\nThis is the Village of Harlem. A vibrant, colorful, eclectic, and the most famous Village in New York.\n\nI am a proud Harlem resident and I am so excited to share my home with you. I am also an avid traveler and I love to meet new people from around the world.\n\nWhen you stay at my place, you will have your own private room and bathroom. You will also have access to the kitchen and the living room.\n\nI am located in the heart of Harlem, just a few blocks from the 2/3 subway station. From there, it is just a few stops to downtown Manhattan.\n\nYou will be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer. The famous Apollo Theater is just a few blocks away. The beautiful Central Park is also a short walk away.\n\nCome and experience the real New York City in the Village of Harlem. I look forward to meeting you and showing you around my home. |
3 | Huge 2 BR Upper East Cental Park\n\nHost Sing\n\nEast Harlem\nManhattan\n\nPrice: $190\n\nThis huge 2 bedroom is located in the heart of Manhattan, steps away from Central Park. It is newly renovated with stainless steel appliances, exposed brick, and beautiful hardwood floors. The apartment is located in a very safe and convenient area, with a variety of restaurants and stores nearby. The subway is also very close, making it easy to get around the city.\n\nThis is the perfect place for anyone looking to explore New York City. |
Note how the 3rd generation from the Cohere model outputted Cental Park
instead of the correct spelling of Central Park
! At first glance it looks like the model is hallucinating Cental Park
(spelled incorrectly), but this actually is in the data. This is a nice anecdote to show how the model will attend to the input in spite of it's prior knowledge, even though it has prior knowledge about Manhattan, it will still call it Cental Park
because that's what the retrieved content says to do.
Generate New Data Objects
In the previous example we’ve enhanced existing data objects by adding a description
property. But we can now even create complete new data objects (e.g., Ads for specific target audiences) based on the new objects.
- Python
- TypeScript
generatePrompt = """
Please write an engaging advertisement for the following AirBnb Listing:
Description: {description}
"""
ads = client.query\
.get("Listing", ["description", "room_type", "neighbourhood"])\
.with_generate(single_prompt=generatePrompt)\
.with_additional(["id"])\
.with_limit(5)\
.do()["data"]["Get"]["Listing"]
for ad in ads:
new_ad_properties = {
"content": ad["_additional"]["generate"]["singleResult"]
}
new_ad_id = get_valid_uuid(uuid4())
client.data_object.create(
data_object = new_ad_properties,
class_name = "Ad",
uuid = new_ad_id
)
client.data_object.reference.add(
from_uuid = ad["_additional"]["id"],
from_property_name = "hasAd",
to_uuid = new_ad_id
)
const generate_prompt: string = 'Please write a description for the following AirBnB Listing in English. NAME: {name} HOST_NAME {host_name} NEIGHBOURHOOD {neighbourhood} NEIGHBOURHOOD_GROUP {neighbourhood_group} PRICE {price}. Please do not make up any information about the property in your description.';
const properties_str = 'name host_name neighbourhood neighbourhood_group price _additional{ id }';
client.graphql
.get()
.withClassName('Listing')
.withFields(properties_str)
.withGenerate({
singlePrompt: generate_prompt,
})
.withLimit(5)
.do()
.then(results => {
//loop through results to add to `generated_descriptions`
let generated_data = results["data"]["Get"]["Listing"];
for (let i = 0; i < 5; i++) {
let uuid = generated_data[i]["_additional"]["id"];
let generated_result = generated_data[i]["_additional"]["generate"]["singleResult"];
let new_description_property = {
"description": generated_result
};
console.log(new_description_property);
client.data
.getterById()
.withClassName('Listing')
.withId(uuid)
.do()
.then(res => {
client.data
.updater()
.withId(uuid)
.withClassName('Listing')
.withProperties(new_description_property)
.do();
})
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
}
})
.catch(err => {
console.error(err);
});
Let's see the resulting ads and the descriptions they were sourced from:
OpenAI Generations
Description | Ad |
---|---|
This cozy private room in the Bedford-Stuyvesant neighbourhood of Brooklyn is the perfect place to stay for an extended period of time. Located at 40.68876 latitude and -73.94312 longitude, this room is clean and quiet, and has a minimum stay of 60 nights. With a calculated host listings count of 1 and availability of 365 days a year, you can be sure to find a spot here. There are no reviews yet, so be the first to experience this great room! | Are you looking for a place to stay for an extended period of time? Look no further than this cozy private room in the Bedford-Stuyvesant neighbourhood of Brooklyn! Located at 40.68876 latitude and -73.94312 longitude, this room is clean and quiet, and has a minimum stay of 60 nights. With a calculated host listings count of 1 and availability of 365 days a year, you can be sure to find a spot here. Be the first to experience this great room and write a review! Don't miss out on this amazing opportunity - book now! |
This beautiful two bedroom apartment is located in the Upper East Side of Manhattan, just a short walk away from Central Park. The apartment is situated in the East Harlem neighbourhood, and is surrounded by a variety of restaurants, shops, and other attractions. The apartment is available for rent for a minimum of seven nights, and is priced at $190 per night. The apartment is equipped with all the necessary amenities, and is available for rent for 249 days out of the year. | Welcome to this beautiful two bedroom apartment in the Upper East Side of Manhattan! Located in the East Harlem neighbourhood, this apartment is just a short walk away from Central Park and surrounded by a variety of restaurants, shops, and other attractions. Enjoy all the necessary amenities in this apartment, available for rent for a minimum of seven nights at a price of $190 per night. With 249 days available for rent out of the year, this is the perfect place to stay for your next vacation or business trip! Book now and experience the best of Manhattan! |
This cozy private room is located in the Flatbush neighbourhood of Brooklyn. Enjoy the convenience of being in the city while still having access to the peacefulness of the countryside. The room is available for a minimum of one night and is available for booking all year round. With a latitude of 40.63702 and longitude of -73.96327, you'll be able to explore the city with ease. This listing has no reviews yet, so be the first to experience this unique country space in the city. | Are you looking for a unique getaway in the city? Look no further than this cozy private room in the Flatbush neighbourhood of Brooklyn! Enjoy the convenience of being in the city while still having access to the peacefulness of the countryside. With a latitude of 40.63702 and longitude of -73.96327, you'll be able to explore the city with ease. This listing has no reviews yet, so be the first to experience this one-of-a-kind country space in the city. Book now for a minimum of one night and enjoy all year round! |
Cohere Generations
Description | Ad |
---|---|
Huge 2 BR Upper East Cental Park\n\nHost Sing\n\nEast Harlem\nManhattan\n\nPrice: $190\n\nThis huge 2 bedroom is located in the heart of Manhattan, steps away from Central Park. It is newly renovated with stainless steel appliances, exposed brick, and beautiful hardwood floors. The apartment is located in a very safe and convenient area, with a variety of restaurants and stores nearby. The subway is also very close, making it easy to get around the city.\n\nThis is the perfect place for anyone looking to explore New York City. | Welcome to your home away from home in the heart of Manhattan! This huge 2 bedroom is located just steps away from Central Park and all the best that New York City has to offer.\n\nThe apartment has been newly renovated with stainless steel appliances, exposed brick, and beautiful hardwood floors. You'll love the convenience of being located in a very safe and convenient area, with a variety of restaurants and stores nearby. The subway is also very close, making it easy to get around the city.\n\nWhether you're here for business or pleasure, this is the perfect place to call home during your stay. Don't miss out on the opportunity to explore all that New York City has to offer from the comfort of this amazing apartment. Book your stay today and start planning your adventure! |
Welcome to your country space in the city! This beautiful, bright, and quiet 2 bedroom apartment has been completely renovated and features a private entrance, a large kitchen with brand new stainless steel appliances, two bedrooms each with queen size beds, and a full bathroom with a soaking tub. There is also a washer and dryer in the unit as well as a dishwasher. The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park. | Welcome to your country space in the city! This beautiful, bright, and quiet 2 bedroom apartment has been completely renovated and features a private entrance, a large kitchen with brand new stainless steel appliances, two bedrooms each with queen size beds, and a full bathroom with a soaking tub. There is also a washer and dryer in the unit as well as a dishwasher. The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park.\n\nPlease note that there is a $150 cleaning fee and a $500 security deposit. The security deposit will be refunded after your stay if there is no damage to the apartment.\n\nWe look forward to hosting you! |
THE VILLAGE OF HARLEM....NEW YORK !\n\nThis is the Village of Harlem. A vibrant, colorful, eclectic, and the most famous Village in New York.\n\nI am a proud Harlem resident and I am so excited to share my home with you. I am also an avid traveler and I love to meet new people from around the world.\n\nWhen you stay at my place, you will have your own private room and bathroom. You will also have access to the kitchen and the living room.\n\nI am located in the heart of Harlem, just a few blocks from the 2/3 subway station. From there, it is just a few stops to downtown Manhattan.\n\nYou will be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer. The famous Apollo Theater is just a few blocks away. The beautiful Central Park is also a short walk away.\n\nCome and experience the real New York City in the Village of Harlem. I look forward to meeting you | Welcome to THE VILLAGE OF HARLEM....NEW YORK!\n\nThis is the Village of Harlem. A vibrant, colorful, eclectic, and the most famous Village in New York.\n\nI am a proud Harlem resident and I am so excited to share my home with you. I am also an avid traveler and I love to meet new people from around the world.\n\nWhen you stay at my place, you will have your own private room and bathroom. You will also have access to the kitchen and the living room.\n\nI am located in the heart of Harlem, just a few blocks from the 2/3 subway station. From there, it is just a few stops to downtown Manhattan.\n\nYou will be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer. The famous Apollo Theater is just a few blocks away. The beautiful Central Park is also a short walk away.\n\nCome and experience the real New York City in the Village of Harlem. I look forward to meeting you and showing you around my home. |
In the future we may want to add other properties to the Ad
objects, such as dates when we ran the Ad
, how much we spent, and what the resulting Click-Through-Rate was. We could then generate a new Ad
by taking the top 5 highest CTR ads as a reference!
Targeted Ads
Now we will add more data to our prompt, a high-level ad target. We will write ads targeting (1) young couples, (2) elderly couples, and (3) single travelers. We will add target
as a property to the Ad
class, like this:
target_property = {
"dataType": [
"text"
],
"name": "target",
"description": "High-level audience target for this ad."
}
client.schema.property.create("Ad", target_property)
OpenAI Generations
Ad Target | Ad |
---|---|
For Young Couples | Are you looking for a cozy place to stay for an extended period of time? Look no further than this private room in the Bedford-Stuyvesant neighbourhood of Brooklyn! Located at 40.68876 latitude and -73.94312 longitude, this room is clean, quiet, and perfect for young couples. With a minimum stay of 60 nights and availability of 365 days a year, you can be sure to find a spot here. Plus, you can be the first to experience this great room - there are no reviews yet! Don't miss out on this great opportunity - book your stay today! |
For Elderly Couples | Are you an elderly couple looking for a place to stay for an extended period of time? Look no further than this cozy private room in the Bedford-Stuyvesant neighbourhood of Brooklyn! Located at 40.68876 latitude and -73.94312 longitude, this room is clean and quiet, and has a minimum stay of 60 nights. With a calculated host listings count of 1 and availability of 365 days a year, you can be sure to find a spot here. There are no reviews yet, so be the first to experience this great room! Enjoy the peace and quiet of this room and make it your home away from home. |
For Single Travelers | Are you a single traveler looking for a place to stay for an extended period of time? Look no further than this cozy private room in the Bedford-Stuyvesant neighbourhood of Brooklyn! Located at 40.68876 latitude and -73.94312 longitude, this room is clean, quiet, and has a minimum stay of 60 nights. With a calculated host listings count of 1 and availability of 365 days a year, you can be sure to find a spot here. Be the first to experience this great room and make it your home away from home! |
Generic Ad | Are you looking for a place to stay for an extended period of time? Look no further than this cozy private room in the Bedford-Stuyvesant neighbourhood of Brooklyn! Located at 40.68876 latitude and -73.94312 longitude, this room is clean and quiet, and has a minimum stay of 60 nights. With a calculated host listings count of 1 and availability of 365 days a year, you can be sure to find a spot here. Be the first to experience this great room and write a review! Don't miss out on this amazing opportunity - book now! |
In the future we may want to add other properties, such as dates when we ran the Ad, how much we spent, and what the resulting Click-Through-Rate was. We could then generate a new Ad by taking the top 5 highest CTR ads as a reference!
Cohere Generations
Target | Ad |
---|---|
For Young Couples | Welcome to the Village of Harlem, New York! This vibrant, colorful, eclectic, and famous village is home to a proud Harlem resident who can't wait to share their home with you. As an avid traveler, they love to meet new people from around the world and show them the best of what Harlem has to offer. When you stay at this Airbnb, you'll have your own private room and bathroom, as well as access to the kitchen and living room. The host is located in the heart of Harlem, just a few blocks from the 2/3 subway station, making it easy to get to downtown Manhattan and other parts of the city. You'll be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer, including the famous Apollo Theater and beautiful Central Park. The host looks forward to meeting you and showing you around their home, so book your stay today and experience the real New York City in the Village of Harlem! |
For Elderly Couples | Description: THE VILLAGE OF HARLEM....NEW YORK! This is the Village of Harlem. A vibrant, colorful, eclectic, and the most famous Village in New York. I am a proud Harlem resident and I am so excited to share my home with you. I am also an avid traveler and I love to meet new people from around the world. When you stay at my place, you will have your own private room and bathroom. You will also have access to the kitchen and the living room. I am located in the heart of Harlem, just a few blocks from the 2/3 subway station. From there, it is just a few stops to downtown Manhattan. You will be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer. The famous Apollo Theater is just a few blocks away. The beautiful Central Park is also a short walk away. Come and experience the real New York City in the Village of Harlem. I look forward to meeting you and showing you around my home. |
For Single Travelers | Welcome to the Village of Harlem, New York! This vibrant, colorful, eclectic, and famous village is home to a proud Harlem resident who can't wait to share their home with you. As an avid traveler, they love to meet new people from around the world. When you stay at this Airbnb, you'll have your own private room and bathroom, as well as access to the kitchen and living room. The host is located in the heart of Harlem, just a few blocks from the 2/3 subway station, making it easy to get to downtown Manhattan. You'll be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer, including the famous Apollo Theater and beautiful Central Park. The host looks forward to meeting you and showing you around their home, so book your stay today! |
Generic Ad | Welcome to THE VILLAGE OF HARLEM....NEW YORK! This is the Village of Harlem. A vibrant, colorful, eclectic, and the most famous Village in New York. I am a proud Harlem resident and I am so excited to share my home with you. I am also an avid traveler and I love to meet new people from around the world. When you stay at my place, you will have your own private room and bathroom. You will also have access to the kitchen and the living room. I am located in the heart of Harlem, just a few blocks from the 2/3 subway station. From there, it is just a few stops to downtown Manhattan. You will be surrounded by the best restaurants, bars, and nightclubs that Harlem has to offer. The famous Apollo Theater is just a few blocks away. The beautiful |
Personlized Ads for Connor and Bob
Let’s keep unpeeling the onion and show how we could even further target these ads based on user biographies.
users = client.query\
.get("User", ["biography"])\
.with_additional(["id"])\
.with_limit(5)\
.do()["data"]["Get"]["User"]
for user in users:
generatePrompt = """
Please write an engaging advertisement for the following AirBnb Listing:
Description: {description}
Please write the advertisement for this listing to target the following user:
""" + user["biography"]
ads = client.query\
.get("Listing", ["description"])\
.with_generate(single_prompt=generatePrompt)\
.with_additional(["id"])\
.with_limit(5)\
.do()["data"]["Get"]["Listing"]
for ad in ads:
new_ad_properties = {
"content": ad["_additional"]["generate"]["singleResult"],
}
new_ad_id = get_valid_uuid(uuid4())
client.data_object.create(
data_object = new_ad_properties,
class_name = "Ad",
uuid = new_ad_id
)
client.data_object.reference.add(
from_uuid = new_ad_id,
from_property_name = "hasUserTarget",
to_uuid = user["_additional"]["id"]
)
OpenAI Generations
Name | Description | Targeted Ad #1 | Targeted Ad #2 |
---|---|---|---|
Connor | Often travels with a golden doodle named Bowen. | Attention all pet lovers! Are you looking for a spacious and comfortable apartment in the heart of New York City that welcomes your furry friend? Look no further than this stunning 2 bedroom apartment in vibrant East Harlem...Book now and start planning your next adventure with your golden doodle named Bowen! | Attention all travelers with furry friends! Are you looking for a peaceful and affordable stay in the heart of Manhattan? Look no further than this private room in the Inwood neighborhood, offering a magnificent view of the Cloisters...And the best part? You can bring your golden doodle named Bowen along for the adventure! No need to leave your furry friend behind on your travels...Please note that availability for this listing is currently at zero for the next 365 days, so book now to secure your spot for your next adventure with your furry friend. |
Bob | Prolific weightlifter who will get upset if he doesn’t have a good gym to workout in. | Attention all weightlifters! Are you planning a trip to New York City and worried about finding a suitable place to stay that caters to your fitness needs? Look no further than this spacious 2 bedroom apartment located in the vibrant East Harlem neighbourhood of Manhattan...So what are you waiting for? Book now and experience the excitement of New York City from the comfort of this spacious apartment. | Attention all weightlifters! Are you looking for a peaceful and affordable stay in the city that won't compromise your workout routine? Look no further than this private room in the Inwood neighborhood of Manhattan...Unfortunately, availability for this listing is currently at zero for the next 365 days, but keep it in mind for your next trip to the city. Don't let your workout routine suffer while traveling - book this listing now! |
Cohere Generations
Name | Description | Targeted Ad 1 | Targeted Ad 2 |
---|---|---|---|
Connor | Connor often travels with a golden doodle named Bowen. | Welcome to your country space in the city! This beautiful, bright, and quiet 2 bedroom apartment has been completely renovated and features a private entrance, a large kitchen with brand new stainless steel appliances, two bedrooms each with queen size beds, and a full bathroom with a soaking tub. There is also a washer and dryer in the unit as well as a dishwasher. The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park. The space: This beautiful, bright, and quiet 2 bedroom apartment has been completely renovated and features a private entrance, a large kitchen with brand new stainless steel appliances, two bedrooms each with queen size beds, and a full bathroom with a soaking tub. There is also a washer and dryer in the unit as well as a dishwasher. The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park. The neighborhood: The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park. The beds: The apartment has two bedrooms each with queen size beds. The bathroom: The full bathroom has a soaking tub. The kitchen: The large kitchen has brand new stainless steel appliances. The living room: The living room is bright and spacious. The dining room: The dining room is perfect for enjoying meals with friends and family. The outdoor space: The apartment has a private entrance. | Welcome to Huge 2 BR Upper East Cental Park. This huge 2 bedroom is located in the heart of Manhattan, steps away from Central Park. It is newly renovated with stainless steel appliances, exposed brick, and beautiful hardwood floors. The apartment is located in a very safe and convenient area, with a variety of restaurants and stores nearby. The subway is also very close, making it easy to get around the city. This is the perfect place for anyone looking to explore New York City. |
Bob | Bob is a prolific weightlifter who will get upset if he doesn’t have a good gym to workout in. | Hello, weightlifters! Are you looking for a place to stay in New York City that will allow you to pursue your fitness goals? Look no further! This huge 2 bedroom is located in the heart of Manhattan, steps away from Central Park. It is newly renovated with stainless steel appliances, exposed brick, and beautiful hardwood floors. The apartment is located in a very safe and convenient area, with a variety of restaurants and stores nearby. The subway is also very close, making it easy to get around the city. So what are you waiting for? Book your stay today and experience the best of New York City! | Welcome to your country space in the city! This beautiful, bright, and quiet 2 bedroom apartment has been completely renovated and features a private entrance, a large kitchen with brand new stainless steel appliances, two bedrooms each with queen size beds, and a full bathroom with a soaking tub. There is also a washer and dryer in the unit as well as a dishwasher. The apartment is located in a very quiet and safe neighbourhood, and is also close to the subway and many bus lines. It is also a short walk to the beautiful Prospect Park. The gym is located in the building and is easily accessible. |
Deeper into Personalization
Personalized digital experiences have been taken to a new level with the latest advances in AI technology. Along with personalized recommendations or search results, the content itself can now be individualized to cater to your particular needs and preferences.From ads that look for the nearest dog parks or gyms, we may imagine a future where video advertisements are generated! The video for Connor shows maybe even him and his dog walking through central park, whereas the video for Bob shows him hitting a hang clean in a local gym! We may even imagine custom metaphors when explaining complex concepts for people. For example, “life is like a game of fetch” for Connor the dog owner, or “life is like pushing and resting in the gym” for Bob the weightlifter.
Other Use Case Examples of Feedback Loops
- TV Shows: Streaming services could show different scenes or alternate endings of a movie or TV show based on the user’s preferences.
- Code: AI can generate cod snippets based on the user’s requirements and create a feedback loop with tests to improve the code over time.
- AutoCAD drawings: AI could create CAD drawings of buildings based on 3D models and store information about the materials available in the environment, making it easier for architects and engineers to design and plan construction projects.
- Tesla Configuration: The car’s settings could be personalized based on the user’s driving style and preferences, such as choosing a slow and relaxed drive home versus a fast and sporty one.
When Do Generative Feedback Loops Run?
Having illustrated the general concept of Generative Feedback Loops, where we use data from the database to supplement the factual knowledge of generative models and then write the generated outputs back to the database for future use, let’s discuss when to kick this off.
Data Ingestion
Data Ingestion is a shorthand reference to importing data into the database. For example, every time a new User is added to the AirBnB database, we may want to kick off a Generative Feedback Loop of retrieving information about a listing and this new user and save the new ads targeted to this user. On the other hand, we may want to kick this off when a new Listing is added, writing ads for each of our users!
As another example, imagine that we have a collection of podcast episodes. Every time a new episode is added to the database, we want to kick off generation of a summary and a comparison of the podcast compared to the existing podcasts in the database. To further reinforce the idea of Generative Feedback Loops, we may retrieve a previously generated podcast summary that has been saved and indexed with semantic vector search, and use this to prompt the generative model to analyze the uniqueness of the latest podcast episode!
In addition to generating novel things based on our data, we may also task LLMs with adding symbolic properties.Gilardi, Alizadeh, and Kubli very recently published “ChatGPT Outperforms Crowd-Workers for Text-Annotation Tasks”. In this paper, Gilardi et al. compare the ability of humans with ChatGPT in categorizing 2,382 tweets into categories representative of 5 classification tasks such as whether a tweet is about content moderation, which of six predefined topics the tweet is about, and so on. This study illustrates how cheap and effective this technique is for adding labels to our data. When we generate these symbolic structures like “room_type”, we can then use it in filtered vector search! Filtered Vector Search has recently been made 1000(!) times faster in Weaviate thanks to roaring bitmap indexing!
Another powerful idea is the emergence of Knowledge Graphs 2.0
. We can use LLMs to suggest relations between pieces of content and then connect these nodes together with the relational edges. Check out this example of GraphGPT!
From ChatGPT to AutoGPT and the role of Weaviate
Another title for this section would be “Complex Tasks that run overnight”. The latest imagination inspiring feat of AI has been the rise of AutoGPT! AutoGPT is a loop of prompts in which the LLM breaks a complex task into subtasks, executes them, reflects on the plan, and so on until the complex task has been completed.
Generative Feedback Loops are one of the key pieces to this puzzle. Firstly, the agent may need to save intermediate results to reference later. For example, if the agent is tasked with: “Please make an example for John on how to add ref2vec to his Weaviate app”. The agent can save a summary of John’s app after researching his code base and maybe message history on the Weaviate slack. This summary can then be used in the retrieval-augmented prompting when figuring out where to add ref2vec.
Another application of Generative Feedback Loops is for humans to debug the chain of reasoning that happened when a model like this runs overnight. Further, we may imagine multi-agent systems with roles, such as marketers, artists, product designers, and engineers. By saving intermediate results, other agents can access it and keep the party going.
Conclusion
In summary, we have presented the concept of Generative Feedback Loops. This describes not only using results from the database to answer a query, but saving the resulting generation back in the database for future reference. Hopefully this example with AirBnB listings and advertisements helped inspire your thinking about how you can use this technology and where personalization seems to be headed. We ended the article by presenting a couple of scenarios of when this runs such as Data Ingestion, and the trend towards more autonomous AI assistants. Thank you so much for reading!
Ready to start building?
Check out the Quickstart tutorial, or build amazing apps with a free trial of Weaviate Cloud (WCD).
Don't want to miss another blog post?
Sign up for our bi-weekly newsletter to stay updated!
By submitting, I agree to the Terms of Service and Privacy Policy.