-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIn document search cross-encoder
1 lines (1 loc) · 29.6 KB
/
In document search cross-encoder
1
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[],"dockerImageVersionId":30648,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Overview\n\nIn notebook [Retrieve & Re-Rank](https://www.kaggle.com/code/aisuko/retrieve-re-rank). We use [Simple English Wikipedia](https://huggingface.co/datasets/aisuko/simple_english_wikipedia_p0) as document collection to provide answers to user questions/search queries. However, if we only have a small set of paragraphs, we don't do the retrieval stage. In this notebook, we take the single Wikipedia article about Melbourne and split into paragrahs. Then, the search query/question and all paragraphs are scored using the Cross-Encoder re-ranker. The most relevant passages for the query are returned.\n\n\nHere, we are going to use `cross-encoder/ms-macro-TinyBERT-L-2`, a BERT model with only 2 layers trained on the MS MARCO dataset. This is an extremly quick model able to score up to 9000 passages per second (on a V100 GPU). We can also use a larger model, which gives better results but is also slower.\n\nNote: Here we score the [query, passage]-pair for every new query, this search method becomes at some point in-efficient if the document gets too large.","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"!pip install sentence-transformers==2.3.1\n!pip install nltk==3.8.1","metadata":{"execution":{"iopub.status.busy":"2024-05-20T14:00:08.756661Z","iopub.execute_input":"2024-05-20T14:00:08.757519Z","iopub.status.idle":"2024-05-20T14:00:39.807821Z","shell.execute_reply.started":"2024-05-20T14:00:08.757477Z","shell.execute_reply":"2024-05-20T14:00:39.806590Z"},"trusted":true},"execution_count":1,"outputs":[{"name":"stdout","text":"Collecting sentence-transformers==2.3.1\n Downloading sentence_transformers-2.3.1-py3-none-any.whl.metadata (11 kB)\nRequirement already satisfied: transformers<5.0.0,>=4.32.0 in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (4.37.0)\nRequirement already satisfied: tqdm in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (4.66.1)\nRequirement already satisfied: torch>=1.11.0 in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (2.1.2)\nRequirement already satisfied: numpy in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (1.24.4)\nRequirement already satisfied: scikit-learn in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (1.2.2)\nRequirement already satisfied: scipy in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (1.11.4)\nRequirement already satisfied: nltk in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (3.2.4)\nRequirement already satisfied: sentencepiece in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (0.1.99)\nRequirement already satisfied: huggingface-hub>=0.15.1 in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (0.20.3)\nRequirement already satisfied: Pillow in /opt/conda/lib/python3.10/site-packages (from sentence-transformers==2.3.1) (9.5.0)\nRequirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (3.13.1)\nRequirement already satisfied: fsspec>=2023.5.0 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (2023.12.2)\nRequirement already satisfied: requests in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (2.31.0)\nRequirement already satisfied: pyyaml>=5.1 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (6.0.1)\nRequirement already satisfied: typing-extensions>=3.7.4.3 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (4.9.0)\nRequirement already satisfied: packaging>=20.9 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (21.3)\nRequirement already satisfied: sympy in /opt/conda/lib/python3.10/site-packages (from torch>=1.11.0->sentence-transformers==2.3.1) (1.12)\nRequirement already satisfied: networkx in /opt/conda/lib/python3.10/site-packages (from torch>=1.11.0->sentence-transformers==2.3.1) (3.2.1)\nRequirement already satisfied: jinja2 in /opt/conda/lib/python3.10/site-packages (from torch>=1.11.0->sentence-transformers==2.3.1) (3.1.2)\nRequirement already satisfied: regex!=2019.12.17 in /opt/conda/lib/python3.10/site-packages (from transformers<5.0.0,>=4.32.0->sentence-transformers==2.3.1) (2023.12.25)\nRequirement already satisfied: tokenizers<0.19,>=0.14 in /opt/conda/lib/python3.10/site-packages (from transformers<5.0.0,>=4.32.0->sentence-transformers==2.3.1) (0.15.1)\nRequirement already satisfied: safetensors>=0.3.1 in /opt/conda/lib/python3.10/site-packages (from transformers<5.0.0,>=4.32.0->sentence-transformers==2.3.1) (0.4.2)\nRequirement already satisfied: six in /opt/conda/lib/python3.10/site-packages (from nltk->sentence-transformers==2.3.1) (1.16.0)\nRequirement already satisfied: joblib>=1.1.1 in /opt/conda/lib/python3.10/site-packages (from scikit-learn->sentence-transformers==2.3.1) (1.3.2)\nRequirement already satisfied: threadpoolctl>=2.0.0 in /opt/conda/lib/python3.10/site-packages (from scikit-learn->sentence-transformers==2.3.1) (3.2.0)\nRequirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/lib/python3.10/site-packages (from packaging>=20.9->huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (3.1.1)\nRequirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from jinja2->torch>=1.11.0->sentence-transformers==2.3.1) (2.1.3)\nRequirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (3.3.2)\nRequirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (3.6)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (1.26.18)\nRequirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers==2.3.1) (2023.11.17)\nRequirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.10/site-packages (from sympy->torch>=1.11.0->sentence-transformers==2.3.1) (1.3.0)\nDownloading sentence_transformers-2.3.1-py3-none-any.whl (132 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m132.8/132.8 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n\u001b[?25hInstalling collected packages: sentence-transformers\nSuccessfully installed sentence-transformers-2.3.1\nCollecting nltk==3.8.1\n Downloading nltk-3.8.1-py3-none-any.whl.metadata (2.8 kB)\nRequirement already satisfied: click in /opt/conda/lib/python3.10/site-packages (from nltk==3.8.1) (8.1.7)\nRequirement already satisfied: joblib in /opt/conda/lib/python3.10/site-packages (from nltk==3.8.1) (1.3.2)\nRequirement already satisfied: regex>=2021.8.3 in /opt/conda/lib/python3.10/site-packages (from nltk==3.8.1) (2023.12.25)\nRequirement already satisfied: tqdm in /opt/conda/lib/python3.10/site-packages (from nltk==3.8.1) (4.66.1)\nDownloading nltk-3.8.1-py3-none-any.whl (1.5 MB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.5/1.5 MB\u001b[0m \u001b[31m16.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n\u001b[?25hInstalling collected packages: nltk\n Attempting uninstall: nltk\n Found existing installation: nltk 3.2.4\n Uninstalling nltk-3.2.4:\n Successfully uninstalled nltk-3.2.4\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\npreprocessing 0.1.13 requires nltk==3.2.4, but you have nltk 3.8.1 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed nltk-3.8.1\n","output_type":"stream"}]},{"cell_type":"markdown","source":"We generate some information(1000 words) about Melbourne Australia by using Google Gemini.","metadata":{}},{"cell_type":"code","source":"from nltk import sent_tokenize\n\nmelbourne_info=\"\"\"Melbourne: A mosaic of stories under the Southern Cross\n\nMelbourne, Australia's cultural gem, shimmers like a kaleidoscope beneath the watchful gaze of the Southern Cross. Its tapestry is woven from threads of history, painted with strokes of vibrant street art, and hums with the rhythm of diverse voices. From the grand bluestone facades of Victorian-era buildings to the glass-and-steel skyscrapers whispering tales of progress, the city breathes a unique blend of old and new.\n\nWander cobbled laneways adorned with stencils and murals, each a silent storyteller chronicling artistic dreams. Duck into hidden bars, their intimate spaces echoing with laughter and clinking glasses as locals unwind over craft beers brewed with Melbourne's signature spirit. Inhale the intoxicating aroma of coffee wafting from countless cafes, fueling the city's creative pulse and fostering lively debates that spill onto sun-drenched terraces.\n\nImmerse yourself in the vibrant tapestry of cultures that call Melbourne home. Explore bustling Chinatown, a sensory feast of sights, sounds, and smells, where dim sum restaurants overflow with families sharing stories over steaming baskets. Meander through vibrant Greek neighborhoods, where tavernas spill onto lively streets filled with the aroma of souvlaki and the sounds of bouzouki music. Unwind in the lush Royal Botanic Gardens, a tranquil oasis where native flora bursts with color and the serene lake reflects the city's ever-changing moods.\n\nStep back in time at Federation Square, where grand buildings whisper tales of the city's colonial past. Marvel at the architectural marvel of St. Paul's Cathedral, its spires reaching towards the sky like silent prayers. Delve into the city's sporting passion at the Melbourne Cricket Ground (MCG), where the roar of the crowd electrifies the air during a thrilling game of cricket or Australian Rules Football.\n\nEmbrace the city's artistic soul at the National Gallery of Victoria, where masterpieces from across the globe come alive. Be mesmerized by contemporary installations at the Australian Centre for the Moving Image (ACMI), or get lost in the whimsical world of children's literature at the Melbourne Museum. As dusk paints the sky in hues of orange and purple, lose yourself in the magic of a performance at the Arts Centre Melbourne, the city's beating heart for all things theatrical.\n\nMelbourne's soul simmers after dark. Laneways transform into open-air bars, pulsating with the energy of live music and animated conversations. Rooftop bars offer breathtaking panoramas of the city bathed in the warm glow of a million lights. Intimate jazz bars tucked away in hidden corners lull you into a state of blissful serenity with soulful melodies.\n\nAs dawn paints the sky with soft pastels, head to Queen Victoria Market, a vibrant labyrinth of stalls overflowing with fresh produce, artisan cheeses, and handcrafted souvenirs. Mingle with the friendly locals, their voices a symphony of accents reflecting the city's multicultural tapestry. Savor a steaming cup of coffee and a flaky pastry at a bustling cafe, the perfect start to a day filled with new discoveries.\n\nMelbourne is more than just a city; it's a feeling. It's the warmth of a smile from a stranger, the shared joy of a spontaneous street performance, the comforting aroma of freshly baked bread wafting from a local bakery. It's the city that embraces individuality, fosters creativity, and celebrates the beauty of diversity. So, come, explore its hidden gems, savor its unique flavors, and immerse yourself in the vibrant melody that is Melbourne.\"\"\"\n\n\nparagraphs=[]\nfor paragraph in melbourne_info.replace('\\r\\n','\\n').split('\\n\\n'):\n if len(paragraph.strip())>0:\n paragraphs.append(sent_tokenize(paragraph.strip()))\n\nlen(paragraphs)","metadata":{"execution":{"iopub.status.busy":"2024-05-20T14:00:39.810659Z","iopub.execute_input":"2024-05-20T14:00:39.811107Z","iopub.status.idle":"2024-05-20T14:00:40.885989Z","shell.execute_reply.started":"2024-05-20T14:00:39.811060Z","shell.execute_reply":"2024-05-20T14:00:40.884943Z"},"trusted":true},"execution_count":2,"outputs":[{"execution_count":2,"output_type":"execute_result","data":{"text/plain":"9"},"metadata":{}}]},{"cell_type":"markdown","source":"We combine up to 3 sentences into a passage.\n\n- Smaller value: Context from other sentences might get lost\n- Larger value: More context from the paragraph remains, but results are longer","metadata":{}},{"cell_type":"code","source":"window_size=3\npassages=[]\nfor paragraph in paragraphs:\n for start_idx in range(0, len(paragraph), window_size):\n end_idx=min(start_idx+window_size, len(paragraph))\n passages.append(' '.join(paragraph[start_idx:end_idx]))\n \nprint('Paragraphs:', len(paragraphs))\nprint('Sentences:', sum([len(p) for p in paragraphs]))\nprint('Passages:', len(passages))","metadata":{"execution":{"iopub.status.busy":"2024-05-20T14:00:40.890965Z","iopub.execute_input":"2024-05-20T14:00:40.891269Z","iopub.status.idle":"2024-05-20T14:00:40.898728Z","shell.execute_reply.started":"2024-05-20T14:00:40.891243Z","shell.execute_reply":"2024-05-20T14:00:40.897607Z"},"trusted":true},"execution_count":3,"outputs":[{"name":"stdout","text":"Paragraphs: 9\nSentences: 28\nPassages: 12\n","output_type":"stream"}]},{"cell_type":"markdown","source":"# Loading the cross-encoder","metadata":{}},{"cell_type":"code","source":"from sentence_transformers import CrossEncoder\n\nmodel=CrossEncoder('cross-encoder/ms-marco-TinyBERT-L-2')\nmodel","metadata":{"execution":{"iopub.status.busy":"2024-05-20T14:00:40.899844Z","iopub.execute_input":"2024-05-20T14:00:40.900127Z","iopub.status.idle":"2024-05-20T14:00:49.922839Z","shell.execute_reply.started":"2024-05-20T14:00:40.900103Z","shell.execute_reply":"2024-05-20T14:00:49.921730Z"},"trusted":true},"execution_count":4,"outputs":[{"output_type":"display_data","data":{"text/plain":"config.json: 0%| | 0.00/612 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"183852581b014d9494140369e7fd5c59"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"pytorch_model.bin: 0%| | 0.00/17.6M [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"4189edb15ff74239adcec30d5a25d735"}},"metadata":{}},{"name":"stderr","text":"/opt/conda/lib/python3.10/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()\n return self.fget.__get__(instance, owner)()\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"tokenizer_config.json: 0%| | 0.00/543 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"78bc1816ea7f41cfb3156cf568de2747"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"vocab.txt: 0%| | 0.00/232k [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"fef7c5f8d4ec4476bcae4c049ad50952"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"special_tokens_map.json: 0%| | 0.00/112 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"48cfb53f645e47cf88a01052c6a2a519"}},"metadata":{}},{"execution_count":4,"output_type":"execute_result","data":{"text/plain":"<sentence_transformers.cross_encoder.CrossEncoder.CrossEncoder at 0x7b7eae952c80>"},"metadata":{}}]},{"cell_type":"markdown","source":"Here we have 5 questions from Gemini.","metadata":{}},{"cell_type":"code","source":"import time\n\nquestions = [\n \"What distinguishes Melbourne within Australia based on the provided description?\",\n \"How does the paragraph portray the link between Melbourne's art scene and the Southern Cross, considering its history?\",\n \"Which diverse cultures are highlighted as contributing to Melbourne's vibrancy?\",\n \"What specific historical landmarks are recommended for visitors based on the description?\",\n \"How do Melbourne's bars, as depicted in the text, contribute to the city's overall atmosphere?\"\n]\n\nfor query in questions:\n start_time=time.time()\n \n # concatenate the query and all passages and predict the scores for the pairs [query, passage]\n model_inputs=[[query, passage] for passage in passages]\n scores=model.predict(model_inputs)\n \n # soert the scores in decreasing order\n results=[{'input':inp, 'score':score} for inp, score in zip(model_inputs, scores)]\n results=sorted(results, key=lambda x:x['score'], reverse=True)\n \n print('Query:', query)\n print('Search took {:.2f} seconds'.format(time.time()-start_time))\n for hit in results[0:5]:\n print('Score:{:.2f}'.format(hit['score']),'\\t', hit['input'][1])\n print('==========')","metadata":{"execution":{"iopub.status.busy":"2024-05-20T14:00:49.924837Z","iopub.execute_input":"2024-05-20T14:00:49.925427Z","iopub.status.idle":"2024-05-20T14:00:50.844239Z","shell.execute_reply.started":"2024-05-20T14:00:49.925374Z","shell.execute_reply":"2024-05-20T14:00:50.843298Z"},"trusted":true},"execution_count":5,"outputs":[{"output_type":"display_data","data":{"text/plain":"Batches: 0%| | 0/1 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"1ce6a0f849184f8d92641ff61ef0f28b"}},"metadata":{}},{"name":"stdout","text":"Query: What distinguishes Melbourne within Australia based on the provided description?\nSearch took 0.80 seconds\nScore:0.15 \t Melbourne, Australia's cultural gem, shimmers like a kaleidoscope beneath the watchful gaze of the Southern Cross. Its tapestry is woven from threads of history, painted with strokes of vibrant street art, and hums with the rhythm of diverse voices. From the grand bluestone facades of Victorian-era buildings to the glass-and-steel skyscrapers whispering tales of progress, the city breathes a unique blend of old and new.\nScore:0.03 \t Melbourne is more than just a city; it's a feeling. It's the warmth of a smile from a stranger, the shared joy of a spontaneous street performance, the comforting aroma of freshly baked bread wafting from a local bakery. It's the city that embraces individuality, fosters creativity, and celebrates the beauty of diversity.\nScore:0.02 \t Melbourne: A mosaic of stories under the Southern Cross\nScore:0.02 \t Melbourne's soul simmers after dark. Laneways transform into open-air bars, pulsating with the energy of live music and animated conversations. Rooftop bars offer breathtaking panoramas of the city bathed in the warm glow of a million lights.\nScore:0.01 \t So, come, explore its hidden gems, savor its unique flavors, and immerse yourself in the vibrant melody that is Melbourne.\n==========\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"Batches: 0%| | 0/1 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"5d9d9c040b914298a454492815a4e480"}},"metadata":{}},{"name":"stdout","text":"Query: How does the paragraph portray the link between Melbourne's art scene and the Southern Cross, considering its history?\nSearch took 0.03 seconds\nScore:0.50 \t Melbourne, Australia's cultural gem, shimmers like a kaleidoscope beneath the watchful gaze of the Southern Cross. Its tapestry is woven from threads of history, painted with strokes of vibrant street art, and hums with the rhythm of diverse voices. From the grand bluestone facades of Victorian-era buildings to the glass-and-steel skyscrapers whispering tales of progress, the city breathes a unique blend of old and new.\nScore:0.17 \t Wander cobbled laneways adorned with stencils and murals, each a silent storyteller chronicling artistic dreams. Duck into hidden bars, their intimate spaces echoing with laughter and clinking glasses as locals unwind over craft beers brewed with Melbourne's signature spirit. Inhale the intoxicating aroma of coffee wafting from countless cafes, fueling the city's creative pulse and fostering lively debates that spill onto sun-drenched terraces.\nScore:0.03 \t Melbourne's soul simmers after dark. Laneways transform into open-air bars, pulsating with the energy of live music and animated conversations. Rooftop bars offer breathtaking panoramas of the city bathed in the warm glow of a million lights.\nScore:0.02 \t Embrace the city's artistic soul at the National Gallery of Victoria, where masterpieces from across the globe come alive. Be mesmerized by contemporary installations at the Australian Centre for the Moving Image (ACMI), or get lost in the whimsical world of children's literature at the Melbourne Museum. As dusk paints the sky in hues of orange and purple, lose yourself in the magic of a performance at the Arts Centre Melbourne, the city's beating heart for all things theatrical.\nScore:0.02 \t Melbourne is more than just a city; it's a feeling. It's the warmth of a smile from a stranger, the shared joy of a spontaneous street performance, the comforting aroma of freshly baked bread wafting from a local bakery. It's the city that embraces individuality, fosters creativity, and celebrates the beauty of diversity.\n==========\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"Batches: 0%| | 0/1 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"371f5bb16249427e8050900f4c85abb9"}},"metadata":{}},{"name":"stdout","text":"Query: Which diverse cultures are highlighted as contributing to Melbourne's vibrancy?\nSearch took 0.03 seconds\nScore:0.59 \t Melbourne, Australia's cultural gem, shimmers like a kaleidoscope beneath the watchful gaze of the Southern Cross. Its tapestry is woven from threads of history, painted with strokes of vibrant street art, and hums with the rhythm of diverse voices. From the grand bluestone facades of Victorian-era buildings to the glass-and-steel skyscrapers whispering tales of progress, the city breathes a unique blend of old and new.\nScore:0.20 \t Melbourne is more than just a city; it's a feeling. It's the warmth of a smile from a stranger, the shared joy of a spontaneous street performance, the comforting aroma of freshly baked bread wafting from a local bakery. It's the city that embraces individuality, fosters creativity, and celebrates the beauty of diversity.\nScore:0.16 \t Wander cobbled laneways adorned with stencils and murals, each a silent storyteller chronicling artistic dreams. Duck into hidden bars, their intimate spaces echoing with laughter and clinking glasses as locals unwind over craft beers brewed with Melbourne's signature spirit. Inhale the intoxicating aroma of coffee wafting from countless cafes, fueling the city's creative pulse and fostering lively debates that spill onto sun-drenched terraces.\nScore:0.15 \t Immerse yourself in the vibrant tapestry of cultures that call Melbourne home. Explore bustling Chinatown, a sensory feast of sights, sounds, and smells, where dim sum restaurants overflow with families sharing stories over steaming baskets. Meander through vibrant Greek neighborhoods, where tavernas spill onto lively streets filled with the aroma of souvlaki and the sounds of bouzouki music.\nScore:0.08 \t Embrace the city's artistic soul at the National Gallery of Victoria, where masterpieces from across the globe come alive. Be mesmerized by contemporary installations at the Australian Centre for the Moving Image (ACMI), or get lost in the whimsical world of children's literature at the Melbourne Museum. As dusk paints the sky in hues of orange and purple, lose yourself in the magic of a performance at the Arts Centre Melbourne, the city's beating heart for all things theatrical.\n==========\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"Batches: 0%| | 0/1 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"488643c7ffc04de58ba8574fb5f58be0"}},"metadata":{}},{"name":"stdout","text":"Query: What specific historical landmarks are recommended for visitors based on the description?\nSearch took 0.02 seconds\nScore:0.10 \t Wander cobbled laneways adorned with stencils and murals, each a silent storyteller chronicling artistic dreams. Duck into hidden bars, their intimate spaces echoing with laughter and clinking glasses as locals unwind over craft beers brewed with Melbourne's signature spirit. Inhale the intoxicating aroma of coffee wafting from countless cafes, fueling the city's creative pulse and fostering lively debates that spill onto sun-drenched terraces.\nScore:0.01 \t Melbourne, Australia's cultural gem, shimmers like a kaleidoscope beneath the watchful gaze of the Southern Cross. Its tapestry is woven from threads of history, painted with strokes of vibrant street art, and hums with the rhythm of diverse voices. From the grand bluestone facades of Victorian-era buildings to the glass-and-steel skyscrapers whispering tales of progress, the city breathes a unique blend of old and new.\nScore:0.01 \t Unwind in the lush Royal Botanic Gardens, a tranquil oasis where native flora bursts with color and the serene lake reflects the city's ever-changing moods.\nScore:0.00 \t Step back in time at Federation Square, where grand buildings whisper tales of the city's colonial past. Marvel at the architectural marvel of St. Paul's Cathedral, its spires reaching towards the sky like silent prayers. Delve into the city's sporting passion at the Melbourne Cricket Ground (MCG), where the roar of the crowd electrifies the air during a thrilling game of cricket or Australian Rules Football.\nScore:0.00 \t As dawn paints the sky with soft pastels, head to Queen Victoria Market, a vibrant labyrinth of stalls overflowing with fresh produce, artisan cheeses, and handcrafted souvenirs. Mingle with the friendly locals, their voices a symphony of accents reflecting the city's multicultural tapestry. Savor a steaming cup of coffee and a flaky pastry at a bustling cafe, the perfect start to a day filled with new discoveries.\n==========\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":"Batches: 0%| | 0/1 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"d7ecc0479abb43948d94acc05c78527d"}},"metadata":{}},{"name":"stdout","text":"Query: How do Melbourne's bars, as depicted in the text, contribute to the city's overall atmosphere?\nSearch took 0.03 seconds\nScore:0.77 \t Wander cobbled laneways adorned with stencils and murals, each a silent storyteller chronicling artistic dreams. Duck into hidden bars, their intimate spaces echoing with laughter and clinking glasses as locals unwind over craft beers brewed with Melbourne's signature spirit. Inhale the intoxicating aroma of coffee wafting from countless cafes, fueling the city's creative pulse and fostering lively debates that spill onto sun-drenched terraces.\nScore:0.37 \t Melbourne's soul simmers after dark. Laneways transform into open-air bars, pulsating with the energy of live music and animated conversations. Rooftop bars offer breathtaking panoramas of the city bathed in the warm glow of a million lights.\nScore:0.14 \t Melbourne is more than just a city; it's a feeling. It's the warmth of a smile from a stranger, the shared joy of a spontaneous street performance, the comforting aroma of freshly baked bread wafting from a local bakery. It's the city that embraces individuality, fosters creativity, and celebrates the beauty of diversity.\nScore:0.09 \t Embrace the city's artistic soul at the National Gallery of Victoria, where masterpieces from across the globe come alive. Be mesmerized by contemporary installations at the Australian Centre for the Moving Image (ACMI), or get lost in the whimsical world of children's literature at the Melbourne Museum. As dusk paints the sky in hues of orange and purple, lose yourself in the magic of a performance at the Arts Centre Melbourne, the city's beating heart for all things theatrical.\nScore:0.05 \t Immerse yourself in the vibrant tapestry of cultures that call Melbourne home. Explore bustling Chinatown, a sensory feast of sights, sounds, and smells, where dim sum restaurants overflow with families sharing stories over steaming baskets. Meander through vibrant Greek neighborhoods, where tavernas spill onto lively streets filled with the aroma of souvlaki and the sounds of bouzouki music.\n==========\n","output_type":"stream"}]}]}