Update example notebooks

This commit is contained in:
davidmezzetti
2023-03-29 14:26:56 -04:00
parent 49c2b8350f
commit 8434fa5aec
44 changed files with 169 additions and 334 deletions
+9 -7
View File
@@ -32,27 +32,29 @@
"source": [
"# Introducing txtai\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications. \n",
"[txtai](https://github.com/neuml/txtai) is an open-source platform for semantic search and workflows powered by language models.\n",
"\n",
"Traditional search systems use keywords to find data. Semantic search applications have an understanding of natural language and identify results that have the same meaning, not necessarily the same keywords.\n",
"Traditional search systems use keywords to find data. Semantic search has an understanding of natural language and identifies results that have the same meaning, not necessarily the same keywords.\n",
"\n",
"Backed by state-of-the-art machine learning models, data is transformed into vector representations for search (also known as embeddings). Innovation is happening at a rapid pace, models can understand concepts in documents, audio, images and video.\n",
"Data is transformed into embeddings and stored in vector indexes for search.\n",
"\n",
"The following is a summary of key features:\n",
"\n",
"- 🔎 Large-scale similarity search with multiple index backends ([Faiss](https://github.com/facebookresearch/faiss), [Annoy](https://github.com/spotify/annoy), [Hnswlib](https://github.com/nmslib/hnswlib)) and support for external vector databases\n",
"- 📄 Create embeddings for text snippets, documents, audio, images and video\n",
"- 💡 Machine-learning pipelines that run question-answering, labeling, transcription, translation, summarization, LLM prompts and more\n",
"- 📄 Create embeddings for text, documents, audio, images and video\n",
"- 💡 Pipelines powered by language models that run question-answering, labeling, transcription, translation, summarization, LLM prompts and more\n",
"- ↪️️ Workflows to join pipelines together and aggregate business logic. txtai processes can be microservices or full-fledged indexing workflows.\n",
"- ⚙️ Build with Python or YAML. API bindings available for [JavaScript](https://github.com/neuml/txtai.js), [Java](https://github.com/neuml/txtai.java), [Rust](https://github.com/neuml/txtai.rs) and [Go](https://github.com/neuml/txtai.go).\n",
"- ☁️ Cloud-native architecture that scales out with container orchestration systems (e.g. Kubernetes)\n",
"\n",
"Applications range from similarity search to NLP-driven data extractions that generate structured data. The following applications are powered by txtai.\n",
"Integrate vector search, conversational search, automatic summarization, transcription, translation and more.\n",
"\n",
"The following applications are powered by txtai.\n",
"\n",
"- [txtchat](https://github.com/neuml/txtchat) - Conversational search and workflows for all\n",
"- [paperai](https://github.com/neuml/paperai) - Semantic search and workflows for medical/scientific papers\n",
"- [codequestion](https://github.com/neuml/codequestion) - Semantic search for developers\n",
"- [tldrstory](https://github.com/neuml/tldrstory) - Semantic search for headlines and story text\n",
"- [neuspo](https://neuspo.com) - Fact-driven, real-time sports event and news site\n",
"\n",
"txtai is built with Python 3.7+, [Hugging Face Transformers](https://github.com/huggingface/transformers), [Sentence Transformers](https://github.com/UKPLab/sentence-transformers) and [FastAPI](https://github.com/tiangolo/fastapi)\n",
"\n",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "02 - Build an Embeddings index with Hugging Face Datasets",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -22,8 +20,6 @@
"source": [
"# Build an Embeddings index with Hugging Face Datasets\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\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.\n",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "03 - Build an Embeddings index from a data source",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Build an Embeddings index from a data source\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\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 an embedding index with a larger dataset. \n",
"\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",
@@ -4,9 +4,7 @@
"metadata": {
"accelerator": "GPU",
"colab": {
"name": "04 - Add semantic search to Elasticsearch",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
@@ -22,8 +20,6 @@
"source": [
"# Add semantic search to Elasticsearch\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Part 2 and Part 3 of this series showed how to index and search data in txtai. Part 2 indexed and searched a Hugging Face Dataset, Part 3 indexed and searched an external data source. \n",
"\n",
"txtai is modular in design, it's components can be individually used. txtai has a similarity function that works on lists of text. This method can be integrated with any external search service, such as a REST API, a SQL query or anything else that returns text search results. \n",
+1 -5
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "05 - Extractive QA with txtai",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Extractive QA with txtai\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"In Parts 1 through 4, 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."
]
},
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "06 - Extractive QA with Elasticsearch",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Extractive QA with Elasticsearch\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\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 Elasticsearch system."
]
},
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "07 - Apply labels with zero-shot classification",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Apply labels with zero-shot classification\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"This notebook shows how zero-shot classification can be used to perform text classification, labeling and topic modeling. 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",
"The examples in this notebook pick the best matching label using a list of labels for a snippet of text.\n",
+1 -5
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "08 - API Gallery",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
@@ -21,8 +19,6 @@
"source": [
"# API Gallery\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\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."
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "09 - Building abstractive text summaries",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Building abstractive text summaries\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"In the field of text summarization, there are two primary categories of summarization, extractive and abstractive summarization.\n",
"\n",
"Extractive summarization takes subsections of the text and joins them together to form a summary. This is commonly backed by graph algorithms like TextRank to find the sections/sentences with the most commonality. These summaries can be highly effective but they are unable to transform text and don't have a contextual understanding.\n",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "10 - Extract text from documents",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Extract text from documents\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Up to this point, all the examples have been working with sections of text, which have already been split through some other means. What happens if we're working with documents? First we need to get the text out of these documents, then figure out how to index to best support similarity search.\n",
"\n",
"This notebook shows how documents can have text extracted and segmented to support similarity search."
+10 -13
View File
@@ -3,8 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -20,8 +19,6 @@
"source": [
"# Transcribe audio to text\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"This notebook covers the transcription of audio files to text using models provided by Hugging Face."
]
},
@@ -49,7 +46,7 @@
"!wget -N https://github.com/neuml/txtai/releases/download/v3.5.0/tests.tar.gz\n",
"!tar -xvzf tests.tar.gz"
],
"execution_count": 8,
"execution_count": null,
"outputs": []
},
{
@@ -79,7 +76,7 @@
"# Create transcription model\n",
"transcribe = Transcription()"
],
"execution_count": 9,
"execution_count": null,
"outputs": []
},
{
@@ -114,7 +111,7 @@
" print(text)\n",
" print()\n"
],
"execution_count": 10,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -303,7 +300,7 @@
"id": "-KgYwAQzFVll",
"outputId": "7b1e9541-1a6f-4814-ae14-21f4bd9794e7"
},
"execution_count": 11,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -356,13 +353,13 @@
"id": "k3Rb2OU9Mq3h",
"outputId": "5e40ecd5-3df1-4864-c7a3-3e26bd087415"
},
"execution_count": 12,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Writing workflow.yml\n"
"Overwriting workflow.yml\n"
]
}
]
@@ -384,7 +381,7 @@
"id": "cj49U095IxTc",
"outputId": "a55b8717-f5fc-4e8f-ef1b-5fecc3f8200a"
},
"execution_count": 26,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -431,7 +428,7 @@
"id": "XDpqwf8PNHNo",
"outputId": "7ec28122-69a3-47cc-d2ed-acaa186e4aa1"
},
"execution_count": 29,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -463,4 +460,4 @@
}
}
]
}
}
@@ -3,8 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
@@ -20,8 +19,6 @@
"source": [
"# Translate text between languages\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"This notebook covers machine translation backed by Hugging Face models. The quality of machine translation via cloud services has come a very long way and produces high quality results. This notebook shows how the models from Hugging Face give developers a reasonable alternative for local machine translation."
]
},
@@ -45,7 +42,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai#egg=txtai[pipeline]"
],
"execution_count": 1,
"execution_count": null,
"outputs": []
},
{
@@ -75,7 +72,7 @@
"# Create translation model\n",
"translate = Translation()"
],
"execution_count": 14,
"execution_count": null,
"outputs": []
},
{
@@ -103,7 +100,7 @@
"translation = translate(\"This is a test translation into Spanish\", \"es\")\n",
"translation"
],
"execution_count": 16,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -133,7 +130,7 @@
"source": [
"translate(translation, \"en\")"
],
"execution_count": 17,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -185,7 +182,7 @@
"# Run multiple translations\n",
"run()"
],
"execution_count": 18,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -251,7 +248,7 @@
"id": "REb0X2Kz60Ew",
"outputId": "ae13d4d0-318f-4740-f725-0029ceeabeac"
},
"execution_count": 11,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -291,7 +288,7 @@
"id": "d5usam_jhKaz",
"outputId": "c12368a0-ea26-4191-be5a-f2de70711003"
},
"execution_count": 12,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -330,7 +327,7 @@
"id": "JkOLnvKZWI95",
"outputId": "fef6402c-e20e-43e1-a3eb-e4580913fa7e"
},
"execution_count": 13,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "13 - Similarity search with images",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -22,8 +20,6 @@
"source": [
"# Similarity search with images\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"txtai as the name implies works with text and ai, pretty straightforward. But that doesn't mean it can't work with different types of content. For example, an image can be described with words. We can use that description to compare an image to a query or other documents. This notebook shows how images and text can be embedded into the same space to support similarity search."
]
},
+11 -15
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "14 - Run pipeline workflows",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -22,8 +20,6 @@
"source": [
"# Run pipeline workflows\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"txtai has a growing list of models available through it's pipeline framework. Pipelines wrap a machine learning model and transform data. Currently, pipelines can wrap Hugging Face models, Hugging Face pipelines or PyTorch models (support for TensorFlow is in the backlog).\n",
"\n",
"The following is a list of the currently implemented pipelines.\n",
@@ -64,7 +60,7 @@
"!wget -N https://github.com/neuml/txtai/releases/download/v2.0.0/tests.tar.gz\n",
"!tar -xvzf tests.tar.gz"
],
"execution_count": 11,
"execution_count": null,
"outputs": []
},
{
@@ -97,7 +93,7 @@
"# Create a translation instance\n",
"translate = Translation()"
],
"execution_count": 12,
"execution_count": null,
"outputs": []
},
{
@@ -132,7 +128,7 @@
"# Workflows are generators for efficiency, read results to list for display\n",
"list(workflow(data))"
],
"execution_count": 13,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -201,7 +197,7 @@
"# Run workflow\n",
"list(workflow(data))"
],
"execution_count": 14,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -288,7 +284,7 @@
"# Cleanup temporary storage\n",
"documents.close()"
],
"execution_count": 15,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -327,7 +323,7 @@
"# Run a search query and show the result.\n",
"embeddings.search(\"changement climatique\", 1)[0]"
],
"execution_count": 16,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -356,7 +352,7 @@
"# Run a search query and show the result.\n",
"embeddings.search(\"traitement du langage naturel\", 1)[0]"
],
"execution_count": 17,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -437,7 +433,7 @@
"id": "HoVlk_vNJKHY",
"outputId": "34b68bcb-a6d5-4029-9bf2-f33e4381d1bc"
},
"execution_count": 18,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -470,7 +466,7 @@
"id": "a_klVZAXHJcw",
"outputId": "33229268-0f98-4ca1-af7d-212bcbde6482"
},
"execution_count": 19,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -499,7 +495,7 @@
"id": "I5xin0VNHJOu",
"outputId": "2fbb9a93-b860-437d-c361-ee21eed75b6b"
},
"execution_count": 20,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "15 - Distributed embeddings cluster",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Distributed embeddings cluster\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"The txtai API is a web-based service backed by [FastAPI](https://fastapi.tiangolo.com/). All txtai functionality is available via the API. The API can also cluster multiple embeddings indices into a single logical index to horizontally scale over multiple nodes. \n",
"\n",
"This notebook installs the txtai API and shows an example of building an embeddings cluster."
+1 -5
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "16 - Train a text labeler",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -22,8 +20,6 @@
"source": [
"# Train a text labeler\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"The [Hugging Face Model Hub](https://huggingface.co/models) has a wide range of models that can handle many tasks. While these models perform well, the best performance often is found when fine-tuning a model with task-specific data. \n",
"\n",
"Hugging Face provides a [number of full-featured examples](https://github.com/huggingface/transformers/tree/master/examples) available to assist with training task-specific models. When building models from the command line, these scripts are a great way to get started.\n",
+1 -5
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "17 - Train without labels",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -22,8 +20,6 @@
"source": [
"# Train without labels\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Almost all data available is unlabeled. Labeled data takes effort to manually review and/or takes time to collect. Zero-shot classification takes existing large language models and runs a similarity comparison between candidate text and a list of labels. This has been shown to perform surprisingly well.\n",
"\n",
"The problem with zero-shot classifiers is that they need to have a large number of parameters (400M+) to perform well against general tasks, which comes with sizable hardware requirements.\n",
@@ -21,8 +21,6 @@
"source": [
"# Export and run models with ONNX\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"The [ONNX runtime](https://onnx.ai/) provides a common serialization format for machine learning models. ONNX supports a number of [different platforms/languages](https://onnxruntime.ai/docs/how-to/install.html#requirements) and has features built in to help reduce inference time. \n",
"\n",
"PyTorch has robust support for exporting Torch models to ONNX. This enables exporting Hugging Face Transformer and/or other downstream models directly to ONNX. \n",
@@ -1351,4 +1349,4 @@
]
}
]
}
}
+1 -5
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "19 - Train a QA model",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -22,8 +20,6 @@
"source": [
"# Train a QA model\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"The [Hugging Face Model Hub](https://huggingface.co/models) has a wide range of models that can handle many tasks. While these models perform well, the best performance is often found when fine-tuning a model with task-specific data. \n",
"\n",
"Hugging Face provides a [number of full-featured examples](https://github.com/huggingface/transformers/tree/master/examples) to assist with training task-specific models. When building models from the command line, these scripts are a great way to get started.\n",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "20 - Extractive QA to build structured data",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,8 +19,6 @@
"source": [
"# Extractive QA to build structured data\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Traditional ETL/data parsing systems establish rules to extract information of interest. Regular expressions, string parsing and similar methods define fixed rules. This works in many cases but what if you are working with unstructured data containing numerous variations? The rules can be cumbersome and hard to maintain over time.\n",
"\n",
"This notebook uses machine learning and extractive question-answering (QA) to utilize the vast knowledge built into large language models. These models have been trained on extremely large datasets, learning the many variations of natural language. "
@@ -22,8 +22,6 @@
"source": [
"# Export and run other machine learning models\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"txtai primarily has support for [Hugging Face Transformers](https://github.com/huggingface/transformers) and [ONNX](https://github.com/microsoft/onnxruntime) models. This enables txtai to hook into the rich model framework available in Python, export this functionality via the API to other languages (JavaScript, Java, Go, Rust) and even export and natively load models with ONNX.\n",
"\n",
"What about other machine learning frameworks? Say we have an existing TF-IDF + Logistic Regression model that has been well tuned. Can this model be exported to ONNX and used in txtai for labeling and similarity queries? Or what about a simple PyTorch text classifier? Yes, both of these can be done!\n",
@@ -22,8 +22,6 @@
"source": [
"# Transform tabular data with composable workflows\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"txtai executes machine-learning workflows to transform data and build AI-powered semantic search applications. txtai has support for processing both unstructured and structured data. Structured or tabular data is grouped into rows and columns. This can be a spreadsheet, an API call that returns JSON or XML or even list of key-value pairs.\n",
"\n",
"This notebook will walk through examples on how to use workflows with the tabular pipeline to transform and index structured data.\n"
-2
View File
@@ -22,8 +22,6 @@
"source": [
"# Tensor workflows\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Many of the examples and use cases for txtai focus on transforming text. Makes sense as txt is even in the name! But that doesn't mean txtai only works with text.\n",
"\n",
"This notebook will cover examples of how to efficiently process tensors using txtai workflows."
+1 -5
View File
@@ -34,10 +34,6 @@
"source": [
"# 💡 What's new in txtai 4.0\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai 4.0 brings a number of major feature enhancements, most importantly the capability to store full document content and text right in txtai. This notebook will cover all the changes with examples."
]
},
@@ -573,4 +569,4 @@
]
}
]
}
}
@@ -8,8 +8,6 @@
"source": [
"# Generate image captions and detect objects\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"txtai as the name implies works with text and ai, pretty straightforward. But that doesn't mean it can't work with different types of content. For example, an image can be described with words. We can use that description to compare an image to a query or other documents. This notebook shows how images and text can be embedded into the same space to generate image captions and detect objects."
]
},
@@ -34,8 +34,6 @@
"source": [
"# Entity extraction workflows\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Entity extraction is the process of identifying names, locations, organizations and other entity-like tokens in unstructured text. Entity extraction can organize data into topics and/or feed downstream machine learning pipelines.\n",
"\n",
"This notebook will show how to use the entity extraction pipeline in txtai with workflows."
+1 -3
View File
@@ -22,8 +22,6 @@
"source": [
"# Workflow scheduling\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Workflows are a simple yet powerful construct that takes a callable and returns elements. They are streaming and work on data in batches, allowing large volumes of data to be processed efficiently. When working with streaming data, workflows continually run until the data stream is exhausted. \n",
"\n",
"Workflows can also be scheduled to run. In this case, a static set of elements, dynamically expands. For example, an API service endpoint that returns items, or polling a directory with files coming in and out. \n",
@@ -441,4 +439,4 @@
}
}
]
}
}
@@ -22,8 +22,6 @@
"source": [
"# Push notifications with workflows\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Workflows are a simple yet powerful construct that takes a callable and returns elements. They are streaming and work on data in batches, allowing large volumes of data to be processed efficiently.\n",
"\n",
"This notebook will show how workflows can be used to push notifications upon certain event triggers. Using this method, an activity feed of content can be created."
+13 -19
View File
@@ -20,9 +20,7 @@
"file_extension": ".py"
},
"colab": {
"name": "29 - Anatomy of a txtai index",
"provenance": [],
"collapsed_sections": []
"provenance": []
}
},
"cells": [
@@ -34,10 +32,6 @@
"source": [
"# Anatomy of a txtai index\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"This notebook inspects the filesystem of a txtai embeddings index and gives an overview of the structure."
]
},
@@ -66,7 +60,7 @@
"!pip install git+https://github.com/neuml/txtai\n",
"!apt-get update && apt-get install -y file xxd"
],
"execution_count": 25,
"execution_count": null,
"outputs": []
},
{
@@ -110,7 +104,7 @@
"# Run a search\n",
"embeddings.search(\"feel good story\", 1)"
],
"execution_count": 26,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -150,7 +144,7 @@
"id": "o7nKY0AWxBWU",
"outputId": "be7eca6e-dbbc-40c5-df1f-9726554de476"
},
"execution_count": 27,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -209,7 +203,7 @@
"id": "aPH-dnV2ZuL1",
"outputId": "6d8d1329-a2e8-4538-b197-0e2959b9eef2"
},
"execution_count": 28,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -285,7 +279,7 @@
"id": "aNQSCiXHzOTj",
"outputId": "00b5ebdf-961b-45ac-d90c-e6b824c11979"
},
"execution_count": 29,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -369,7 +363,7 @@
"id": "32TmOeRZ0Lec",
"outputId": "895b569c-3509-4f38-c4eb-36340d718d15"
},
"execution_count": 30,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -617,7 +611,7 @@
"id": "ofIHY-pV7kWH",
"outputId": "f990cc01-e235-4010-ccfd-fdbb5692cabe"
},
"execution_count": 31,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -666,7 +660,7 @@
"id": "0oOC8ToG1pyn",
"outputId": "6fa8a8a7-3831-4307-a818-a4b62f8a81e8"
},
"execution_count": 32,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -734,7 +728,7 @@
},
"outputId": "0f290fdc-2bb7-4022-e4a0-1dc54b080bc5"
},
"execution_count": 33,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -967,7 +961,7 @@
"id": "lz7xwroECzx2",
"outputId": "3740cb3b-5904-453e-af93-5ee98c14652d"
},
"execution_count": 34,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -1009,7 +1003,7 @@
"id": "DXWf90-UDM0H",
"outputId": "7c31c4ea-5e2d-4873-d9cf-d9b7e6196754"
},
"execution_count": 35,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -1048,7 +1042,7 @@
"id": "RaJPqDV3I3sm",
"outputId": "3c416f6f-2ca6-481b-dc53-193e89f7da3e"
},
"execution_count": 36,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -20,9 +20,7 @@
"file_extension": ".py"
},
"colab": {
"name": "30 - Embeddings SQL custom functions",
"provenance": [],
"collapsed_sections": []
"provenance": []
}
},
"cells": [
@@ -34,10 +32,6 @@
"source": [
"# Embeddings SQL custom functions\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai 4.0 added support for SQL-based embeddings queries. This feature combines natural language queries for similarity with concrete filtering rules. txtai now has support for user-defined SQL functions, making this feature even more powerful."
]
},
@@ -65,7 +59,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai#egg=txtai[pipeline]"
],
"execution_count": 13,
"execution_count": null,
"outputs": []
},
{
@@ -109,7 +103,7 @@
"# Run a search\n",
"embeddings.search(\"feel good story\", 1)"
],
"execution_count": 14,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -158,7 +152,7 @@
"id": "rbsEXtysDDNg",
"outputId": "f966be17-086b-49b4-e1af-62b766f1c995"
},
"execution_count": 15,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -228,7 +222,7 @@
"id": "83e8yXpXFh4F",
"outputId": "0b17e9be-8983-418d-9903-b1e72efc5918"
},
"execution_count": 16,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -288,7 +282,7 @@
"id": "L2DDJrd0RAaN",
"outputId": "0bb437ec-5c9b-4a0c-fe8a-07f641c94a49"
},
"execution_count": 17,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -347,7 +341,7 @@
"id": "FZ_7G6M4RUbz",
"outputId": "4eca94f3-d2aa-4449-dc6f-f1091ad9dd67"
},
"execution_count": 18,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -32,10 +32,6 @@
"source": [
"# Near duplicate image detection\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"This notebook will give an overview of how perceptual image hashes can be used to detect duplicate and near duplicate images."
]
},
@@ -67,7 +63,7 @@
"!wget -N https://github.com/neuml/txtai/releases/download/v3.5.0/tests.tar.gz\n",
"!tar -xvzf tests.tar.gz"
],
"execution_count": 15,
"execution_count": null,
"outputs": []
},
{
@@ -111,7 +107,7 @@
"id": "Qch4TtJPgdg0",
"outputId": "0f4b9cf4-570e-424b-8f69-84dce3b5badc"
},
"execution_count": 16,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -172,7 +168,7 @@
"id": "csFOHf5Ri66U",
"outputId": "20a8a47e-2ebd-4e1e-d893-df37ff5a59a7"
},
"execution_count": 17,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -219,7 +215,7 @@
"id": "c40UPAUVjjfM",
"outputId": "282689c9-f179-4bfb-9311-b7e8ca2b6e93"
},
"execution_count": 18,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -286,7 +282,7 @@
"id": "nJh6xkT8le0r",
"outputId": "f874ae12-a5b8-438c-e883-d948ae87e68c"
},
"execution_count": 19,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
+9 -15
View File
@@ -20,9 +20,7 @@
"file_extension": ".py"
},
"colab": {
"name": "32 - Model explainability",
"provenance": [],
"collapsed_sections": []
"provenance": []
}
},
"cells": [
@@ -34,10 +32,6 @@
"source": [
"# Model explainability\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"Neural/transformers based approaches have recently made amazing advancements. But it is difficult to understand how models make decisions. This is especially important in sensitive areas where models are being used to drive critical decisions.\n",
"\n",
"This notebook will cover how to gain a level of understanding of complex natural language model outputs."
@@ -67,7 +61,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai#egg=txtai[pipeline] shap"
],
"execution_count": 28,
"execution_count": null,
"outputs": []
},
{
@@ -111,7 +105,7 @@
},
"outputId": "956e405c-568b-44bc-b8ea-d4b6f3cea9b5"
},
"execution_count": 29,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -189,7 +183,7 @@
"id": "klJYGOrypXUL",
"outputId": "88959716-1dcc-4fee-d784-cb398aa87eb5"
},
"execution_count": 30,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -232,7 +226,7 @@
"id": "OOc8OfKfcpPL",
"outputId": "75541eb6-f607-42b7-c2c8-43346fa7da8f"
},
"execution_count": 31,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -274,7 +268,7 @@
"id": "viuEwL4scQjx",
"outputId": "cb65e678-b694-4fe6-eb94-dea821bda643"
},
"execution_count": 32,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -325,7 +319,7 @@
"id": "Nwrd3v6cdKR_",
"outputId": "da949ae7-f681-4197-9df2-d5e2cb304f24"
},
"execution_count": 33,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -397,7 +391,7 @@
"id": "YW_qbzPKpRdL",
"outputId": "c21b3558-feed-4854-9444-954f87aa8422"
},
"execution_count": 46,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -664,7 +658,7 @@
"id": "SU2hHRjCpc_I",
"outputId": "83e1ada5-de45-426a-ae64-dae5b66b8e6a"
},
"execution_count": 48,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
+11 -17
View File
@@ -20,9 +20,7 @@
"file_extension": ".py"
},
"colab": {
"name": "33 - Query translation",
"provenance": [],
"collapsed_sections": []
"provenance": []
}
},
"cells": [
@@ -34,10 +32,6 @@
"source": [
"# Query translation\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai supports two main types of queries: natural language statements and SQL statements. Natural language queries handles a search engine like query. SQL statements enable more complex filtering, sorting and column selection. Query translation bridges the gap between the two and enables filtering for natural language queries.\n",
"\n",
"For example, the query:\n",
@@ -78,7 +72,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai#egg=txtai[pipeline]"
],
"execution_count": 29,
"execution_count": null,
"outputs": []
},
{
@@ -122,7 +116,7 @@
"# Run a search\n",
"embeddings.search(\"feel good story\", 1)"
],
"execution_count": 30,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -180,7 +174,7 @@
"id": "04iOgP_ojSfK",
"outputId": "41e73130-75e6-4ae9-b690-685972a13565"
},
"execution_count": 31,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -261,7 +255,7 @@
"id": "L2DDJrd0RAaN",
"outputId": "c60bfc29-187b-4926-8656-04063b2ca85c"
},
"execution_count": 32,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -298,7 +292,7 @@
"id": "mnGSBNMonur2",
"outputId": "dc14d898-b46f-42e6-88e0-434863cc15d6"
},
"execution_count": 33,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -335,7 +329,7 @@
"id": "Js2b_M61oitg",
"outputId": "fab080cb-d082-4cf3-8314-12d23acc3c02"
},
"execution_count": 34,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -363,7 +357,7 @@
"id": "pcxPgriwomWv",
"outputId": "7e71dd09-7c4f-4147-ba9e-47a45c1cf90f"
},
"execution_count": 35,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -400,7 +394,7 @@
"id": "LMaf7JJzonAC",
"outputId": "71080bd1-2d9e-41ba-9501-2cdedaf26d6d"
},
"execution_count": 36,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -426,7 +420,7 @@
"id": "ADFNLhvto_0J",
"outputId": "12e08ea8-7203-4fb0-cb84-1133b5db9dc0"
},
"execution_count": 37,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -484,7 +478,7 @@
"id": "FZ_7G6M4RUbz",
"outputId": "b00ce1c2-8df2-4289-8d03-991174a0e74f"
},
"execution_count": 38,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
-4
View File
@@ -35,10 +35,6 @@
"source": [
"# Build a QA database\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"Conversational AI is a growing field that could potentially automate much of the customer service industry. Full automation is still a ways away (most of us have been on a call with an automated agent and just want to get to a person) but it certainly can be a solid first line before human intervention.\n",
"\n",
"This notebook presents a process to answer user questions using a txtai embeddings instance. It's not conversational AI but instead looks to find the closest existing question to a user question. This is useful in cases where there are a list of frequently asked questions. "
@@ -8,10 +8,6 @@
"source": [
"# Pictures are worth a thousand words\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"One of the hottest🔥 models as of June 2022 is [DALL-E mini](https://wandb.ai/dalle-mini/dalle-mini/reports/DALL-E-mini-Generate-images-from-any-text-prompt--VmlldzoyMDE4NDAy). There are a number of projects and examples utilizing this model as seen [here](https://huggingface.co/spaces/dalle-mini/dalle-mini), [here](https://github.com/borisdayma/dalle-mini) and [here](https://github.com/kuprel/min-dalle). There have even been mainstream news articles covering this model.\n",
"\n",
"This notebook presents a workflow to build a summary of a webpage and then generate an image of this summary. While there are a number of potential use cases for text to image models, this example is focused on showing the power of workflows and also provides interesting insights into how DALL-E mini \"sees\" the world."
+15 -21
View File
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "36 - Run txtai in native code",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -23,10 +21,6 @@
"source": [
"# Run txtai in native code\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai currently has two main methods of execution: Python or via a HTTP API. There are API bindings for [JavaScript](https://github.com/neuml/txtai.js), [Java](https://github.com/neuml/txtai.java), [Rust](https://github.com/neuml/txtai.rs) and [Go](https://github.com/neuml/txtai.go).\n",
"\n",
"This notebook presents a way to run txtai as part of a native executable with the [Python C API](https://docs.python.org/3/c-api/index.html). We'll run an example in C and even call txtai from assembly code!\n",
@@ -50,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"id": "xEvX9vCpn4E0"
},
@@ -114,7 +108,7 @@
"id": "DPWrubv5oOn7",
"outputId": "bdfba131-c36e-421d-8c17-a726be4615d2"
},
"execution_count": 2,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -252,7 +246,7 @@
"id": "rv64SWDkpmIx",
"outputId": "1c19ae3c-7f06-43ac-8638-37ee7b5e4eab"
},
"execution_count": 3,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -311,7 +305,7 @@
"id": "apBnMta8pepD",
"outputId": "e6573cec-6b92-424c-e594-aa46c7cd18b6"
},
"execution_count": 4,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -343,7 +337,7 @@
"metadata": {
"id": "KjQYctCqp1Vi"
},
"execution_count": 16,
"execution_count": null,
"outputs": []
},
{
@@ -358,7 +352,7 @@
"id": "t5IWOF8ap-a7",
"outputId": "071f3d26-955e-4e10-cce4-5ed9774960d5"
},
"execution_count": 17,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -395,7 +389,7 @@
"id": "SLq5ix5mGPAb",
"outputId": "a46720e6-c721-4df5-92a7-a1bd897511d0"
},
"execution_count": 7,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -473,7 +467,7 @@
"id": "osrjXJonqcTm",
"outputId": "b2d662d0-2a71-4b53-a956-c9277c4a7d2b"
},
"execution_count": 8,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -495,7 +489,7 @@
"metadata": {
"id": "sQMEx0LFq80Z"
},
"execution_count": 9,
"execution_count": null,
"outputs": []
},
{
@@ -510,7 +504,7 @@
"id": "YG6faU7HrCrH",
"outputId": "a7a77cbf-5806-4241-cd67-03e79438e6f2"
},
"execution_count": 10,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -616,7 +610,7 @@
"id": "wzTYCSaqCSZu",
"outputId": "1f48015f-7654-4d86-9f2a-2e462c22f4e6"
},
"execution_count": 11,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -639,7 +633,7 @@
"id": "BSmdBuPhIIbw",
"outputId": "b45c1ea5-e0fb-4331-f033-5370cdc2ead0"
},
"execution_count": 12,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -665,7 +659,7 @@
"metadata": {
"id": "HoRsPeorC5rC"
},
"execution_count": 13,
"execution_count": null,
"outputs": []
},
{
@@ -680,7 +674,7 @@
"id": "7Da6TZlDC8Mj",
"outputId": "e2b46994-62d1-42d1-ab77-0d690a7d7d67"
},
"execution_count": 14,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -3,9 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "37 - Embeddings index components",
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -23,10 +21,6 @@
"source": [
"# Embeddings index components\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"The main components of txtai are `embeddings`, `pipeline`, `workflow` and an `api`. The following shows the top level view of the txtai src tree.\n",
"\n",
"```\n",
@@ -22,10 +22,6 @@
"source": [
"# Introducing the Semantic Graph\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"One of the main use cases of txtai is semantic search over a corpus of data. Semantic search provides an understanding of natural language and identifies results that have the same meaning, not necessarily the same keywords. Within an Embeddings instance sits a wealth of implied knowledge and relationships between rows. Many approximate nearest neighbor (ANN) indexes are even backed by graphs. What if we are able to tap into this knowledge?\n",
"\n",
"Semantic graphs, also known as knowledge graphs or semantic networks, build a graph network with semantic relationships connecting the nodes. In txtai, they can take advantage of the relationships inherently learned within an embeddings index. This opens exciting possibilities for exploring relationships, such as topics and interconnections in a dataset. \n",
@@ -1491,4 +1487,4 @@
}
}
]
}
}
@@ -3,8 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": []
"provenance": []
},
"kernelspec": {
"name": "python3",
@@ -21,10 +20,6 @@
"source": [
"# Classic Topic Modeling with BM25\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai 5.0 introduced topic modeling via [semantic graphs](https://neuml.hashnode.dev/introducing-the-semantic-graph). Semantic graphs can be easily integrated into an embeddings instance to add topic modeling to a txtai index.\n",
"\n",
"In addition to transformers-backed models, txtai also has support for traditional indexing methods. Given the modular design of txtai, traditional scoring methods like BM25 can be combined with graphs to build topic models. \n",
@@ -48,7 +43,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"id": "xEvX9vCpn4E0"
},
@@ -115,7 +110,7 @@
"id": "LJ2FskiiQ_l_",
"outputId": "fc4685d9-5ec2-4fbe-a347-857a74b9b509"
},
"execution_count": 3,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -151,7 +146,7 @@
"id": "slLtmzfbRuf6",
"outputId": "27aca9cb-8704-475c-c38d-01da65328686"
},
"execution_count": 4,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -225,7 +220,7 @@
"metadata": {
"id": "MEpZAr0TUMCK"
},
"execution_count": 7,
"execution_count": null,
"outputs": []
},
{
@@ -249,7 +244,7 @@
"id": "HyKiVFBerQfw",
"outputId": "fdba468b-bac1-4f63-c915-5fcad78880f7"
},
"execution_count": 10,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -295,7 +290,7 @@
"id": "sYd9nKqYrwhe",
"outputId": "0db63a74-2c01-433a-d754-6f0988894ffe"
},
"execution_count": 44,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -343,7 +338,7 @@
"id": "hpwfJFcRv19j",
"outputId": "0bb4d53d-27c2-42f5-cfaf-89c785cb73da"
},
"execution_count": 85,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -400,7 +395,7 @@
"metadata": {
"id": "oodIUmwrsZRd"
},
"execution_count": 23,
"execution_count": null,
"outputs": []
},
{
@@ -416,7 +411,7 @@
"id": "gZzStey9tEkl",
"outputId": "8e6398d5-0fd8-465c-ce95-45b98eb2c195"
},
"execution_count": 43,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
+1 -3
View File
@@ -21,8 +21,6 @@
"source": [
"# Text to speech generation\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"Text To Speech (TTS) models have made great strides in quality over the last few years. Unfortunately, it's not currently possible to use these libraries without installing a large number of dependencies.\n",
"\n",
"The txtai TextToSpeech pipeline has the following objectives:\n",
@@ -432,4 +430,4 @@
}
}
]
}
}
@@ -21,10 +21,6 @@
"source": [
"# Train a language model from scratch\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai has a robust training pipeline that can fine-tune large language models (LLMs) for downstream tasks such as labeling text. txtai also has the ability to train language models from scratch.\n",
"\n",
"The vast majority of time, fine-tuning a LLM yields the best results. But when making significant changes to the structure of a model, training from scratch is often required.\n",
@@ -21,11 +21,6 @@
"source": [
"# Prompt-driven search with LLMs\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"This notebook revisits the Extractor pipeline, which has been covered in a number of previous notebooks. This pipeline is a combination of a similarity instance (embeddings or similarity pipeline) to build a question context and a model that answers questions.\n",
"\n",
"The Extractor pipeline recently underwent a number of major upgrades to support the following.\n",
@@ -56,7 +51,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai datasets"
],
"execution_count": 25,
"execution_count": null,
"outputs": []
},
{
@@ -91,7 +86,7 @@
"# Create extractor instance\n",
"extractor = Extractor(embeddings, \"google/flan-t5-base\")"
],
"execution_count": 26,
"execution_count": null,
"outputs": []
},
{
@@ -101,7 +96,7 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "141284a7-83e3-4c28-bb14-cef9d47a7650"
"outputId": "cacb7e9d-471a-437d-c68d-a8b51f876413"
},
"source": [
"data = [\"Giants hit 3 HRs to down Dodgers\",\n",
@@ -134,7 +129,7 @@
" print(answer)\n",
" print()"
],
"execution_count": 27,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -204,9 +199,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "yL716oEZ43t-",
"outputId": "835a72bd-ab7e-48c5-96b1-66ab8da1e5b2"
"outputId": "23f4b0e7-a60a-4e89-fb57-06966e6612f8"
},
"execution_count": 28,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -253,9 +248,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "5O1WBJ8153Mo",
"outputId": "e60d5c1b-088c-4e50-da3a-d61781b9dd7c"
"outputId": "ddf09da2-7d4c-4fd3-b0da-df5631bacd13"
},
"execution_count": 29,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -292,9 +287,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "h7BsoJC3CFOq",
"outputId": "9d522335-5f2f-4853-98cb-98ec09fcfcc4"
"outputId": "44ae0dec-4f79-4d44-88f5-585e5eae9cb2"
},
"execution_count": 30,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -345,9 +340,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "0NNLBwC-83MM",
"outputId": "6d3c926d-b0f1-4b62-d1d9-afd252a4c3bb"
"outputId": "4b9fabd7-baf9-4f7d-bb8b-c9c60c5101e4"
},
"execution_count": 31,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -370,9 +365,9 @@
"height": 36
},
"id": "1P0zqkTW9cZW",
"outputId": "f1bd4a7c-5936-4cfd-d25d-23811c0a3abe"
"outputId": "4f2232db-761b-464f-b47d-6695c84ffb80"
},
"execution_count": 32,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -385,7 +380,7 @@
}
},
"metadata": {},
"execution_count": 32
"execution_count": 8
}
]
},
@@ -414,9 +409,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "qZPhLqSxGMbK",
"outputId": "790dae79-ad76-4522-a434-c40238a3549b"
"outputId": "e3b2909a-1ee8-480f-afa3-201a8e27cb08"
},
"execution_count": 33,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -503,9 +498,9 @@
"base_uri": "https://localhost:8080/"
},
"id": "yYAa9N7EYm7E",
"outputId": "4bbd59d7-4ade-41f0-86e2-882c1eef6a34"
"outputId": "72208327-bfb7-466f-c664-3630f207b6dd"
},
"execution_count": 37,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
+11 -15
View File
@@ -21,10 +21,6 @@
"source": [
"# Embeddings in the Cloud\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"Embeddings is the engine that delivers semantic search. Data is transformed into embeddings vectors where similar concepts will produce similar vectors. Indexes both large and small are built with these vectors. The indexes are used to find results that have the same meaning, not necessarily the same keywords. \n",
"\n",
"In addition to local storage, embeddings can be synced with cloud storage. Given that txtai is a fully encapsulated index format, cloud sync is simply a matter of moving a group of files to and from cloud storage. This can be object storage such as AWS S3/Azure Blob/Google Cloud or the [Hugging Face Hub](https://hf.co/models). More details on available options can be found in the [documentation](https://neuml.github.io/txtai/embeddings/configuration/cloud/). There is also an [article](https://medium.com/neuml/serverless-vector-search-with-txtai-96f6163ab972) available that covers how to build and store indexes in cloud object storage.\n",
@@ -52,7 +48,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai"
],
"execution_count": 1,
"execution_count": null,
"outputs": []
},
{
@@ -81,7 +77,7 @@
"embeddings = Embeddings()\n",
"embeddings.load(provider=\"huggingface-hub\", container=\"neuml/txtai-intro\")"
],
"execution_count": 2,
"execution_count": null,
"outputs": []
},
{
@@ -114,7 +110,7 @@
" # Print text\n",
" print(\"%-20s %s\" % (query, result[\"text\"]))"
],
"execution_count": 3,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -167,7 +163,7 @@
"metadata": {
"id": "yL716oEZ43t-"
},
"execution_count": 4,
"execution_count": null,
"outputs": []
},
{
@@ -183,7 +179,7 @@
"metadata": {
"id": "1V8nrm9IHPQc"
},
"execution_count": 5,
"execution_count": null,
"outputs": []
},
{
@@ -211,7 +207,7 @@
"id": "5O1WBJ8153Mo",
"outputId": "f20e0688-54e7-43ce-e2f9-6f11f94026bc"
},
"execution_count": 6,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -252,7 +248,7 @@
"id": "V4_tI2urWyZ3",
"outputId": "3101db94-2ad8-4ea9-f646-411f57b3027b"
},
"execution_count": 7,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -293,7 +289,7 @@
"id": "N1owMgfqW6ZO",
"outputId": "04699cc3-6127-4a76-83c0-b105ce1924b2"
},
"execution_count": 8,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -334,7 +330,7 @@
"id": "wqIAc67RXdpR",
"outputId": "37c273fa-c3e5-4d91-dbfe-3d09d31be127"
},
"execution_count": 9,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -395,7 +391,7 @@
"id": "h7BsoJC3CFOq",
"outputId": "1e8f2ff2-6847-460f-b5b8-9e546fd7bf62"
},
"execution_count": 10,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -446,7 +442,7 @@
"id": "NWvENgWNU23V",
"outputId": "7008c6e5-8fbc-4275-fa6a-8d32d7ea3fbd"
},
"execution_count": 11,
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
@@ -21,11 +21,6 @@
"source": [
"# Prompt templates and task chains\n",
"\n",
"_This notebook is part of a tutorial series on [txtai](https://github.com/neuml/txtai), an AI-powered semantic search platform._\n",
"\n",
"\n",
"[txtai](https://github.com/neuml/txtai) executes machine-learning workflows to transform data and build AI-powered semantic search applications.\n",
"\n",
"txtai has long had support for workflows. Workflows connect the input and outputs of machine learning models together to create powerful transformation and processing functions.\n",
"\n",
"There has been a recent surge in interest in \"model prompting\", which is the process of building a natural language description of a task and passing it to a large language model (LLM). txtai has recently improved support for task templating, which builds string outputs from a set of parameters.\n",
@@ -53,7 +48,7 @@
"%%capture\n",
"!pip install git+https://github.com/neuml/txtai#egg=txtai[api]"
],
"execution_count": 1,
"execution_count": null,
"outputs": []
},
{
@@ -106,7 +101,7 @@
"\n",
"print(list(workflow(inputs)))"
],
"execution_count": 17,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -168,7 +163,7 @@
"id": "GwV5A9xRYtYs",
"outputId": "ffe6ee65-95a7-46c6-e6b9-5324eab26ca8"
},
"execution_count": 2,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -194,7 +189,7 @@
"id": "dr7Lv5S5X98e",
"outputId": "d6ac0427-671d-4525-aa21-664430109af3"
},
"execution_count": 18,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -235,7 +230,7 @@
"metadata": {
"id": "vDxQj1ZIYsz3"
},
"execution_count": 3,
"execution_count": null,
"outputs": []
},
{
@@ -253,7 +248,7 @@
"id": "R1o08SVtZW7h",
"outputId": "99875acd-18a8-4c2c-ead3-cb6975a4b2d2"
},
"execution_count": 5,
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
@@ -300,7 +295,7 @@
"id": "hRUyh0cQl_P2",
"outputId": "9db8481d-0b6e-4a31-bdf6-5443df5f768a"
},
"execution_count": 15,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -371,7 +366,7 @@
"id": "rM3Y551LqF-J",
"outputId": "85623785-c15f-4996-9460-0644f69cf5bf"
},
"execution_count": 20,
"execution_count": null,
"outputs": [
{
"output_type": "stream",
@@ -395,7 +390,7 @@
"id": "1Elb8JANqpwX",
"outputId": "b1f1ffa1-6c47-4d90-b6f1-8098d4dc45f8"
},
"execution_count": 45,
"execution_count": null,
"outputs": [
{
"output_type": "stream",