Prerequisites & requirements
In this section you are going to populate your Weaviate instance with a movie dataset, using the Cohere API to embed the text data.
Weaviate instance
Make sure to have your Weaviate instance set up. You should have created an instance and be able to connect to it.
AI model access
This course is set up to use Cohere's AI models. As such, you will need an Cohere API key to follow along.
If you don't have one, go to the Cohere website and sign up for an account and create an API key. At the time of writing, Cohere's free "trial" type key was sufficient for this course.
Recall from the previous lesson that you are to provide the Cohere API key to Weaviate every time you connect to your instance.
- Weaviate Cloud (WCD)
- Local Docker
import weaviate
import os
headers = {
"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")
} # Replace with your Cohere API key
client = weaviate.connect_to_weaviate_cloud(
cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL
auth_credentials=os.getenv("WEAVIATE_API_KEY"), # Replace with your WCD key
headers=headers,
)
import weaviate
import os
headers = {
"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")
} # Replace with your Cohere API key
client = weaviate.connect_to_local(headers=headers)
You can use any of Weaviate's AI model integrations for this course. But you will have to make small changes where appropriate. Where you see code like Configure.Vectors.text2vec_cohere() or Configure.Generative.cohere(), replace them with the equivalent code for your chosen provider. You may also need to provide the appropriate API key to Weaviate, instead of the Cohere API key.
Source data
We are going to use a movie dataset sourced from TMDB. The dataset can be found in this GitHub repository, and it contains bibliographic information on ~700 movies released between 1990 and 2024.
See sample data
| backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 |
| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 |
| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 |
| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 |
| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 |
Next, you will create a corresponding object collection and import the data.