use_cases/archive/movie_reviews/notebooks/02-personalised-movie-reviews.ipynb (1,481 lines of code) (raw):
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Summarise Personalised Reviews"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"from IPython.core.interactiveshell import InteractiveShell\n",
"InteractiveShell.ast_node_interactivity = \"all\""
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Set up Azure OpenAI"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"import openai\n",
"from dotenv import load_dotenv\n",
"\n",
"# Set up Azure OpenAI\n",
"load_dotenv()\n",
"openai.api_type = \"azure\"\n",
"openai.api_base = \"https://tutorial-openai-01-2023.openai.azure.com/\"\n",
"openai.api_version = \"2022-12-01\"\n",
"openai.api_key = os.getenv(\"OPENAI_API_KEY\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Deploy a Language Model\n",
"ref: \n",
"- https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models\n",
"- https://learn.microsoft.com/en-us/azure/cognitive-services/openai/concepts/models#text-search-embedding"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found a succeeded deployment of \"text-search-davinci-query-001\" that supports text search with id: deployment-33421982e4f64be9a3a9b2bb9af45def.\n"
]
}
],
"source": [
"# id of desired_model\n",
"query_model = \"text-search-davinci-query-001\" # suitable for Search, context relevance, information retrieval\n",
"\n",
"# list models deployed\n",
"deployment_id = None\n",
"result = openai.Deployment.list()\n",
"\n",
"for deployment in result.data:\n",
" if deployment[\"status\"] != \"succeeded\":\n",
" continue\n",
" \n",
" model = openai.Model.retrieve(deployment[\"model\"])\n",
" if model[\"id\"] == query_model:\n",
" deployment_id = deployment[\"id\"]\n",
" \n",
"# if not model deployed, deploy one\n",
"if not deployment_id:\n",
" print('No deployment with status: succeeded found.')\n",
"\n",
" # Now let's create the deployment\n",
" print(f'Creating a new deployment with model: {query_model}')\n",
" result = openai.Deployment.create(model=query_model, scale_settings={\"scale_type\":\"standard\"})\n",
" deployment_id = result[\"id\"]\n",
" print(f'Successfully created {query_model} with deployment_id {deployment_id}')\n",
"else:\n",
" print(f'Found a succeeded deployment of \"{query_model}\" that supports text search with id: {deployment_id}.')"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Embeddings for Reviews\n",
"\n",
"See [01-get-embeddings.ipynb](./01-get-embeddings.ipynb) on how to get embeddings.\n",
"\n",
"In this example, we will load embeddings from a file. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Data"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"fname = '../data/rottentomatoes-20movies-embeddings.csv'\n",
"df_orig = pd.read_csv(fname, delimiter='\\t', index_col=False) # This takes approx 46 sec."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Movie</th>\n",
" <th>Publish</th>\n",
" <th>Review</th>\n",
" <th>Date</th>\n",
" <th>Score</th>\n",
" <th>Word_Count</th>\n",
" <th>embedding</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>SOLO: A STAR WARS STORY</td>\n",
" <td>Stuff.co.nz</td>\n",
" <td>The formula is strong with this one.</td>\n",
" <td>24/05/2018</td>\n",
" <td>70.0</td>\n",
" <td>7</td>\n",
" <td>[-0.013439337722957134, 0.006897337269037962, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>BLACK PANTHER</td>\n",
" <td>Gone With The Twins</td>\n",
" <td>Just about the same as every other Marvel title.</td>\n",
" <td>05/12/2020</td>\n",
" <td>50.0</td>\n",
" <td>9</td>\n",
" <td>[-0.006859001703560352, 0.0037438718136399984,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>DUNKIRK</td>\n",
" <td>Screen Zealots</td>\n",
" <td>This is one heck of a stunning war picture.</td>\n",
" <td>20/12/2018</td>\n",
" <td>80.0</td>\n",
" <td>9</td>\n",
" <td>[-0.003785009030252695, 0.004640915431082249, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>KNIVES OUT</td>\n",
" <td>Student Edge</td>\n",
" <td>Don't fear: No spoilers here. All you need to ...</td>\n",
" <td>26/11/2019</td>\n",
" <td>80.0</td>\n",
" <td>17</td>\n",
" <td>[0.0009526872891001403, 0.016423344612121582, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>KNIVES OUT</td>\n",
" <td>Deep Focus Review</td>\n",
" <td>Sharp and funny, Knives Out exceeds expectatio...</td>\n",
" <td>23/02/2022</td>\n",
" <td>100.0</td>\n",
" <td>29</td>\n",
" <td>[-0.005653353873640299, 0.010235012508928776, ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Movie Publish \\\n",
"0 SOLO: A STAR WARS STORY Stuff.co.nz \n",
"1 BLACK PANTHER Gone With The Twins \n",
"2 DUNKIRK Screen Zealots \n",
"3 KNIVES OUT Student Edge \n",
"4 KNIVES OUT Deep Focus Review \n",
"\n",
" Review Date Score \\\n",
"0 The formula is strong with this one. 24/05/2018 70.0 \n",
"1 Just about the same as every other Marvel title. 05/12/2020 50.0 \n",
"2 This is one heck of a stunning war picture. 20/12/2018 80.0 \n",
"3 Don't fear: No spoilers here. All you need to ... 26/11/2019 80.0 \n",
"4 Sharp and funny, Knives Out exceeds expectatio... 23/02/2022 100.0 \n",
"\n",
" Word_Count embedding \n",
"0 7 [-0.013439337722957134, 0.006897337269037962, ... \n",
"1 9 [-0.006859001703560352, 0.0037438718136399984,... \n",
"2 9 [-0.003785009030252695, 0.004640915431082249, ... \n",
"3 17 [0.0009526872891001403, 0.016423344612121582, ... \n",
"4 29 [-0.005653353873640299, 0.010235012508928776, ... "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"(6640, 7)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"\n",
"DEVELOPMENT = False # Set to True for development using a subset of data\n",
"\n",
"if DEVELOPMENT:\n",
" # Sub-sample for development\n",
" df = df_orig.sample(n=50, replace=False, random_state=9).copy()\n",
"else:\n",
" df = df_orig.copy()\n",
"\n",
"# drop rows with NaN\n",
"df.dropna(inplace=True)\n",
"\n",
"# convert string to array\n",
"df[\"embedding\"] = df['embedding'].apply(eval).apply(np.array) # This takes approx 3 min 13 sec\n",
"df.head()\n",
"df.shape"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"JOKER 380\n",
"CAPTAIN MARVEL 373\n",
"ONCE UPON A TIME... IN HOLLYWOOD 372\n",
"AVENGERS: ENDGAME 370\n",
"US 358\n",
"STAR WARS: THE RISE OF SKYWALKER 351\n",
"A STAR IS BORN 340\n",
"BLACK PANTHER 339\n",
"AVENGERS: INFINITY WAR 329\n",
"SOLO: A STAR WARS STORY 321\n",
"STAR WARS: THE LAST JEDI 320\n",
"SPIDER-MAN: FAR FROM HOME 319\n",
"DUNKIRK 316\n",
"KNIVES OUT 311\n",
"TOY STORY 4 309\n",
"READY PLAYER ONE 308\n",
"WONDER WOMAN 307\n",
"1917 306\n",
"FIRST MAN 306\n",
"ROGUE ONE: A STAR WARS STORY 305\n",
"Name: Movie, dtype: int64"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Movie'].value_counts()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Count Tokens"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/anaconda/envs/azureml_py38/lib/python3.8/site-packages/pandas/core/indexing.py:670: SettingWithCopyWarning: \n",
"A value is trying to be set on a copy of a slice from a DataFrame\n",
"\n",
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
" iloc._setitem_with_indexer(indexer, value)\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Movie</th>\n",
" <th>Publish</th>\n",
" <th>Review</th>\n",
" <th>Date</th>\n",
" <th>Score</th>\n",
" <th>Word_Count</th>\n",
" <th>embedding</th>\n",
" <th>token_count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>SOLO: A STAR WARS STORY</td>\n",
" <td>Stuff.co.nz</td>\n",
" <td>The formula is strong with this one.</td>\n",
" <td>24/05/2018</td>\n",
" <td>70.0</td>\n",
" <td>7</td>\n",
" <td>[-0.013439337722957134, 0.006897337269037962, ...</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>BLACK PANTHER</td>\n",
" <td>Gone With The Twins</td>\n",
" <td>Just about the same as every other Marvel title.</td>\n",
" <td>05/12/2020</td>\n",
" <td>50.0</td>\n",
" <td>9</td>\n",
" <td>[-0.006859001703560352, 0.0037438718136399984,...</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>DUNKIRK</td>\n",
" <td>Screen Zealots</td>\n",
" <td>This is one heck of a stunning war picture.</td>\n",
" <td>20/12/2018</td>\n",
" <td>80.0</td>\n",
" <td>9</td>\n",
" <td>[-0.003785009030252695, 0.004640915431082249, ...</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>KNIVES OUT</td>\n",
" <td>Student Edge</td>\n",
" <td>Don't fear: No spoilers here. All you need to ...</td>\n",
" <td>26/11/2019</td>\n",
" <td>80.0</td>\n",
" <td>17</td>\n",
" <td>[0.0009526872891001403, 0.016423344612121582, ...</td>\n",
" <td>23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>KNIVES OUT</td>\n",
" <td>Deep Focus Review</td>\n",
" <td>Sharp and funny, Knives Out exceeds expectatio...</td>\n",
" <td>23/02/2022</td>\n",
" <td>100.0</td>\n",
" <td>29</td>\n",
" <td>[-0.005653353873640299, 0.010235012508928776, ...</td>\n",
" <td>37</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Movie Publish \\\n",
"0 SOLO: A STAR WARS STORY Stuff.co.nz \n",
"1 BLACK PANTHER Gone With The Twins \n",
"2 DUNKIRK Screen Zealots \n",
"3 KNIVES OUT Student Edge \n",
"4 KNIVES OUT Deep Focus Review \n",
"\n",
" Review Date Score \\\n",
"0 The formula is strong with this one. 24/05/2018 70.0 \n",
"1 Just about the same as every other Marvel title. 05/12/2020 50.0 \n",
"2 This is one heck of a stunning war picture. 20/12/2018 80.0 \n",
"3 Don't fear: No spoilers here. All you need to ... 26/11/2019 80.0 \n",
"4 Sharp and funny, Knives Out exceeds expectatio... 23/02/2022 100.0 \n",
"\n",
" Word_Count embedding token_count \n",
"0 7 [-0.013439337722957134, 0.006897337269037962, ... 8 \n",
"1 9 [-0.006859001703560352, 0.0037438718136399984,... 10 \n",
"2 9 [-0.003785009030252695, 0.004640915431082249, ... 10 \n",
"3 17 [0.0009526872891001403, 0.016423344612121582, ... 23 \n",
"4 29 [-0.005653353873640299, 0.010235012508928776, ... 37 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import tiktoken\n",
"encoding = tiktoken.get_encoding('gpt2')\n",
"\n",
"df['token_count'] = ''\n",
"\n",
"for idx, movie, review in zip(df.index.values, df['Movie'].loc[df.index.values], df['Review'].loc[df.index.values]):\n",
" df['token_count'].loc[idx] = len(encoding.encode(review))\n",
"\n",
"df.head()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Find documents with similar embeddings to the embeddings of the question"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"def get_embedding(text, deployment_id=deployment_id):\n",
" \"\"\" \n",
" Get embeddings for an input text. \n",
" \"\"\"\n",
" result = openai.Embedding.create(\n",
" deployment_id=deployment_id,\n",
" input=text\n",
" )\n",
" result = np.array(result[\"data\"][0][\"embedding\"])\n",
" return result\n",
"\n",
"def vector_similarity(x, y):\n",
" \"\"\"\n",
" Returns the similarity between two vectors. \n",
" Because OpenAI Embeddings are normalized to length 1, the cosine similarity is the same as the dot product.\n",
" \"\"\"\n",
" similarity = np.dot(x, y)\n",
" return similarity \n",
"\n",
"def order_document_sections_by_query_similarity(query, contexts):\n",
" \"\"\"\n",
" Find the query embedding for the supplied query, and compare it against all of the pre-calculated document embeddings\n",
" to find the most relevant sections. \n",
" Return the list of document sections, sorted by relevance in descending order.\n",
" \"\"\"\n",
" query_embedding = get_embedding(query)\n",
"\n",
" document_similarities = sorted([\n",
" (vector_similarity(query_embedding, doc_embedding), doc_index) for doc_index, doc_embedding in contexts.items()\n",
" ], reverse=True)\n",
" \n",
" return document_similarities"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Construct prompt\n",
"Add relevant document sections to the query prompt."
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"MAX_SECTION_LEN = 500\n",
"SEPARATOR = \"\\n* \"\n",
"ENCODING = \"gpt2\" # encoding for text-davinci-003\n",
"\n",
"encoding = tiktoken.get_encoding(ENCODING)\n",
"separator_len = len(encoding.encode(SEPARATOR))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"def construct_prompt(query: str, context_embeddings: pd.DataFrame, df: pd.DataFrame) -> str:\n",
" \"\"\"\n",
" Append sections of document that are most similar to the query.\n",
" \"\"\"\n",
" most_relevant_document_sections = order_document_sections_by_query_similarity(query, context_embeddings)\n",
" \n",
" chosen_sections = []\n",
" chosen_sections_len = 0\n",
" chosen_sections_indexes = []\n",
" \n",
" for _, section_index in most_relevant_document_sections:\n",
" # Add contexts until we run out of space. \n",
" document_section = df.loc[section_index]\n",
" \n",
" chosen_sections_len += document_section['token_count'] + separator_len\n",
" if chosen_sections_len > MAX_SECTION_LEN:\n",
" break\n",
" \n",
" chosen_sections.append(SEPARATOR + \n",
" 'movie title: ' + document_section['Movie'] + ' ' +\n",
" document_section['Review'].replace(\"\\n\", \" \"))\n",
" \n",
" chosen_sections_indexes.append(str(section_index))\n",
" \n",
" # Diagnostic information\n",
" print(f\"Selected {len(chosen_sections)} document sections, with indexes:\") \n",
" for i in chosen_sections_indexes:\n",
" print(i + \" \" + df['Movie'].loc[int(i)] + \n",
" )\n",
" \n",
" header = \"\"\"Answer the question truthfully using context, if unsure, say \"I don't know.\"\\n\\nContext:\\n\"\"\"\n",
" prompt = header + \"\".join(chosen_sections) + \"\\n\\n Q: \" + query + \"\\n A:\"\n",
" \n",
" return prompt"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example prompts"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 11 document sections, with indexes:\n",
"3025 CAPTAIN MARVEL\n",
"2821 CAPTAIN MARVEL\n",
"2801 CAPTAIN MARVEL\n",
"2724 CAPTAIN MARVEL\n",
"2817 CAPTAIN MARVEL\n",
"2955 CAPTAIN MARVEL\n",
"2991 CAPTAIN MARVEL\n",
"3023 CAPTAIN MARVEL\n",
"2960 CAPTAIN MARVEL\n",
"2868 CAPTAIN MARVEL\n",
"2984 CAPTAIN MARVEL\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: CAPTAIN MARVEL A plucky and pleasing, if predictable, excursion that burns brightly, if briefly.\n",
"* movie title: CAPTAIN MARVEL It's perfectly possible to point out the narrative hiccups of the movie and, at the same time, to stress how important its existence and success are. [Full review in Portuguese]\n",
"* movie title: CAPTAIN MARVEL Captain Marvel is an unremarkable, passable time killer...[Brie] Larson's performance is wooden...while the film's big action scenes are so lacking in imagination the screen often looks as though it's being continually doused in technicolour vomit.\n",
"* movie title: CAPTAIN MARVEL Unfortunately, the lackluster writing and serviceable production diminish the basic thrills we expect from the MCU, making Captain Marvel a letdown, if only because of its vast potential. It remains diverting, and that's all.\n",
"* movie title: CAPTAIN MARVEL The strong lead and the fun, nostalgic-but-not-too-nostalgic vibe floats the movie through some iffy direction and an underutilized supporting cast. This is a good launching point for something that will hopefully be great when it's all said and done.\n",
"* movie title: CAPTAIN MARVEL You would think that after 21 feature films, Marvel would have perfected the superhero origin story formula, but to Brie Larson's detriment, this time they forgot to add \"character\" and \"personality\" into the mix. [Full Review in Spanish]\n",
"* movie title: CAPTAIN MARVEL An eminently fun and thoroughly enjoyable picture that ... establishes Captain Marvel, in the supremely qualified hands of Larson, as an Avenger nonpareil.\n",
"* movie title: CAPTAIN MARVEL As shaky and unfocused as Captain Marvel often seems, it manages to reach its destination with confidence. In the end, Larson sticks the landing, albeit with something more muted than absolute triumph.\n",
"* movie title: CAPTAIN MARVEL Soars as an origin story with heart, cheeky humor, wit and warmth, zingy dialogue, punchy action, colorful characters and a hero--heroine--who breaks the glass ceiling on two worlds.\n",
"* movie title: CAPTAIN MARVEL Some aesthetic and narrative reluctance makes the film seem more like a rushed production to present the character before Avengers: Endgame. [Full Review in Spanish]\n",
"* movie title: CAPTAIN MARVEL Despite its flaws, Captain Marvel cements the desire to see Carol Danvers in action again. [Full Review in Spanish]\n",
"\n",
" Q: Summarise reviews of Captain Marvel.\n",
" A:\n"
]
}
],
"source": [
"query = 'Summarise reviews of Captain Marvel.'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Retrieve Information"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"def retrieve_information(prompt):\n",
" try:\n",
" # Request API\n",
" response = openai.Completion.create(\n",
" deployment_id= \"text-davinci-003\", # Assumed already deployed\n",
" prompt=prompt,\n",
" temperature=1,\n",
" max_tokens=100,\n",
" top_p=1.0,\n",
" frequency_penalty=0.0,\n",
" presence_penalty=1\n",
" )\n",
"\n",
" # response\n",
" result = response['choices'][0]['text']; print(result)\n",
" except Exception as err:\n",
" print(idx)\n",
" print(f\"Unexpected {err=}, {type(err)=}\")\n",
"\n",
" return "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Queries"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 11 document sections, with indexes:\n",
"3025 CAPTAIN MARVEL\n",
"2821 CAPTAIN MARVEL\n",
"2801 CAPTAIN MARVEL\n",
"2724 CAPTAIN MARVEL\n",
"2817 CAPTAIN MARVEL\n",
"2955 CAPTAIN MARVEL\n",
"2991 CAPTAIN MARVEL\n",
"3023 CAPTAIN MARVEL\n",
"2960 CAPTAIN MARVEL\n",
"2868 CAPTAIN MARVEL\n",
"2984 CAPTAIN MARVEL\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: CAPTAIN MARVEL A plucky and pleasing, if predictable, excursion that burns brightly, if briefly.\n",
"* movie title: CAPTAIN MARVEL It's perfectly possible to point out the narrative hiccups of the movie and, at the same time, to stress how important its existence and success are. [Full review in Portuguese]\n",
"* movie title: CAPTAIN MARVEL Captain Marvel is an unremarkable, passable time killer...[Brie] Larson's performance is wooden...while the film's big action scenes are so lacking in imagination the screen often looks as though it's being continually doused in technicolour vomit.\n",
"* movie title: CAPTAIN MARVEL Unfortunately, the lackluster writing and serviceable production diminish the basic thrills we expect from the MCU, making Captain Marvel a letdown, if only because of its vast potential. It remains diverting, and that's all.\n",
"* movie title: CAPTAIN MARVEL The strong lead and the fun, nostalgic-but-not-too-nostalgic vibe floats the movie through some iffy direction and an underutilized supporting cast. This is a good launching point for something that will hopefully be great when it's all said and done.\n",
"* movie title: CAPTAIN MARVEL You would think that after 21 feature films, Marvel would have perfected the superhero origin story formula, but to Brie Larson's detriment, this time they forgot to add \"character\" and \"personality\" into the mix. [Full Review in Spanish]\n",
"* movie title: CAPTAIN MARVEL An eminently fun and thoroughly enjoyable picture that ... establishes Captain Marvel, in the supremely qualified hands of Larson, as an Avenger nonpareil.\n",
"* movie title: CAPTAIN MARVEL As shaky and unfocused as Captain Marvel often seems, it manages to reach its destination with confidence. In the end, Larson sticks the landing, albeit with something more muted than absolute triumph.\n",
"* movie title: CAPTAIN MARVEL Soars as an origin story with heart, cheeky humor, wit and warmth, zingy dialogue, punchy action, colorful characters and a hero--heroine--who breaks the glass ceiling on two worlds.\n",
"* movie title: CAPTAIN MARVEL Some aesthetic and narrative reluctance makes the film seem more like a rushed production to present the character before Avengers: Endgame. [Full Review in Spanish]\n",
"* movie title: CAPTAIN MARVEL Despite its flaws, Captain Marvel cements the desire to see Carol Danvers in action again. [Full Review in Spanish]\n",
"\n",
" Q: Summarise reviews of Captain Marvel.\n",
" A:\n",
" Reviews of Captain Marvel generally have a positive outlook and praise the movie for its production, Brie Larson's performance, action scenes, wit and humor, and heart. However, there are some criticisms about its narrative and sloppy direction. Nevertheless, the movie is seen as an important addition to the Marvel Cinematic Universe.\n"
]
}
],
"source": [
"query = 'Summarise reviews of Captain Marvel.'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 13 document sections, with indexes:\n",
"4755 READY PLAYER ONE\n",
"4908 READY PLAYER ONE\n",
"4872 READY PLAYER ONE\n",
"4980 READY PLAYER ONE\n",
"4843 READY PLAYER ONE\n",
"4819 READY PLAYER ONE\n",
"4949 READY PLAYER ONE\n",
"4999 READY PLAYER ONE\n",
"4782 READY PLAYER ONE\n",
"4795 READY PLAYER ONE\n",
"4801 READY PLAYER ONE\n",
"4802 READY PLAYER ONE\n",
"4966 READY PLAYER ONE\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: READY PLAYER ONE It's a film to watch and enjoy once, but probably not to return to again and again, like Spielberg's best. It's fixated on easter eggs and it's like an easter egg itself: shiny and pretty, inducing a brief sugar high, but ultimately hollow.\n",
"* movie title: READY PLAYER ONE ...this failed the watch test miserably as I didn't know if I would actually survive almost 2 1/2 hours of watching all this nonsensical gobbledygook. But it will probably gross a billion dollars.\n",
"* movie title: READY PLAYER ONE Escapist fun made for mandatory repeat viewings to try to catch all the characters and icons hidden throughout. With READY PLAYER ONE, Spielberg has crafted an electronic Wonderland that is a love song to fandom and pop culture itself.\n",
"* movie title: READY PLAYER ONE Like watching high-speed drone footage, flying over a flea market, filled with outdated game consoles, posters, forgotten DVDs and CDs. It should be fun in a geeky way, but there's little humour and character engagement\n",
"* movie title: READY PLAYER ONE Spielberg's message about not losing touch with reality and corporate takeovers may be too obvious, but the glorious visuals will captivate you to the end.\n",
"* movie title: READY PLAYER ONE A stunning piece of popcorn cinema... one big budget blockbuster worth immersing yourself in ASAP.\n",
"* movie title: READY PLAYER ONE The action scenes are thrilling and there is just enough poignant self-critique and meta-commentary to make it more than just empty nostalgia.\n",
"* movie title: READY PLAYER ONE It is without a question one of the year's most energetic, visually rewarding, and ultimately exhausting motion pictures.\n",
"* movie title: READY PLAYER ONE Ready Player One isn't a transcendent piece of cinema. That's OK. It IS a well-made piece of popcorn entertainment that also manages to be an odd ouroboros of layered Spielbergian nostalgia-ception.\n",
"* movie title: READY PLAYER ONE Despite its many issues, Ready Player One is still an enjoyable ride that ticks all the boxes of a big summer blockbuster.\n",
"* movie title: READY PLAYER ONE Although there are some fun sequences and genuine wonder to behold, the film is a pandering, noisy, visual mess with a thin plot and even thinner characters.\n",
"* movie title: READY PLAYER ONE It's Spielberg's sloppiest film since Hook, but still has enough moments that transcend simple nostalgia to make it worthwhile even if it is an uneven thrill ride.\n",
"* movie title: READY PLAYER ONE A fun popcorn flick and a great free-for-all of pop culture that only someone with Steven Spielberg's muscle could pull together.\n",
"\n",
" Q: Should I watch Ready Player One?\n",
" A:\n",
" Whether or not you should watch Ready Player One depends on what type of movie-watching experience you are looking for. It offers an enjoyable ride filled with exciting action and visual effects, but its thin plot and characters may not appeal to some viewers.\n"
]
}
],
"source": [
"query = 'Should I watch Ready Player One?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 12 document sections, with indexes:\n",
"2093 SPIDER-MAN: FAR FROM HOME\n",
"2228 SPIDER-MAN: FAR FROM HOME\n",
"2148 SPIDER-MAN: FAR FROM HOME\n",
"2238 SPIDER-MAN: FAR FROM HOME\n",
"2116 SPIDER-MAN: FAR FROM HOME\n",
"2348 SPIDER-MAN: FAR FROM HOME\n",
"2253 SPIDER-MAN: FAR FROM HOME\n",
"2169 SPIDER-MAN: FAR FROM HOME\n",
"2044 SPIDER-MAN: FAR FROM HOME\n",
"2050 SPIDER-MAN: FAR FROM HOME\n",
"2207 SPIDER-MAN: FAR FROM HOME\n",
"2211 SPIDER-MAN: FAR FROM HOME\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Goodness, this is cleverly constructed stuff - full of fun, humour, youth and big visual effects, but underpinned by a screenplay that does a really well thought-through job of linking the MCU's future to its hugely popular past.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME It has it all: great battles and special effects, a touching human tale, dramatic twists, wit and humor, stunning scenery, super-cool gadgets, a clear place in the Marvel mythology.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Special credit must be given to the effects team, which brings to life Mysterio's trippy, perception-altering powers in a way once thought unimaginable for a live-action film.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Spider-Man: Far From Home wants to dazzle you with action and effects, but the first post-Endgame Marvel movie is at its best when it shows its heart.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Watts does a wonderful job of visualizing the chaos and nightmarish paranoia that Mysterio's antics cause Spider-Man.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME It's not quite the home-run of Homecoming, but Far From Home isn't far from matching it, with heaps of humour, energetic action, and the answers Endgame left you craving.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME still isn't quite up to par with the rest of the MCU for scope and drama and still can't touch either the original Sam Raimi films or Into The Spider-Verse at visualizing Spider-Man action, it DOES know where its strengths are: Its characters.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Spider-Man: Far From Home perfectly addresses Avengers: Endgame, and shows us why Mysterio is a villain to be feared. Filled with action, humor, and deceit - it is a MUST SEE!\n",
"* movie title: SPIDER-MAN: FAR FROM HOME This film has the best Spider-Man scene that has ever been filmed. It's not just visually stunning, but emotionally charged like no other. [Full review in Spanish]\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Breezy and light-hearted with some epic action pieces, it's a visual kaleidoscope that will send 'Peter Tingles' down your spine.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME A doozy of a story packed with visual surrealism and clever plot surprises.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME If you still get a kick out of seeing Spider-Man do his thing, this is a top-level effort on a par with Sam Raimi's much-loved Spider-Man 2.\n",
"\n",
" Q: Should I watch Spiderman Far from Home? I am big fan of visual effects.\n",
" A:\n",
" Yes, Spiderman Far from Home is full of fun, humour, youth and big visual effects. Special credit must be given to the effects team, which brings to life Mysterio's trippy, perception-altering powers in a way once thought unimaginable for a live-action film. It also has stunning scenery and super cool gadgets. The best Spider-Man scene that has ever been filmed is featured in the movie, and it's emotionally charged. So yes, if you're a fan of\n"
]
}
],
"source": [
"query = 'Should I watch Spiderman Far from Home? I am big fan of visual effects.'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 11 document sections, with indexes:\n",
"2093 SPIDER-MAN: FAR FROM HOME\n",
"2309 SPIDER-MAN: FAR FROM HOME\n",
"2253 SPIDER-MAN: FAR FROM HOME\n",
"2090 SPIDER-MAN: FAR FROM HOME\n",
"2044 SPIDER-MAN: FAR FROM HOME\n",
"2228 SPIDER-MAN: FAR FROM HOME\n",
"2050 SPIDER-MAN: FAR FROM HOME\n",
"2110 SPIDER-MAN: FAR FROM HOME\n",
"2169 SPIDER-MAN: FAR FROM HOME\n",
"2310 SPIDER-MAN: FAR FROM HOME\n",
"2116 SPIDER-MAN: FAR FROM HOME\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Goodness, this is cleverly constructed stuff - full of fun, humour, youth and big visual effects, but underpinned by a screenplay that does a really well thought-through job of linking the MCU's future to its hugely popular past.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME The story is pyrotechnical. The soundtrack is multi-decibel. There is no room for wit, thought, emotion or seriously challenging novelty. But, simultaneously, I'd rather watch Holland do this rubbish than most movie actors.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME still isn't quite up to par with the rest of the MCU for scope and drama and still can't touch either the original Sam Raimi films or Into The Spider-Verse at visualizing Spider-Man action, it DOES know where its strengths are: Its characters.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME One of the problems with Far from Home is its visual mundanity, and it betrays this genre of films' (especially the much vaunted MCU's) slavish obsession with technology.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME This film has the best Spider-Man scene that has ever been filmed. It's not just visually stunning, but emotionally charged like no other. [Full review in Spanish]\n",
"* movie title: SPIDER-MAN: FAR FROM HOME It has it all: great battles and special effects, a touching human tale, dramatic twists, wit and humor, stunning scenery, super-cool gadgets, a clear place in the Marvel mythology.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Breezy and light-hearted with some epic action pieces, it's a visual kaleidoscope that will send 'Peter Tingles' down your spine.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME This is a zippy, funny movie - a scene where Peter shares a jail cell with three Dutch football fans is a treat - with excellent special effects. It races by in two hours without any boring detours.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Spider-Man: Far From Home perfectly addresses Avengers: Endgame, and shows us why Mysterio is a villain to be feared. Filled with action, humor, and deceit - it is a MUST SEE!\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Tom Holland continues to hit the right note as the teenager turned superhero, the effects are great, and the story just sufficiently interesting (if predictable) to keep you entertained for two hours\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Watts does a wonderful job of visualizing the chaos and nightmarish paranoia that Mysterio's antics cause Spider-Man.\n",
"\n",
" Q: Why shouldn't I watch spiderman? I am big fan of visual effects.\n",
" A:\n",
" I don't think you should not watch Spider-Man: Far From Home as it has great visual effects, battles and special effects, stunning scenery, and super cool gadgets. The film also has an emotionally charged Spider-Man scene, excellent humor and wit, and unique visuals.\n"
]
}
],
"source": [
"query = 'Why shouldn\\'t I watch spiderman? I am big fan of visual effects.'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 15 document sections, with indexes:\n",
"932 1917\n",
"778 1917\n",
"821 1917\n",
"879 1917\n",
"831 1917\n",
"851 1917\n",
"773 1917\n",
"694 1917\n",
"685 1917\n",
"686 1917\n",
"665 1917\n",
"861 1917\n",
"702 1917\n",
"909 1917\n",
"674 1917\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: 1917 Tense, powerful and breathtaking, 1917 is a visceral movie you won't forget in a hurry - and it's the first must-see movie of next year.\n",
"* movie title: 1917 From the sole perspective of the filmmaking craft, \"1917\" is worth a watch.\n",
"* movie title: 1917 This is a movie one does not watch so much as witness. It simply must be seen.\n",
"* movie title: 1917 Sitting through it is like watching someone else playing a video game for two solid hours, and not an especially compelling one at that.\n",
"* movie title: 1917 Full of thrills and spills yet surprisingly intimate and personal, 1917 is a breathtaking, profound tour de force, easily sealing its position as one of the greatest war films of all time.\n",
"* movie title: 1917 However well-intentioned its spectacle, 1917 feels fundamentally wrong-disrespectful to a historical reality in its very attempts to evoke it.\n",
"* movie title: 1917 Despite having a thin story, the reason why you should go see 1917 is because of the amazing cinematography.\n",
"* movie title: 1917 A cinematic experience on war, tension, and the boundaries of drama within a realistic setting of desperation. [Full review in Spanish].\n",
"* movie title: 1917 It's safe to say that 1917 is a phenomenal technical display of a captivating war-time drama. It's visually enthralling, and the film is sure to keep you engaged all the way through.\n",
"* movie title: 1917 A brutal, tense and unforgiving film that achieves the highs in technicality by balancing it with a triumphant look at the bravery on the war-front.\n",
"* movie title: 1917 The film's formal indulgences distract from its dramatic potential.\n",
"* movie title: 1917 A film, or any work, can be extraordinarily well-wrought and still feel a bit pointless. An abundance of fiddly labor, little flicks of the wrist, all meant to leave us impressed by the challenge of the very doing of the work.\n",
"* movie title: 1917 a gripping, harrowing portrait of war that is made all the more compelling by its tight narrative and temporal focus\n",
"* movie title: 1917 A gorgeous display of immersive filmmaking that artistically is mostly empty calories.\n",
"* movie title: 1917 The film's final hour loses steam and is beset by more than a few narrative lapses it ultimately can't overcome. Still, this is a worthwhile epic best seen on the big screen.\n",
"\n",
" Q: Why shouldn't I watch 1917?\n",
" A:\n",
" I don't know.\n"
]
}
],
"source": [
"query = 'Why shouldn\\'t I watch 1917?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 13 document sections, with indexes:\n",
"674 1917\n",
"879 1917\n",
"759 1917\n",
"719 1917\n",
"949 1917\n",
"952 1917\n",
"932 1917\n",
"734 1917\n",
"831 1917\n",
"862 1917\n",
"738 1917\n",
"701 1917\n",
"694 1917\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: 1917 The film's final hour loses steam and is beset by more than a few narrative lapses it ultimately can't overcome. Still, this is a worthwhile epic best seen on the big screen.\n",
"* movie title: 1917 Sitting through it is like watching someone else playing a video game for two solid hours, and not an especially compelling one at that.\n",
"* movie title: 1917 In other words, \"1917\" often seems built more to wow audience than make them feel. And it may well have been a better film set around extended cuts than fully committing to the one-take gimmick.\n",
"* movie title: 1917 It proves that its long takes, instead of being a way of making things more difficult or 'artistic', are a vital component for this particular story. [Full review in Spanish]\n",
"* movie title: 1917 You might make your own heroic 300-yard dash following 1917 just to watch it again; it's ambitious with much to take away and contemplate over, equal parts unforgettable and frustrating\n",
"* movie title: 1917 Although 1917's filmmaking very much brings attention to itself, it's an astonishing piece of filmmaking, portraying war with enormous panache. This is big-screen bravado, and then some.\n",
"* movie title: 1917 Tense, powerful and breathtaking, 1917 is a visceral movie you won't forget in a hurry - and it's the first must-see movie of next year.\n",
"* movie title: 1917 With its extraordinary long takes and constant focus on the protagonists, it allows the viewers to become even more immersed in the action, inviting total emotional engagement which never lets up.\n",
"* movie title: 1917 Full of thrills and spills yet surprisingly intimate and personal, 1917 is a breathtaking, profound tour de force, easily sealing its position as one of the greatest war films of all time.\n",
"* movie title: 1917 1917 is a visceral experience that should be watched in the theatre on the biggest IMAX screen you can find.\n",
"* movie title: 1917 An epic, immersive and marvelous cinematic achievement that delivers plenty of edge-of-your-seat thrills. [Full Review in Spanish]\n",
"* movie title: 1917 1917 is as much of an endurance test in the cinema as it seemingly was on the other side of the camera, and it's one that lands with a grotesque, powerful punch.\n",
"* movie title: 1917 A cinematic experience on war, tension, and the boundaries of drama within a realistic setting of desperation. [Full review in Spanish].\n",
"\n",
" Q: I am not a big fan of lengthy movie, should I watch 1917?\n",
" A:\n",
" That depends on your personal preference. While 1917 features long takes and is often referred to as a 'cinematic experience', it also has received positive reviews from critics, describing it as 'a visceral movie you won't forget in a hurry' and 'an epic, immersive and marvelous cinematic achievement'.\n"
]
}
],
"source": [
"query = 'I am not a big fan of lengthy movie, should I watch 1917?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 11 document sections, with indexes:\n",
"2823 CAPTAIN MARVEL\n",
"2093 SPIDER-MAN: FAR FROM HOME\n",
"2148 SPIDER-MAN: FAR FROM HOME\n",
"2857 CAPTAIN MARVEL\n",
"2116 SPIDER-MAN: FAR FROM HOME\n",
"3091 CAPTAIN MARVEL\n",
"2785 CAPTAIN MARVEL\n",
"2253 SPIDER-MAN: FAR FROM HOME\n",
"2875 CAPTAIN MARVEL\n",
"2851 CAPTAIN MARVEL\n",
"3005 CAPTAIN MARVEL\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: CAPTAIN MARVEL Great visual effects and acting by Brie Larson make for an enjoyable watch that embraces a confident and smart woman character, something rarely seen in this genre.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Goodness, this is cleverly constructed stuff - full of fun, humour, youth and big visual effects, but underpinned by a screenplay that does a really well thought-through job of linking the MCU's future to its hugely popular past.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Special credit must be given to the effects team, which brings to life Mysterio's trippy, perception-altering powers in a way once thought unimaginable for a live-action film.\n",
"* movie title: CAPTAIN MARVEL While not the worst of the MCU, CAPTAIN MARVEL is so much less than it should've been. Even Goose the Flerken can't save it from a lacking lead performance, dull action, awful VFX, and a clichéd, amateurish script.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME Watts does a wonderful job of visualizing the chaos and nightmarish paranoia that Mysterio's antics cause Spider-Man.\n",
"* movie title: CAPTAIN MARVEL Captain Marvel is full of hysterical funny moments, gorgeous visuals and is an action packed spectacle. It is one of Marvel's best films, Brie Larson is perfectly cast as the relentless \"Avenger\".\n",
"* movie title: CAPTAIN MARVEL There's no shortage of action scenes but they're heavy on special effects and light on emotional resonance.\n",
"* movie title: SPIDER-MAN: FAR FROM HOME still isn't quite up to par with the rest of the MCU for scope and drama and still can't touch either the original Sam Raimi films or Into The Spider-Verse at visualizing Spider-Man action, it DOES know where its strengths are: Its characters.\n",
"* movie title: CAPTAIN MARVEL I'd say it's on par with Thor: Ragnarok for being a mostly jovial entry into the MCU and I like it just about as much. I also can't wait to see what Larson brings to the table in Avengers: End Game.\n",
"* movie title: CAPTAIN MARVEL Usually Marvel origin films have trouble sticking the landing, but Captain Marvel is just the opposite, it feels like it takes off in the 3rd act and becomes a near flawless action movie that kicks Phase IV into overdrive.\n",
"* movie title: CAPTAIN MARVEL It's meant to show the lighter, more family-friendly side of the MCU, and to that extent, younger viewers should be pleased. But there are no lump-in-your throat moments in \"Captain Marvel.\"\n",
"\n",
" Q: I love visual effects, should I watch Captain Marvel or Spiderman?\n",
" A:\n",
" Spiderman: Far From Home has better visual effects than Captain Marvel, so if you love visual effects you should watch Spiderman: Far From Home.\n"
]
}
],
"source": [
"query = 'I love visual effects, should I watch Captain Marvel or Spiderman?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 15 document sections, with indexes:\n",
"5719 DUNKIRK\n",
"5938 DUNKIRK\n",
"2463 AVENGERS: ENDGAME\n",
"920 1917\n",
"713 1917\n",
"726 1917\n",
"699 1917\n",
"2369 AVENGERS: ENDGAME\n",
"943 1917\n",
"672 1917\n",
"1817 TOY STORY 4\n",
"860 1917\n",
"842 1917\n",
"734 1917\n",
"5157 BLACK PANTHER\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: DUNKIRK It's an emotional gauntlet, as you'll be glued to the edge of your seats with your eyes staring at the screening.\n",
"* movie title: DUNKIRK The most emotional moments in Nolan's film are the smaller ones, a soldier slipping into the sea swimming towards home, a young hero recognized in a local newspaper.\n",
"* movie title: AVENGERS: ENDGAME Emotional heft combines with a sweeping sense of the epic, often within the same scene.\n",
"* movie title: 1917 Emotionally hollow, 1917 is the big what if of 2019.\n",
"* movie title: 1917 Emotional and poetic in its spectacular mixture of noise, chaos and almost abstract calm. [Full Review in Spanish]\n",
"* movie title: 1917 I was expecting an exciting and technical marvel, but it's an emotional one too. It's breathtaking, in that I didn't want to breathe.\n",
"* movie title: 1917 One of the most technically proficient, emotionally compelling, and jaw-dropping goliaths of a war film that I've ever seen.\n",
"* movie title: AVENGERS: ENDGAME It's one of the funniest movies of the 20-plus in the franchise, but it's also the one that made me the most emotional. But more than anything, it left me satisfied and thrilled that I kept watching them through the years.\n",
"* movie title: 1917 It's both stylish and gimmicky, while also emotionally tense and incredibly clever, resulting in a unique cinematic experience that's frequently harrowing, propulsive, and often emotional excruciating.\n",
"* movie title: 1917 A measured compromise of its emotional quotient to create a visual feast, [1917] is undoubtedly impressive while remaining remote.\n",
"* movie title: TOY STORY 4 This might be just the most emotional experience you'll have in a cinema all year.\n",
"* movie title: 1917 A war film that will take you on both a physical and emotional journey, 1917 is likely to be remembered as one of the great movies of 2020.\n",
"* movie title: 1917 It's a tribute to heroism with an abbreviated emotional outreach, yet it's consistently impressive to look at and to sense the scale of.\n",
"* movie title: 1917 With its extraordinary long takes and constant focus on the protagonists, it allows the viewers to become even more immersed in the action, inviting total emotional engagement which never lets up.\n",
"* movie title: BLACK PANTHER Emotional, occasionally funny, and narratively unpredictable... I doubt any other blockbuster will manage to surpass Black Panther this year. [Full review in Spanish]\n",
"\n",
" Q: I love emotional movies, what movie should I watch?\n",
" A:\n",
" It depends on what kind of emotional experience you are looking for, but some good ones you could consider are Dunkirk, Avengers: Endgame, 1917, Toy Story 4, and Black Panther.\n"
]
}
],
"source": [
"query = 'I love emotional movies, what movie should I watch?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 13 document sections, with indexes:\n",
"1289 JOKER\n",
"1184 JOKER\n",
"1245 JOKER\n",
"1025 JOKER\n",
"1295 JOKER\n",
"991 JOKER\n",
"1082 JOKER\n",
"1336 JOKER\n",
"1240 JOKER\n",
"1269 JOKER\n",
"1332 JOKER\n",
"1319 JOKER\n",
"1121 JOKER\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: JOKER This movie is indeed terrifying, but that's because it's horrifically, unintentionally insightful of how such men are viewed, both from without and within.\n",
"* movie title: JOKER The social commentary of \"Joker\" is laughably one-dimensional and Phoenix's Fleck isn't that scary. Really, he's more sad than anything.\n",
"* movie title: JOKER The Joker is deadly serious, a bleak but oddly beautiful horror film that evokes the nightmarish nihilism of Martin Scorsese's Taxi Driver.\n",
"* movie title: JOKER A disturbing and frightening origin story that reflects on sensitive issues that affect today's society. Joaquin Phoenix's bravura performance as the popular comic book villain is nothing short of extraordinary. [Full Review in Spanish]\n",
"* movie title: JOKER Joker is powerful and disturbing..in a good way. Phoenix has never been better AND scary. A highly entertaining drama that evolves to a can't forget thriller.\n",
"* movie title: JOKER Joker is dark, dense, violent, and monstrous. A descent into Hades that is unlike anything we've seen on screen that's inspired by a comic [Full review in Spanish]\n",
"* movie title: JOKER The chilling take away I got is that the cackling laugh of the Joker gets into your head, as if the filmmaker thinks that's enough to explain this sad mental illness story.\n",
"* movie title: JOKER Whether Joker is a social commentary on issues such as poverty or mental illness, a new mysterious take on the best known DC Comics villain, or another unforgettable piece of cinema by Martin Scorsese, you'll need to see to believe it.\n",
"* movie title: JOKER It's provocative, disturbing, occasionally funny, sometimes heartbreaking and the way Phillips plays with the intensity dial is incredible.\n",
"* movie title: JOKER It's a very good movie, and it features a blood-curdling performance from Joaquin Phoenix, in the most frightening portrayal of a violent maniac in decades.\n",
"* movie title: JOKER This is a truly nightmarish vision of late-era capitalism - arguably the best social horror film since Get Out - and Joaquin Phoenix is magnetic in it.\n",
"* movie title: JOKER Todd Phillips' Joker is deeply unsettling. It's a film which follows you home at night, insidious and nightmarish\n",
"* movie title: JOKER Joker is a tough watch that is not entirely rewarding but is ambitious enough to swing for the fences when it sees the opportunity.\n",
"\n",
" Q: Is Joker a scary movie?\n",
" A:\n",
" Yes, Joker is a scary movie.\n"
]
}
],
"source": [
"query = 'Is Joker a scary movie?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 13 document sections, with indexes:\n",
"991 JOKER\n",
"1347 JOKER\n",
"1105 JOKER\n",
"1119 JOKER\n",
"1121 JOKER\n",
"1126 JOKER\n",
"1336 JOKER\n",
"1314 JOKER\n",
"1078 JOKER\n",
"1086 JOKER\n",
"1090 JOKER\n",
"1180 JOKER\n",
"1297 JOKER\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: JOKER Joker is dark, dense, violent, and monstrous. A descent into Hades that is unlike anything we've seen on screen that's inspired by a comic [Full review in Spanish]\n",
"* movie title: JOKER Simply calling Joker a \"comic book movie\" does it a disservice; it is a story that feels like it could be about any number of disaffected people who are marginalized by the ruthless world in which we live.\n",
"* movie title: JOKER \"Joker\" is a character study laced with societal commentary, more art-house than blockbuster. And in a world of ready-made superhero franchises, it's so bold, it's shocking.\n",
"* movie title: JOKER A dark, deranged and often mesmerizing take on the superhero genre. The sort of movie that crawls into your guts and stays there awhile.\n",
"* movie title: JOKER Joker is a tough watch that is not entirely rewarding but is ambitious enough to swing for the fences when it sees the opportunity.\n",
"* movie title: JOKER Joker is ultimately an-in-your face examination of a broken class system that creates its own monsters. It's a gritty and morbidly beautiful journey with little comfort to spare, but many messages to mull over.\n",
"* movie title: JOKER Whether Joker is a social commentary on issues such as poverty or mental illness, a new mysterious take on the best known DC Comics villain, or another unforgettable piece of cinema by Martin Scorsese, you'll need to see to believe it.\n",
"* movie title: JOKER A violent, nihilistic horror film masquerading as both a character drama and a comic book movie\n",
"* movie title: JOKER 'Joker' is a slow-burn psychological thriller that often feels like it's hitting a little too close to home.\n",
"* movie title: JOKER The kind of rich, complex movie DC has been trying and failing to make ever since The Dark Knight Rises.\n",
"* movie title: JOKER Joker is raw, unsettling, and experimental, anchored by an absolutely mesmerizing central performance.\n",
"* movie title: JOKER [T]he film is more character study than franchise film, a psychologically rich portrait of a mentally ill loner that just happens to take place in a world that will one day yield a cowl-wearing billionaire vigilante.\n",
"* movie title: JOKER Joker is a dark and complex exploration of mental illness, led by Phoenix's phenomenal performance, which elevates the film to the next level.\n",
"\n",
" Q: What type of movie is Joker?\n",
" A:\n",
" Joker is a dark, complex exploration of mental illness, led by Phoenix's phenomenal performance. It is a character study laced with societal commentary and art-house vibe, more about disaffected people and a broken class system than a superhero franchise.\n"
]
}
],
"source": [
"query = 'What type of movie is Joker?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Failed Examples"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"The set of examples below failed to retrieve both the movie title in query. Therefore, the response is deemed not reliable. "
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 11 document sections, with indexes:\n",
"303 KNIVES OUT\n",
"225 KNIVES OUT\n",
"296 KNIVES OUT\n",
"279 KNIVES OUT\n",
"36 KNIVES OUT\n",
"148 KNIVES OUT\n",
"131 KNIVES OUT\n",
"147 KNIVES OUT\n",
"60 KNIVES OUT\n",
"273 KNIVES OUT\n",
"57 KNIVES OUT\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: KNIVES OUT If there's a case for a film that should be experienced purely with an audience, Rian Johnson's \"Knives Out\" would be a spectacular example. His latest feature is a deliciously entertaining, hysterical whodunit from start to finish.\n",
"* movie title: KNIVES OUT This film is super satisfying. It's funny, the mystery plot really works, and it also has something to say, which it does with enjoyably righteous anger. Go for the production design and the plot, leave being blown away by De Armas.\n",
"* movie title: KNIVES OUT One of the funniest films of the year, this tale of deception and intrigue packs an all-star cast at their very best and some theatrical filmmaking from a technical master\n",
"* movie title: KNIVES OUT What makes Knives Out such a joyful experience (and one that should absolutely be seen with a massive crowd) is the catharsis that comes with its very arch depiction of the toxins that currently poison the American culture.\n",
"* movie title: KNIVES OUT I LOVED it. An amazing cast of characters led flawlessly by Daniel Craig, Chris Evans and Ana de Armas. The moment I thought I knew what was happening, a twist threw me. One of my year's favorite films.\n",
"* movie title: KNIVES OUT Knives Out is a film for lovers of murder mysteries, fans of dysfunctional family dramedies and everyone who just loves great movies.\n",
"* movie title: KNIVES OUT [C]inematic legerdemain as its cast expertly calibrate their performances so that arch never strays into the certain disaster of becoming artificial. The result is a giddily entertaining, emotionally engaging film that sets a new standard for its genre.\n",
"* movie title: KNIVES OUT Knives Out is an enticing addition to Johnson's filmography and a welcome appetizer before he goes back into orbit for more Star Wars adventures.\n",
"* movie title: KNIVES OUT Most of the actors are just gussied up in cameo roles and the script is not half as clever as it thinks it is. Still you have highly watchable performances by Ana De Armas and Chris Evans.\n",
"* movie title: KNIVES OUT Knives Out is what a good trip to the cinema is all about. It is a witty, surprising, and terrifically performed film from Rian Johnson and an all-star modern classic whodunnit that subverts expectations.\n",
"* movie title: KNIVES OUT Features a tight plot, a superlative ensemble cast and hilarious dialogue that practically sings. One of the best of 2019.\n",
"\n",
" Q: I love emotional movies, should I watch Knives Out or A Star Is Born?\n",
" A:\n",
" Knives Out is an emotionally engaging film that features a strong ensemble cast, witty dialogue and surprising plot twists. If you're looking for an emotional movie experience, Knives Out might be the perfect choice.\n"
]
}
],
"source": [
"query = 'I love emotional movies, should I watch Knives Out or A Star Is Born?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 12 document sections, with indexes:\n",
"4 KNIVES OUT\n",
"102 KNIVES OUT\n",
"288 KNIVES OUT\n",
"290 KNIVES OUT\n",
"147 KNIVES OUT\n",
"213 KNIVES OUT\n",
"32 KNIVES OUT\n",
"269 KNIVES OUT\n",
"104 KNIVES OUT\n",
"184 KNIVES OUT\n",
"225 KNIVES OUT\n",
"264 KNIVES OUT\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: KNIVES OUT Sharp and funny, Knives Out exceeds expectations by proving to be more than its surface implies, even as Johnson demonstrates his first-rate skill in the story's maneuvers and charades.\n",
"* movie title: KNIVES OUT On the performance front, the Knives Out show is comprehensively stolen - and never once returned - by a wired, inspired and kookily amusing Daniel Craig.\n",
"* movie title: KNIVES OUT Similar to Ready or Not earlier this year, Knives Out is an unabashed commentary on the current state of affairs in America.\n",
"* movie title: KNIVES OUT Through clever plotting and smart sleight of hand, Johnson has crafted a whodunit that's worthy of Agatha Christie or Arthur Conan Doyle, and one that will have audiences guessing until the final few reels.\n",
"* movie title: KNIVES OUT Knives Out is an enticing addition to Johnson's filmography and a welcome appetizer before he goes back into orbit for more Star Wars adventures.\n",
"* movie title: KNIVES OUT An entirely entertaining murder-mystery jape; dryly funny, deliciously retro yet decidedly modern. Whenever you think you've got it figured out, it trips you up again... and you love it for doing so.\n",
"* movie title: KNIVES OUT Knives Out does go on a bit longer and there are one too many running down corridors and driving from one place to another, but as a whole the film pays off with humor, mayhem, and shows us families to whom \"entitlement\" is their middle name.\n",
"* movie title: KNIVES OUT You'll burst out laughing and adore how Johnson's cast plays their cards with confidence, masks their bluffs, and presents a gallery of rogues with enjoyable deceit.\n",
"* movie title: KNIVES OUT The film is a magician's trick so thoroughly satisfying, you have no choice but to give in to its mischievous entreaties. You won't have a better time in the cineplex this year.\n",
"* movie title: KNIVES OUT Johnson has crafted a wonderfully jumbled tale of family and murder that pays homage to murder mysteries and is effortlessly entertaining.\n",
"* movie title: KNIVES OUT This film is super satisfying. It's funny, the mystery plot really works, and it also has something to say, which it does with enjoyably righteous anger. Go for the production design and the plot, leave being blown away by De Armas.\n",
"* movie title: KNIVES OUT Johnson, on temporary sabbatical from the Star Wars universe after The Last Jedi, has used his time well. Murder he wrote - and what a writer he is.\n",
"\n",
" Q: How is Knives Out compared to Joker?\n",
" A:\n",
" I don't know.\n"
]
}
],
"source": [
"query = 'How is Knives Out compared to Joker?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 12 document sections, with indexes:\n",
"759 1917\n",
"943 1917\n",
"831 1917\n",
"922 1917\n",
"830 1917\n",
"932 1917\n",
"777 1917\n",
"738 1917\n",
"671 1917\n",
"861 1917\n",
"748 1917\n",
"750 1917\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: 1917 In other words, \"1917\" often seems built more to wow audience than make them feel. And it may well have been a better film set around extended cuts than fully committing to the one-take gimmick.\n",
"* movie title: 1917 It's both stylish and gimmicky, while also emotionally tense and incredibly clever, resulting in a unique cinematic experience that's frequently harrowing, propulsive, and often emotional excruciating.\n",
"* movie title: 1917 Full of thrills and spills yet surprisingly intimate and personal, 1917 is a breathtaking, profound tour de force, easily sealing its position as one of the greatest war films of all time.\n",
"* movie title: 1917 With incredibly immersive visuals, courtesy of the great Roger Deakins, 1917 is a major cinematic achievement on the technical level, even while the script retreads classic war film themes without anything new to say.\n",
"* movie title: 1917 This action-packed film that looks like it was all shot with one continuous camera exposure is an emotional, compelling and inspiring hero's journey through the nightmare setting of trench warfare.\n",
"* movie title: 1917 Tense, powerful and breathtaking, 1917 is a visceral movie you won't forget in a hurry - and it's the first must-see movie of next year.\n",
"* movie title: 1917 The film's unique strength lies in its hyper-focused approach. The concentration on one minor mission might feel limiting, but at its best 1917 becomes a refracting lens for the vastness of the Great War's suffering...\n",
"* movie title: 1917 An epic, immersive and marvelous cinematic achievement that delivers plenty of edge-of-your-seat thrills. [Full Review in Spanish]\n",
"* movie title: 1917 This is a contemplative story of a mission and the men who sacrifice their own safety for the greater good. It highlights the ever-present danger of attack but it is the character's emotional journey that makes for a compelling story.\n",
"* movie title: 1917 A film, or any work, can be extraordinarily well-wrought and still feel a bit pointless. An abundance of fiddly labor, little flicks of the wrist, all meant to leave us impressed by the challenge of the very doing of the work.\n",
"* movie title: 1917 The film is thrilling, moving on effectively from one shocking set piece to another, studding the narrative too with starry cameos.\n",
"* movie title: 1917 It's a tense, unnerving ride that accomplishes its goal of translating the first-person experience of war better than any war movies that have come before it. It's a level up.\n",
"\n",
" Q: Is the movie Joker better or 1917?\n",
" A:\n",
" I don't know.\n"
]
}
],
"source": [
"query = 'Is the movie Joker better or 1917?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"In the example below, there is no movie title Superman. Yet, it provides a response based on 'Wonder Woman'. \n",
"\n",
"Mitigation: Consider using `Movie` title as a filter. "
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Selected 12 document sections, with indexes:\n",
"6146 WONDER WOMAN\n",
"6206 WONDER WOMAN\n",
"6149 WONDER WOMAN\n",
"6116 WONDER WOMAN\n",
"6220 WONDER WOMAN\n",
"6202 WONDER WOMAN\n",
"6107 WONDER WOMAN\n",
"6201 WONDER WOMAN\n",
"6039 WONDER WOMAN\n",
"6311 WONDER WOMAN\n",
"6231 WONDER WOMAN\n",
"6119 WONDER WOMAN\n",
"Answer the question truthfully using context, if unsure, say \"I don't know.\"\n",
"\n",
"Context:\n",
"\n",
"* movie title: WONDER WOMAN Wonder Woman is a great action movie, full of adventure and light drama, similar to films like Christopher Reeve's Superman. [Full review in Spanish]\n",
"* movie title: WONDER WOMAN There is an engaging, old‑school feel to Wonder Woman, a film that has some of the sincerity and charm of the early Christopher Reeve Superman epics.\n",
"* movie title: WONDER WOMAN DC finally breaks its long losing streak with a satisfying effort- and all it took was changing absolutely everything (Splice Today)\n",
"* movie title: WONDER WOMAN A well-intentioned film that in an age of cynicism dares to recapitulate the importance of the primeval ideal of a superhero: the discovery of inspirational models and escapism. [Full review in Spanish]\n",
"* movie title: WONDER WOMAN Filled with the kind of humor and earnestness that [the last couple DC films] were criticized for lacking, Wonder Woman is an absolute joy to watch, thanks in large part to its two leads.\n",
"* movie title: WONDER WOMAN Wonder Woman is funny, exciting and fun, but more importantly, it's touching and inspiring. [Full review in Spanish]\n",
"* movie title: WONDER WOMAN As befitting the genre, Wonder Woman is heroic and spirited. The fighting sequences are spectacular, and the story is engrossing, uplifting and fun. There's even a bit of romance and humor amid all the action. [Full review in Japanese]\n",
"* movie title: WONDER WOMAN Gadot's contribution to the film cannot be understated. She brings a sense of innocence and conviction to the role that's reminiscent of Christopher Reeve's approach to the Man of Steel in \"Superman: The Movie.\"\n",
"* movie title: WONDER WOMAN Although it has a charismatic role from Gal Gadot, it has nothing exciting for two hours that turns wonderful to yawn. [Full review in Spanish]\n",
"* movie title: WONDER WOMAN As witty and heartfelt as it is thrilling - a film that fangirls, fanboys and even those suffering from superhero fatigue can enjoy.\n",
"* movie title: WONDER WOMAN Wonder Woman is good. Not great, but good. And really, after Man Of Steel, Batman V Superman: Dawn Of Justice and Suicide Squad, that's all it needs to be.\n",
"* movie title: WONDER WOMAN That optimism [is] what makes Diana Prince a real superheroine, and it's that vision that makes Wonder Woman a movie that really thrills. [Full review in Spanish]\n",
"\n",
" Q: What are the reviews of Superman?\n",
" A:\n",
" The reviews of Superman are generally positive, with people comparing its light drama and adventure to Christopher Reeve's Superman.\n"
]
}
],
"source": [
"query = 'What are the reviews of Superman?'\n",
"prompt = construct_prompt(query=query, context_embeddings=df['embedding'], df=df); print(prompt)\n",
"retrieve_information(prompt=prompt)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "azureml_py38",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "6d65a8c07f5b6469e0fc613f182488c0dccce05038bbda39e5ac9075c0454d11"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}