Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Refresh notebook

davidmezzettic79562083c50
diff --git a/examples/01_Introducing_txtai.ipynb b/examples/01_Introducing_txtai.ipynb
index b8c5ce09..52e21f34 100644
--- a/examples/01_Introducing_txtai.ipynb
+++ b/examples/01_Introducing_txtai.ipynb
@@ -78,7 +78,7 @@
"# Install translation pipeline dependencies for later examples\n",
"!pip install sentencepiece sacremoses fasttext"
],
- "execution_count": null,
+ "execution_count": 1,
"outputs": []
},
{
@@ -118,7 +118,7 @@
"# Create an embeddings\n",
"embeddings = Embeddings(path=\"sentence-transformers/nli-mpnet-base-v2\")"
],
- "execution_count": null,
+ "execution_count": 2,
"outputs": []
},
{
@@ -129,7 +129,7 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
- "outputId": "ff163c33-b771-4914-e619-a94d6aba6a0a"
+ "outputId": "369b637e-1e1c-4229-f68e-92917be5fbd0"
},
"source": [
"# Create an index for the list of text\n",
@@ -147,7 +147,7 @@
" # Print text\n",
" print(\"%-20s %s\" % (query, data[uid]))"
],
- "execution_count": null,
+ "execution_count": 3,
"outputs": [
{
"output_type": "stream",
@@ -157,7 +157,7 @@
"--------------------------------------------------\n",
"feel good story Maine man wins $1M from $25 lottery ticket\n",
"climate change Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg\n",
- "public health story The National Park Service warns against sacrificing slower friends in a bear attack\n",
+ "public health story US tops 5 million confirmed virus cases\n",
"war Beijing mobilises invasion craft along coast as Taiwan tensions escalate\n",
"wildlife The National Park Service warns against sacrificing slower friends in a bear attack\n",
"asia Beijing mobilises invasion craft along coast as Taiwan tensions escalate\n",
@@ -196,7 +196,7 @@
"base_uri": "https://localhost:8080/"
},
"id": "2CERR0U2Ac8C",
- "outputId": "277ff4c6-7ca7-4960-8bb7-aa0fbf57da28"
+ "outputId": "0c1f4dd2-1319-410b-91a4-7753adba2c26"
},
"source": [
"# Run initial query\n",
@@ -220,7 +220,7 @@
"uid = embeddings.search(\"feel good story\", 1)[0][0]\n",
"print(\"After delete: \", udata[uid])"
],
- "execution_count": null,
+ "execution_count": 4,
"outputs": [
{
"output_type": "stream",
@@ -252,7 +252,7 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
- "outputId": "843931bf-06ab-4eb2-ca53-5579e2e4d8e4"
+ "outputId": "5460fcd8-5b9f-4064-9ac3-f72e5db9ecf4"
},
"source": [
"embeddings.save(\"index\")\n",
@@ -263,7 +263,7 @@
"uid = embeddings.search(\"climate change\", 1)[0][0]\n",
"print(data[uid])"
],
- "execution_count": null,
+ "execution_count": 5,
"outputs": [
{
"output_type": "stream",
@@ -313,9 +313,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "lclxiRFRqsFv",
- "outputId": "2b699284-ee8f-4f53-d001-3573adbdbc80"
+ "outputId": "3bd15b63-3bf4-4132-a819-0f560fce3f92"
},
- "execution_count": null,
+ "execution_count": 6,
"outputs": [
{
"output_type": "stream",
@@ -325,7 +325,7 @@
"--------------------------------------------------\n",
"feel good story Maine man wins $1M from $25 lottery ticket\n",
"climate change Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg\n",
- "public health story The National Park Service warns against sacrificing slower friends in a bear attack\n",
+ "public health story US tops 5 million confirmed virus cases\n",
"war Beijing mobilises invasion craft along coast as Taiwan tensions escalate\n",
"wildlife The National Park Service warns against sacrificing slower friends in a bear attack\n",
"asia Beijing mobilises invasion craft along coast as Taiwan tensions escalate\n",
@@ -361,9 +361,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "WykNb8y3vohL",
- "outputId": "79c92b57-c990-401f-8f03-2f35d3e8484a"
+ "outputId": "5617e912-1014-495c-9dc9-e5729988d77f"
},
- "execution_count": null,
+ "execution_count": 7,
"outputs": [
{
"output_type": "stream",
@@ -413,9 +413,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "MOntBQIdVv-J",
- "outputId": "d73427c7-f1f7-4e6b-8b26-a52bfe40c6ff"
+ "outputId": "c9d0d3e7-d7b4-4421-f63d-402db6918cca"
},
- "execution_count": null,
+ "execution_count": 8,
"outputs": [
{
"output_type": "stream",
@@ -468,16 +468,16 @@
"base_uri": "https://localhost:8080/"
},
"id": "aPH-dnV2ZuL1",
- "outputId": "5b72a137-83f9-44dd-b4d1-b5b776718701"
+ "outputId": "c563060c-d292-4b19-aa64-f4c629008cdb"
},
- "execution_count": null,
+ "execution_count": 9,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
- "[{'text': 'The National Park Service warns against sacrificing slower friends in a bear attack', 'score': 0.3172506093978882}]\n",
- "[{'text': 'Maine man wins $1M from $25 lottery ticket', 'length': 42, 'score': 0.08485741913318634}]\n",
+ "[{'text': 'The National Park Service warns against sacrificing slower friends in a bear attack', 'score': 0.3151373863220215}]\n",
+ "[{'text': 'Maine man wins $1M from $25 lottery ticket', 'length': 42, 'score': 0.08329027891159058}]\n",
"[{'count(*)': 6, 'min(length)': 39, 'max(length)': 94, 'sum(length)': 387}]\n"
]
}
@@ -530,9 +530,9 @@
"height": 307
},
"id": "Ef4-Gd8ZtzUF",
- "outputId": "775692ab-8b58-4c91-cadc-a7543448a1fb"
+ "outputId": "aaa811e8-ee3a-43ed-dab3-994ca6014a64"
},
- "execution_count": null,
+ "execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
@@ -547,7 +547,7 @@
"width": 600
}
},
- "execution_count": 63
+ "execution_count": 10
}
]
},
@@ -591,27 +591,27 @@
"base_uri": "https://localhost:8080/"
},
"id": "k7eRzturtCwr",
- "outputId": "87754cb5-2bf7-48f6-ea68-fe468da0e8e2"
+ "outputId": "794d10d6-8463-4e8c-c1d1-0af59e97e59f"
},
- "execution_count": null,
+ "execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
- "[{'topic': 'us_cases_million_confirmed',\n",
- " 'category': 'finance',\n",
+ "[{'topic': 'confirmed_cases_us_5',\n",
+ " 'category': 'health',\n",
" 'text': 'US tops 5 million confirmed virus cases'},\n",
- " {'topic': \"canada's_iceberg_suddenly_forming\",\n",
+ " {'topic': 'collapsed_iceberg_ice_intact',\n",
" 'category': 'climate',\n",
" 'text': \"Canada's last fully intact ice shelf has suddenly collapsed, forming a Manhattan-sized iceberg\"},\n",
- " {'topic': 'coast_taiwan_mobilises_escalate',\n",
+ " {'topic': 'beijing_along_craft_tensions',\n",
" 'category': 'world politics',\n",
" 'text': 'Beijing mobilises invasion craft along coast as Taiwan tensions escalate'}]"
]
},
"metadata": {},
- "execution_count": 64
+ "execution_count": 11
}
]
},
@@ -660,7 +660,7 @@
"metadata": {
"id": "TOwwKw3w_eJG"
},
- "execution_count": null,
+ "execution_count": 12,
"outputs": []
},
{
@@ -673,9 +673,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "M0HKb9mzxkL-",
- "outputId": "4b04946e-d0dd-4f32-d9ac-69b7693be76b"
+ "outputId": "16200bfc-715a-4dfe-89c4-cd6476c0425a"
},
- "execution_count": null,
+ "execution_count": 13,
"outputs": [
{
"output_type": "execute_result",
@@ -685,7 +685,7 @@
]
},
"metadata": {},
- "execution_count": 66
+ "execution_count": 13
}
]
},
@@ -699,9 +699,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "-SnA1s0kxw9x",
- "outputId": "3d9f0163-9978-4eda-968b-6cea4dffa550"
+ "outputId": "9f6d7cc6-7325-4ac4-ded0-aa0502d088e0"
},
- "execution_count": null,
+ "execution_count": 14,
"outputs": [
{
"output_type": "execute_result",
@@ -709,11 +709,11 @@
"text/plain": [
"[{'id': '4',\n",
" 'text': 'Maine man wins $1M from $25 lottery ticket',\n",
- " 'score': 0.08485741913318634}]"
+ " 'score': 0.08329027891159058}]"
]
},
"metadata": {},
- "execution_count": 67
+ "execution_count": 14
}
]
},
@@ -772,9 +772,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "vWX9Q6Iy0X3Z",
- "outputId": "2bfc4bdf-2a60-4a23-eeb4-5050e0036543"
+ "outputId": "82f9f9cc-b7fb-4ee9-cd35-9b00c022f83a"
},
- "execution_count": null,
+ "execution_count": 15,
"outputs": [
{
"output_type": "execute_result",
@@ -784,7 +784,7 @@
]
},
"metadata": {},
- "execution_count": 68
+ "execution_count": 15
}
]
},
@@ -810,9 +810,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "ioC-gY4wwWVQ",
- "outputId": "a223d780-ce2d-4cec-8d89-7c666f3037ff"
+ "outputId": "d6eab14a-83cd-434c-faa8-2afe285e842b"
},
- "execution_count": null,
+ "execution_count": 16,
"outputs": [
{
"output_type": "execute_result",
@@ -823,7 +823,7 @@
]
},
"metadata": {},
- "execution_count": 69
+ "execution_count": 16
}
]
},
@@ -850,9 +850,9 @@
"height": 36
},
"id": "NAFMSJO-k8qW",
- "outputId": "386c4a3f-0c17-46c4-9f04-29618b03105c"
+ "outputId": "c2b07b49-f50d-4f74-a2fe-17bc699a91f1"
},
- "execution_count": null,
+ "execution_count": 17,
"outputs": [
{
"output_type": "execute_result",
@@ -865,7 +865,7 @@
}
},
"metadata": {},
- "execution_count": 70
+ "execution_count": 17
}
]
},
@@ -914,9 +914,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "JFzSs_Wa012D",
- "outputId": "46454177-a1c8-49f2-d6ea-d652fc700f8c"
+ "outputId": "055e4f6d-a324-47ce-e3be-5aae06b28651"
},
- "execution_count": null,
+ "execution_count": 18,
"outputs": [
{
"output_type": "stream",
@@ -954,9 +954,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "ySOK3HDK1nOZ",
- "outputId": "bcc6e331-0695-4d06-f188-57879d24964a"
+ "outputId": "551f425d-8c99-4705-8dc8-7e23458a3ed5"
},
- "execution_count": null,
+ "execution_count": 19,
"outputs": [
{
"output_type": "execute_result",
@@ -966,7 +966,7 @@
]
},
"metadata": {},
- "execution_count": 72
+ "execution_count": 19
}
]
},
@@ -989,9 +989,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "hJAC430s4yIV",
- "outputId": "f1f03726-0ec7-456c-a7d9-7d5b6c098155"
+ "outputId": "8e0c4d6a-42d4-45e8-e79a-7872639c5512"
},
- "execution_count": null,
+ "execution_count": 20,
"outputs": [
{
"output_type": "execute_result",
@@ -1001,7 +1001,7 @@
]
},
"metadata": {},
- "execution_count": 73
+ "execution_count": 20
}
]
},
@@ -1038,9 +1038,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "zfwpSmTLnVU8",
- "outputId": "0b8447bb-9ae2-49dd-81ce-cf6e8ac20e25"
+ "outputId": "154a34ff-2919-415b-a5b7-fb7c9f5b9cf1"
},
- "execution_count": null,
+ "execution_count": 21,
"outputs": [
{
"output_type": "stream",
@@ -1067,9 +1067,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "8mo2XSr9nXJH",
- "outputId": "cf73d90e-736f-48ce-9b8f-8e6f47b7f3a3"
+ "outputId": "b9775570-4dd1-486e-f0c8-62f94fdb85b1"
},
- "execution_count": null,
+ "execution_count": 22,
"outputs": [
{
"output_type": "execute_result",
@@ -1079,7 +1079,7 @@
]
},
"metadata": {},
- "execution_count": 75
+ "execution_count": 22
}
]
},