💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Refresh and reorganize example notebooks, closes #52
davidmezzetti469a2fa2a915
diff --git a/README.md b/README.mdindex 6bcabaa8..392e2aa3 100644--- a/README.md+++ b/README.md@@ -93,12 +93,12 @@ The examples directory has a series of examples and notebooks giving an overview| Notebook | Description | ||:----------|:-------------|------:|| [Introducing txtai](https://github.com/neuml/txtai/blob/master/examples/01_Introducing_txtai.ipynb) | Overview of the functionality provided by txtai | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/01_Introducing_txtai.ipynb) |-| [Extractive QA with txtai](https://github.com/neuml/txtai/blob/master/examples/02_Extractive_QA_with_txtai.ipynb) | Extractive question-answering with txtai | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/02_Extractive_QA_with_txtai.ipynb) |+| [Build an Embeddings index with Hugging Face Datasets](https://github.com/neuml/txtai/blob/master/examples/02_Build_an_Embeddings_index_with_Hugging_Face_Datasets.ipynb) | Embedding index with Hugging Face Datasets | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/02_Build_an_Embeddings_index_with_Hugging_Face_Datasets) || [Build an Embeddings index from a data source](https://github.com/neuml/txtai/blob/master/examples/03_Build_an_Embeddings_index_from_a_data_source.ipynb) | Embeddings index from a data source backed by word embeddings | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/03_Build_an_Embeddings_index_from_a_data_source.ipynb) |-| [Extractive QA with Elasticsearch](https://github.com/neuml/txtai/blob/master/examples/04_Extractive_QA_with_Elasticsearch.ipynb) | Extractive question-answering with Elasticsearch | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/04_Extractive_QA_with_Elasticsearch.ipynb) |-| [Labeling with zero-shot classification](https://github.com/neuml/txtai/blob/master/examples/05_Labeling_with_zero_shot_classification.ipynb) | Labeling with zero-shot classification | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/05_Labeling_with_zero_shot_classification.ipynb) |-| [API Gallery](https://github.com/neuml/txtai/blob/master/examples/06_API_Gallery.ipynb) | Using txtai in JavaScript, Java, Rust and Go | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/06_API_Gallery.ipynb) |-| [Integrate with Hugging Face Datasets](https://github.com/neuml/txtai/blob/master/examples/07_Integrate_with_Hugging_Face_Datasets.ipynb) | Index and search Hugging Face Datasets | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/07_Integrate_with_Hugging_Face_Datasets) |+| [Extractive QA with txtai](https://github.com/neuml/txtai/blob/master/examples/04_Extractive_QA_with_txtai.ipynb) | Extractive question-answering with txtai | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/04_Extractive_QA_with_txtai.ipynb) |+| [Extractive QA with Elasticsearch](https://github.com/neuml/txtai/blob/master/examples/05_Extractive_QA_with_Elasticsearch.ipynb) | Extractive question-answering with Elasticsearch | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/05_Extractive_QA_with_Elasticsearch.ipynb) |+| [Labeling with zero-shot classification](https://github.com/neuml/txtai/blob/master/examples/06_Labeling_with_zero_shot_classification.ipynb) | Labeling with zero-shot classification | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/06_Labeling_with_zero_shot_classification.ipynb) |+| [API Gallery](https://github.com/neuml/txtai/blob/master/examples/07_API_Gallery.ipynb) | Using txtai in JavaScript, Java, Rust and Go | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/07_API_Gallery.ipynb) |## Configurationdiff --git a/examples/01_Introducing_txtai.ipynb b/examples/01_Introducing_txtai.ipynbindex 31a82f43..b8218f72 100644--- a/examples/01_Introducing_txtai.ipynb+++ b/examples/01_Introducing_txtai.ipynb@@ -33,13 +33,13 @@"source": ["# Part 1: Introducing txtai\n","\n",- "[txtai](https://github.com/neuml/txtai) builds an AI-powered index over sections of text. txtai supports building text indices to perform similarity searches and create extractive question-answering based systems. \n",+ "[txtai](https://github.com/neuml/txtai) builds an AI-powered index over sections of text. txtai supports building text indices to perform similarity searches and create extractive question-answering based systems. txtai also has functionality for zero-shot classification. \n","\n","NeuML uses txtai and/or the concepts behind it to power all of our Natural Language Processing (NLP) applications. Example applications:\n","\n","- [paperai](https://github.com/neuml/paperai) - AI-powered literature discovery and review engine for medical/scientific papers\n","- [tldrstory](https://github.com/neuml/tldrstory) - AI-powered understanding of headlines and story text\n",- "- [neuspo](https://neuspo.com) - a fact-driven, real-time sports event and news site\n",+ "- [neuspo](https://neuspo.com) - Fact-driven, real-time sports event and news site\n","- [codequestion](https://github.com/neuml/codequestion) - Ask coding questions directly from the terminal\n","\n","txtai is built on the following stack:\n",@@ -128,7 +128,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "b50e3b2c-337a-4bbe-cf7b-72eb2e75bada"+ "outputId": "86661189-5aec-43a9-8577-17017c1e99c9"},"source": ["import numpy as np\n",@@ -199,7 +199,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "cf66b86f-9c46-441d-e24c-2d00a455de59"+ "outputId": "f5fddb55-ff37-42bf-d85f-cac81304a6ad"},"source": ["# Create an index for the list of sections\n",@@ -256,7 +256,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "52db38d6-4a0f-4d81-bb77-60b5cf62eccd"+ "outputId": "4c1d124d-4ee2-4f2f-e79a-2a859a224e4d"},"source": ["embeddings.save(\"index\")\n",@@ -286,7 +286,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "abf029ec-9bf0-48c2-c2bd-07326b073010"+ "outputId": "3c35204b-eea7-4d5a-c27d-9eb1001996c8"},"source": ["!ls index"@@ -331,7 +331,7 @@},"source": ["# Next\n",- "In part 2 of this series, we'll look at how to use txtai to run extractive searches"+ "In part 2 of this series, we'll look at how to use txtai on larger datasets with the Hugging Face Datasets library."]}]diff --git a/examples/07_Integrate_with_Hugging_Face_Datasets.ipynb b/examples/02_Build_an_Embeddings_index_with_Hugging_Face_Datasets.ipynbsimilarity index 94%rename from examples/07_Integrate_with_Hugging_Face_Datasets.ipynbrename to examples/02_Build_an_Embeddings_index_with_Hugging_Face_Datasets.ipynbindex 069e552f..7114c415 100644--- a/examples/07_Integrate_with_Hugging_Face_Datasets.ipynb+++ b/examples/02_Build_an_Embeddings_index_with_Hugging_Face_Datasets.ipynb@@ -3,7 +3,7 @@"nbformat_minor": 0,"metadata": {"colab": {- "name": "07 - Integrate with Hugging Face Datasets",+ "name": "02 - Build an Embeddings index with Hugging Face Datasets","provenance": [],"collapsed_sections": []},@@ -20,9 +20,9 @@"id": "LjmhJ4ad9kBL"},"source": [- "# Part 7: Integrate with Hugging Face Datasets\n",+ "# Part 2: Build an Embeddings index with Hugging Face Datasets\n","\n",- "This notebook shows how txtai can integrate with Hugging Face's [Datasets](https://github.com/huggingface/datasets) library. Datasets opens access to a large and growing list of publicly available datasets. Datasets has functionality to select, transform and filter data stored in each dataset.\n",+ "This notebook shows how txtai can index and search with Hugging Face's [Datasets](https://github.com/huggingface/datasets) library. Datasets opens access to a large and growing list of publicly available datasets. Datasets has functionality to select, transform and filter data stored in each dataset.\n","\n","In this example, txtai will be used to index and query a dataset."]@@ -136,7 +136,7 @@"height": 1000},"id": "YVmbiY92vxEO",- "outputId": "095982b7-08df-455a-dbc8-93f770b1185f"+ "outputId": "46b94655-b9bf-4982-c7ed-2d6a0a251e39"},"source": ["from IPython.core.display import display, HTML\n",@@ -305,6 +305,16 @@}}]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "kDx7IBPXR1eS"+ },+ "source": [+ "# Next\n",+ "In part 3 of this series, we'll explore using word embeddings vs transformer embeddings."+ ]}]}\ No newline at end of filediff --git a/examples/03_Build_an_Embeddings_index_from_a_data_source.ipynb b/examples/03_Build_an_Embeddings_index_from_a_data_source.ipynbindex f54cba66..8ffbf6f1 100644--- a/examples/03_Build_an_Embeddings_index_from_a_data_source.ipynb+++ b/examples/03_Build_an_Embeddings_index_from_a_data_source.ipynb@@ -21,9 +21,9 @@"source": ["# Part 3: Build an Embeddings index from a data source\n","\n",- "In Part 1, we gave a general overview of txtai, the backing technology and examples of how to use it for similarity searches. Part 2 covered how to use txtai for extractive question-answer systems.\n",+ "In Part 1, we gave a general overview of txtai, the backing technology and examples of how to use it for similarity searches. Part 2 covered an embedding index with a larger dataset. \n","\n",- "The previous examples worked on data stored in memory for demo purposes. For real world large-scale use cases, data is usually stored in a database (Elasticsearch, SQL, MongoDB, files, etc). This example covers reading data from SQLite, building a Embedding index backed by word embeddings and running queries against the generated Embeddings index.\n",+ "For real world large-scale use cases, data is often stored in a database (Elasticsearch, SQL, MongoDB, files, etc). Here we'll show how to read from SQLite, build a Embedding index backed by word embeddings and run queries against the generated Embeddings index.\n","\n","This example covers functionality found in the [paperai](https://github.com/neuml/paperai) library. See that library for a full solution that can be used with the dataset discussed below."]@@ -61,48 +61,22 @@"\n","This example is going to work off a subset of the [CORD-19](https://www.semanticscholar.org/cord19) dataset. COVID-19 Open Research Dataset (CORD-19) is a free resource of scholarly articles, aggregated by a coalition of leading research groups, covering COVID-19 and the coronavirus family of viruses.\n","\n",- "The following download is SQLite database with a subject of CORD-19, generated from a [Kaggle notebook](https://www.kaggle.com/davidmezzetti/cord-19-slim/output). More information on this data format, can be found in the [CORD-19 Analysis](https://www.kaggle.com/davidmezzetti/cord-19-analysis-with-sentence-embeddings) notebook."+ "The following download is a SQLite database generated from a [Kaggle notebook](https://www.kaggle.com/davidmezzetti/cord-19-slim/output). More information on this data format, can be found in the [CORD-19 Analysis](https://www.kaggle.com/davidmezzetti/cord-19-analysis-with-sentence-embeddings) notebook."]},{"cell_type": "code","metadata": {- "id": "TONQ4_Kv9dtd",- "colab": {- "base_uri": "https://localhost:8080/"- },- "outputId": "86f08372-8418-4f02-c932-6e4db6e710bb"+ "id": "TONQ4_Kv9dtd"},"source": [+ "%%capture\n","!wget https://github.com/neuml/txtai/releases/download/v1.1.0/tests.gz\n","!gunzip tests.gz\n","!mv tests articles.sqlite"],"execution_count": 2,- "outputs": [- {- "output_type": "stream",- "text": [- "--2020-12-24 15:51:34-- https://github.com/neuml/txtai/releases/download/v1.1.0/tests.gz\n",- "Resolving github.com (github.com)... 140.82.113.3\n",- "Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n",- "HTTP request sent, awaiting response... 302 Found\n",- "Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/286301447/080d8800-e653-11ea-8d02-c0c858a09e7a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201224%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201224T155134Z&X-Amz-Expires=300&X-Amz-Signature=e9edf741855ab7e67d29082569baf7ce5ff3dd727f02bbd9420105b3bf892669&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=286301447&response-content-disposition=attachment%3B%20filename%3Dtests.gz&response-content-type=application%2Foctet-stream [following]\n",- "--2020-12-24 15:51:34-- https://github-production-release-asset-2e65be.s3.amazonaws.com/286301447/080d8800-e653-11ea-8d02-c0c858a09e7a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201224%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201224T155134Z&X-Amz-Expires=300&X-Amz-Signature=e9edf741855ab7e67d29082569baf7ce5ff3dd727f02bbd9420105b3bf892669&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=286301447&response-content-disposition=attachment%3B%20filename%3Dtests.gz&response-content-type=application%2Foctet-stream\n",- "Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.104.99\n",- "Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.104.99|:443... connected.\n",- "HTTP request sent, awaiting response... 200 OK\n",- "Length: 2456199 (2.3M) [application/octet-stream]\n",- "Saving to: ‘tests.gz’\n",- "\n",- "tests.gz 100%[===================>] 2.34M --.-KB/s in 0.09s \n",- "\n",- "2020-12-24 15:51:35 (25.3 MB/s) - ‘tests.gz’ saved [2456199/2456199]\n",- "\n"- ],- "name": "stdout"- }- ]+ "outputs": []},{"cell_type": "markdown",@@ -112,7 +86,7 @@"source": ["# Build Word Vectors\n","\n",- "This example will build a search system backed by word embeddings. While note quite as powerful as transformer embeddings, they often provide a good tradeoff of performance to functionality for an embedding based search system.\n",+ "This example will build a search system backed by word embeddings. While not quite as powerful as transformer embeddings, they often provide a good tradeoff of performance to functionality for an embedding based search system.\n","\n","For this notebook, we'll build our own custom embeddings for demo purposes. A number of pre-trained word embedding models are available:\n","\n",@@ -127,7 +101,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "a0b20a83-ab38-49da-8148-afa31c1f64cd"+ "outputId": "0360df2f-9c4b-4c1a-8495-a250ba9ae39f"},"source": ["import os\n",@@ -173,8 +147,8 @@"Converting vectors to magnitude format\n","total 78948\n","-rw-r--r-- 1 root root 8065024 Aug 25 01:44 articles.sqlite\n",- "-rw-r--r-- 1 root root 24145920 Dec 24 15:55 cord19-300d.magnitude\n",- "-rw-r--r-- 1 root root 48625387 Dec 24 15:54 cord19-300d.txt\n",+ "-rw-r--r-- 1 root root 24145920 Jan 7 01:39 cord19-300d.magnitude\n",+ "-rw-r--r-- 1 root root 48625387 Jan 7 01:38 cord19-300d.txt\n","drwxr-xr-x 1 root root 4096 Dec 21 17:29 sample_data\n"],"name": "stdout"@@ -189,7 +163,7 @@"source": ["# Build an embeddings index\n","\n",- "The following steps builds an embeddings index using the word vector model just created. This model builds a BM25 + fastText index. BM25 is used to build a weighted average of the word embeddings for a section. More information on this method can be found in this [Medium article](https://towardsdatascience.com/building-a-sentence-embedding-index-with-fasttext-and-bm25-f07e7148d240?gi=79da927aa10). "+ "The following steps build an embeddings index using the word vector model just created. This model builds a BM25 + fastText index. BM25 is used to build a weighted average of the word embeddings for a section. More information on this method can be found in this [Medium article](https://towardsdatascience.com/building-a-sentence-embedding-index-with-fasttext-and-bm25-f07e7148d240?gi=79da927aa10). "]},{@@ -199,7 +173,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "a05b496a-6fe3-44a9-fed3-1e1ff66e53a9"+ "outputId": "2f464dec-4c68-4079-d8a0-b62070a846c0"},"source": ["import sqlite3\n",@@ -285,7 +259,7 @@"base_uri": "https://localhost:8080/","height": 293},- "outputId": "97229a51-0b97-46d6-9e53-f29439cd0c9f"+ "outputId": "7c3ae07a-74a3-4603-89ef-cce0a6c51769"},"source": ["import pandas as pd\n",@@ -387,7 +361,7 @@"source": ["# Extracting additional columns from query results\n","\n",- "The example above uses the Embeddings index to find the top 5 best matches. In addition to this, an Extractor instance is used to ask additional questions over the search results, creating a richer query response."+ "The example above uses the Embeddings index to find the top 5 best matches. In addition to this, an Extractor instance (this will be explained further in part 4) is used to ask additional questions over the search results, creating a richer query response."]},{@@ -413,7 +387,7 @@"base_uri": "https://localhost:8080/","height": 293},- "outputId": "00332ff6-13e3-4af2-ce27-dc0670d6878c"+ "outputId": "61f60aad-e6a3-4572-f5f3-f44d7c520ec8"},"source": ["db = sqlite3.connect(\"articles.sqlite\")\n",@@ -533,7 +507,7 @@},"source": ["# Next\n",- "In part 4 of this series, we'll use combine the power of Elasticsearch with Extractive QA to build a large-scale, advanced search system.\n"+ "In part 4 of this series, we'll look at how to use txtai to run extractive searches"]}]diff --git a/examples/02_Extractive_QA_with_txtai.ipynb b/examples/04_Extractive_QA_with_txtai.ipynbsimilarity index 90%rename from examples/02_Extractive_QA_with_txtai.ipynbrename to examples/04_Extractive_QA_with_txtai.ipynbindex 9762847c..6b5d3980 100644--- a/examples/02_Extractive_QA_with_txtai.ipynb+++ b/examples/04_Extractive_QA_with_txtai.ipynb@@ -3,7 +3,7 @@"nbformat_minor": 0,"metadata": {"colab": {- "name": "02 - Extractive QA with txtai",+ "name": "04 - Extractive QA with txtai","provenance": []},"kernelspec": {@@ -18,9 +18,9 @@"id": "vwELCooy4ljr"},"source": [- "# Part 2: Extractive QA with txtai\n",+ "# Part 4: Extractive QA with txtai\n","\n",- "In Part 1, we gave a general overview of txtai, the backing technology and examples of how to use it for similarity searches. This notebook builds on that and extends to building extractive question-answering systems."+ "In Parts 1 through 3, we gave a general overview of txtai, the backing technology and examples of how to use it for similarity searches. This notebook builds on that and extends to building extractive question-answering systems."]},{@@ -88,7 +88,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "0e802561-f115-4f5e-ada3-f2605c2e458f"+ "outputId": "5c1ef8f8-3957-497e-ecee-2b574404292d"},"source": ["sections = [\"Giants hit 3 HRs to down Dodgers\",\n",@@ -158,7 +158,7 @@},"source": ["# Next\n",- "In part 3 of this series, we'll look at how to use txtai on larger datasets and explore using word embeddings vs transformer embeddings"+ "In part 5 of this series, we'll use combine the power of Elasticsearch with Extractive QA to build a large-scale, advanced search system."]}]diff --git a/examples/04_Extractive_QA_with_Elasticsearch.ipynb b/examples/05_Extractive_QA_with_Elasticsearch.ipynbsimilarity index 80%rename from examples/04_Extractive_QA_with_Elasticsearch.ipynbrename to examples/05_Extractive_QA_with_Elasticsearch.ipynbindex 8a6c5f13..32f51a6e 100644--- a/examples/04_Extractive_QA_with_Elasticsearch.ipynb+++ b/examples/05_Extractive_QA_with_Elasticsearch.ipynb@@ -3,7 +3,7 @@"nbformat_minor": 0,"metadata": {"colab": {- "name": "04 - Extractive QA with Elasticsearch",+ "name": "05 - Extractive QA with Elasticsearch","provenance": [],"collapsed_sections": []},@@ -19,9 +19,9 @@"id": "zzZbP0LM6m5z"},"source": [- "# Extractive QA with Elasticsearch\n",+ "# Part 5: Extractive QA with Elasticsearch\n","\n",- "txtai is datastore agnostic, the library analyzes sets of text. The following example shows how extractive question-answering can be added on top of an Elasticesearch system."+ "txtai is datastore agnostic, the library analyzes sets of text. The following example shows how extractive question-answering can be added on top of an Elasticsearch system."]},{@@ -51,7 +51,7 @@"!tar -xzf elasticsearch-7.8.1-linux-x86_64.tar.gz\n","!chown -R daemon:daemon elasticsearch-7.8.1"],- "execution_count": 1,+ "execution_count": 8,"outputs": []},{@@ -70,7 +70,7 @@"server = Popen(['elasticsearch-7.8.1/bin/elasticsearch'], stdout=PIPE, stderr=STDOUT, preexec_fn=lambda: os.setuid(1))\n","!sleep 30"],- "execution_count": 2,+ "execution_count": 9,"outputs": []},{@@ -83,48 +83,22 @@"\n","This example is going to work off a subset of the [CORD-19](https://www.semanticscholar.org/cord19) dataset. COVID-19 Open Research Dataset (CORD-19) is a free resource of scholarly articles, aggregated by a coalition of leading research groups, covering COVID-19 and the coronavirus family of viruses.\n","\n",- "The following download is SQLite database with a subject of CORD-19, generated from a [Kaggle notebook](https://www.kaggle.com/davidmezzetti/cord-19-slim/output). More information on this data format, can be found in the [CORD-19 Analysis](https://www.kaggle.com/davidmezzetti/cord-19-analysis-with-sentence-embeddings) notebook."+ "The following download is a SQLite database generated from a [Kaggle notebook](https://www.kaggle.com/davidmezzetti/cord-19-slim/output). More information on this data format, can be found in the [CORD-19 Analysis](https://www.kaggle.com/davidmezzetti/cord-19-analysis-with-sentence-embeddings) notebook."]},{"cell_type": "code","metadata": {- "id": "8tVrIqSq-KBa",- "colab": {- "base_uri": "https://localhost:8080/"- },- "outputId": "032600e4-3b80-4b22-e208-f97a89075b44"+ "id": "8tVrIqSq-KBa"},"source": [+ "%%capture\n","!wget https://github.com/neuml/txtai/releases/download/v1.1.0/tests.gz\n","!gunzip tests.gz\n","!mv tests articles.sqlite"],- "execution_count": 3,- "outputs": [- {- "output_type": "stream",- "text": [- "--2020-12-24 15:52:18-- https://github.com/neuml/txtai/releases/download/v1.1.0/tests.gz\n",- "Resolving github.com (github.com)... 140.82.113.3\n",- "Connecting to github.com (github.com)|140.82.113.3|:443... connected.\n",- "HTTP request sent, awaiting response... 302 Found\n",- "Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/286301447/080d8800-e653-11ea-8d02-c0c858a09e7a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201224%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201224T155134Z&X-Amz-Expires=300&X-Amz-Signature=e9edf741855ab7e67d29082569baf7ce5ff3dd727f02bbd9420105b3bf892669&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=286301447&response-content-disposition=attachment%3B%20filename%3Dtests.gz&response-content-type=application%2Foctet-stream [following]\n",- "--2020-12-24 15:52:18-- https://github-production-release-asset-2e65be.s3.amazonaws.com/286301447/080d8800-e653-11ea-8d02-c0c858a09e7a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201224%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201224T155134Z&X-Amz-Expires=300&X-Amz-Signature=e9edf741855ab7e67d29082569baf7ce5ff3dd727f02bbd9420105b3bf892669&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=286301447&response-content-disposition=attachment%3B%20filename%3Dtests.gz&response-content-type=application%2Foctet-stream\n",- "Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.217.96.132\n",- "Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.217.96.132|:443... connected.\n",- "HTTP request sent, awaiting response... 200 OK\n",- "Length: 2456199 (2.3M) [application/octet-stream]\n",- "Saving to: ‘tests.gz’\n",- "\n",- "tests.gz 100%[===================>] 2.34M --.-KB/s in 0.09s \n",- "\n",- "2020-12-24 15:52:18 (25.4 MB/s) - ‘tests.gz’ saved [2456199/2456199]\n",- "\n"- ],- "name": "stdout"- }- ]+ "execution_count": 10,+ "outputs": []},{"cell_type": "markdown",@@ -144,7 +118,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "1b400e43-4852-427c-891b-01be632cc6ad"+ "outputId": "96399343-0a96-4c4c-aacc-a55b73df8c08"},"source": ["import sqlite3\n",@@ -195,7 +169,7 @@"\n","print(\"Total articles inserted: {}\".format(rows))\n"],- "execution_count": 4,+ "execution_count": 11,"outputs": [{"output_type": "stream",@@ -226,7 +200,7 @@"base_uri": "https://localhost:8080/","height": 293},- "outputId": "b3c14060-0d9a-451c-af89-e01759851ef4"+ "outputId": "27953588-c372-4dcb-cf24-b5e664624d5a"},"source": ["import pandas as pd\n",@@ -252,7 +226,7 @@"\n","display(HTML(df.to_html(index=False)))"],- "execution_count": 5,+ "execution_count": 12,"outputs": [{"output_type": "display_data",@@ -269,6 +243,12 @@" </thead>\n"," <tbody>\n"," <tr>\n",+ " <td>Management of osteoarthritis during COVID‐19 pandemic</td>\n",+ " <td>2020-05-21 00:00:00</td>\n",+ " <td>https://doi.org/10.1002/cpt.1910</td>\n",+ " <td>Indeed, risk factors are sex, obesity, genetic factors and mechanical factors (3) .</td>\n",+ " </tr>\n",+ " <tr>\n"," <td>Prevalence and Impact of Myocardial Injury in Patients Hospitalized with COVID-19 Infection</td>\n"," <td>2020-04-24 00:00:00</td>\n"," <td>http://medrxiv.org/cgi/content/short/2020.04.20.20072702v1?rss=1</td>\n",@@ -292,12 +272,6 @@" <td>https://doi.org/10.7150/ijbs.45134</td>\n"," <td>• Three major risk factors for COVID-19 were sex (male), age (≥60), and severe pneumonia.</td>\n"," </tr>\n",- " <tr>\n",- " <td>Associations with covid-19 hospitalisation amongst 406,793 adults: the UK Biobank prospective cohort study</td>\n",- " <td>2020-05-11 00:00:00</td>\n",- " <td>http://medrxiv.org/cgi/content/short/2020.05.06.20092957v1?rss=1</td>\n",- " <td>In addition, many risk factors for covid-19 documented in the literature are highly correlated and it is not clear which may be independently related to risk.</td>\n",- " </tr>\n"," </tbody>\n","</table>"],@@ -327,7 +301,7 @@"# Create extractor instance using qa model designed for the CORD-19 dataset\n","extractor = Extractor(embeddings, \"NeuML/bert-small-cord19qa\")"],- "execution_count": 6,+ "execution_count": 13,"outputs": []},{@@ -338,7 +312,7 @@"base_uri": "https://localhost:8080/","height": 328},- "outputId": "fba7fd0b-5017-4c94-a15c-b691277d464f"+ "outputId": "6461efc2-cbed-4e05-c5d4-13eb9c9f60bb"},"source": ["document = {\n",@@ -379,7 +353,7 @@"\n","display(HTML(df.to_html(index=False)))"],- "execution_count": 7,+ "execution_count": 14,"outputs": [{"output_type": "display_data",@@ -457,7 +431,7 @@},"source": ["# Next\n",- "Part 5 of this series uses zero-shot classification to apply labels to input text.\n"+ "Part 6 of this series uses zero-shot classification to apply labels to input text.\n"]}]diff --git a/examples/05_Labeling_with_zero_shot_classification.ipynb b/examples/06_Labeling_with_zero_shot_classification.ipynbsimilarity index 96%rename from examples/05_Labeling_with_zero_shot_classification.ipynbrename to examples/06_Labeling_with_zero_shot_classification.ipynbindex a61fdbc8..cd46c252 100644--- a/examples/05_Labeling_with_zero_shot_classification.ipynb+++ b/examples/06_Labeling_with_zero_shot_classification.ipynb@@ -3,7 +3,7 @@"nbformat_minor": 0,"metadata": {"colab": {- "name": "05 - Labeling with zero-shot classification",+ "name": "06 - Labeling with zero-shot classification","provenance": [],"collapsed_sections": []},@@ -19,7 +19,7 @@"id": "4Pjmz-RORV8E"},"source": [- "# Part 5: Labeling with zero-shot classification\n",+ "# Part 6: Labeling with zero-shot classification\n","\n","This notebook shows how zero-shot classification can be used to perform text classification/labeling. txtai provides a light-weight wrapper around the zero-shot-classification pipeline in Hugging Face Transformers. This method works impressively well out of the box. Kudos to the Hugging Face team for the phenomenal work on zero-shot classification!\n","\n",@@ -103,7 +103,7 @@"base_uri": "https://localhost:8080/"},"id": "-K2YJJzsVtfq",- "outputId": "ce2e7c95-14cc-4972-c030-bcbf424cf1c0"+ "outputId": "f7185ce7-f4b4-4290-bf2c-44210e7f21c0"},"source": ["sections = [\"Dodgers lose again, give up 3 HRs in a loss to the Giants\",\n",@@ -170,7 +170,7 @@"base_uri": "https://localhost:8080/"},"id": "uIf064M9pbjn",- "outputId": "75e38914-6491-42cb-d915-6ab55f681f9d"+ "outputId": "ccb8c2ee-cc06-424b-caf2-1e8162e7a0c1"},"source": ["tags = [\"😀\", \"😡\"]\n",@@ -212,7 +212,7 @@},"source": ["# Next\n",- "Part 6 of this series shows how to use the txtai API."+ "Part 7 of this series shows how to use the txtai API."]}]diff --git a/examples/06_API_Gallery.ipynb b/examples/07_API_Gallery.ipynbsimilarity index 96%rename from examples/06_API_Gallery.ipynbrename to examples/07_API_Gallery.ipynbindex 443e9fcc..e710793c 100644--- a/examples/06_API_Gallery.ipynb+++ b/examples/07_API_Gallery.ipynb@@ -3,7 +3,7 @@"nbformat_minor": 0,"metadata": {"colab": {- "name": "06 - API Gallery",+ "name": "07 - API Gallery","provenance": [],"collapsed_sections": []},@@ -19,13 +19,11 @@"id": "4Pjmz-RORV8E"},"source": [- "# Part 6: API Gallery\n",+ "# Part 7: API Gallery\n","\n","The txtai API is a web-based service backed by [FastAPI](https://fastapi.tiangolo.com/). All txtai functionality including similarity search, extractive QA and zero-shot labeling is available via the API.\n","\n",- "This notebook installs the txtai API and shows an example using each of the supported language bindings for txtai.\n",- "\n",- "The examples in this notebook are **Christmas themed! 🎅❄️🎄🎁**"+ "This notebook installs the txtai API and shows an example using each of the supported language bindings for txtai."]},{@@ -128,7 +126,7 @@"height": 324},"id": "-K2YJJzsVtfq",- "outputId": "9e979db5-d25d-4f50-b7ee-e353e4ff9d23"+ "outputId": "8f740a3a-c380-474a-f1aa-8c26adfb3c85"},"source": ["sections = [\"Wears a red suit and says ho ho\",\n",@@ -203,7 +201,7 @@"colab": {"base_uri": "https://localhost:8080/"},- "outputId": "c9b3aedf-63d5-45f0-c55a-c154bdfdba01"+ "outputId": "8cc1e672-00ac-4495-f2ed-d1d7ae482105"},"source": ["%%writefile index.yml\n",@@ -216,7 +214,7 @@{"output_type": "stream","text": [- "Overwriting index.yml\n"+ "Writing index.yml\n"],"name": "stdout"}@@ -281,7 +279,7 @@"base_uri": "https://localhost:8080/"},"id": "zJbKRTSJV-kd",- "outputId": "61847d78-69dc-4b03-afb0-e2107bd16265"+ "outputId": "46da8eb8-3c0c-42bd-a9bf-6c4af265be9f"},"source": ["%%writefile txtai.js/examples/node/src/labels.js\n",@@ -362,7 +360,7 @@"base_uri": "https://localhost:8080/"},"id": "ckOHNqyaeL-B",- "outputId": "8e12e280-da43-4ef7-9e91-121b9569802c"+ "outputId": "993dda3b-e7ac-4ac9-9b34-9bd4dbe6e229"},"source": ["!node dist/labels.js"@@ -441,7 +439,7 @@"base_uri": "https://localhost:8080/"},"id": "v73L8Gw0p6fh",- "outputId": "76a7d9d8-029c-4dd5-e47a-e1414a2d4930"+ "outputId": "c9a7b89f-2ec2-4ccb-c64b-3dd467936fbb"},"source": ["%%writefile txtai.java/examples/src/main/java/LabelsDemo.java\n",@@ -508,7 +506,7 @@"base_uri": "https://localhost:8080/"},"id": "N2Mm3Gl5sH1z",- "outputId": "084ed3f1-2f23-4d7d-be44-fba8700b9f24"+ "outputId": "eb9b04af-7442-4290-88e9-5a8eec07f8e1"},"source": ["os.chdir(\"txtai.java/examples\")\n",@@ -592,7 +590,7 @@"base_uri": "https://localhost:8080/"},"id": "jjggKnKQ7jQO",- "outputId": "c8b3ab7d-2699-43e9-c2d2-c46c9d09b3e6"+ "outputId": "d4924ae2-b8a8-45ce-9295-b2cd2d57125d"},"source": ["%%writefile txtai.rs/examples/demo/src/labels.rs\n",@@ -665,7 +663,7 @@"base_uri": "https://localhost:8080/"},"id": "-_v_FbL0-yPk",- "outputId": "ad31b672-0022-4482-d9b5-9cab38e9b3d6"+ "outputId": "5d00872d-491b-4cfc-9622-8e38ea31c3d7"},"source": ["!cargo run labels"@@ -675,7 +673,7 @@{"output_type": "stream","text": [- "\u001b[0m\u001b[0m\u001b[1m\u001b[32m Finished\u001b[0m dev [unoptimized + debuginfo] target(s) in 0.07s\n",+ "\u001b[0m\u001b[0m\u001b[1m\u001b[32m Finished\u001b[0m dev [unoptimized + debuginfo] target(s) in 0.08s\n","\u001b[0m\u001b[0m\u001b[1m\u001b[32m Running\u001b[0m `target/debug/demo labels`\n","Text Label\n","---------------------------------------------------------------------------\n",@@ -747,7 +745,7 @@"base_uri": "https://localhost:8080/"},"id": "bLBJwkN4ANpi",- "outputId": "8a02aa7f-21a4-4434-eceb-54f4a2bf80c3"+ "outputId": "62c80276-678c-4e88-9637-ca2df507b176"},"source": ["%%writefile labels.go\n",@@ -785,7 +783,7 @@{"output_type": "stream","text": [- "Overwriting labels.go\n"+ "Writing labels.go\n"],"name": "stdout"}@@ -807,7 +805,7 @@"base_uri": "https://localhost:8080/"},"id": "l1xnUbtdAy0p",- "outputId": "0bcdad5d-3e2c-4823-e7ab-87532fe06ae5"+ "outputId": "7f802a37-14c9-42bf-f1b9-8c539fcf58be"},"source": ["!go run labels.go"