Skip to content

Commit 3702553

Browse files
committed
Adding title to make the build pass
1 parent 680b27c commit 3702553

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

supporting-blog-content/multilingual-embedding/multilingual_embedding.ipynb

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Lost In Translation? Multilingual Embedding Models Are All You Need*\n",
8+
"\n",
9+
"This notebook by Quynh Nguyen shows how cross-lingual vector search overcomes language barriers, enabling you to query and retrieve information in any language from both single and multilingual datasets. It accompanies the piece *Lost In Translation? Multilingual Embedding Models Are All You Need* from [Elasticsearch Labs](https://www.elastic.co/search-labs)."
10+
]
11+
},
312
{
413
"cell_type": "code",
514
"execution_count": null,
@@ -40,7 +49,7 @@
4049
" print(f\"Data successfully downloaded and saved to {output_file}\")\n",
4150
"else:\n",
4251
" print(f\"Failed to download data: {response.status_code}\")\n",
43-
" print(response.text)\n"
52+
" print(response.text)"
4453
]
4554
},
4655
{
@@ -54,7 +63,7 @@
5463
"# Get credentials securely for localhost Elasticsearch\n",
5564
"print(\"Enter your Elasticsearch credentials:\")\n",
5665
"cloud_id = input(\"Enter your cloud_id: \")\n",
57-
"api_key = getpass(\"Enter your api_key: \")\n"
66+
"api_key = getpass(\"Enter your api_key: \")"
5867
]
5968
},
6069
{
@@ -82,14 +91,15 @@
8291
],
8392
"source": [
8493
"from elasticsearch import Elasticsearch\n",
94+
"\n",
8595
"try:\n",
8696
" es = Elasticsearch(\n",
8797
" hosts=[{\"host\": \"localhost\", \"port\": 9200, \"scheme\": \"https\"}],\n",
8898
" basic_auth=(\"elastic\", \"qaf_admin\"),\n",
8999
" verify_certs=False, # Set to True if you have valid SSL certificates\n",
90100
" # Alternatively, you can use Elastic cloud_id and api_key\n",
91-
" #api_key=getpass(\"API Key: \")\n",
92-
" #cloud_id=getpass(\"Cloud ID: \"),\n",
101+
" # api_key=getpass(\"API Key: \")\n",
102+
" # cloud_id=getpass(\"Cloud ID: \"),\n",
93103
" )\n",
94104
"\n",
95105
" # Test the connection\n",
@@ -101,7 +111,7 @@
101111
"except Exception as e:\n",
102112
" print(f\"Error connecting to Elasticsearch: {e}\")\n",
103113
" print(\"Please check your credentials\")\n",
104-
" raise\n"
114+
" raise"
105115
]
106116
},
107117
{
@@ -147,7 +157,7 @@
147157
" es.indices.create(index=index_name, body=mapping)\n",
148158
"\n",
149159
"# Load the JSON data\n",
150-
"with open('./multilingual_coco_sample.json', 'r') as f:\n",
160+
"with open(\"./multilingual_coco_sample.json\", \"r\") as f:\n",
151161
" data = json.load(f)\n",
152162
"\n",
153163
"rows = data[\"rows\"]\n",
@@ -175,16 +185,16 @@
175185
" if description == \"\":\n",
176186
" continue\n",
177187
" # Add index operation\n",
188+
" bulk_data.append({\"index\": {\"_index\": index_name}})\n",
189+
" # Add document\n",
178190
" bulk_data.append(\n",
179-
" {\"index\": {\"_index\": index_name}}\n",
191+
" {\n",
192+
" \"language\": lang,\n",
193+
" \"description\": description,\n",
194+
" \"en\": first_eng_caption,\n",
195+
" \"image_url\": image_url,\n",
196+
" }\n",
180197
" )\n",
181-
" # Add document\n",
182-
" bulk_data.append({\n",
183-
" \"language\": lang,\n",
184-
" \"description\": description,\n",
185-
" \"en\": first_eng_caption,\n",
186-
" \"image_url\": image_url,\n",
187-
" })\n",
188198
"\n",
189199
"# Perform bulk indexing\n",
190200
"if bulk_data:\n",

0 commit comments

Comments
 (0)