From 50f1296a8e98efef1ff577e2d06b6767a7ac4ded Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Wed, 14 Aug 2024 16:47:23 -0400 Subject: [PATCH 1/6] Updated cohere notebook for video --- ...d-cohere-elasticsearch-inference-api.ipynb | 495 ++++++++++++++++++ 1 file changed, 495 insertions(+) create mode 100644 notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb diff --git a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb new file mode 100644 index 00000000..9c7fbd5c --- /dev/null +++ b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb @@ -0,0 +1,495 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "68a13ecd", + "metadata": {}, + "source": [ + "# Tutorial: Using Cohere with the elastic open inference API\n", + "\n", + "## TODO [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]()\n", + "\n", + "This tutorial shows you how to compute embeddings with\n", + "Cohere using the elastic open inference API and store them for efficient vector or hybrid\n", + "search in Elasticsearch. This tutorial uses the Python Elasticsearch client\n", + "to perform the operations.\n", + "\n", + "You'll learn how to:\n", + "* create an inference endpoint for text embedding using the Cohere service,\n", + "* create the necessary index mapping for the Elasticsearch index using semantic search,\n", + "* rerank with retrievers using Cohere's rerank model,\n", + "* design a RAG system with Cohere's Chat API.\n", + "\n", + "The tutorial uses the [gqd/fictional-characters](https://huggingface.co/datasets/gqd/fictional-characters/blob/main/heros.json) data set.\n", + "\n", + "Refer to [Cohere's tutorial](https://docs.cohere.com/docs/elasticsearch-and-cohere) for an example using a different data set." + ] + }, + { + "cell_type": "markdown", + "id": "7f068b1b", + "metadata": {}, + "source": [ + "## 🧰 Requirements\n", + "\n", + "For this example, you will need:\n", + "\n", + "- An Elastic deployment:\n", + " - We'll be using [Elastic serverless](https://www.elastic.co/docs/current/serverless) for this example (available with a [free trial](https://cloud.elastic.co/registration?utm_source=github&utm_content=elasticsearch-labs-notebook))\n", + " \n", + "- A paid [Cohere account](https://cohere.com/) is required to use the Open Inference API with \n", + "the Cohere service as the Cohere free trial API usage is limited.\n", + "\n", + "- Python 3.7+.\n", + "\n", + "- the 8.15+ python elasticsearch client" + ] + }, + { + "cell_type": "markdown", + "id": "aac02d37", + "metadata": {}, + "source": [ + "## Install and import required packages\n", + "\n", + "Install Elasticsearch and Cohere:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "50940b4d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: elasticsearch==8.15 in /Users/mh/.venv/lib/python3.11/site-packages (8.15.0)\n", + "Requirement already satisfied: elastic-transport<9,>=8.13 in /Users/mh/.venv/lib/python3.11/site-packages (from elasticsearch==8.15) (8.13.1)\n", + "Requirement already satisfied: urllib3<3,>=1.26.2 in /Users/mh/.venv/lib/python3.11/site-packages (from elastic-transport<9,>=8.13->elasticsearch==8.15) (2.1.0)\n", + "Requirement already satisfied: certifi in /Users/mh/.venv/lib/python3.11/site-packages (from elastic-transport<9,>=8.13->elasticsearch==8.15) (2023.11.17)\n", + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" + ] + } + ], + "source": [ + "!pip install elasticsearch==8.15" + ] + }, + { + "cell_type": "markdown", + "id": "3b24d95b", + "metadata": {}, + "source": [ + "Import the required packages:" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "1a5a5eeb", + "metadata": {}, + "outputs": [], + "source": [ + "from elasticsearch import Elasticsearch, helpers\n", + "import json\n", + "import requests\n", + "from getpass import getpass" + ] + }, + { + "cell_type": "markdown", + "id": "3d0dacc5", + "metadata": {}, + "source": [ + "## Create an Elasticsearch client" + ] + }, + { + "cell_type": "markdown", + "id": "74841401", + "metadata": {}, + "source": [ + "Now you can instantiate the Python Elasticsearch client.\n", + "\n", + "First provide your password and Cloud ID.\n", + "Then create a `client` object that instantiates an instance of the `Elasticsearch` class." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "76394974", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "Elasticsearch.__init__() got an unexpected keyword argument 'endpoint'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[13], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m ELASTIC_API_KEY \u001b[38;5;241m=\u001b[39m getpass(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mElastic API key: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Create the client instance\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m client \u001b[38;5;241m=\u001b[39m \u001b[43mElasticsearch\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# For local development\u001b[39;49;00m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# hosts=[\"http://localhost:9200\"]\u001b[39;49;00m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[43mendpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mELASTIC_SERVERLESS_ENDPOINT\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[43mapi_key\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mELASTIC_API_KEY\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 13\u001b[0m \u001b[38;5;66;03m# Confirm the client has connected\u001b[39;00m\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28mprint\u001b[39m(client\u001b[38;5;241m.\u001b[39minfo())\n", + "\u001b[0;31mTypeError\u001b[0m: Elasticsearch.__init__() got an unexpected keyword argument 'endpoint'" + ] + } + ], + "source": [ + "ELASTIC_SERVERLESS_ENDPOINT = getpass(\"Elastic serverless endpoint: \")\n", + "# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#creating-an-api-key\n", + "ELASTIC_API_KEY = getpass(\"Elastic API key: \")\n", + "\n", + "# Create the client instance\n", + "client = Elasticsearch(\n", + " # For local development\n", + " # hosts=[\"http://localhost:9200\"]\n", + " endpoint=ELASTIC_SERVERLESS_ENDPOINT,\n", + " api_key=ELASTIC_API_KEY,\n", + ")\n", + "\n", + "# Confirm the client has connected\n", + "print(client.info())" + ] + }, + { + "cell_type": "markdown", + "id": "3d29b809", + "metadata": {}, + "source": [ + "## Create the inference endpoints\n", + "\n", + "Create the inference endpoint first. In this example, the inference endpoint \n", + "uses Cohere's `embed-english-v3.0` model and the `embedding_type` is set to\n", + "`byte`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ae8ae88c", + "metadata": {}, + "outputs": [], + "source": [ + "COHERE_API_KEY = getpass(\"Cohere API key: \")\n", + "co = cohere.Client(api_key=COHERE_API_KEY)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6e524ce4", + "metadata": {}, + "outputs": [], + "source": [ + "client.inference.put_model(\n", + " task_type=\"text_embedding\",\n", + " inference_id=\"cohere_embeddings\",\n", + " body={\n", + " \"service\": \"cohere\",\n", + " \"service_settings\": {\n", + " \"api_key\": COHERE_API_KEY,\n", + " \"model_id\": \"embed-english-v3.0\",\n", + " \"embedding_type\": \"byte\",\n", + " },\n", + " },\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "884e424d", + "metadata": {}, + "source": [ + "You can find your API keys in your Cohere dashboard under the\n", + "[API keys section](https://dashboard.cohere.com/api-keys)." + ] + }, + { + "cell_type": "markdown", + "id": "178c32db", + "metadata": {}, + "source": [ + "## Create the index mapping\n", + "\n", + "Create the index mapping for the index that will contain the embeddings." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35ab26b2", + "metadata": {}, + "outputs": [], + "source": [ + "client.indices.create(\n", + " index=\"characters-index\",\n", + " mappings={\n", + " \"properties\": {\n", + " \"infer_field\": {\n", + " \"type\": \"semantic_text\",\n", + " \"inference_id\": \"cohere_embeddings\",\n", + " },\n", + " \"title\": {\"type\": \"text\", \"copy_to\": \"infer_field\"},\n", + " }\n", + " },\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "9c5e1e7b", + "metadata": {}, + "source": [ + "## Prepare data and insert documents\n", + "\n", + "This example uses the [SciFact](https://huggingface.co/datasets/mteb/scifact) data\n", + "set that you can find on HuggingFace." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "c71b8367", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'title': '\"Eat\" Owner', 'parsed': {'image': 'Vlcsnap-2016-09-06-05h31m34s50.png', 'origin': \"''Wander Over Yonder''\", 'fullname': 'Unknown', 'alias': '\"Eat\" Owner', 'occupation': 'Restaurant owner', 'skills': 'Management skills', 'goals': 'Manage his restaurant.
\\nHelp the rebels defeat Lord Dominator.
', 'hobby': '', 'family': 'Unknown', 'friends': 'Michelle', 'enemies': 'Lord Dominator', 'type of hero': 'Alien'}, 'origin': \"''Wander Over Yonder''\"}\n" + ] + }, + { + "ename": "NameError", + "evalue": "name 'client' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[19], line 24\u001b[0m\n\u001b[1;32m 16\u001b[0m documents\u001b[38;5;241m.\u001b[39mappend(\n\u001b[1;32m 17\u001b[0m {\n\u001b[1;32m 18\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_index\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcohere-embeddings\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 19\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_source\u001b[39m\u001b[38;5;124m\"\u001b[39m: data_dict,\n\u001b[1;32m 20\u001b[0m }\n\u001b[1;32m 21\u001b[0m )\n\u001b[1;32m 23\u001b[0m \u001b[38;5;66;03m# Use the bulk endpoint to index\u001b[39;00m\n\u001b[0;32m---> 24\u001b[0m helpers\u001b[38;5;241m.\u001b[39mbulk(\u001b[43mclient\u001b[49m, documents)\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mData ingestion completed, text embeddings generated!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mNameError\u001b[0m: name 'client' is not defined" + ] + } + ], + "source": [ + "url = \"https://huggingface.co/datasets/gqd/fictional-characters/resolve/main/heros.json\"\n", + "\n", + "# Fetch the JSONL data from the URL\n", + "response = requests.get(url)\n", + "response.raise_for_status() # Ensure we notice bad responses\n", + "\n", + "# Split the content by new lines and parse each line as JSON\n", + "data = json.loads(response.text)\n", + "\n", + "print(data[0])\n", + "\n", + "# Prepare the documents to be indexed\n", + "documents = []\n", + "for line in data:\n", + " data_dict = line\n", + " documents.append(\n", + " {\n", + " \"_index\": \"characters-index\",\n", + " \"_source\": data_dict,\n", + " }\n", + " )\n", + "\n", + "# Use the bulk endpoint to index\n", + "helpers.bulk(client, documents)\n", + "\n", + "print(\"Data ingestion completed, text embeddings generated!\")" + ] + }, + { + "cell_type": "markdown", + "id": "9332078a", + "metadata": {}, + "source": [ + "Your index is populated with the SciFact data and text embeddings for the text\n", + "field." + ] + }, + { + "cell_type": "markdown", + "id": "153ce2d5", + "metadata": {}, + "source": [ + "## Add the rerank inference endpoint\n", + "\n", + "To combine the results more effectively, use \n", + "[Cohere's Rerank v3](https://docs.cohere.com/docs/rerank-2) model through the\n", + "inference API to provide a more precise semantic reranking of the results.\n", + "\n", + "Create an inference endpoint with your Cohere API key and the used model name as\n", + "the `model_id` (`rerank-english-v3.0` in this example)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "886c4d15", + "metadata": {}, + "outputs": [], + "source": [ + "client.inference.put_model(\n", + " task_type=\"rerank\",\n", + " inference_id=\"cohere_rerank\",\n", + " body={\n", + " \"service\": \"cohere\",\n", + " \"service_settings\": {\n", + " \"api_key\": COHERE_API_KEY,\n", + " \"model_id\": \"rerank-english-v3.0\",\n", + " },\n", + " \"task_settings\": {\n", + " \"top_n\": 100,\n", + " },\n", + " },\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "ebf82d4a", + "metadata": {}, + "source": [ + "Rerank the results using the new inference endpoint." + ] + }, + { + "cell_type": "markdown", + "id": "610035af", + "metadata": {}, + "source": [ + "## Semantic search with reranking\n", + "\n", + "Let's start querying the index!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ab735ef0", + "metadata": {}, + "outputs": [], + "source": [ + "def semantic_search_with_reranking(query):\n", + " return client.search(\n", + " index=\"characters-index\",\n", + " retriever={\n", + " \"text_similarity_reranker\": {\n", + " \"retriever\": {\n", + " \"standard\": {\n", + " \"query\": {\"semantic\": {\"field\": \"infer_field\", \"query\": query}}\n", + " }\n", + " },\n", + " \"field\": \"titles\",\n", + " \"inference_id\": \"my_cohere_rerank_endpoint\",\n", + " \"inference_text\": query,\n", + " \"rank_window_size\": 100,\n", + " }\n", + " },\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3f0fc7e1", + "metadata": {}, + "outputs": [], + "source": [ + "pretty_print_characters(\n", + " semantic_search_with_reranking(\"Who are the stars of the Harry Potter series?\")\n", + ")\n", + "pretty_print_characters(\n", + " semantic_search_with_reranking(\"Who are the hobbits in the lord of the rings?\")\n", + ")\n", + "pretty_print_characters(\n", + " semantic_search_with_reranking(\"Who are the hobbits in the hobbit?\")\n", + ")\n", + "pretty_print_characters(\n", + " semantic_search_with_reranking(\"Who are the stars of star wars\")\n", + ")\n", + "pretty_print_characters(semantic_search_with_reranking(\"Who is the coolest character?\"))" + ] + }, + { + "cell_type": "markdown", + "id": "9539ff47", + "metadata": {}, + "source": [ + "## Retrieval Augmented Generation (RAG) with Cohere and Elasticsearch\n", + "\n", + "RAG is a method for generating text using additional information fetched from an\n", + "external data source. With the ranked results, you can build a RAG system on\n", + "top of what you created with \n", + "[Cohere's Chat API](https://docs.cohere.com/docs/chat-api).\n", + "\n", + "Pass in the retrieved documents and the query to receive a grounded response\n", + "using Cohere's newest generative model \n", + "[Command R+](https://docs.cohere.com/docs/command-r-plus).\n", + "\n", + "Then pass in the query and the documents to the Chat API, and print out the\n", + "response." + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "id": "39badebf", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Query: What is biosimilarity?\n", + "Response: Biosimilarity is based on the comparability concept, which has been used successfully for several decades to ensure close similarity of a biological product before and after a manufacturing change. Over the last 10 years, experience with biosimilars has shown that even complex biotechnology-derived proteins can be copied successfully.\n", + "Sources:\n", + "Interchangeability of Biosimilars: A European Perspective: Many of the best-selling ‘blockbuster’ biological medicinal products are, or will soon be, facing competition from similar biological medicinal products (biosimilars) in the EU. Biosimilarity is based on the comparability concept, which has been used successfully for several decades to ensure close similarity of a biological product before and after a manufacturing change. Over the last 10 years, experience with biosimilars has shown that even complex biotechnology-derived proteins can be copied successfully. Most best-selling biologicals are used for chronic treatment. This has triggered intensive discussion on the interchangeability of a biosimilar with its reference product, with the main concern being immunogenicity. We explore the theoretical basis of the presumed risks of switching between a biosimilar and its reference product and the available data on switches. Our conclusion is that a switch between comparable versions of the same active substance approved in accordance with EU legislation is not expected to trigger or enhance immunogenicity. On the basis of current knowledge, it is unlikely and very difficult to substantiate that two products, comparable on a population level, would have different safety or efficacy in individual patients upon a switch. Our conclusion is that biosimilars licensed in the EU are interchangeable.\n" + ] + } + ], + "source": [ + "response = co.chat(message=query, documents=ranked_documents, model=\"command-r-plus\")\n", + "\n", + "source_documents = []\n", + "for citation in response.citations:\n", + " for document_id in citation.document_ids:\n", + " if document_id not in source_documents:\n", + " source_documents.append(document_id)\n", + "\n", + "print(f\"Query: {query}\")\n", + "print(f\"Response: {response.text}\")\n", + "print(\"Sources:\")\n", + "for document in response.documents:\n", + " if document[\"id\"] in source_documents:\n", + " print(f\"{document['title']}: {document['text']}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 19183e685d9a67ff8e50080fc104c284b2f6636b Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Thu, 15 Aug 2024 14:48:00 -0400 Subject: [PATCH 2/6] Mostly completed --- ...d-cohere-elasticsearch-inference-api.ipynb | 388 ++++++++++++++---- 1 file changed, 301 insertions(+), 87 deletions(-) diff --git a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb index 9c7fbd5c..31a95e61 100644 --- a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb +++ b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb @@ -57,7 +57,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 1, "id": "50940b4d", "metadata": {}, "outputs": [ @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 2, "id": "1a5a5eeb", "metadata": {}, "outputs": [], @@ -121,33 +121,31 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 18, "id": "76394974", "metadata": {}, "outputs": [ { - "ename": "TypeError", - "evalue": "Elasticsearch.__init__() got an unexpected keyword argument 'endpoint'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[13], line 6\u001b[0m\n\u001b[1;32m 3\u001b[0m ELASTIC_API_KEY \u001b[38;5;241m=\u001b[39m getpass(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mElastic API key: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Create the client instance\u001b[39;00m\n\u001b[0;32m----> 6\u001b[0m client \u001b[38;5;241m=\u001b[39m \u001b[43mElasticsearch\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# For local development\u001b[39;49;00m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# hosts=[\"http://localhost:9200\"]\u001b[39;49;00m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[43mendpoint\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mELASTIC_SERVERLESS_ENDPOINT\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[43mapi_key\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mELASTIC_API_KEY\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 13\u001b[0m \u001b[38;5;66;03m# Confirm the client has connected\u001b[39;00m\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28mprint\u001b[39m(client\u001b[38;5;241m.\u001b[39minfo())\n", - "\u001b[0;31mTypeError\u001b[0m: Elasticsearch.__init__() got an unexpected keyword argument 'endpoint'" + "name": "stdout", + "output_type": "stream", + "text": [ + "{'name': 'serverless', 'cluster_name': 'b84f5a8ed15b4766b3f34666e7e06313', 'cluster_uuid': 'yecqXsgJTzuBufJH9q7zag', 'version': {'number': '8.11.0', 'build_flavor': 'serverless', 'build_type': 'docker', 'build_hash': '00000000', 'build_date': '2023-10-31', 'build_snapshot': False, 'lucene_version': '9.7.0', 'minimum_wire_compatibility_version': '8.11.0', 'minimum_index_compatibility_version': '8.11.0'}, 'tagline': 'You Know, for Search'}\n" ] } ], "source": [ "ELASTIC_SERVERLESS_ENDPOINT = getpass(\"Elastic serverless endpoint: \")\n", - "# https://www.elastic.co/search-labs/tutorials/install-elasticsearch/elastic-cloud#creating-an-api-key\n", "ELASTIC_API_KEY = getpass(\"Elastic API key: \")\n", "\n", "# Create the client instance\n", "client = Elasticsearch(\n", " # For local development\n", " # hosts=[\"http://localhost:9200\"]\n", - " endpoint=ELASTIC_SERVERLESS_ENDPOINT,\n", + " hosts=[ELASTIC_SERVERLESS_ENDPOINT],\n", " api_key=ELASTIC_API_KEY,\n", + " request_timeout=120,\n", + " max_retries=10,\n", + " retry_on_timeout=True,\n", ")\n", "\n", "# Confirm the client has connected\n", @@ -168,23 +166,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "id": "ae8ae88c", "metadata": {}, "outputs": [], "source": [ - "COHERE_API_KEY = getpass(\"Cohere API key: \")\n", - "co = cohere.Client(api_key=COHERE_API_KEY)" + "COHERE_API_KEY = getpass(\"Cohere API key: \")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "6e524ce4", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "ObjectApiResponse({'model_id': 'cohere_embeddings', 'inference_id': 'cohere_embeddings', 'task_type': 'text_embedding', 'service': 'cohere', 'service_settings': {'similarity': 'dot_product', 'dimensions': 1024, 'model_id': 'embed-english-v3.0', 'rate_limit': {'requests_per_minute': 10000}, 'embedding_type': 'byte'}, 'task_settings': {}})" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "client.inference.put_model(\n", + "client.inference.delete(inference_id=\"cohere_embeddings\", force=True)\n", + "client.inference.put(\n", " task_type=\"text_embedding\",\n", " inference_id=\"cohere_embeddings\",\n", " body={\n", @@ -219,10 +228,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "35ab26b2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'characters-index'})" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "client.indices.create(\n", " index=\"characters-index\",\n", @@ -251,7 +271,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 22, "id": "c71b8367", "metadata": {}, "outputs": [ @@ -259,18 +279,90 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'title': '\"Eat\" Owner', 'parsed': {'image': 'Vlcsnap-2016-09-06-05h31m34s50.png', 'origin': \"''Wander Over Yonder''\", 'fullname': 'Unknown', 'alias': '\"Eat\" Owner', 'occupation': 'Restaurant owner', 'skills': 'Management skills', 'goals': 'Manage his restaurant.
\\nHelp the rebels defeat Lord Dominator.
', 'hobby': '', 'family': 'Unknown', 'friends': 'Michelle', 'enemies': 'Lord Dominator', 'type of hero': 'Alien'}, 'origin': \"''Wander Over Yonder''\"}\n" - ] - }, - { - "ename": "NameError", - "evalue": "name 'client' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[19], line 24\u001b[0m\n\u001b[1;32m 16\u001b[0m documents\u001b[38;5;241m.\u001b[39mappend(\n\u001b[1;32m 17\u001b[0m {\n\u001b[1;32m 18\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_index\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcohere-embeddings\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 19\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_source\u001b[39m\u001b[38;5;124m\"\u001b[39m: data_dict,\n\u001b[1;32m 20\u001b[0m }\n\u001b[1;32m 21\u001b[0m )\n\u001b[1;32m 23\u001b[0m \u001b[38;5;66;03m# Use the bulk endpoint to index\u001b[39;00m\n\u001b[0;32m---> 24\u001b[0m helpers\u001b[38;5;241m.\u001b[39mbulk(\u001b[43mclient\u001b[49m, documents)\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mData ingestion completed, text embeddings generated!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[0;31mNameError\u001b[0m: name 'client' is not defined" + "{'title': '\"Eat\" Owner', 'parsed': {'image': 'Vlcsnap-2016-09-06-05h31m34s50.png', 'origin': \"''Wander Over Yonder''\", 'fullname': 'Unknown', 'alias': '\"Eat\" Owner', 'occupation': 'Restaurant owner', 'skills': 'Management skills', 'goals': 'Manage his restaurant.
\\nHelp the rebels defeat Lord Dominator.
', 'hobby': '', 'family': 'Unknown', 'friends': 'Michelle', 'enemies': 'Lord Dominator', 'type of hero': 'Alien'}, 'origin': \"''Wander Over Yonder''\"}\n", + "0 of 8058\n", + "100 of 8058\n", + "200 of 8058\n", + "300 of 8058\n", + "400 of 8058\n", + "500 of 8058\n", + "600 of 8058\n", + "700 of 8058\n", + "800 of 8058\n", + "900 of 8058\n", + "1000 of 8058\n", + "1100 of 8058\n", + "1200 of 8058\n", + "1300 of 8058\n", + "1400 of 8058\n", + "1500 of 8058\n", + "1600 of 8058\n", + "1700 of 8058\n", + "1800 of 8058\n", + "1900 of 8058\n", + "2000 of 8058\n", + "2100 of 8058\n", + "2200 of 8058\n", + "2300 of 8058\n", + "2400 of 8058\n", + "2500 of 8058\n", + "2600 of 8058\n", + "2700 of 8058\n", + "2800 of 8058\n", + "2900 of 8058\n", + "3000 of 8058\n", + "3100 of 8058\n", + "3200 of 8058\n", + "3300 of 8058\n", + "3400 of 8058\n", + "3500 of 8058\n", + "3600 of 8058\n", + "3700 of 8058\n", + "3800 of 8058\n", + "3900 of 8058\n", + "4000 of 8058\n", + "4100 of 8058\n", + "4200 of 8058\n", + "4300 of 8058\n", + "4400 of 8058\n", + "4500 of 8058\n", + "4600 of 8058\n", + "4700 of 8058\n", + "4800 of 8058\n", + "4900 of 8058\n", + "5000 of 8058\n", + "5100 of 8058\n", + "5200 of 8058\n", + "5300 of 8058\n", + "5400 of 8058\n", + "5500 of 8058\n", + "5600 of 8058\n", + "5700 of 8058\n", + "5800 of 8058\n", + "5900 of 8058\n", + "6000 of 8058\n", + "6100 of 8058\n", + "6200 of 8058\n", + "6300 of 8058\n", + "6400 of 8058\n", + "6500 of 8058\n", + "6600 of 8058\n", + "6700 of 8058\n", + "6800 of 8058\n", + "6900 of 8058\n", + "7000 of 8058\n", + "7100 of 8058\n", + "7200 of 8058\n", + "7300 of 8058\n", + "7400 of 8058\n", + "7500 of 8058\n", + "7600 of 8058\n", + "7700 of 8058\n", + "7800 of 8058\n", + "7900 of 8058\n", + "8000 of 8058\n", + "(8058, [])\n", + "Data ingestion completed, text embeddings generated!\n" ] } ], @@ -284,12 +376,15 @@ "# Split the content by new lines and parse each line as JSON\n", "data = json.loads(response.text)\n", "\n", + "wanted_fields = [\"title\", \"origin\"]\n", "print(data[0])\n", "\n", "# Prepare the documents to be indexed\n", "documents = []\n", - "for line in data:\n", - " data_dict = line\n", + "for i, line in enumerate(data):\n", + " if i % 100 == 0:\n", + " print(i, \"of\", len(data))\n", + " data_dict = dict((k, line[k]) for k in wanted_fields if k in line)\n", " documents.append(\n", " {\n", " \"_index\": \"characters-index\",\n", @@ -298,7 +393,7 @@ " )\n", "\n", "# Use the bulk endpoint to index\n", - "helpers.bulk(client, documents)\n", + "print(helpers.bulk(client, documents))\n", "\n", "print(\"Data ingestion completed, text embeddings generated!\")" ] @@ -329,12 +424,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "id": "886c4d15", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "ObjectApiResponse({'model_id': 'cohere_rerank', 'inference_id': 'cohere_rerank', 'task_type': 'rerank', 'service': 'cohere', 'service_settings': {'model_id': 'rerank-english-v3.0', 'rate_limit': {'requests_per_minute': 10000}}, 'task_settings': {'top_n': 100, 'return_documents': True}})" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "client.inference.put_model(\n", + "client.inference.delete(inference_id=\"cohere_rerank\")\n", + "client.inference.put(\n", " task_type=\"rerank\",\n", " inference_id=\"cohere_rerank\",\n", " body={\n", @@ -343,21 +450,11 @@ " \"api_key\": COHERE_API_KEY,\n", " \"model_id\": \"rerank-english-v3.0\",\n", " },\n", - " \"task_settings\": {\n", - " \"top_n\": 100,\n", - " },\n", + " \"task_settings\": {\"top_n\": 100, \"return_documents\": True},\n", " },\n", ")" ] }, - { - "cell_type": "markdown", - "id": "ebf82d4a", - "metadata": {}, - "source": [ - "Rerank the results using the new inference endpoint." - ] - }, { "cell_type": "markdown", "id": "610035af", @@ -370,7 +467,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 82, "id": "ab735ef0", "metadata": {}, "outputs": [], @@ -385,35 +482,62 @@ " \"query\": {\"semantic\": {\"field\": \"infer_field\", \"query\": query}}\n", " }\n", " },\n", - " \"field\": \"titles\",\n", - " \"inference_id\": \"my_cohere_rerank_endpoint\",\n", + " \"field\": \"title\",\n", + " \"inference_id\": \"cohere_rerank\",\n", " \"inference_text\": query,\n", " \"rank_window_size\": 100,\n", " }\n", " },\n", - " )" + " )\n", + "\n", + "\n", + "def pretty_print_characters(docs):\n", + " hits = docs[\"hits\"][\"hits\"]\n", + " for hit in hits:\n", + " source = hit[\"_source\"]\n", + " print(\"Title:\", source[\"title\"] + \" (Origin:\", source[\"origin\"] + \")\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 83, "id": "3f0fc7e1", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Title: Sarah Connor (Terminator Genisys) (Origin: {{W|Terminator Genisys|Terminator Genisys)\n", + "Title: Malachi (Babylon 5) (Origin: ''Babylon 5'' episode ''The Coming of Shadows'')\n", + "Title: Michael (E.T.) (Origin: ''E.T. the Extra-Terrestrial'')\n", + "Title: Jack (Mass Effect) (Origin: ''{{w|Mass Effect 2)\n", + "Title: Jane (Babylon 5) (Origin: ''Babylon 5'')\n", + "Title: Jean-Luc Picard (Origin: ''Star Trek: The Next Generation'')\n", + "Title: Data (Star Trek) (Origin: ''Star Trek: The Next Generation'')\n", + "Title: Walter (Alien Covenant) (Origin: ''Alien: Covenant'')\n", + "Title: Adam Warlock (Marvel's Guardians of the Galaxy) (Origin: ''{{w|Marvel's Guardians of the Galaxy)\n", + "Title: Cooper (Jurassic Park) (Origin: ''Jurassic Park III'')\n", + "\n", + "Title: Abraham Van Helsing (Hotel Transylvania) (Origin: ''Hotel Transylvania 3: Summer Vacation'')\n", + "Title: Rand al'Thor (Origin: ''The Wheel of Time'')\n", + "Title: Draco Malfoy (Origin: ''Harry Potter'' series)\n", + "Title: Arthur Pendragon (Shrek) (Origin: ''{{W|Shrek the Third)\n", + "Title: Robin Hood (Prince of Thieves) (Origin: 1991 film ''Robin Hood: Prince of Thieves'')\n", + "Title: Christopher Robin (Disney) (Origin: ''Winnie the Pooh'')\n", + "Title: Remus Lupin (Origin: ''Harry Potter and the Prisoner of Azkaban'')\n", + "Title: Wade (Hotel Transylvania) (Origin: ''Hotel Transylvania'')\n", + "Title: Wilbur (Hotel Transylvania) (Origin: ''Hotel Transylvania'')\n", + "Title: Helga Hufflepuff (Origin: ''Harry Potter and the Philosopher's Stone'')\n" + ] + } + ], "source": [ - "pretty_print_characters(\n", - " semantic_search_with_reranking(\"Who are the stars of the Harry Potter series?\")\n", - ")\n", - "pretty_print_characters(\n", - " semantic_search_with_reranking(\"Who are the hobbits in the lord of the rings?\")\n", - ")\n", - "pretty_print_characters(\n", - " semantic_search_with_reranking(\"Who are the hobbits in the hobbit?\")\n", - ")\n", - "pretty_print_characters(\n", - " semantic_search_with_reranking(\"Who are the stars of star wars\")\n", - ")\n", - "pretty_print_characters(semantic_search_with_reranking(\"Who is the coolest character?\"))" + "sci_fi_characters = semantic_search_with_reranking(\"Characters from sci-fi movies\")\n", + "pretty_print_characters(sci_fi_characters)\n", + "print()\n", + "fantasy_characters = semantic_search_with_reranking(\"Characters from fantasy movies\")\n", + "pretty_print_characters(fantasy_characters)" ] }, { @@ -438,37 +562,127 @@ }, { "cell_type": "code", - "execution_count": 48, - "id": "39badebf", + "execution_count": 96, + "id": "f0cd13fe", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "ObjectApiResponse({'model_id': 'cohere_completion', 'inference_id': 'cohere_completion', 'task_type': 'completion', 'service': 'cohere', 'service_settings': {'model_id': 'command-r-plus', 'rate_limit': {'requests_per_minute': 10000}}, 'task_settings': {}})" + ] + }, + "execution_count": 96, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "client.inference.delete(inference_id=\"cohere_completion\")\n", + "client.inference.put(\n", + " task_type=\"completion\",\n", + " inference_id=\"cohere_completion\",\n", + " body={\n", + " \"service\": \"cohere\",\n", + " \"service_settings\": {\n", + " \"api_key\": COHERE_API_KEY,\n", + " \"model_id\": \"command-r-plus\",\n", + " },\n", + " },\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "2a9333e5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Query: What is biosimilarity?\n", - "Response: Biosimilarity is based on the comparability concept, which has been used successfully for several decades to ensure close similarity of a biological product before and after a manufacturing change. Over the last 10 years, experience with biosimilars has shown that even complex biotechnology-derived proteins can be copied successfully.\n", - "Sources:\n", - "Interchangeability of Biosimilars: A European Perspective: Many of the best-selling ‘blockbuster’ biological medicinal products are, or will soon be, facing competition from similar biological medicinal products (biosimilars) in the EU. Biosimilarity is based on the comparability concept, which has been used successfully for several decades to ensure close similarity of a biological product before and after a manufacturing change. Over the last 10 years, experience with biosimilars has shown that even complex biotechnology-derived proteins can be copied successfully. Most best-selling biologicals are used for chronic treatment. This has triggered intensive discussion on the interchangeability of a biosimilar with its reference product, with the main concern being immunogenicity. We explore the theoretical basis of the presumed risks of switching between a biosimilar and its reference product and the available data on switches. Our conclusion is that a switch between comparable versions of the same active substance approved in accordance with EU legislation is not expected to trigger or enhance immunogenicity. On the basis of current knowledge, it is unlikely and very difficult to substantiate that two products, comparable on a population level, would have different safety or efficacy in individual patients upon a switch. Our conclusion is that biosimilars licensed in the EU are interchangeable.\n" + "['Abraham Van Helsing (Hotel Transylvania)', \"Adam Warlock (Marvel's Guardians of the Galaxy)\", 'Arthur Pendragon (Shrek)', 'Christopher Robin (Disney)', 'Cooper (Jurassic Park)', 'Data (Star Trek)', 'Draco Malfoy', 'Helga Hufflepuff', 'Jack (Mass Effect)', 'Jane (Babylon 5)', 'Jean-Luc Picard', 'Malachi (Babylon 5)', 'Michael (E.T.)', \"Rand al'Thor\", 'Remus Lupin', 'Robin Hood (Prince of Thieves)', 'Sarah Connor (Terminator Genisys)', 'Wade (Hotel Transylvania)', 'Walter (Alien Covenant)', 'Wilbur (Hotel Transylvania)']\n" ] } ], "source": [ - "response = co.chat(message=query, documents=ranked_documents, model=\"command-r-plus\")\n", + "characters = []\n", + "for hit in sci_fi_characters[\"hits\"][\"hits\"]:\n", + " characters.append(hit[\"_source\"][\"title\"])\n", + "for hit in fantasy_characters[\"hits\"][\"hits\"]:\n", + " characters.append(hit[\"_source\"][\"title\"])\n", + "\n", "\n", - "source_documents = []\n", - "for citation in response.citations:\n", - " for document_id in citation.document_ids:\n", - " if document_id not in source_documents:\n", - " source_documents.append(document_id)\n", + "characters.sort()\n", + "print(characters)\n", "\n", + "query = \"What generes of movies are these characters from?\"\n", + "input = [\n", + " query,\n", + " \"characters\",\n", + " characters,\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "id": "39badebf", + "metadata": {}, + "outputs": [], + "source": [ + "response = client.inference.inference(\n", + " inference_id=\"cohere_completion\", input=str(input)\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "id": "ea437663", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Query: What generes of movies are these characters from?\n", + "Here is a list of the movie genres that the characters in your list are from:\n", + "\n", + "- Abraham Van Helsing, Wade, and Wilbur (Hotel Transylvania): Animated comedy, Fantasy, Horror\n", + "- Adam Warlock (Marvel's Guardians of the Galaxy): Sci-fi, Action, Superhero\n", + "- Arthur Pendragon (Shrek): Animated comedy, Fantasy\n", + "- Christopher Robin (Disney): Live-action adaptation of animated characters, Fantasy\n", + "- Cooper (Jurassic Park): Sci-fi, Adventure, Thriller\n", + "- Data and Jean-Luc Picard (Star Trek): Sci-fi, Adventure\n", + "- Draco Malfoy, Remus Lupin (Harry Potter series): Fantasy, Magical realism\n", + "- Helga Hufflepuff (Harry Potter series): Fantasy, Magical realism\n", + "- Jack (Mass Effect): Sci-fi, Action, Military fiction\n", + "- Jane and Malachi (Babylon 5): Sci-fi, Drama\n", + "- Michael (E.T.): Sci-fi, Fantasy, Family drama\n", + "- Rand al'Thor (The Wheel of Time): Fantasy\n", + "- Robin Hood (Prince of Thieves): Adventure, Historical fiction\n", + "- Sarah Connor (Terminator Genisys): Sci-fi, Action, Thriller\n", + "- Walter (Alien Covenant): Sci-fi, Horror\n", + "\n", + "Please note that some of these characters may appear in multiple genres depending on their appearances in different adaptations or franchise entries. This list considers the primary genre associated with each character's most well-known portrayal.\n" + ] + } + ], + "source": [ "print(f\"Query: {query}\")\n", - "print(f\"Response: {response.text}\")\n", - "print(\"Sources:\")\n", - "for document in response.documents:\n", - " if document[\"id\"] in source_documents:\n", - " print(f\"{document['title']}: {document['text']}\")" + "completion_response = response[\"completion\"][0][\"result\"]\n", + "print(completion_response)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20fffc2c", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From 7b22da52163586bdcc0ecd07dace9889cb3cf80c Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Thu, 22 Aug 2024 16:15:31 -0400 Subject: [PATCH 3/6] recording version after precommit --- ...d-cohere-elasticsearch-inference-api.ipynb | 711 ++++++++++++------ 1 file changed, 465 insertions(+), 246 deletions(-) diff --git a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb index 31a95e61..bf4c39b6 100644 --- a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb +++ b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb @@ -5,9 +5,9 @@ "id": "68a13ecd", "metadata": {}, "source": [ - "# Tutorial: Using Cohere with the elastic open inference API\n", + "# Tutorial: Retrieval Augmented Generation (RAG) with Cohere via the elastic open inference API\n", "\n", - "## TODO [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]()\n", + "## [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]()\n", "\n", "This tutorial shows you how to compute embeddings with\n", "Cohere using the elastic open inference API and store them for efficient vector or hybrid\n", @@ -15,12 +15,14 @@ "to perform the operations.\n", "\n", "You'll learn how to:\n", - "* create an inference endpoint for text embedding using the Cohere service,\n", - "* create the necessary index mapping for the Elasticsearch index using semantic search,\n", - "* rerank with retrievers using Cohere's rerank model,\n", - "* design a RAG system with Cohere's Chat API.\n", + "* create inference endpoints to use the Cohere service,\n", + "* create index mappings to use semantic search\n", + "* rerank with retrievers using Cohere's rerank model\n", + "* implement a RAG system with Cohere's Chat API.\n", "\n", - "The tutorial uses the [gqd/fictional-characters](https://huggingface.co/datasets/gqd/fictional-characters/blob/main/heros.json) data set.\n", + "This tutorial is based on [a blog post from April 2024](https://www.elastic.co/search-labs/blog/elasticsearch-cohere-rerank) discussing rerank, and RAG\n", + "\n", + "The tutorial uses the [josephrmartinez/recipe-dataset](https://github.com/josephrmartinez/recipe-dataset) data set.\n", "\n", "Refer to [Cohere's tutorial](https://docs.cohere.com/docs/elasticsearch-and-cohere) for an example using a different data set." ] @@ -33,7 +35,7 @@ "## 🧰 Requirements\n", "\n", "For this example, you will need:\n", - "\n", + "- To know about [semantic-search](https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-search.html)\n", "- An Elastic deployment:\n", " - We'll be using [Elastic serverless](https://www.elastic.co/docs/current/serverless) for this example (available with a [free trial](https://cloud.elastic.co/registration?utm_source=github&utm_content=elasticsearch-labs-notebook))\n", " \n", @@ -42,7 +44,7 @@ "\n", "- Python 3.7+.\n", "\n", - "- the 8.15+ python elasticsearch client" + "- python elasticsearch client 8.15+" ] }, { @@ -57,24 +59,10 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "50940b4d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: elasticsearch==8.15 in /Users/mh/.venv/lib/python3.11/site-packages (8.15.0)\n", - "Requirement already satisfied: elastic-transport<9,>=8.13 in /Users/mh/.venv/lib/python3.11/site-packages (from elasticsearch==8.15) (8.13.1)\n", - "Requirement already satisfied: urllib3<3,>=1.26.2 in /Users/mh/.venv/lib/python3.11/site-packages (from elastic-transport<9,>=8.13->elasticsearch==8.15) (2.1.0)\n", - "Requirement already satisfied: certifi in /Users/mh/.venv/lib/python3.11/site-packages (from elastic-transport<9,>=8.13->elasticsearch==8.15) (2023.11.17)\n", - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "!pip install elasticsearch==8.15" ] @@ -89,13 +77,14 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "1a5a5eeb", "metadata": {}, "outputs": [], "source": [ "from elasticsearch import Elasticsearch, helpers\n", - "import json\n", + "import csv\n", + "from io import StringIO\n", "import requests\n", "from getpass import getpass" ] @@ -121,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 2, "id": "76394974", "metadata": {}, "outputs": [ @@ -129,7 +118,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'name': 'serverless', 'cluster_name': 'b84f5a8ed15b4766b3f34666e7e06313', 'cluster_uuid': 'yecqXsgJTzuBufJH9q7zag', 'version': {'number': '8.11.0', 'build_flavor': 'serverless', 'build_type': 'docker', 'build_hash': '00000000', 'build_date': '2023-10-31', 'build_snapshot': False, 'lucene_version': '9.7.0', 'minimum_wire_compatibility_version': '8.11.0', 'minimum_index_compatibility_version': '8.11.0'}, 'tagline': 'You Know, for Search'}\n" + "{'name': 'serverless', 'cluster_name': 'e13f203a74d34057a6079bb6ad73afb9', 'cluster_uuid': 't5Vrz6xHRgeDfV0f5t_vqQ', 'version': {'number': '8.11.0', 'build_flavor': 'serverless', 'build_type': 'docker', 'build_hash': '00000000', 'build_date': '2023-10-31', 'build_snapshot': False, 'lucene_version': '9.7.0', 'minimum_wire_compatibility_version': '8.11.0', 'minimum_index_compatibility_version': '8.11.0'}, 'tagline': 'You Know, for Search'}\n" ] } ], @@ -157,7 +146,7 @@ "id": "3d29b809", "metadata": {}, "source": [ - "## Create the inference endpoints\n", + "## Create the text embedding inference endpoints\n", "\n", "Create the inference endpoint first. In this example, the inference endpoint \n", "uses Cohere's `embed-english-v3.0` model and the `embedding_type` is set to\n", @@ -166,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 3, "id": "ae8ae88c", "metadata": {}, "outputs": [], @@ -176,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 4, "id": "6e524ce4", "metadata": {}, "outputs": [ @@ -186,13 +175,12 @@ "ObjectApiResponse({'model_id': 'cohere_embeddings', 'inference_id': 'cohere_embeddings', 'task_type': 'text_embedding', 'service': 'cohere', 'service_settings': {'similarity': 'dot_product', 'dimensions': 1024, 'model_id': 'embed-english-v3.0', 'rate_limit': {'requests_per_minute': 10000}, 'embedding_type': 'byte'}, 'task_settings': {}})" ] }, - "execution_count": 20, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "client.inference.delete(inference_id=\"cohere_embeddings\", force=True)\n", "client.inference.put(\n", " task_type=\"text_embedding\",\n", " inference_id=\"cohere_embeddings\",\n", @@ -228,31 +216,31 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 5, "id": "35ab26b2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'characters-index'})" + "ObjectApiResponse({'acknowledged': True, 'shards_acknowledged': True, 'index': 'recipes-index'})" ] }, - "execution_count": 21, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "client.indices.create(\n", - " index=\"characters-index\",\n", + " index=\"recipes-index\",\n", " mappings={\n", " \"properties\": {\n", " \"infer_field\": {\n", " \"type\": \"semantic_text\",\n", " \"inference_id\": \"cohere_embeddings\",\n", " },\n", - " \"title\": {\"type\": \"text\", \"copy_to\": \"infer_field\"},\n", + " \"Title\": {\"type\": \"text\", \"copy_to\": \"infer_field\"},\n", " }\n", " },\n", ")" @@ -263,15 +251,13 @@ "id": "9c5e1e7b", "metadata": {}, "source": [ - "## Prepare data and insert documents\n", - "\n", - "This example uses the [SciFact](https://huggingface.co/datasets/mteb/scifact) data\n", - "set that you can find on HuggingFace." + "## Prepare data and ingest documents\n", + "The tutorial uses the [josephrmartinez/recipe-dataset](https://github.com/josephrmartinez/recipe-dataset) data set." ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 6, "id": "c71b8367", "metadata": {}, "outputs": [ @@ -279,134 +265,81 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'title': '\"Eat\" Owner', 'parsed': {'image': 'Vlcsnap-2016-09-06-05h31m34s50.png', 'origin': \"''Wander Over Yonder''\", 'fullname': 'Unknown', 'alias': '\"Eat\" Owner', 'occupation': 'Restaurant owner', 'skills': 'Management skills', 'goals': 'Manage his restaurant.
\\nHelp the rebels defeat Lord Dominator.
', 'hobby': '', 'family': 'Unknown', 'friends': 'Michelle', 'enemies': 'Lord Dominator', 'type of hero': 'Alien'}, 'origin': \"''Wander Over Yonder''\"}\n", - "0 of 8058\n", - "100 of 8058\n", - "200 of 8058\n", - "300 of 8058\n", - "400 of 8058\n", - "500 of 8058\n", - "600 of 8058\n", - "700 of 8058\n", - "800 of 8058\n", - "900 of 8058\n", - "1000 of 8058\n", - "1100 of 8058\n", - "1200 of 8058\n", - "1300 of 8058\n", - "1400 of 8058\n", - "1500 of 8058\n", - "1600 of 8058\n", - "1700 of 8058\n", - "1800 of 8058\n", - "1900 of 8058\n", - "2000 of 8058\n", - "2100 of 8058\n", - "2200 of 8058\n", - "2300 of 8058\n", - "2400 of 8058\n", - "2500 of 8058\n", - "2600 of 8058\n", - "2700 of 8058\n", - "2800 of 8058\n", - "2900 of 8058\n", - "3000 of 8058\n", - "3100 of 8058\n", - "3200 of 8058\n", - "3300 of 8058\n", - "3400 of 8058\n", - "3500 of 8058\n", - "3600 of 8058\n", - "3700 of 8058\n", - "3800 of 8058\n", - "3900 of 8058\n", - "4000 of 8058\n", - "4100 of 8058\n", - "4200 of 8058\n", - "4300 of 8058\n", - "4400 of 8058\n", - "4500 of 8058\n", - "4600 of 8058\n", - "4700 of 8058\n", - "4800 of 8058\n", - "4900 of 8058\n", - "5000 of 8058\n", - "5100 of 8058\n", - "5200 of 8058\n", - "5300 of 8058\n", - "5400 of 8058\n", - "5500 of 8058\n", - "5600 of 8058\n", - "5700 of 8058\n", - "5800 of 8058\n", - "5900 of 8058\n", - "6000 of 8058\n", - "6100 of 8058\n", - "6200 of 8058\n", - "6300 of 8058\n", - "6400 of 8058\n", - "6500 of 8058\n", - "6600 of 8058\n", - "6700 of 8058\n", - "6800 of 8058\n", - "6900 of 8058\n", - "7000 of 8058\n", - "7100 of 8058\n", - "7200 of 8058\n", - "7300 of 8058\n", - "7400 of 8058\n", - "7500 of 8058\n", - "7600 of 8058\n", - "7700 of 8058\n", - "7800 of 8058\n", - "7900 of 8058\n", - "8000 of 8058\n", - "(8058, [])\n", + "999 of 13000\n", + "(999, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '998', 'Title': \"Mr. Tingles' Punch\", 'Ingredients': \"['1 (750 ml) bottle light rum', '2 tablespoons Sichuan peppercorns', '25 ounces pomegranate juice', '8 1/2 ounces fresh lemon juice', '8 1/2 ounces 1:1 simple syrup (see note)', '4 ounces water', 'GARNISH: ice block, about 20 lemon wheels, 1/4 cup pomegranate seeds, and 1 tablespoon each black and pink peppercorns (optional)']\", 'Instructions': 'At least 24 hours before you plan to serve the punch, fill a Tupperware or cake pan with water and freeze to make an ice block that will fit in your serving vessel, or make several trays of large ice cubes.\\nMeanwhile, make the infused rum: Carefully spoon Sichuan peppercorns directly into the bottle of rum, using a funnel if desired. Reseal the bottle and let sit at room temperature for 24 hours, jostling occasionally to move the peppercorns around. Strain the infused rum through a fine-mesh strainer and discard peppercorns. If not serving immediately, return the infused rum to the bottle using a funnel and store in a cool, dark place for up to 3 months.\\nWhen ready to serve, combine entire bottle of infused rum with the measured pomegranate juice, lemon juice, simple syrup, and water in a large punch bowl. Stir well to mix and carefully add the ice block. Garnish punch bowl with lemon wheels, pomegranate seeds, and peppercorns if using. Ladle into ice-filled punch glasses and garnish each glass with a lemon wheel.', 'Image_Name': 'mr-tingles-pomegranate-rum-punch', 'Cleaned_Ingredients': \"['1 (750 ml) bottle light rum', '2 tablespoons Sichuan peppercorns', '25 ounces pomegranate juice', '8 1/2 ounces fresh lemon juice', '8 1/2 ounces 1:1 simple syrup (see note)', '4 ounces water', 'GARNISH: ice block', 'about 20 lemon wheels', '1/4 cup pomegranate seeds', 'and 1 tablespoon each black and pink peppercorns (optional)']\"}}\n", + "1999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '1998', 'Title': 'Red Posole with Pork', 'Ingredients': \"['3 pounds pork shoulder (Boston butt)', '1 large white onion, halved through root end, plus chopped for serving', '2 heads of garlic, halved crosswise', '1 bay leaf', '3 whole cloves', '10 guajillo chiles, ribs and seeds removed', '6 dried chiles de árbol, ribs and seeds removed', 'Kosher salt', '3 (15-ounce) cans white hominy, rinsed', 'Thinly sliced cabbage, thinly sliced radishes, dried oregano, and lime wedges (for serving)']\", 'Instructions': 'Place pork shoulder, onion halves, garlic, bay leaf, and cloves in a large pot. Pour in 14 cups water (pork should be submerged). Bring to a simmer and cook, skimming as needed and turning pork occasionally, until meat is cooked through and tender but not yet falling apart, 2 1/2–3 hours. Transfer pork to a plate; let cool slightly. Strain broth into a large bowl, then transfer back to pot. Slice pork into 1/2\" slices and add to broth.\\nMeanwhile, preheat oven to 350°F. Toast all the chiles on a rimmed baking sheet until brown (do not char) and starting to lightly puff in places, about 5 minutes. Bring 3 cups water to a boil in a medium saucepan; add chiles. Remove from heat and let chiles soak until softened, 10–12 minutes. Blend chiles and cooking liquid in a blender until smooth; season with salt.\\nAdd chile purée to pork and broth. Bring to a simmer, add hominy, and cook, skimming off fat from surface, until pork is so tender it’s nearly falling apart, 45–60 minutes; season with more salt.\\nDivide posole among bowls, top with onion, cabbage, radishes, and oregano. Serve with lime wedges.\\nPosole can be made 3 days ahead. Let cool; cover and chill.', 'Image_Name': 'red-posole-with-pork', 'Cleaned_Ingredients': \"['3 pounds pork shoulder (Boston butt)', '1 large white onion, halved through root end, plus chopped for serving', '2 heads of garlic, halved crosswise', '1 bay leaf', '3 whole cloves', '10 guajillo chiles, ribs and seeds removed', '6 dried chiles de árbol, ribs and seeds removed', 'Kosher salt', '3 (15-ounce) cans white hominy, rinsed', 'Thinly sliced cabbage', 'thinly sliced radishes', 'dried oregano', 'and lime wedges (for serving)']\"}}\n", + "2999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '2998', 'Title': 'Ramp and Walnut Pistou', 'Ingredients': \"['1/4 cup walnuts', '1 bunch ramps (about 6 ounces), trimmed', '1/2 cup olive oil', '1 tablespoon white wine vinegar', 'Kosher salt, freshly ground pepper']\", 'Instructions': 'Preheat oven to 350°F. Toast walnuts on a rimmed baking sheet, tossing once, until golden brown, 8–10 minutes. Let cool. Coarsely chop; place in a medium bowl.\\nHeat a dry medium cast-iron skillet over high. Add ramps and cook, turning occasionally, until bulbs and greens are evenly charred. Remove from skillet and let cool. Coarsely chop and add to bowl with walnuts. Add oil and vinegar and toss to coat; season with salt and pepper.\\nPistou (without vinegar) can be made 2 days ahead. Cover and chill. Add vinegar just before serving.', 'Image_Name': 'ramp-and-walnut-pistou', 'Cleaned_Ingredients': \"['1/4 cup walnuts', '1 bunch ramps (about 6 ounces), trimmed', '1/2 cup olive oil', '1 tablespoon white wine vinegar', 'Kosher salt', 'freshly ground pepper']\"}}\n", + "3999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '3998', 'Title': 'Best-Ever Grilled Cheese', 'Ingredients': \"['2 slices Pullman or other white bread', 'A dab of butter', 'Mayonnaise', 'A few slices American cheese or cheddar', 'Pepper']\", 'Instructions': \"Place 2 slices Pullman or other white bread on a cutting board and spread mayonnaise on top side of each; this is key to a golden, delectable crunch. Heat a small skillet (nonstick, ideally) over medium. Slide in a dab of butter. When it melts, place 1 slice of bread, mayonnaise side down, in skillet; top with a few slices American cheese or cheddar; season with pepper. Top with second slice of bread, mayonnaise side up. When underside is golden brown, about 4 minutes, turn sandwich and add another dab of butter to skillet. Press down on sandwich to encourage even browning and to help melt cheese—be gentle, don't smash it. Cook until second side is golden brown and cheese is melted. Eat immediately, preferably with Campbell's Tomato Soup.\", 'Image_Name': 'best-ever-grilled-cheese-51264120', 'Cleaned_Ingredients': \"['2 slices Pullman or other white bread', 'A dab of butter', 'Mayonnaise', 'A few slices American cheese or cheddar', 'Pepper']\"}}\n", + "4999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '4998', 'Title': 'Spicy Jalapeño Sweet Potato Fries', 'Ingredients': \"['3 medium peeled sweet potatoes', '1 tablespoon cornstarch', '1/2 teaspoon jalapeño salt', 'Vegetable oil cooking spray', '1 jalapeño']\", 'Instructions': 'Heat oven to 425°. Cut 3 medium peeled sweet potatoes into 1/4-inch-thick fries. In a bowl, combine 1 tablespoon cornstarch and 1/2 teaspoon jalapeño salt; add fries and toss. Arrange fries on two baking sheets coated with vegetable oil cooking spray; coat with more cooking spray. Bake until fries begin to brown, 10 minutes. Remove from oven and flip; spritz with cooking spray and sprinkle with 1 sliced jalapeño. Bake until golden, 8 minutes.', 'Image_Name': 'spicy-jalapeno-sweet-potato-fries-51206450', 'Cleaned_Ingredients': \"['3 medium peeled sweet potatoes', '1 tablespoon cornstarch', '1/2 teaspoon jalapeño salt', 'Vegetable oil cooking spray', '1 jalapeño']\"}}\n", + "5999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '5998', 'Title': 'Pumpkin Turnovers', 'Ingredients': \"['4 to 5 pound pumpkin (orange or striped)', '2 cups water', '3 cinnamon sticks', '5 whole cloves', '16 ounces piloncillo or 2 cups packed dark brown sugar', '3 cups all-purpose flour', '2 teaspoons baking powder', '1/2 teaspoon salt', '1/2 cup shortening', '2 eggs', '1/2 cup milk', '2 tablespoons granulated sugar', '1 teaspoon cinnamon (optional)', 'Canned evaporated milk or egg white', 'Cinnamon-sugar mixture (1 teaspoon ground cinnamon mixed with 1/4 cup sugar)']\", 'Instructions': 'Rinse off the exterior of the pumpkin in cool or warm water, no soap. Using a serrated knife cut the pumpkin in half and scoop out the pumpkin seeds. Scrape out the stringy layer (pulp) with a spoon. Discard seeds and pulp. Cut pumpkin into 3- to 4-inch slices leaving the skin on.\\nIn a steamer or large pot, steam the pumpkin in the 2 cups of water, making sure to keep the lid on tight, for 20 to 40 minutes, or until pumpkin is tender. The pumpkin is ready when your fork slides easily into the flesh.\\nLet the pumpkin cool. Once cooled, scoop the pumpkin flesh off the skins and into a mixing bowl. Discard the skins. Mash the steamed pumpkin with a potato masher and strain the liquid into a bowl. Reserve the liquid and set pumpkin puree aside.\\nIn the same large pot, put the reserved liquid from the pumpkin (about 1/2 to 2/3 cup) and add cinnamon sticks and cloves. Bring liquid to a boil and then remove from the heat. Replace lid and let steep for 30 minutes.\\nRemove cinnamon and cloves and add pumpkin puree to the liquid. Add the piloncillo and over medium-low heat let it melt into the pumpkin puree, stirring occasionally so it will not burn or stick to the pot. The pumpkin puree will turn a dark color with the piloncillo making it sweeter.\\nOnce the piloncillo has melted, lower the heat to low and let simmer uncovered until all the water evaporates. Remove from heat and allow pumpkin puree to cool down before refrigerating, about 15 minutes.\\nTo help puree set, place in the refrigerator for 3 hours or overnight. If some liquid separates, remove it with a spoon before using so the filling is not watery.\\nYou can make the empanada dough after your filling has chilled.\\nMix the first 3 dry ingredients. Cut in the shortening. It is best to use your hands. Add the eggs, milk, sugar, and cinnamon. Continue to work in with your hands until you have a soft dough. Split the dough in half, wrap in plastic wrap, and refrigerate for about 20 to 30 minutes.\\nPreheat the oven to 350 degrees F.\\nTake out half the dough and split it into 12 equal balls of dough.\\nOn a floured surface, roll out the dough balls into small round circles. Place a small dollop of pumpkin filling on one half of each of the dough circles. Wet the bottom edge of the circles with water to help seal the two halves. Fold over the dough to cover filling and seal off the edges with a fork by pressing down along the edges. This also makes for a pretty pattern when baked. Repeat with remaining dough and filling.\\nBrush each empanada with some canned evaporated milk or egg whites, sprinkle with cinnamon and sugar mixture. Puncture the top of each empanada with a fork to allow steam to escape while baking.\\nSpray a large cookie sheet with cooking spray, place the empanadas on the cookie sheet and bake for 15 to 20 minutes on middle rack in the oven. If after 15 minutes you notice the bottoms of the empanadas starting to brown, move the cookie sheet to the top rack and continue to bake for the last 5 minutes, until golden brown.\\nEnjoy the empanadas warm or at room temperature. Refrigerate baked empanadas for a few days. Reheat in a toaster oven or bake at 350 degrees for 8 minutes.', 'Image_Name': 'pumpkin-turnovers-51119020', 'Cleaned_Ingredients': \"['4 to 5 pound pumpkin (orange or striped)', '2 cups water', '3 cinnamon sticks', '5 whole cloves', '16 ounces piloncillo or 2 cups packed dark brown sugar', '3 cups all-purpose flour', '2 teaspoons baking powder', '1/2 teaspoon salt', '1/2 cup shortening', '2 eggs', '1/2 cup milk', '2 tablespoons granulated sugar', '1 teaspoon cinnamon (optional)', 'Canned evaporated milk or egg white', 'Cinnamon-sugar mixture (1 teaspoon ground cinnamon mixed with 1/4 cup sugar)']\"}}\n", + "6999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '6998', 'Title': 'Classic Coleslaw Dressing', 'Ingredients': \"['2/3 cup mayonnaise', '1/4 cup minced onion', '3 tablespoons minced dill pickle', '2 tablespoons pickle brine', '2 tablespoons distilled white vinegar', '1 tablespoon prepared white horseradish', '1 tablespoon sugar', '1 teaspoon kosher salt', '1/2 teaspoon celery seeds', '1/2 teaspoon freshly ground black pepper']\", 'Instructions': 'Whisk all ingredients in a medium bowl to blend. DO AHEAD: Can be made 1 day ahead. Keep chilled.', 'Image_Name': 'classic-coleslaw-dressing-366414', 'Cleaned_Ingredients': \"['2/3 cup mayonnaise', '1/4 cup minced onion', '3 tablespoons minced dill pickle', '2 tablespoons pickle brine', '2 tablespoons distilled white vinegar', '1 tablespoon prepared white horseradish', '1 tablespoon sugar', '1 teaspoon kosher salt', '1/2 teaspoon celery seeds', '1/2 teaspoon freshly ground black pepper']\"}}\n", + "7999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '7998', 'Title': 'Buttermilk Spice Cake with Pear Compote and Crème Fraîche', 'Ingredients': \"['2 tablespoons sugar', '1 tablespoon fresh lime juice', 'Large pinch of salt', '3 Bosc pears (about 1 1/2 pounds total), peeled, quartered, cored, cut into 1/2-inch cubes', '1 cup plus 1 tablespoon all purpose flour', '1/4 cup cornstarch', '1/2 teaspoon salt', '1/2 teaspoon (scant) baking powder', '1/4 teaspoon baking soda', '1/8 teaspoon ground allspice', '1/8 teaspoon ground ginger', '1/8 teaspoon ground black pepper', '1/8 teaspoon ground whole star anise*', '1/2 cup (1 stick) unsalted butter, room temperature', '3/4 cup sugar', '2 large eggs', '1 3-inch piece vanilla bean, split lengthwise', '1/4 teaspoon finely grated lime peel', '3/4 cup buttermilk', 'Powdered sugar', '1 1/2 cups crème fraîche**']\", 'Instructions': \"Mix sugar, lime juice, and salt in heavy large saucepan. Add pears and toss gently to coat. Cover and cook over medium-low heat until pears are just tender, stirring occasionally, 10 to 12 minutes. Transfer mixture to bowl. DO AHEAD: Can be made 1 day ahead. Chill until cold, then cover and keep chilled.\\nPreheat oven to 350°F. Butter and flour 9-inch-diameter cake pan with 2-inch-high sides; line pan with round of parchment paper. Sift first 9 ingredients into medium bowl. Using electric mixer, beat butter in large bowl until fluffy. Gradually add sugar, beating until smooth. Beat in eggs 1 at a time, beating to blend between additions. Scrape in seeds from vanilla bean and add lime peel; beat to blend. Beat in flour mixture in 4 additions alternately with buttermilk in 3 additions, scraping down bowl occasionally. Transfer batter to prepared pan.\\nBake cake until beginning to brown on top and tester inserted into center comes out clean, about 30 minutes. Cool cake in pan on cooling rack. DO AHEAD: Cake can be made 1 day ahead. Cover and let stand at room temperature.\\nCut around pan sides to loosen cake. Turn cake out onto rack; peel off parchment and turn right side up onto platter. Sift powdered sugar over. Cut into wedges. Serve with pear compote and dollop of crème fraîche.\\nA brown, star-shaped seedpod that's available in the spice section of some supermarkets and at specialty foods stores and Asian markets.\\n** Available at most supermarkets and at specialty foods stores.\", 'Image_Name': 'buttermilk-spice-cake-with-pear-compote-and-creme-fraiche-357493', 'Cleaned_Ingredients': \"['2 tablespoons sugar', '1 tablespoon fresh lime juice', 'Large pinch of salt', '3 Bosc pears (about 1 1/2 pounds total), peeled, quartered, cored, cut into 1/2-inch cubes', '1 cup plus 1 tablespoon all purpose flour', '1/4 cup cornstarch', '1/2 teaspoon salt', '1/2 teaspoon (scant) baking powder', '1/4 teaspoon baking soda', '1/8 teaspoon ground allspice', '1/8 teaspoon ground ginger', '1/8 teaspoon ground black pepper', '1/8 teaspoon ground whole star anise*', '1/2 cup (1 stick) unsalted butter, room temperature', '3/4 cup sugar', '2 large eggs', '1 3-inch piece vanilla bean, split lengthwise', '1/4 teaspoon finely grated lime peel', '3/4 cup buttermilk', 'Powdered sugar', '1 1/2 cups crème fraîche**']\"}}\n", + "8999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '8998', 'Title': 'Five-Spice Roast Chicken', 'Ingredients': \"['4 garlic cloves, pressed', '2 tablespoons coarse kosher salt', '2 tablespoons extra-virgin olive oil', '1 teaspoon Chinese five-spice powder*', '1 cut-up chicken (8 pieces; about 3 1/2 pounds)', '1 large onion, peeled, cut into 16 wedges']\", 'Instructions': 'Combine garlic, salt, olive oil, and Chinese five-spice powder in large bowl. Add chicken pieces; turn to coat. Cover and chill at least 1 hour or overnight. Preheat oven to 425°F. Arrange onion wedges in 13x9x2-inch roasting pan.\\nArrange chicken, skin side up, atop onions. Roast until chicken is cooked through, basting occasionally with pan juices, about 50 minutes. Remove chicken from oven and let rest 10 minutes. Arrange chicken and onions on platter and serve.', 'Image_Name': 'five-spice-roast-chicken-352011', 'Cleaned_Ingredients': \"['4 garlic cloves, pressed', '2 tablespoons coarse kosher salt', '2 tablespoons extra-virgin olive oil', '1 teaspoon Chinese five-spice powder*', '1 cut-up chicken (8 pieces; about 3 1/2 pounds)', '1 large onion', 'peeled', 'cut into 16 wedges']\"}}\n", + "9999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '9998', 'Title': 'Capellini with Shrimp and Creamy Tomato Sauce', 'Ingredients': \"['3 tablespoons olive oil', '1 pound peeled large shrimp', '3 large garlic cloves, forced through a garlic press', '1/4 teaspoon dried oregano', '1/2 cup sweet (red) vermouth', '1 (14- to 15-ounce) can diced tomatoes, drained', '3/4 cup heavy cream', '1/2 teaspoon fresh lemon juice', '1/2 pound capellini']\", 'Instructions': 'Heat oil in a 12-inch heavy skillet over medium-high heat until it shimmers, then cook shrimp and garlic with oregano, 1/2 teaspoon salt, and 1/4 teaspoon pepper, turning once, until golden, about 2 minutes total. Stir in vermouth and tomatoes, scraping up any brown bits from bottom of skillet. Add cream and briskly simmer until sauce has thickened slightly, about 1 minute. Stir in lemon juice.\\nMeanwhile, cook capellini in a pasta pot of boiling salted water (3 tablespoons salt for 6 quarts water) until al dente. Reserve 1 cup pasta-cooking water, then drain pasta.\\nServe immediately, topped with shrimp and sauce. Thin with some of reserved water if necessary.', 'Image_Name': 'capellini-with-shrimp-and-creamy-tomato-sauce-241995', 'Cleaned_Ingredients': \"['3 tablespoons olive oil', '1 pound peeled large shrimp', '3 large garlic cloves, forced through a garlic press', '1/4 teaspoon dried oregano', '1/2 cup sweet (red) vermouth', '1 (14- to 15-ounce) can diced tomatoes, drained', '3/4 cup heavy cream', '1/2 teaspoon fresh lemon juice', '1/2 pound capellini']\"}}\n", + "10999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '10998', 'Title': 'Chocolate-Honey Dome Cake with Chocolate-Honey Glaze', 'Ingredients': \"['Nonstick vegetable oil spray', '2 1/4 cups all purpose flour', '1/4 cup unsweetened cocoa powder', '1 teaspoon baking soda', '1/2 teaspoon salt', '3/4 cup sugar', '1/2 cup honey', '2 large eggs', '1 teaspoon vanilla extract', '3/4 cup vegetable oil', '1 1/2 cups buttermilk', '1 tablespoon water', '1 teaspoon unflavored gelatin', '1 1/4 cups heavy whipping cream, divided', '1/2 cup sour cream', '3 tablespoons honey', '1/2 cup finely grated bittersweet chocolate (about 1 ounce)', '10 ounces bittersweet chocolate, chopped', '1 cup heavy whipping cream', '1/2 cup honey', '1 cup pecans, toasted, chopped']\", 'Instructions': 'Preheat oven to 350°F. Spray 9-inch-diameter cake pan with 2-inch-high sides with nonstick spray. Line bottom with parchment round. Whisk flour, cocoa powder, baking soda, and salt in medium bowl. Whisk sugar, honey, eggs, and vanilla in large bowl to blend. Whisk in oil, then half of dry ingredients. Whisk in buttermilk, then remaining dry ingredients. Pour into prepared pan. Bake cake until tester inserted into center comes out clean, about 55 minutes (cake will dome). Cool 10 minutes. Invert onto rack; remove parchment. Turn over; cool cake completely on rack. DO AHEAD Can be made 1 day ahead. Store airtight at room temperature.\\nCut cake in half horizontally. Place bottom half of cake on cardboard round, tart pan bottom, or springform pan bottom.\\nPlace 1 tablespoon water in small bowl. Sprinkle gelatin over. Let stand 10 minutes to soften gelatin. Bring 1/4 cup cream to boil in small saucepan. Remove from heat and stir in gelatin mixture. Cool to room temperature, stirring often, about 5 minutes.\\nMeanwhile, using electric mixer, beat remaining 1 cup cream, sour cream, and honey in medium bowl until peaks form. Beat gelatin mixture, then grated chocolate into whipped cream mixture. Immediately spread filling over bottom half of cake, leaving 1/2-inch border at edges. Place top half of cake atop filling, pressing gently to spread filling just to edge of cake. Cover and chill cake overnight.\\nPlace chocolate in large measuring cup. Bring cream and honey to boil in heavy small saucepan, stirring to blend. Pour hot cream mixture over chocolate in cup; stir until smooth. Let cool 5 minutes.\\nPlace rack on rimmed baking sheet. Transfer cake to rack. Pour glaze over cake, allowing glaze to drip down sides. Use spatula to spread glaze over sides. Pat nuts onto sides of cake. Chill 1 hour to set glaze. DO AHEAD Can be made 1 day ahead. Keep refrigerated.', 'Image_Name': 'chocolate-honey-dome-cake-with-chocolate-honey-glaze-237916', 'Cleaned_Ingredients': \"['Nonstick vegetable oil spray', '2 1/4 cups all purpose flour', '1/4 cup unsweetened cocoa powder', '1 teaspoon baking soda', '1/2 teaspoon salt', '3/4 cup sugar', '1/2 cup honey', '2 large eggs', '1 teaspoon vanilla extract', '3/4 cup vegetable oil', '1 1/2 cups buttermilk', '1 tablespoon water', '1 teaspoon unflavored gelatin', '1 1/4 cups heavy whipping cream, divided', '1/2 cup sour cream', '3 tablespoons honey', '1/2 cup finely grated bittersweet chocolate (about 1 ounce)', '10 ounces bittersweet chocolate, chopped', '1 cup heavy whipping cream', '1/2 cup honey', '1 cup pecans', 'toasted', 'chopped']\"}}\n", + "11999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '11998', 'Title': 'Pappardelle with Pancetta, Broccoli Rabe, and Pine Nuts', 'Ingredients': \"['4 tablespoons extra-virgin olive oil, divided', '3 garlic cloves, peeled, flattened', '1 medium onion, chopped', '3 ounces thinly sliced pancetta, chopped', '1 teaspoon fennel seeds, crushed', '1/4 teaspoon dried crushed red pepper', '1 large bunch broccoli rabe (also called rapini; generous 1 pound), stems sliced 1/2 inch thick, tops cut into 2-inch pieces', '1 cup water', '1 8.8-ounce package dried pappardelle pasta', '1 cup freshly grated Pecorino Romano cheese, plus additional for serving', '1/2 cup pine nuts, toasted']\", 'Instructions': 'Heat 2 tablespoons oil in heavy large skillet over medium-high heat. Add garlic and cook until golden brown, stirring frequently, about 3 minutes. Discard garlic. Add onion, pancetta, and fennel seeds to skillet; sauté until onion is tender and pancetta begins to brown, about 8 minutes. Add dried crushed red pepper, then broccoli rabe stems and cook 4 minutes to soften slightly, stirring occasionally. Stir in broccoli rabe tops, sprinkle with salt, and add 1 cup water. Cover and cook until stems and tops are tender, about 5 minutes. Season to taste with salt and pepper.\\nMeanwhile, cook pasta in large pot of boiling salted water until just tender but still firm to bite. Drain pasta, reserving 1 cup cooking liquid.\\nAdd pasta to skillet with broccoli rabe and stir over low heat to combine, adding reserved cooking liquid by tablespoonfuls to moisten if necessary. Stir in remaining 2 tablespoons oil and 1 cup cheese. Season to taste with salt and generous amount of pepper. Transfer to shallow bowl. Sprinkle with pine nuts and serve, passing additional cheese separately.', 'Image_Name': 'pappardelle-with-pancetta-broccoli-rabe-and-pine-nuts-234397', 'Cleaned_Ingredients': \"['4 tablespoons extra-virgin olive oil, divided', '3 garlic cloves, peeled, flattened', '1 medium onion, chopped', '3 ounces thinly sliced pancetta, chopped', '1 teaspoon fennel seeds, crushed', '1/4 teaspoon dried crushed red pepper', '1 large bunch broccoli rabe (also called rapini; generous 1 pound), stems sliced 1/2 inch thick, tops cut into 2-inch pieces', '1 cup water', '1 8.8-ounce package dried pappardelle pasta', '1 cup freshly grated Pecorino Romano cheese, plus additional for serving', '1/2 cup pine nuts', 'toasted']\"}}\n", + "12999 of 13000\n", + "(1000, [])\n", + "last doc: {'_index': 'recipes-index', '_source': {'ID': '12998', 'Title': 'Pear, Pancetta, and Walnut Salad', 'Ingredients': \"['3/4 teaspoon whole coriander seeds', '1 tablespoon fresh lemon juice', '1/2 small shallot, minced', '3 tablespoons extra-virgin olive oil', '1 1/2 ounces thinly sliced pancetta, chopped', '1 large head of butter lettuce, torn into bite-size pieces (about 8 cups)', '1 large red Anjou pear, unpeeled, quartered, cored, sliced', '1/4 cup coarsely chopped toasted walnuts']\", 'Instructions': 'Toast coriander seeds in small skillet over medium heat until aromatic, about 2 minutes. Transfer to mortar and grind coarsely with pestle. Transfer to small bowl. Mix in lemon juice and shallot. Gradually whisk in olive oil. Season dressing to taste with salt and pepper.\\nHeat heavy medium skillet over medium-high heat. Add pancetta and sauté until crisp, about 4 minutes. Transfer to paper-towel-lined plate. Place lettuce in large bowl. (Dressing, pancetta, and lettuce can be prepared 2 hours ahead. Let dressing and pancetta stand at room temperature. Cover lettuce with damp kitchen towel and refrigerate.)\\nToss lettuce with dressing. Top with pear slices, then walnuts and pancetta.', 'Image_Name': 'pear-pancetta-and-walnut-salad-230921', 'Cleaned_Ingredients': \"['3/4 teaspoon whole coriander seeds', '1 tablespoon fresh lemon juice', '1/2 small shallot, minced', '3 tablespoons extra-virgin olive oil', '1 1/2 ounces thinly sliced pancetta, chopped', '1 large head of butter lettuce, torn into bite-size pieces (about 8 cups)', '1 large red Anjou pear, unpeeled, quartered, cored, sliced', '1/4 cup coarsely chopped toasted walnuts']\"}}\n", "Data ingestion completed, text embeddings generated!\n" ] } ], "source": [ - "url = \"https://huggingface.co/datasets/gqd/fictional-characters/resolve/main/heros.json\"\n", + "url = \"https://raw.githubusercontent.com/josephrmartinez/recipe-dataset/main/13k-recipes.csv\"\n", "\n", - "# Fetch the JSONL data from the URL\n", + "# Fetch the CSV data from the URL\n", "response = requests.get(url)\n", "response.raise_for_status() # Ensure we notice bad responses\n", "\n", - "# Split the content by new lines and parse each line as JSON\n", - "data = json.loads(response.text)\n", + "file = StringIO(\n", + " \"ID\" + response.text\n", + ") # cast the csv String to a file (the ID field name is missing for this dataset)\n", + "reader = csv.DictReader(file) # load the data as a dict\n", "\n", - "wanted_fields = [\"title\", \"origin\"]\n", - "print(data[0])\n", "\n", "# Prepare the documents to be indexed\n", "documents = []\n", - "for i, line in enumerate(data):\n", - " if i % 100 == 0:\n", - " print(i, \"of\", len(data))\n", - " data_dict = dict((k, line[k]) for k in wanted_fields if k in line)\n", + "for i, line in enumerate(reader):\n", + " if i % 1000 == 999:\n", + " print(i, \"of\", 13000)\n", + " print(helpers.bulk(client, documents)) # Use the bulk endpoint to index\n", + " print(\"last doc:\", documents[-1])\n", + " documents = []\n", " documents.append(\n", " {\n", - " \"_index\": \"characters-index\",\n", - " \"_source\": data_dict,\n", + " \"_index\": \"recipes-index\",\n", + " \"_source\": line,\n", " }\n", " )\n", "\n", - "# Use the bulk endpoint to index\n", - "print(helpers.bulk(client, documents))\n", "\n", "print(\"Data ingestion completed, text embeddings generated!\")" ] }, - { - "cell_type": "markdown", - "id": "9332078a", - "metadata": {}, - "source": [ - "Your index is populated with the SciFact data and text embeddings for the text\n", - "field." - ] - }, { "cell_type": "markdown", "id": "153ce2d5", @@ -424,7 +357,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 7, "id": "886c4d15", "metadata": {}, "outputs": [ @@ -434,13 +367,12 @@ "ObjectApiResponse({'model_id': 'cohere_rerank', 'inference_id': 'cohere_rerank', 'task_type': 'rerank', 'service': 'cohere', 'service_settings': {'model_id': 'rerank-english-v3.0', 'rate_limit': {'requests_per_minute': 10000}}, 'task_settings': {'top_n': 100, 'return_documents': True}})" ] }, - "execution_count": 42, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "client.inference.delete(inference_id=\"cohere_rerank\")\n", "client.inference.put(\n", " task_type=\"rerank\",\n", " inference_id=\"cohere_rerank\",\n", @@ -462,19 +394,19 @@ "source": [ "## Semantic search with reranking\n", "\n", - "Let's start querying the index!" + "Let's start by defining our query" ] }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 8, "id": "ab735ef0", "metadata": {}, "outputs": [], "source": [ "def semantic_search_with_reranking(query):\n", " return client.search(\n", - " index=\"characters-index\",\n", + " index=\"recipes-index\",\n", " retriever={\n", " \"text_similarity_reranker\": {\n", " \"retriever\": {\n", @@ -482,25 +414,88 @@ " \"query\": {\"semantic\": {\"field\": \"infer_field\", \"query\": query}}\n", " }\n", " },\n", - " \"field\": \"title\",\n", + " \"field\": \"Title\",\n", " \"inference_id\": \"cohere_rerank\",\n", " \"inference_text\": query,\n", " \"rank_window_size\": 100,\n", " }\n", " },\n", - " )\n", - "\n", - "\n", - "def pretty_print_characters(docs):\n", - " hits = docs[\"hits\"][\"hits\"]\n", - " for hit in hits:\n", - " source = hit[\"_source\"]\n", - " print(\"Title:\", source[\"title\"] + \" (Origin:\", source[\"origin\"] + \")\")" + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "e32dd994", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'took': 594, 'timed_out': False, '_shards': {'total': 5, 'successful': 5, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 75, 'relation': 'eq'}, 'max_score': 0.5445592, 'hits': [{'_index': 'recipes-index', '_id': 'uMGue5EBXCyFCBTsEnIC', '_score': 0.5445592, '_rank': 1, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Spicy Sesame Noodles with Chopped Peanuts and Thai Basil', 'embeddings': [29, -29, -30, -59, -35, -20, -19, 3, -45, 12, -1, -1, -34, -43, 9, -58, 29, -37, -19, -13, 3, -15, 3, 3, 31, -48, -71, 5, -37, -37, -2, 59, 51, 81, -105, 67, -64, 47, -5, 29, 61, -35, -32, 28, -43, -25, 47, -6, 17, -56, 5, 13, 10, -86, -44, -38, 62, 62, 74, -91, -128, -31, 68, -14, 19, -4, -19, 10, 7, 29, 54, -34, 21, -8, -2, -11, 8, -1, 41, 8, -21, -10, -4, -44, -5, -45, -17, 32, -3, 31, -16, -19, 35, 38, 33, -19, 8, 38, -16, 61, 6, -42, 60, -49, -27, -2, 18, 62, 37, 26, -18, 32, 40, 4, -66, -27, -20, -6, 1, -26, 23, 32, 29, -14, -30, -17, -18, -64, 7, 45, -24, 4, 3, 2, -17, -14, 20, -28, -7, 6, 31, -27, 47, 1, -21, -9, -10, 32, 55, 12, -25, -16, 0, 36, -15, 33, -37, 21, 4, 31, -19, -3, 14, 30, -5, -2, 22, 7, 26, 57, 22, -89, -12, -12, -20, 28, 55, 29, -21, 78, 13, -36, 26, -19, 11, -48, -22, -3, 62, -2, -30, -27, -105, 37, 50, 50, 1, 45, 34, -112, -31, 6, -57, 27, -21, -58, 5, 10, 93, 23, -51, 3, 12, -49, -75, 26, -11, -1, 26, 16, 52, -1, 14, -23, 31, -15, -13, -33, 5, 27, -93, 17, -77, -63, -76, 13, 16, 62, 29, -4, 30, -16, -36, -50, 57, -21, 3, -34, 29, -6, 53, -47, 34, -33, 30, 37, -2, 47, -31, 79, -54, 127, 118, 56, 54, 8, 89, 75, -17, -6, -11, 44, -17, 6, 2, -72, -49, 27, -23, -30, -20, 32, 50, -17, -37, 19, 73, 11, -39, 20, 18, 101, 15, 34, -19, 24, 86, 127, -56, 43, -46, -9, 33, -100, -1, 43, 29, 26, 1, -86, 41, -37, 18, -27, 13, -15, -31, 1, -40, -29, -44, 69, 2, 14, 41, -11, -7, 8, -30, 5, 12, -1, -4, 37, 5, 8, 51, -59, 12, -10, 95, -21, -29, 12, 10, -40, -3, -28, -3, 27, 0, -5, 30, 35, 65, -112, -81, 78, -40, -25, -39, 17, -45, -32, -2, -3, -40, 15, 47, 42, 51, 20, -57, -20, -20, -59, 28, -22, 15, 14, 10, -21, 57, -46, 63, 17, -16, 41, 12, -5, -53, -5, -72, -92, -18, 55, -30, -30, 70, -35, 30, -21, 12, -2, -22, -20, -16, -7, 45, 8, -15, 43, -28, 23, -29, -3, -23, -20, -56, 21, 63, -69, 9, 25, -52, -22, 0, 80, -66, -47, -18, -59, -33, -16, 45, 60, -18, -12, -36, -20, -37, -28, -26, 21, -40, 0, -18, -22, -3, 80, -3, -14, -2, 24, -49, 25, -43, 6, 51, 3, 10, -5, -52, 12, -22, -21, 71, -9, -51, 25, -22, 35, 50, 13, -27, -54, 47, 44, -57, -66, -73, 21, -51, 56, -7, 2, 51, 34, 15, -96, -115, -39, 53, -114, 29, 15, -6, 59, 64, 27, -44, -11, 27, -70, -25, -11, 27, -8, 45, 50, -17, -13, -5, 23, -45, 25, -8, -30, -8, 20, -13, -12, 6, 15, 25, -1, -38, 29, -4, -31, 36, 18, -18, -15, -15, -7, -20, 9, -21, -16, -26, -36, 19, -10, 19, 2, 15, 40, -43, 22, -4, 6, -3, -13, -30, -52, -61, 34, 32, -6, 4, -25, -24, 8, -41, 20, -2, -32, -77, 11, -27, -14, 15, -24, -58, -31, 23, 4, 20, -4, -11, 19, -7, 7, -36, 50, -23, 7, -14, 33, 19, -6, -24, -88, 19, 41, 0, -17, -38, 20, 0, 26, 13, -15, 14, 21, 0, 38, 11, -5, -17, 4, -30, 19, -37, -19, -1, 30, -25, -12, -14, -29, -9, -38, 13, -60, -44, -68, -25, 0, -58, 1, -19, 32, 38, -17, -21, 10, -29, -29, 46, 27, -17, -10, 8, 10, -2, -42, -47, -17, 30, 1, 40, -109, -34, -90, -8, 95, -73, 28, 7, 45, -16, -12, 82, 40, 5, 19, 13, 39, -60, -3, 122, 4, 9, -68, 71, -42, 16, -57, 10, 43, 37, 5, -32, 88, 1, -53, -18, -31, -25, 33, -38, 10, 7, -56, -18, -17, 52, -57, 7, 12, -71, -46, -38, 30, 34, 32, -13, -25, 22, 36, 18, -49, 56, 56, 127, 2, -21, -10, -69, 21, 27, -82, -3, 25, -47, -5, 12, 15, 8, -40, 0, -2, 9, -43, 0, -22, -40, 6, -88, 33, 10, 17, 9, -34, 25, 1, 41, 14, 113, -54, 15, -32, 17, -30, 21, -48, -18, -10, -23, -10, 10, 45, -23, 69, -13, -26, 0, 31, -24, -7, -5, 36, 9, 71, -9, -21, 17, 32, -40, 27, -52, -14, 77, -6, 60, -128, 90, -3, -5, -26, 14, 39, 16, -29, -45, 11, 8, -57, -10, -41, -11, 26, -15, 32, -31, 38, 29, 33, 13, 22, 1, -13, -58, 30, 6, -3, 54, -47, -23, 40, 11, -10, -26, -1, 19, -24, -25, 17, 28, -14, -27, -3, -4, 14, 10, 35, -1, 35, 45, -52, 59, 38, -23, -15, -18, -33, 28, 50, 46, -52, 16, 14, 0, -15, -38, -30, -7, 78, -11, -1, 5, 4, 20, 13, 22, 29, -12, 48, 30, -32, 38, -20, -35, 33, -3, 0, 11, 17, 30, -88, -70, -127, -92, 16, 35, 3, 32, -22, 5, -60, 1, -44, -45, -91, -57, -23, -27, 20, -42, 24, -11, -45, -14, 20, 97, 14, -3, 3, -2, -8, -31, 16, -12, -12, -36, 0, 22, -25, -28, 3, 8, -50, -57, 15, -36, -33, -13, 0, -6, -42, -45, 50, 7, -27, -36, 36, 33, -63, -27, -7, -53, 0, -58, 40, 58, -59, -17, -58, -49, -21, 30, -50, 33, 49, -50, -75, -18, -10, 18, -8, 0, 6, -49, 58, -10, -43, 119, 58, -35, -5, -6, 25, -39, -25, 6, 12, -29, -13, -40, 6, -27, -16, 1, 93, -54, -9, -28, 40, 37, -51, 47, -73, 81, 38, 62, -11, 71, -68, -6, 5, 27, 12, -42, 70, 16, -34, 1, -74, -42, 35, -6, -19, 21, -17, -15, -24, -128, -51, -7, -13, -74, 24]}]}}, 'Ingredients': \"['1 tablespoon peanut oil', '2 tablespoons minced peeled fresh ginger', '2 garlic cloves, minced', '3 tablespoons Asian sesame oil', '2 tablespoons soy sauce', '2 tablespoons balsamic vinegar', '1 1/2 tablespoons sugar', '1 tablespoon (or more) hot chili oil*', '1 1/2 teaspoons salt', '1 pound fresh Chinese egg noodles or fresh angel hair pasta', '12 green onions (white and pale green parts only), thinly sliced', '1/2 cup coarsely chopped roasted peanuts', '1/4 cup thinly sliced fresh Thai basil leaves', '*Available in the Asian foods section of many supermarkets and at Asian markets.']\", 'Title': 'Spicy Sesame Noodles with Chopped Peanuts and Thai Basil', 'Instructions': 'Heat peanut oil in small skillet over medium heat. Add ginger and garlic; sauté 1 minute. Transfer to large bowl. Add next 6 ingredients; whisk to blend.\\nPlace noodles in sieve over sink. Separate noodles with fingers and shake to remove excess starch. Cook in large pot of boiling salted water until just tender, stirring occasionally. Drain and rinse under cold water until cool. Drain thoroughly and transfer to bowl with sauce. Add sliced green onions and toss to coat noodles. Let stand at room temperature until noodles have absorbed dressing, tossing occasionally, about 1 hour. Stir in peanuts and Thai basil; toss again. Season to taste with salt and pepper. Serve at room temperature.', 'ID': '10792', 'Image_Name': 'spicy-sesame-noodles-with-chopped-peanuts-and-thai-basil-238798', 'Cleaned_Ingredients': \"['1 tablespoon peanut oil', '2 tablespoons minced peeled fresh ginger', '2 garlic cloves, minced', '3 tablespoons Asian sesame oil', '2 tablespoons soy sauce', '2 tablespoons balsamic vinegar', '1 1/2 tablespoons sugar', '1 tablespoon (or more) hot chili oil*', '1 1/2 teaspoons salt', '1 pound fresh Chinese egg noodles or fresh angel hair pasta', '12 green onions (white and pale green parts only), thinly sliced', '1/2 cup coarsely chopped roasted peanuts', '1/4 cup thinly sliced fresh Thai basil leaves', '*Available in the Asian foods section of many supermarkets and at Asian markets.']\"}}, {'_index': 'recipes-index', '_id': 'gcGte5EBXCyFCBTsl0v4', '_score': 0.4816824, '_rank': 2, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': \"Liu Shaokun's Spicy Buckwheat Noodles with Chicken\", 'embeddings': [29, -29, -21, -29, -35, -20, 7, 0, -28, 41, 21, -2, -20, -36, -17, -59, 50, -33, 0, -5, -8, 28, -4, 31, -14, 62, -42, -41, -20, -40, -20, 49, 53, 31, -83, -28, -28, 8, -47, 48, 14, -13, 8, -20, -30, -32, 34, -20, 6, -14, 25, 2, 48, -89, -36, -45, 56, 76, 70, -84, -125, -34, 52, -22, 35, -12, 39, 22, -41, 60, 86, -24, 19, -31, -22, -37, 38, -26, 3, 7, -45, 38, -25, -63, 20, -31, -39, 7, 3, -47, 5, -31, -41, 41, 27, -47, 22, 2, 20, 50, 0, -61, 52, -46, 6, 50, 19, 78, 49, 16, 11, 24, 10, -37, -4, 20, -23, 21, -14, -14, 20, 66, 19, -5, -83, -21, 6, -94, -37, -12, -9, 37, 1, 4, -31, 6, 27, -30, 27, 2, 27, -58, 17, 59, -49, 13, 18, 14, 11, -41, -38, -26, -30, 49, 13, 43, -56, 41, 5, 45, -84, -23, 8, -32, -12, 7, 51, 18, 7, 31, 12, -98, -35, -4, -17, 43, 29, -8, -4, 74, 18, -14, 0, 9, -4, -17, -28, -17, 60, -7, -13, 10, -75, 23, 21, 10, -53, 12, -5, -58, -36, -25, 21, 10, -15, 15, -18, 23, 105, 11, -39, 6, 20, -109, -104, 28, 9, -25, 33, 4, 41, 16, 26, 14, 32, 10, -46, -10, 10, 25, -33, 51, -28, -33, -70, 11, 51, 84, 17, 1, 54, -16, 27, -35, 34, -2, 69, -75, 16, 11, 48, -41, 23, 0, 4, 15, 12, 89, -41, 12, -27, 126, 54, 31, 21, 27, 56, 51, -50, 4, 9, 63, 0, -7, 8, -67, -36, 33, -22, -33, -20, 26, 126, -8, -10, 45, 96, -12, -18, 4, 16, 88, 19, 30, -7, 17, 61, 119, -50, 43, -76, -14, 70, -106, 11, -6, 19, -9, -31, -2, -44, -10, 21, 110, -16, -58, 2, 47, -31, -71, 5, 61, 29, -13, 41, -37, -46, 1, -95, 43, -8, 2, -12, 70, -19, 29, 0, -11, -16, -43, 3, -73, -1, -7, 38, -29, -45, -3, 9, 10, -22, -14, 0, -13, 69, -84, -73, 37, 5, -33, -6, -30, -43, 52, -23, 17, -12, 29, -6, -6, 13, 6, -33, -26, -75, 5, 23, -26, -42, -15, 4, -24, 91, -5, 53, 8, -44, 74, -16, 4, -60, 22, -33, -59, 42, 25, -23, 20, -35, -45, 25, 0, 26, -7, -3, -46, 0, -4, 20, 1, 26, 1, -6, -5, 9, -55, 34, 3, -106, -14, 100, -31, 6, -21, -30, 26, -35, 37, -46, -50, -31, -43, -20, -24, 40, 22, -30, 7, -36, -18, -56, -23, -19, 51, -6, -25, -69, -68, -2, 25, 12, -12, -28, 12, -44, 55, 51, 2, 48, 16, -18, -8, -15, -17, -5, -61, 39, 35, 8, 2, 56, 61, 56, 23, -13, -10, 4, 22, -61, -17, -24, 14, -18, 77, -40, 41, 0, 6, 5, -86, -87, -46, 14, -95, -5, 2, -6, 102, 37, 23, -42, -19, -23, -46, 23, -29, 42, -1, 25, 117, 13, 4, 23, 53, -61, 25, -33, -8, -17, 28, 21, 32, 9, -1, 65, -17, -32, 0, 35, 12, -5, -6, 25, 19, -8, -48, 5, -4, -9, 3, -6, -49, -19, -3, -2, 21, -48, 4, -15, 3, -30, -33, -61, -19, -30, -70, -100, 45, 31, -48, -9, 58, -38, -36, -26, 38, -25, -18, -31, -33, -7, -23, 74, 26, -30, -39, 41, 14, 36, -23, -36, 6, 26, -26, -16, 64, -53, -1, -28, 35, 10, -1, -16, -120, 25, 21, 29, 6, -61, 34, -54, 41, 2, -33, 27, 61, 2, -23, -21, -41, 14, -17, 3, 37, -18, -25, 9, 19, 18, -34, -20, -27, -32, -23, 16, -49, -31, -11, 3, 6, 2, 17, -28, 43, 51, -33, -15, 20, -26, -48, 51, 17, -12, -31, 12, 8, -11, -28, -2, -17, 9, 19, 3, -64, 36, -44, -21, 108, -69, 13, 38, 86, 22, 0, 103, 36, 18, 22, 23, -13, -28, -77, 51, -20, 1, -22, 46, -22, 20, -47, 9, 35, -49, 67, -40, 96, -10, -51, -2, -38, -12, 51, -32, -3, 12, -30, -47, -50, 42, -51, 29, -17, -71, -83, -17, -12, 3, 23, 18, -16, 33, 38, -20, -52, 112, 61, 127, 14, -15, -69, -73, -2, 39, -59, 2, 39, -56, -27, 2, 23, 14, 70, -11, -27, 37, -96, 25, 3, -28, 95, -55, 37, 17, 33, -27, -11, 24, 27, 15, 4, 68, -61, -27, -25, 26, -33, -55, -26, -18, 26, 22, 3, 31, 24, -97, 13, -13, -6, 18, 10, -9, 1, 3, 29, 3, 24, -43, 29, 42, 54, -74, 68, -69, -22, 47, -11, 19, -89, 83, -6, -34, -14, 31, 17, 4, -17, 19, 19, 9, -25, 24, -45, -22, 37, -24, 28, -49, 95, -7, -17, 16, -8, 0, -46, -62, -5, 14, -12, 29, -44, 15, 48, -14, 17, -44, 33, 47, -71, -26, 28, 37, 8, -62, 2, 4, -25, -15, 30, 20, 0, 65, -51, 46, 29, -21, -25, 1, -35, 43, 120, 2, -5, 13, 0, -21, 63, -50, -24, -9, 33, -18, 18, 22, 4, 25, -22, 1, 20, -40, 23, 13, -12, 18, 20, -17, -4, 29, -20, 29, 44, -12, -121, -36, -76, -79, -54, 64, -6, 42, -37, 41, -18, 12, 49, -1, -42, -68, 26, -43, 37, -63, -23, -2, -33, -13, 16, 68, 8, 23, -5, 4, 23, -15, 25, -32, -27, -35, 42, 18, -9, 4, 48, -27, -104, -72, 41, -73, -50, -32, -1, -25, -49, -57, 15, 12, -31, -34, 6, 16, -97, -22, -36, -47, 16, -54, 49, 17, -32, 0, -9, 9, -20, 19, -24, 20, 68, -48, -27, -34, 35, 37, 2, 30, 7, -106, 10, -45, -11, 13, 0, -13, -9, -13, 15, 23, -62, 19, 12, 7, 22, -35, 29, -45, 3, 36, 91, -54, -3, -8, 2, 55, -14, 14, -20, 47, 36, 35, -38, 22, 0, -16, 0, 41, 16, -52, 32, 13, -65, -20, -65, -43, 11, -14, 27, 3, 30, 3, -65, -110, -75, 7, 5, -72, 47]}]}}, 'Ingredients': \"['3 cups chicken broth or water (24 fl oz)', '1 lb skinless boneless chicken breast halves (2)', '1/2 lb dried buckwheat noodles such as soba noodles', '1 tablespoon peanut oil', '3 tablespoons Chinese black vinegar', '1 tablespoon light soy sauce', '1 tablespoon dark soy sauce', '1 tablespoon chile oil containing sesame oil (such as Chiu Chow Chili Oil from Lee Kum Kee) plus some of sediment from jar', '2 garlic cloves, minced', '1/2 teaspoon sugar', '1/8 teaspoon salt', '3 scallions (green parts only), thinly sliced', '2 tablespoons soy nuts (roasted salted soybeans)']\", 'Title': \"Liu Shaokun's Spicy Buckwheat Noodles with Chicken\", 'Instructions': 'Bring broth to a simmer in a 3-quart saucepan, then add chicken and simmer, uncovered, 6 minutes. Remove pan from heat and cover, then let stand until chicken is cooked through, about 15 minutes. Transfer chicken to a plate and cool at least 10 minutes, reserving broth for another use.\\nWhile chicken is poaching, bring 4 quarts salted cold water to a boil in a 5- to 6-quart saucepan over moderately high heat. Stir in noodles, then 1/2 cup cold water. When water returns to a boil, add another 1/2 cup cold water and bring to a boil again, stirring, then repeat once more, or until noodles are just tender but still firm and chewy throughout.\\nDrain noodles in a colander and rinse well under cold water to cool, then drain well. Toss noodles with peanut oil in a large bowl.\\nStir together vinegar, soy sauces, chile oil with sediment, garlic, sugar, and salt in another bowl until sugar is dissolved, then add to noodles and toss until coated.\\nShred chicken with your fingers into 1/4-inch-wide strips and add to noodles, tossing to combine. Sprinkle with scallions and soy nuts.', 'ID': '753', 'Image_Name': 'liu-shaokuns-spicy-buckwheat-noodles-with-chicken-107966', 'Cleaned_Ingredients': \"['3 cups chicken broth or water (24 fl oz)', '1 lb skinless boneless chicken breast halves (2)', '1/2 lb dried buckwheat noodles such as soba noodles', '1 tablespoon peanut oil', '3 tablespoons Chinese black vinegar', '1 tablespoon light soy sauce', '1 tablespoon dark soy sauce', '1 tablespoon chile oil containing sesame oil (such as Chiu Chow Chili Oil from Lee Kum Kee) plus some of sediment from jar', '2 garlic cloves, minced', '1/2 teaspoon sugar', '1/8 teaspoon salt', '3 scallions (green parts only), thinly sliced', '2 tablespoons soy nuts (roasted salted soybeans)']\"}}, {'_index': 'recipes-index', '_id': 'H8Gte5EBXCyFCBTs_Gge', '_score': 0.40868968, '_rank': 3, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Spicy Spaghetti with Fennel and Herbs', 'embeddings': [38, -5, -36, -46, -26, -18, 16, 7, -30, 45, 18, -14, 44, -58, 16, 2, 32, -37, 15, 9, 8, 12, 2, -19, 10, -18, -70, -1, -7, 2, 3, 9, 65, 39, -97, 12, -10, -6, -45, 70, 40, -22, 40, 43, -26, -6, 17, -42, 40, -63, 8, -22, 12, -44, -51, -30, 33, 32, 59, -86, -94, -49, 68, 19, 16, -40, 15, 23, 3, 31, 62, -13, -10, -14, 1, 17, 27, 29, -2, 24, -55, -28, 63, -42, 3, -47, -23, 31, -36, 34, -26, 5, -3, 37, 11, 3, 12, 25, 21, 29, 14, -68, 65, -47, -48, -22, 44, 54, -4, 31, -46, 25, 39, 24, -73, -44, -51, 20, -10, 7, 8, 57, -37, 17, -11, 11, 6, -53, -9, 21, -31, 23, 10, 15, -7, -6, -23, -17, -20, 0, 44, -54, 25, 14, -54, -24, 5, 48, 23, 2, -37, 7, -9, 84, 6, 101, -31, 44, -16, 81, -10, -17, -16, 3, -12, -5, 34, 22, 12, 66, -19, -47, 27, -19, -37, 21, 54, 45, -16, 37, -19, -74, 9, -20, -9, -16, -10, 18, 42, 0, -17, 9, -68, 30, 8, -10, -4, -5, 13, -39, -25, 9, -25, 45, -35, -9, -28, 13, 111, -6, -65, -20, 28, -42, -85, 28, -21, -18, 15, 31, 43, 11, 3, -9, 41, -19, -4, -44, 4, 9, -77, 40, -16, -57, -94, 7, 7, 44, 25, 25, 6, -31, -34, -19, -3, 6, 13, -7, -20, -60, 20, -14, 71, 16, 41, 54, 15, 83, -26, 26, -52, 127, 85, 46, -37, 37, 22, 51, -46, 15, 13, 67, -15, -15, 1, -20, -65, 49, -17, -16, 12, 56, 58, -9, -38, 34, 54, 27, -15, 2, 15, 113, 19, 50, -12, 27, 48, 127, -59, 45, -47, -12, 28, -74, -20, 59, 20, -1, -5, -93, 77, -9, 3, 5, -15, -57, -14, -4, -87, -75, 0, 77, -27, -19, 38, -7, -61, -19, 40, -7, 7, 17, -12, 39, 12, -25, 38, -33, -27, -84, 6, -81, -12, 32, 57, -45, -13, -30, 42, 42, -53, 9, 18, 29, 93, -113, -98, 103, 0, -7, -17, -4, -53, -14, 34, -19, -48, 13, 56, 35, 61, 25, -22, -14, -21, -86, 5, -38, -48, -33, 0, -40, 73, -34, 71, 38, -24, 26, 16, -1, -66, -30, -52, -41, 16, 40, -49, -12, -24, -17, 4, -4, 25, 18, -14, -11, -26, -18, 55, -15, -4, 19, -3, -34, -21, -14, -33, -5, -67, 14, 40, -43, 9, 15, -41, 11, -28, 29, -44, 21, -1, -34, -18, -14, 15, 60, -20, 31, -19, -21, -47, -19, 51, 17, -18, 22, 10, 6, 5, 29, 4, 2, 12, 10, -40, -5, 28, 26, 30, 19, 14, -11, -41, 13, -44, -46, 47, -9, -15, -2, -39, 87, 23, 9, -16, -39, 28, 27, -29, -44, -41, 21, -21, 44, -11, 11, 11, 0, 16, -82, -84, -45, 46, -100, 7, 3, -14, 71, 9, -18, -35, -22, 14, -14, -9, -3, 62, 1, 21, 70, 3, -19, 0, 0, -29, 19, 19, -39, 2, 4, -40, 3, -2, 55, 0, -5, -68, 51, -18, -3, 32, 50, 53, -16, -44, -50, -4, -53, -38, 15, 0, -62, -34, 7, -15, 63, -18, 84, 1, 39, 4, 6, -67, -28, -21, -57, -64, 54, -1, -61, -32, 32, -29, -1, -32, 37, -11, -17, -51, 0, -23, -10, 22, -5, -37, -33, 32, 15, 28, 3, 34, -6, -29, -1, -13, 39, -34, -20, -36, -3, -22, 9, -26, -106, 14, 16, 16, 12, -51, 26, -20, 32, 7, -13, 25, 80, 59, 13, -2, -7, -10, -39, -3, 26, -31, 11, 18, -2, -68, -61, -19, -55, -3, -2, -25, -80, -40, -89, -34, 30, -47, 25, -32, 19, 26, -1, -13, -5, -17, 6, 39, 39, -39, -42, 27, -12, -44, -39, -36, -10, -15, -17, 9, -48, -15, -65, -26, 127, -120, 47, 32, 30, -3, -7, 18, 54, 26, -1, 37, 3, -51, -32, 112, 0, -20, -6, 77, -42, 39, -26, -3, 42, 63, 7, -41, 73, 27, -68, -24, 0, -28, 44, -33, 7, -24, -55, -42, -2, 76, -23, -5, -2, -21, -32, -12, 8, 11, 40, -21, -15, 42, 51, 4, -27, 89, 66, 126, 7, -32, -29, -71, -4, 5, -48, 15, 40, -76, -15, -11, 9, 12, 33, -7, -17, 19, -84, 32, -35, -41, -44, -40, 12, 14, 7, -22, -46, 25, 8, -10, -5, 102, -56, 11, -7, 28, -39, -57, -29, 4, 9, 8, -18, -32, 13, -86, -11, 18, -17, 33, 24, -42, 9, -23, 21, 11, 65, -25, 14, 30, 79, -33, 43, -95, -30, 31, -1, 48, -66, 86, 44, -12, -28, -10, 1, -27, -3, 28, -8, -9, -21, -17, -59, -30, 2, -6, 17, -26, 39, 38, 26, 31, 33, -51, -4, -97, 51, 6, -6, 30, -55, 6, 50, -6, 20, -67, -31, 60, -16, -33, 91, 15, -12, -20, -5, 23, 42, 0, 4, 1, 23, 78, 4, 27, 36, 5, -11, 30, -53, 63, 75, 58, -47, 0, 69, -9, 0, -8, -32, -7, 40, -17, 8, -26, -1, 33, -34, 7, 25, -52, 17, 14, -17, 41, 27, -32, 59, 0, 26, 32, 22, -13, -128, -33, -85, -77, -89, 94, 9, 31, -42, 22, -45, 8, -27, -46, -128, -11, -2, -71, 46, -85, -27, 94, -71, -48, 0, 42, 27, -18, -24, 21, 7, 15, 56, -51, -19, -35, 40, 13, 19, -6, 35, -23, -39, -47, -3, -35, -36, -1, 16, 28, -40, -126, 124, -32, -40, -18, -1, 3, -11, -11, -25, -63, 1, -42, 43, 33, -19, -43, -26, -25, 0, 24, -56, 37, 27, -62, -47, -1, 26, 46, -16, -1, -19, -84, 6, -17, -16, 52, -17, -13, -19, -7, -20, -27, 6, 27, 20, -5, 23, -55, 40, -43, -40, 41, 106, -55, 17, -34, 14, 63, -46, 60, -25, 30, 28, 46, 5, 17, -46, -31, 20, 56, -6, -87, 66, 26, 8, -22, -27, -22, 39, -41, 11, 8, -27, 4, -34, -86, -26, -5, -34, -73, 24]}]}}, 'Ingredients': \"['1 3-ounce package pancetta (Italian bacon), chopped', '1 tablespoon olive oil', '3 garlic cloves, chopped', '2 large red jalapeño chiles, seeded, finely chopped (about 1/4 cup)', '2 large fennel bulbs, stalks trimmed, cut into thin wedges with some core attached', '1 1/2 cups low-salt chicken broth', '4 tablespoons finely chopped fresh Italian parsley, divided', '2 tablespoons fresh lemon juice', '11/2 teaspoons crushed fennel seeds', '1 pound spaghetti', '2 tablespoons extra-virgin olive oil', '1 1/2 cups finely grated Pecorino Romano or Pecorino Toscano cheese, divided']\", 'Title': 'Spicy Spaghetti with Fennel and Herbs', 'Instructions': 'Sauté pancetta in large skillet over medium heat until pancetta is golden. Using slotted spoon, transfer pancetta to paper towels. Add 1 tablespoon oil to drippings in skillet. Add garlic and chiles; sauté over medium heat 1 minute. Add fennel; cook until beginning to soften, 5 minutes. Mix in broth, 2 tablespoons parsley, lemon juice, and fennel seeds. Bring to boil. Reduce heat to low, cover, and cook until fennel is very tender, 20 minutes. Remove from heat. Season with salt and pepper.\\nCook pasta until tender; drain. Reserve 1 cup cooking liquid. Return pasta to pot.\\nUncover skillet with fennel mixture and return to high heat. Cook until almost all liquid is absorbed, about 4 minutes. Add fennel to pasta. Stir in 2 tablespoons oil, 1/2 cup cheese, and pancetta. Add cooking liquid by 1/4 cupfuls if dry. Toss pasta; transfer to serving bowl. Sprinkle 2 tablespoons parsley over. Serve with cheese.', 'ID': '8079', 'Image_Name': 'spicy-spaghetti-with-fennel-and-herbs-356691', 'Cleaned_Ingredients': \"['1 3-ounce package pancetta (Italian bacon), chopped', '1 tablespoon olive oil', '3 garlic cloves, chopped', '2 large red jalapeño chiles, seeded, finely chopped (about 1/4 cup)', '2 large fennel bulbs, stalks trimmed, cut into thin wedges with some core attached', '1 1/2 cups low-salt chicken broth', '4 tablespoons finely chopped fresh Italian parsley, divided', '2 tablespoons fresh lemon juice', '11/2 teaspoons crushed fennel seeds', '1 pound spaghetti', '2 tablespoons extra-virgin olive oil', '1 1/2 cups finely grated Pecorino Romano or Pecorino Toscano cheese', 'divided']\"}}, {'_index': 'recipes-index', '_id': 'TsGue5EBXCyFCBTsEnIC', '_score': 0.315947, '_rank': 4, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Spicy Soba Noodles with Shiitakes and Cabbage', 'embeddings': [56, 3, -54, -58, 17, -31, -14, -15, -70, 66, -28, 7, 10, -18, 9, -44, 31, -2, 7, 1, 6, 16, -9, 2, 30, 41, -95, -16, 13, -7, 11, 8, 75, 22, -111, -30, -69, 10, -55, 36, 50, -39, -12, -24, -25, -49, 42, -29, 19, -10, 30, 14, 32, -9, -30, -14, 59, 67, 46, -82, -95, 4, 54, 22, 3, 0, -24, 17, -34, 19, 65, -42, 0, -38, 21, 11, 17, 24, 7, 20, -60, -3, 50, -71, 1, -59, -50, 52, -10, 25, -14, -57, 26, 64, 29, -23, 2, 5, 24, 51, 24, -68, 64, -51, 19, 67, -2, 61, 69, 15, 20, 64, 28, -6, -47, -27, -41, 8, 1, -15, 13, 55, 0, 39, -35, 37, 23, -93, -8, -14, -28, 28, 0, 42, -4, 23, 21, -44, 2, -8, 39, -19, 39, 9, -33, -40, 10, 69, 12, -42, 51, -8, -12, 48, -16, 52, -37, 53, -22, 51, -30, -8, -11, 24, -15, -5, 46, 8, 16, 51, 16, -62, -9, -16, -15, 17, 41, 23, -36, 94, 29, -34, -22, 2, 17, -25, -40, -30, 82, -4, -81, -16, -93, 30, 35, 53, -4, 40, 14, -99, -52, 34, -30, 10, 10, -7, 13, 40, 49, 41, -19, 43, -14, -64, -27, 11, -12, -12, 26, -4, 52, 5, 15, -12, 42, 11, -23, -9, 24, 54, -101, 15, -20, 13, -64, 9, 18, 93, 10, -20, 42, -63, -19, -15, 5, -30, 34, -23, 50, -14, 50, -57, 44, -4, 63, 16, -19, 13, -2, 7, -14, 127, 66, 60, 1, 28, 60, 56, -11, 1, 5, 55, -8, 11, 43, -33, -61, 13, 8, 4, -8, 51, 121, -16, -28, 110, 86, -34, -24, -28, -14, 89, 27, 37, 29, 21, 70, 127, -50, 44, -65, -14, 18, -73, -1, 27, 1, 17, -14, -46, 9, 7, 27, 19, 29, -16, 4, 29, -31, -43, -4, 62, 7, 31, 58, -26, 14, 6, -75, 24, 23, -3, 0, 24, -6, 18, 26, -39, -12, -38, 35, -116, -16, 4, 64, -78, -44, -34, 21, 29, -26, 2, 11, 27, 67, -127, -83, 78, -19, -10, 8, 6, -12, -18, -9, -34, -19, 10, 44, 38, 16, 10, -60, -9, 4, -32, -28, -71, -13, -44, -8, -39, 50, -13, 59, 19, -45, 24, 8, 5, -53, -1, -40, -54, -7, 13, -17, 41, -10, -15, 35, -3, 16, 24, -25, -41, -7, -22, 58, 20, 25, 27, 0, 19, -32, 11, 20, -16, -16, -5, 53, -72, 25, 25, -66, 18, -32, 71, -73, -37, -19, -46, -33, -28, 54, 44, -37, -8, -49, -4, -53, -27, -14, 51, -36, 15, -38, -63, -11, 59, -11, 11, -28, 6, -43, -57, 15, 15, 64, -24, -19, -7, -60, 9, -61, 14, 35, 8, -32, -5, -40, 61, 36, 16, -21, 8, 15, -5, -19, -13, -47, 26, 5, 49, 17, 13, 32, 43, 4, -106, -91, -43, -15, -19, 2, -18, -1, 46, 44, -2, -59, 4, -31, -46, -15, 5, 17, 17, 46, 34, 0, 0, -49, -16, -49, 24, -4, -65, 14, 16, -37, 62, -34, 40, 25, -19, -66, 76, 4, -18, 23, 35, 3, -10, -22, -38, -10, -1, 2, 9, -36, -50, 13, 21, 4, 2, -16, 4, -50, 0, 10, 34, -28, 3, -29, -62, -95, 52, 13, -40, 6, -13, -20, 5, -49, 25, -31, -62, -43, 6, 5, 5, 41, -2, -54, -53, 18, 10, 2, -9, -12, -10, 9, -40, -36, 98, -18, 2, -19, 48, -9, 16, -28, -117, 12, 29, 28, 10, -55, 28, -21, 52, 2, -33, -1, 68, 42, -5, -37, -33, -9, -21, -9, 3, -55, 57, -40, 61, 21, -17, -19, -49, -14, -46, -11, -81, -27, -113, -34, 43, -75, 42, -27, 49, 23, -40, -20, 14, 1, -2, 12, 24, 2, -25, 39, -21, -17, 2, -53, 25, 15, 10, 52, -73, -40, -41, -16, 127, -89, 51, 29, 46, 2, -47, 110, 9, -4, -2, 4, 40, -75, -51, 91, -3, -1, 1, 71, -24, 46, -38, 10, 11, 28, -64, 3, 29, 49, 34, -36, -43, 7, 75, -57, 21, 25, -54, -14, -65, 34, -76, 23, -18, -75, -65, 15, 0, -20, -14, 34, 17, 13, 25, -10, -33, 90, 15, 67, -11, -30, -36, -57, -25, 30, -61, 30, -33, -36, -22, 11, -1, 18, 39, -10, -7, 11, -92, -1, 30, 27, -19, -64, 8, 50, 38, 4, -53, 17, -2, -4, 14, 88, -61, 1, 21, 25, -25, -18, -39, 4, 9, -23, 0, -9, 10, -39, 4, -8, -21, 30, 17, -35, 11, 6, 38, -6, 24, -34, 9, -15, 61, -7, 23, -72, -36, 54, 17, 47, -98, 78, -19, -25, -5, 65, -9, 21, -4, -11, 14, 11, -8, 17, -27, -24, 8, -13, 3, -21, 74, 27, -1, 29, -23, -13, 11, -19, 22, -20, -14, -2, -43, 30, 39, -1, 10, -42, -74, 84, 35, -73, 41, 37, -63, -77, 10, 2, -34, -18, 0, 54, 11, 39, -39, 17, 62, -58, -15, -29, -14, 78, 67, 16, -30, -16, 5, -7, 54, -35, -13, -23, 33, 3, 28, 40, -13, 14, 4, -4, 28, -27, 27, 21, -2, 67, -18, -54, 66, -21, 11, -13, 29, 24, -27, -17, -52, -57, 5, 27, 12, 46, -42, 47, -29, 21, 8, 13, -97, -42, -2, -35, 8, -27, -2, -5, -49, -18, 27, 66, 6, 14, 0, 7, 5, -25, 28, -13, -28, -70, 17, -28, 0, 6, 20, 14, -91, -70, 49, -43, -62, -27, 29, 28, -36, -78, 50, -7, -33, 10, -4, 45, -99, -17, -22, -83, -6, -57, 71, 23, -1, -6, -37, -34, -20, 36, -46, 39, 41, -79, -53, -24, 18, 29, -2, 45, -5, -122, 21, -45, -16, 75, 2, -6, -10, -36, 23, -10, -22, 2, -31, -6, -2, -44, 4, -49, 55, 44, 81, -53, -21, -1, 2, 7, -6, 16, -53, 85, 12, 67, -17, 89, -39, -15, -22, 34, -40, -51, 76, 10, -5, -27, -28, -11, 23, -42, 16, 34, -57, -22, -13, -128, -39, -1, 30, -85, 10]}]}}, 'Ingredients': '[\\'1/3 cup water\\', \\'1/3 cup soy sauce\\', \\'2 to 3 teaspoons Korean hot-pepper paste (sometimes labeled \"gochujang\")\\', \\'1 tablespoon packed brown sugar\\', \\'3 tablespoons sesame seeds\\', \\'1/4 cup vegetable oil\\', \\'2 tablespoons finely chopped peeled ginger\\', \\'1 tablespoon finely chopped garlic\\', \\'10 oz fresh shiitake mushrooms, stemmed and thinly sliced\\', \\'1 1/4 pound Napa cabbage, thinly sliced (8 cups)\\', \\'6 scallions, thinly sliced\\', \\'8 to 9 ounces soba (buckwheat noodles)\\', \\'1 cup frozen shelled edamame\\']', 'Title': 'Spicy Soba Noodles with Shiitakes and Cabbage', 'Instructions': 'Stir together all sauce ingredients until brown sugar is dissolved, then set aside.\\nToast sesame seeds in a dry 12-inch heavy skillet (not nonstick) over medium heat, stirring, until pale golden, then transfer to a small bowl.\\nHeat oil in skillet over medium-high heat until it shimmers, then sauté ginger and garlic, stirring, until fragrant, about 30 seconds. Add shiitakes and sauté, stirring frequently, until tender and starting to brown, about 6 minutes. Reduce heat to medium, then add cabbage and most of scallions (reserve about a tablespoon for garnish) and cook, stirring occasionally, until cabbage is crisp-tender, about 6 minutes. Add sauce and simmer 2 minutes.\\nWhile cabbage is cooking, cook soba and edamame together in a pasta pot of boiling salted water (2 tablespoons salt for 6 quarts water) until noodles are just tender, about 6 minutes. Drain in a colander and rinse under cool water to stop cooking and remove excess starch, then drain well again. Transfer to a large bowl and toss with sesame seeds and vegetable mixture. Serve sprinkled with reserved scallions.', 'ID': '10686', 'Image_Name': 'spicy-soba-noodles-with-shiitakes-and-cabbage-239266', 'Cleaned_Ingredients': '[\\'1/3 cup water\\', \\'1/3 cup soy sauce\\', \\'2 to 3 teaspoons Korean hot-pepper paste (sometimes labeled \"gochujang\")\\', \\'1 tablespoon packed brown sugar\\', \\'3 tablespoons sesame seeds\\', \\'1/4 cup vegetable oil\\', \\'2 tablespoons finely chopped peeled ginger\\', \\'1 tablespoon finely chopped garlic\\', \\'10 oz fresh shiitake mushrooms, stemmed and thinly sliced\\', \\'1 1/4 pound Napa cabbage, thinly sliced (8 cups)\\', \\'6 scallions, thinly sliced\\', \\'8 to 9 ounces soba (buckwheat noodles)\\', \\'1 cup frozen shelled edamame\\']'}}, {'_index': 'recipes-index', '_id': 'm8Gue5EBXCyFCBTsDXCt', '_score': 0.2507293, '_rank': 5, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Spicy Curry Noodle Soup with Chicken and Sweet Potato', 'embeddings': [35, -14, -74, -107, 11, -15, -38, 29, 15, -1, -39, 9, -46, -33, 19, -49, 33, -49, -19, -24, 15, 3, -15, 4, 25, 31, -128, 14, -32, -9, -9, 55, 74, 38, -108, 76, 17, -6, -47, 82, 44, -32, 61, -26, 8, -4, 28, -38, 4, -83, 44, -17, 58, -58, -38, -3, 45, 51, 59, -79, -88, -13, 57, 48, 8, -10, -6, 4, -38, 13, 80, -32, 31, 0, -6, -17, 34, 48, 33, -14, -52, -11, 54, -69, 23, -53, -43, 43, -9, -15, -7, -63, -15, 40, 50, -47, -9, 14, -6, 57, -27, -31, 36, -56, 22, 54, 21, 76, 73, -5, 18, 96, 24, 10, -55, -23, -57, 28, -12, 33, 3, 36, 25, -3, -17, 12, -16, -53, 2, -7, -36, 18, 17, 27, -13, 4, 27, -48, -23, 12, 28, -37, 11, 7, -41, 13, -4, 22, -1, -48, 43, -95, -18, 28, 23, 28, -45, 27, 14, 67, -45, -36, -38, -13, -33, 9, 46, 16, 23, 8, 40, -21, 49, -1, -14, -3, -4, 23, -5, 64, 17, -45, -9, 9, -14, 30, -12, 20, 16, 3, 0, 27, -36, 28, 24, -2, -28, 12, -5, -58, 47, -35, 5, -7, -19, -44, 5, -16, 65, -8, -42, 6, 40, -118, -64, 64, -26, -18, 29, -24, 53, 19, 39, 5, 34, 57, -60, 0, -13, 33, -82, 56, -32, 12, -39, 18, 38, 55, 18, -13, 36, -49, -18, -33, 41, -12, 2, -24, 40, -32, 28, -62, 66, -3, 75, 18, 21, 47, -14, 38, -40, 127, 72, 60, 0, 7, 46, 39, -20, -22, 15, 50, -1, 12, 4, -21, -31, -4, -7, 1, 13, 74, 124, -14, -11, 20, 58, -24, 7, 29, 20, 88, 44, 23, -19, 26, 55, 127, -48, 42, -57, -15, 28, -73, 3, -24, -20, 37, -2, -38, -18, 27, 41, 19, 15, -17, 3, 25, -32, -28, -15, 127, 10, -4, 85, -28, -33, -2, -19, 3, 0, -19, -8, 41, 5, -19, 26, 7, -14, -35, 20, -86, -31, -19, 38, -45, -11, -27, -9, 25, -17, -3, -16, -1, 20, -45, -23, 46, -4, -28, -28, 27, -36, 6, 4, -24, -21, 13, 0, 19, 26, -15, -46, -17, -39, -13, 60, -14, 27, 15, 16, -49, 55, -95, 83, 16, -1, 62, 18, -2, -61, -16, -42, -69, 0, 30, -42, -11, -5, -33, 95, -26, 12, 21, -19, -51, 26, 9, 35, -1, 2, -18, -8, -49, 1, -9, 16, -8, -85, -3, 88, -72, 20, 10, -82, -41, -28, 78, -83, 19, -33, -35, -39, -62, 57, 46, -26, 49, -73, 20, -39, -31, -31, 32, -65, 32, -42, -33, -54, 60, -12, 4, -70, 24, -41, 30, -1, -4, 23, 12, -5, 20, -78, -19, -3, 8, -35, 17, -33, 9, 26, 66, 28, 10, 8, -13, -21, 5, -38, 18, -50, 17, -48, 39, 10, -4, 23, 17, 49, -128, -89, -61, 72, -127, 58, -25, -23, 76, 30, 13, -22, -24, -24, -60, -59, -25, 71, 21, 53, 48, 35, 14, 38, 14, -27, 22, 10, -12, -4, 4, -2, 56, -20, 54, 3, -18, -79, -1, 14, -25, 7, -37, 14, 27, 0, 17, 7, -7, -1, -14, 18, -47, -23, -18, -26, 22, -28, 45, -36, 16, 26, 23, -123, -4, 3, -24, -118, 52, -21, -21, -23, 1, -20, 8, -4, 34, -14, -50, -22, -10, -4, -24, 24, -10, -46, -28, 14, 26, 23, 14, 8, -11, -34, -12, -23, 98, -64, 19, -39, 36, -23, 27, 8, -72, -29, -1, 1, 9, -22, 10, -62, 45, -5, -25, 83, 93, 23, 2, -18, -27, 9, -19, -32, 24, -68, 6, 3, 53, 16, -64, 0, -16, -17, 8, 22, -84, -51, -77, -24, -8, -60, -2, -16, 43, 32, -29, -26, 5, -29, -20, 46, 16, -17, -40, 6, 0, -23, -23, -13, -7, 25, -7, -45, -63, 18, -79, 3, 91, -79, 12, 38, 50, 1, -27, 45, 46, -5, 33, -6, 53, -26, -55, 90, 16, 28, -48, 77, -31, 42, -73, 18, 51, 6, 10, -43, 90, -27, -46, -18, 37, -26, 54, -13, 26, -31, -47, -26, -12, 50, -47, 26, 0, -87, -61, -38, 28, -2, 36, 1, 4, 31, 6, -13, -25, 81, 63, 117, 19, -20, -35, -71, -14, -1, -72, -1, -8, -56, -12, 5, 11, -18, 19, -39, -28, 32, -52, 5, -29, -35, 42, -52, 37, 21, 30, -27, -32, 4, 16, 19, 1, 90, -29, -2, -43, 29, -64, -45, -31, 3, 19, -24, 6, -6, 3, -48, 28, -4, 4, 8, 6, -20, 0, 8, 50, 25, 16, -44, 40, 19, 18, -46, 77, 1, -2, 56, -29, 23, -71, 67, 14, -23, -11, 38, 0, 6, -27, -17, 7, -22, -24, -1, -39, -37, 12, -31, 3, -44, 56, -9, -5, 11, -1, -10, -27, -95, -20, 20, -4, 22, -58, 6, 43, 25, -25, -31, 24, -1, -50, -4, -2, 24, 2, -63, 0, -3, -14, -10, 29, 39, 1, 79, 16, 17, 68, 7, -10, -5, -47, 82, 127, 19, -26, 11, 37, -25, 32, -58, -20, 5, 30, -19, 44, 16, -23, 25, -51, -8, 30, -61, 29, 21, -44, 21, -6, -30, 34, -7, 5, 19, 17, 45, -54, 16, -29, -57, -14, 56, -32, 60, -18, 76, -65, -23, 18, -39, -57, -21, 7, -44, 17, -39, -14, 36, -32, -50, 14, 63, 3, 25, -27, -33, 5, 1, 43, -21, -16, -25, 24, 15, -19, 24, 59, -7, -116, -78, 40, -32, -36, -7, 11, -4, -68, -128, 100, -5, -42, -17, 10, 39, -99, -16, -13, -81, -4, -49, 69, 19, -21, -39, -25, -35, -21, 12, -34, 16, 20, -61, -22, -7, 53, 45, 27, -13, -51, -91, 18, -8, 25, 16, -48, 2, -59, -30, -15, -7, -37, 20, -24, -16, 4, -51, 28, -19, 18, 37, 45, -32, 10, -43, 20, 19, -39, 11, -16, 58, 11, 49, -30, 79, -1, -14, 14, 32, 26, -45, 60, 12, 3, -12, -58, -24, 17, -16, 1, 37, -56, 1, -20, -47, -24, 4, 39, -65, 18]}]}}, 'Ingredients': \"['2 tablespoons vegetable oil', '3 tablespoons chopped shallots', '3 garlic cloves, chopped', '2 tablespoons minced lemongrass* (from bottom 4 inches of about 3 stalks, tough outer leaves discarded)', '2 tablespoons minced peeled fresh ginger', '2 tablespoons Thai yellow curry paste*', '2 tablespoons curry powder', '1 teaspoon hot chili paste (such as sambal oelek)*', '2 13.5- to 14-ounce cans unsweetened coconut milk,* divided', '5 cups low-salt chicken broth', '2 1/2 tablespoons fish sauce (such as nam pla or nuoc nam)*', '2 teaspoons sugar', '3 cups snow peas, trimmed', '2 cups 1/2-inch cubes peeled red-skinned sweet potato (yam; from about 1 large)', '1 pound dried rice vermicelli noodles or rice stick noodles*', '3/4 pound skinless boneless chicken thighs, thinly sliced', '1/2 cup thinly sliced red onion', '1/4 cup thinly sliced green onions', '1/4 cup chopped fresh cilantro', '3 red Thai bird chiles or 2 red jalapeño chiles, thinly sliced with seeds', '1 lime, cut into 6 wedges']\", 'Title': 'Spicy Curry Noodle Soup with Chicken and Sweet Potato', 'Instructions': 'Heat oil in heavy large saucepan over medium heat. Add next 4 ingredients; stir until fragrant, about 1 minute. Reduce heat to medium-low. Stir in curry paste, curry powder, and chili paste. Add 1/2 cup coconut milk (scooped from thick liquid at top of can). Stir until thick and fragrant, about 2 minutes. Add remaining coconut milk, broth, fish sauce, and sugar; bring broth to boil. Keep warm. DO AHEAD: Can be made 1 day ahead. Refrigerate until cold, then cover and keep chilled.\\nCook snow peas in large pot of boiling salted water until bright green, about 20 seconds. Using strainer, remove peas from pot; rinse under cold water to cool. Place peas in medium bowl. Bring water in same pot back to boil. Add sweet potato and cook until tender, about 7 minutes. Using strainer, remove sweet potato from pot and rinse under cold water to cool. Place in small bowl. Bring water in same pot back to boil and cook noodles until just tender but still firm to bite, about 6 minutes. Drain; rinse under cold water to cool. Transfer to microwave-safe bowl. DO AHEAD: Can be made 1 hour ahead. Let stand at room temperature.\\nBring broth to simmer. Add chicken; simmer until chicken is cooked through, about 10 minutes. Add sweet potato; stir to heat through, about 1 minute. Heat noodles in microwave in 30-second intervals to rewarm. Cut noodles with scissors if too long. Divide noodles among bowls. Divide snow peas and hot soup among bowls. Scatter red onion, green onions, cilantro, and chiles over soup. Garnish with lime wedges and serve.\\n*Available at some supermarkets, at specialty foods stores and Asian markets, and online from adrianascaravan.com.', 'ID': '10251', 'Image_Name': 'spicy-curry-noodle-soup-with-chicken-and-sweet-potato-241112', 'Cleaned_Ingredients': \"['2 tablespoons vegetable oil', '3 tablespoons chopped shallots', '3 garlic cloves, chopped', '2 tablespoons minced lemongrass* (from bottom 4 inches of about 3 stalks, tough outer leaves discarded)', '2 tablespoons minced peeled fresh ginger', '2 tablespoons Thai yellow curry paste*', '2 tablespoons curry powder', '1 teaspoon hot chili paste (such as sambal oelek)*', '2 13.5- to 14-ounce cans unsweetened coconut milk,* divided', '5 cups low-salt chicken broth', '2 1/2 tablespoons fish sauce (such as nam pla or nuoc nam)*', '2 teaspoons sugar', '3 cups snow peas, trimmed', '2 cups 1/2-inch cubes peeled red-skinned sweet potato (yam; from about 1 large)', '1 pound dried rice vermicelli noodles or rice stick noodles*', '3/4 pound skinless boneless chicken thighs, thinly sliced', '1/2 cup thinly sliced red onion', '1/4 cup thinly sliced green onions', '1/4 cup chopped fresh cilantro', '3 red Thai bird chiles or 2 red jalapeño chiles, thinly sliced with seeds', '1 lime', 'cut into 6 wedges']\"}}, {'_index': 'recipes-index', '_id': 'UcGte5EBXCyFCBTswl2H', '_score': 0.15052763, '_rank': 6, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Sweet and Spicy Peanut Noodles', 'embeddings': [27, 10, -71, -56, 2, -44, 8, 0, -53, 22, -22, -7, -9, -44, 35, -43, 26, -48, -22, -20, 26, -24, -47, -20, -3, -14, -85, -28, -28, -41, -15, 70, 33, 74, -95, 39, -42, 36, -4, 25, 33, -30, -42, 30, -67, -26, 14, -17, 9, -82, 16, -40, 21, -36, -65, -45, 38, 88, 64, -101, -116, 12, 60, 23, 13, 16, 13, 3, 54, 32, -8, -14, 47, -42, 18, 20, -29, 31, 39, -26, -18, 18, 14, -42, 15, -43, -25, 10, -28, -14, -16, 0, -22, 33, 7, -17, 2, 35, -27, 31, -34, -30, 50, -59, -32, -16, 18, 56, 38, 51, -16, 52, 14, -11, -27, -1, -42, 37, -8, 25, 21, 22, 41, -23, -29, -2, -33, -72, 7, 33, -34, 22, -28, -22, -33, -28, 4, 1, -12, -5, 26, -44, 16, 14, -43, -19, 4, 37, 35, -40, -2, -35, -21, 70, 26, 43, -47, 24, 59, 75, 0, -25, -33, -16, -33, -1, 45, 18, 14, 77, 6, -49, -61, -20, -23, -1, 62, 19, -12, 14, -9, -61, 15, -36, 1, -49, -9, 14, 30, 29, -47, -19, -38, 23, 19, 19, 2, 33, 12, -81, -68, 17, -9, 31, 15, -18, -2, 8, 66, 10, -28, -2, 35, -116, -77, 20, -69, -19, 2, 29, 17, 14, 24, -22, 84, 12, -24, -37, 56, 32, -80, 26, -31, -45, -63, -4, 10, 2, 33, 21, 24, 13, -33, -45, 73, 9, 16, -26, 16, -12, 7, -45, 57, -6, 41, 26, -3, 0, -29, 102, -39, 127, 96, 72, -16, -7, 46, 64, -8, -43, 7, 69, -28, 9, 26, -66, -55, 25, -21, -21, -20, -2, 66, 6, -5, 65, 83, 11, -51, -11, 6, 127, 40, 0, 6, 59, 85, 100, -56, 45, -22, -5, 40, -85, -26, 21, -7, 15, -7, -73, 30, 17, 25, 6, 20, -55, -3, 0, -60, -31, -38, 35, 12, -7, 44, -12, -41, 1, -18, -19, 17, -1, -1, 59, 14, 0, 24, 23, 22, -42, 35, -48, -21, 9, 23, -48, 11, -24, -17, 5, 32, -22, 41, 42, 94, -105, -99, 91, 22, -22, -32, 31, -25, 0, 25, -63, -54, 38, 38, 12, 10, 1, -33, 7, -14, -41, 37, -36, 35, 2, 36, -8, 56, -40, 39, 17, -52, 4, 16, 26, -53, -34, -104, -54, 19, 38, -33, -43, -12, -30, 14, -15, -1, 14, -35, 3, -28, -14, 52, 31, 19, -32, 44, -63, -6, 9, 40, 8, -35, -62, 41, -70, 12, -6, -75, -18, 26, 96, -33, -46, -18, -77, -17, -23, 37, 15, -45, 12, -32, -20, -23, -42, -19, 48, -13, -3, -50, -23, -17, 34, -18, 15, -36, 19, -45, -24, -31, 32, 36, 24, 23, -7, -64, 12, -17, -16, 1, -8, -12, -29, 5, 79, 19, -1, -18, -36, 36, 23, -21, -52, -70, 19, 19, 20, -13, 16, 7, 31, 48, -62, -46, -54, 66, -103, 14, -1, 0, 36, 28, 1, -99, 16, -6, -29, -40, -21, 14, 16, 33, 13, 1, -9, 11, -6, -30, 53, -62, -41, -14, -4, 8, 30, -9, 68, 6, -23, -62, -10, -15, 1, 23, -3, 32, -32, 12, -7, -4, -2, 6, 7, 1, -58, -48, 7, -6, 22, 8, 95, -41, 68, 16, 4, -33, 3, -19, -33, -78, 37, -26, -41, -35, -6, -54, 37, -48, 20, 37, -4, -34, 18, -31, -33, 9, 18, -63, -23, 13, -7, 36, 6, 18, 28, 4, 2, -6, 73, -55, -4, -22, 34, -4, 0, -15, -76, 10, 32, 16, -12, -43, 14, -52, 42, 16, -18, 33, 81, -3, 44, -9, 17, 16, -24, -20, 28, -35, 23, -39, 52, -25, -25, 0, -76, 8, -27, -31, -61, -26, -102, -38, 28, -63, 35, -60, 2, -4, 26, -32, -12, -8, 11, 28, 50, 0, -41, 6, -19, -15, -20, -3, 12, 33, -22, 8, -105, 28, -46, -22, 116, -68, 16, 17, 34, 25, -37, 58, 12, 34, 69, -3, 22, -8, -4, 73, -6, 1, -74, 71, -33, 38, -87, -5, -23, 59, -26, -23, 47, 8, -22, -67, -102, -17, 81, -114, 17, 45, -109, -19, -65, 45, -7, 36, -41, -3, -51, 8, 41, 0, 8, -12, -2, 17, 24, -16, -19, 70, 81, 108, 4, -24, -18, -75, -8, 25, -79, -10, 25, -37, -18, 20, 16, 8, -54, -13, -2, 19, -47, -1, 9, -31, 6, -57, 25, 16, 34, -1, -45, 3, 4, 51, 7, 114, -31, 11, -13, 30, -42, -48, -37, 25, 18, -18, -4, -24, 48, -66, 6, -51, -31, 10, 22, -10, 31, -9, 7, -25, 16, -29, -7, 21, 57, -10, 42, -47, -37, 46, -3, 37, -76, 75, -6, 3, -15, 7, 6, -4, -18, 20, -2, 24, -15, -15, -78, -18, -11, -7, -20, -41, 36, 38, -3, 21, 13, -17, 17, -72, 49, -33, -63, 24, -24, 41, 68, 13, -27, -9, 12, 38, -42, -15, 34, 35, 8, -21, 31, 37, 2, -15, -24, 46, 17, 66, -5, 31, 35, -16, -2, 20, -30, 67, 101, 18, 1, 5, 14, -20, 82, -37, -48, -31, 30, -20, -11, -43, 6, 2, 15, 0, 26, -18, 39, 31, 12, 31, -44, -41, 45, -36, 9, -4, 36, -8, -97, -68, -85, -81, -14, 46, 22, 46, -31, 23, -52, 11, -30, -12, -103, 16, 0, -27, -1, 14, -24, 21, -59, -27, 2, 67, 11, -11, -20, 12, -12, -16, 46, -23, -36, -31, 5, 0, -14, 0, 36, -6, -88, -68, 22, -57, -47, -18, 20, 11, -37, -76, 96, -19, -17, -29, 9, 35, -93, -28, -30, -68, 7, -73, 68, -6, -35, -38, -24, -13, -11, 62, -27, 19, 47, -78, -106, -70, 26, 0, 27, 0, -18, -80, 32, -34, 9, 60, -6, -29, -7, -42, 32, 9, -33, 20, 5, -45, 23, -67, -4, -24, -5, -55, 64, -13, -5, -29, 44, 7, 15, 29, -37, 25, 21, 30, 0, 47, -39, -27, 39, 61, 58, -62, 97, 37, -36, -14, -28, -53, 61, -35, 0, 2, -22, -10, -34, -88, -40, -19, 27, -70, 15]}]}}, 'Ingredients': \"['1 teaspoon sesame oil', '1 garlic clove, finely chopped', '2 teaspoons finely chopped ginger', '1/4 cup natural chunky peanut butter', '2 tablespoons low-sodium soy sauce', '1 tablespoon hoisin sauce', '1 tablespoon brown sugar', '1 tablespoon rice vinegar', '1/2 teaspoon Asian chile paste (or to taste)', '6 ounces cooked linguine', '1/3 cup sliced scallions']\", 'Title': 'Sweet and Spicy Peanut Noodles', 'Instructions': 'In a small saucepan, heat oil over medium heat. Add garlic and ginger; cook, stirring, until just soft, 1 minute. Add 3 tablespoons water, peanut butter, soy sauce, hoisin, sugar, vinegar and chile paste; cook, stirring often, until sauce is thick, about 4 minutes. Toss in noodles and scallions; serve at room temperature.', 'ID': '5313', 'Image_Name': 'sweet-and-spicy-peanut-noodles-51183640', 'Cleaned_Ingredients': \"['1 teaspoon sesame oil', '1 garlic clove, finely chopped', '2 teaspoons finely chopped ginger', '1/4 cup natural chunky peanut butter', '2 tablespoons low-sodium soy sauce', '1 tablespoon hoisin sauce', '1 tablespoon brown sugar', '1 tablespoon rice vinegar', '1/2 teaspoon Asian chile paste (or to taste)', '6 ounces cooked linguine', '1/3 cup sliced scallions']\"}}, {'_index': 'recipes-index', '_id': 'oMGte5EBXCyFCBTsk0ka', '_score': 0.11047115, '_rank': 7, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Spicy Tomato–Tuna Noodle Skillet Casserole With Aioli', 'embeddings': [16, -17, -39, -37, -29, -9, -2, 6, -37, 32, -27, -11, 31, -30, 17, -49, 30, -65, -35, -39, 3, -23, 26, -16, 30, 6, -119, -13, -15, -21, -19, 55, 58, 79, -128, 56, -46, 28, -10, 17, 15, -12, 46, 1, -39, 32, -35, -33, 43, -9, 35, -6, 34, -15, -36, -36, 32, 45, 45, -103, -91, -41, 81, 42, 13, -13, -6, 20, -74, -3, 74, -45, -6, -44, 0, 10, 40, -12, -7, 13, -100, 5, 56, -90, 15, -78, -59, 45, -14, -49, -13, -90, -33, 58, 31, -38, 6, 12, -10, 31, -15, -23, 19, -32, 24, 85, 18, 36, 30, -54, 15, 34, 29, 10, -22, -50, -55, 51, -18, 12, -4, 44, -22, -77, 22, -16, -12, -18, -54, 22, -42, 52, 47, 16, -14, -4, -10, -82, -16, -21, 44, -8, 18, -2, -31, 18, 19, 18, -14, -68, 27, -36, 35, 18, -45, 17, -22, 8, -41, -2, 5, -28, -18, 26, -18, 8, 31, 6, 12, 59, -1, 17, 16, -20, -35, -33, 34, 1, -36, 36, -15, -29, -30, -6, -12, 20, -39, -9, 49, -12, -29, 21, -35, 32, 31, 0, -17, 35, 0, -108, 17, 32, -42, -1, -9, -35, 29, 16, 85, 17, -59, -5, 47, -110, -37, 56, 32, 6, 34, -16, 15, 35, 0, -6, 47, 41, -31, -3, 39, 39, -54, 10, -31, 12, -60, -1, 21, 71, 8, -4, 42, -6, 20, 18, 101, -6, 8, 5, 15, -72, 8, -53, 72, -18, 57, 26, -14, 33, -24, 18, -23, 127, 59, 47, -15, 7, 23, 32, -30, -10, 21, 52, 16, 32, -29, -20, -12, 14, -57, 3, 7, 71, -22, -19, -53, 5, 26, 58, -63, 24, 29, 52, -8, 3, -25, 25, 69, 105, -42, 13, -34, -8, 14, -55, -8, 24, -12, 7, -23, -25, -5, 6, 57, 107, 35, -15, 12, 105, 6, -80, 14, 96, -7, 5, 42, -26, -33, -20, -2, 19, 9, 11, -10, 13, 2, -8, 17, -7, -13, -42, 10, -44, 4, -6, -13, -10, -2, -20, -26, 20, -29, -11, 0, 18, 57, -106, -43, 100, -28, -20, 9, 33, 26, 11, -40, -51, -23, 41, -15, -18, 34, -16, -11, -32, -44, -14, 14, -53, 31, 6, -16, -33, 64, -15, 46, -3, -62, 86, -17, 13, -43, 24, -29, -36, -16, 8, -53, -1, -24, -1, -33, -10, 22, -14, -15, -44, -18, -28, 11, -18, -35, 6, -52, -12, 10, -37, 59, -19, -96, 6, 122, -77, 17, -29, -60, -14, -28, 51, -72, -12, -30, -31, -3, -1, -8, 63, -25, 23, -24, -32, 10, -20, -29, 3, -37, -15, -19, -8, 38, 55, -2, -36, -26, -6, -76, 16, -4, 51, 40, 1, 4, -31, 19, 35, -43, -7, 55, 3, -40, 15, -10, 31, 95, 47, -80, 15, 20, 15, -68, -12, -89, 30, -10, 57, -23, 3, 67, 46, 12, -108, -81, -47, 33, -84, 6, -15, -24, 40, 6, 2, -10, -37, 49, -19, -13, -1, 60, 47, 37, 18, 34, 23, -5, -8, -36, 24, -1, -14, -9, 8, -17, 16, -2, 32, 15, 9, -57, 54, -33, -38, 7, 89, 48, 8, -61, -58, -4, 11, -10, -19, -27, -94, -2, -25, -11, 19, 1, 69, -71, 38, -3, 12, -78, -3, 16, -45, -108, 57, 10, -52, -14, 36, -28, -23, -65, 39, -39, -44, -21, 18, -45, -32, 69, 21, -38, -59, 22, 19, -5, -50, 33, -5, 0, -31, -4, 51, -33, 11, -10, 4, -42, 17, -46, -73, 31, 20, -3, 13, 9, 25, -51, 0, -36, -35, 127, 29, 65, -43, 4, -35, 1, 34, -49, 21, -78, -25, -26, 87, 25, -67, 0, 14, -19, -2, -31, -52, -11, -67, -39, -2, -56, -3, -6, 75, 63, -82, -15, 28, -20, -46, 30, 47, 31, -68, 53, -18, -38, -23, -38, 6, 27, 3, -2, -65, -17, -88, -3, 84, -34, 35, 24, 71, -39, -30, 30, 27, 0, -2, -16, 33, -65, -47, 77, 22, -23, 25, 76, -28, 22, -3, 24, 54, -1, 22, -41, 60, -7, -6, -34, -11, -12, 57, -32, 14, -1, -57, -54, 34, 22, -4, -30, 40, -15, 6, -38, 30, 19, 4, 4, 9, 27, 19, 13, -2, 80, 8, 34, -27, -53, -14, -77, -15, -23, -46, 0, 21, -86, -16, 32, 82, -16, -8, 33, -32, 15, -96, 6, -41, -33, 13, -32, 27, 15, 59, -26, 14, 18, -18, -22, 2, 20, -21, -2, -58, 36, -80, -74, -5, 16, 29, -33, -17, -13, 67, -38, 76, -30, -66, -35, 43, -16, -4, -45, -27, 22, 83, -32, 29, 13, 67, -41, 77, -85, -15, 35, -27, 33, -51, 8, 0, 7, 13, 8, 25, 1, 35, 79, 0, -8, -8, -11, -66, 47, 79, 40, 17, -21, 106, -30, 12, 6, -2, -30, -33, -82, -38, 41, 17, 8, -59, 24, 54, -34, 34, -22, 7, 2, -46, 2, 23, 23, 15, -49, -23, -30, 27, 38, 50, -3, 49, 63, 33, 0, 49, 13, 0, 12, -41, 0, 111, 38, 12, 34, 67, -22, 19, -6, -19, -41, 0, -5, 25, 46, -32, 59, -52, 20, -4, -46, -7, 31, -76, 53, -33, -40, 16, -3, -9, 17, 48, 37, -51, 18, -44, -74, -18, 38, -30, 56, 0, -8, -57, -19, -25, -12, -31, 23, -14, -62, 18, -46, -9, 80, -55, -26, -8, 0, 29, -9, -9, 59, 45, -18, 0, -14, -52, 18, 37, 51, 62, -40, 59, -40, -43, -36, -3, -23, -9, 6, 24, 25, -23, -46, 90, -3, -27, -34, -1, 21, -95, -42, -10, -67, 38, -31, 60, 8, 2, -14, 5, -2, -22, 48, -51, 36, 54, -61, -1, -5, -8, 28, -30, 24, -34, -90, 0, -36, 7, 63, 0, -42, -32, -16, 11, -15, -21, 9, 22, -27, 27, -20, 68, -29, 14, 71, 62, -42, 8, -33, -8, 45, -38, 25, -46, 48, 17, 50, 10, 58, -50, -24, 3, 22, -8, -20, 71, 44, -39, -22, -86, -30, 2, 1, 16, 70, -28, 29, 6, -73, 27, -47, 18, -56, -13]}]}}, 'Ingredients': \"['1 large egg yolk', '1 garlic clove, finely grated', '¼ tsp. kosher salt, plus more', '½ cup (or more) extra-virgin olive oil', '1 medium onion, cut into large pieces', '2 garlic cloves', '½ cup coarsely chopped roasted red peppers from a jar', '3 Tbsp. extra-virgin olive oil, plus more for drizzling', '12 oz. rigatoni, mezzi rigatoni, ditali, or other short or medium-length straight tube pasta', '2 (5–6-oz.) cans or jars oil-packed tuna', '1 oil-packed anchovy fillet, coarsely chopped', '1 tsp. kosher salt, divided', 'Freshly ground black pepper', '2 Tbsp. double-concentrated or regular tomato paste', '1 (14.5-oz.) can crushed tomatoes or whole peeled tomatoes with their juices, crushed', '1 tsp. ground turmeric', '¼ tsp. crushed red pepper flakes', 'Coarsely chopped parsley (for serving; optional)']\", 'Title': 'Spicy Tomato–Tuna Noodle Skillet Casserole With Aioli', 'Instructions': 'Whisk egg yolk, garlic, ¼ tsp. salt, and 2 tsp. water in a small bowl to combine. Place bowl on a kitchen towel so it won’t slide around as you whisk and gradually stream in oil, whisking constantly until thick and emulsified. Aioli should be thick but pourable; gradually whisk in more oil if needed. Taste and season with more salt if desired.\\nPlace rack in upper third of oven; preheat to 375°F. Pulse onion, garlic, and roasted red peppers in a food processor until finely chopped; set aside.\\nHeat 3 Tbsp. olive oil in a 10” ovenproof skillet, preferably cast iron, over medium-low. Add pasta and cook, stirring often, until evenly coated in oil and lightly browned, about 5 minutes (depending on the size and shape of your pasta, you may need to work in batches). Using a slotted spoon, transfer to a large bowl. Reserve pan.\\nDrain tuna, reserving 2 Tbsp. tuna oil. place oil in reserved pan and increase heat to medium. Add anchovy, ½ tsp. salt, and reserved chopped vegetable mixture and season with pepper. Cook, stirring occasionally, until vegetables soften, 5–7 minutes. Add tomato paste and cook, stirring, until slightly darkened in color, about 3 minutes. Mix in toasted pasta, tomatoes, turmeric, red pepper flakes, remaining ½ tsp. salt, and 2½ cups water and bring to a boil. Cook, stirring occasionally, until pasta is slightly softened, 8–10 minutes. Remove from heat and stir in drained tuna and ¼ cup water.\\nTransfer skillet to oven and bake casserole until pasta is tender and juices at the edges are bubbling, about 15 minutes. Remove from oven.\\nHeat broiler. Drizzle casserole with a little olive oil and broil until browned and crisped in spots, about 4 minutes.\\nSpoon some aioli over casserole and top with parsley if desired. Serve remaining aioli alongside.', 'ID': '272', 'Image_Name': 'spicy-tomato-tuna-noodle-skillet-casserole-with-aioli', 'Cleaned_Ingredients': \"['1 large egg yolk', '1 garlic clove, finely grated', '¼ tsp. kosher salt, plus more', '½ cup (or more) extra-virgin olive oil', '1 medium onion, cut into large pieces', '2 garlic cloves', '½ cup coarsely chopped roasted red peppers from a jar', '3 Tbsp. extra-virgin olive oil, plus more for drizzling', '12 oz. rigatoni, mezzi rigatoni, ditali, or other short or medium-length straight tube pasta', '2 (5–6-oz.) cans or jars oil-packed tuna', '1 oil-packed anchovy fillet, coarsely chopped', '1 tsp. kosher salt, divided', 'Freshly ground black pepper', '2 Tbsp. double-concentrated or regular tomato paste', '1 (14.5-oz.) can crushed tomatoes or whole peeled tomatoes with their juices, crushed', '1 tsp. ground turmeric', '¼ tsp. crushed red pepper flakes', 'Coarsely chopped parsley (for serving; optional)']\"}}, {'_index': 'recipes-index', '_id': 'VcGue5EBXCyFCBTsI3vR', '_score': 0.08586246, '_rank': 8, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Spicy Asian Noodle and Chicken Salad', 'embeddings': [52, -6, -80, -94, 8, -34, -19, 35, -57, 20, -59, 32, -63, -16, 34, -54, 44, -12, 20, -1, -7, 10, 15, -2, 15, 43, -120, -8, -10, -11, -17, 28, 90, 12, -89, 20, -42, 16, -61, 56, 44, -32, -47, 20, -65, -24, 32, -14, 6, -96, 30, -45, 45, -55, -69, -30, 56, 58, 83, -85, -125, -17, 60, -1, -14, 13, 12, -7, -41, -17, 64, -38, 31, -13, -16, 7, 5, 30, 31, -29, -25, 34, 54, -58, 34, -61, -31, 22, 15, -31, 15, -47, -3, 32, 1, -53, 6, 61, -9, 61, -48, -26, 51, -71, -11, 40, 19, 120, 61, 23, 8, 35, 26, -7, -49, -34, -21, -2, -6, -8, 11, 32, 16, -1, -23, -11, -23, -48, -69, 10, -24, 38, 5, 28, -7, -10, 12, -46, -23, 17, 31, -46, 4, 12, -98, -13, -4, 22, 17, -45, -51, -47, 1, 54, -14, 28, -38, 2, 7, 29, -76, -15, -2, -59, -48, -9, 55, 32, 17, 32, 38, -70, 12, -7, -19, 10, 41, 5, -27, 64, 18, -46, -28, 14, 3, -36, 12, 4, 26, 33, -11, 21, -84, -21, 46, 78, 0, 36, 34, -72, -44, -5, -18, 26, 4, -33, 0, 7, 53, 26, -30, 4, 0, -52, -35, 35, -34, -15, 19, -15, 35, 39, 2, -13, 70, 2, -2, -33, 62, 40, -39, 7, -25, -52, -92, 6, -4, 21, 21, 32, 35, -10, -30, -56, 47, -29, 1, -35, -3, -58, 24, -75, 74, 2, 43, 19, -10, 41, -1, 28, -20, 122, 63, 40, 23, -24, 34, 43, -14, -19, 4, 16, -10, 35, -1, -51, -38, 3, -40, -4, -7, 71, 83, -4, -21, 50, 55, 2, -11, -12, 1, 100, 29, 28, 29, 17, 72, 127, -67, 44, -70, -46, 19, -74, -1, 26, -9, 35, 3, -48, 2, 18, 47, 34, 9, -47, -8, 16, -80, -90, -15, 127, 29, -6, 89, -34, -59, -5, -19, -8, -17, 9, -21, 64, 10, -13, 14, 34, -5, -70, 15, -118, -19, 19, 25, -56, -28, -25, 36, 20, -18, -2, 18, 59, 59, -111, -60, 70, -41, -35, -3, -22, -36, 47, 36, -29, -42, 13, 34, 2, 30, -22, -22, 9, -16, -34, 38, -34, 21, 4, 9, -31, 58, -34, 68, 18, -18, 44, 14, -2, -39, 1, -82, -36, 3, 23, -50, -38, -32, -13, 9, 14, 6, 42, -35, 31, -20, -20, 39, 40, -20, -2, -8, -18, -3, 7, 45, 9, -110, -34, 84, -36, 3, -19, -70, -12, -28, 54, -58, 35, -12, -22, -16, -52, 15, 32, -30, 40, -46, 3, -52, -16, -9, 27, -27, -17, -10, -47, -27, -12, 0, 10, 13, 23, 1, 9, -10, 22, 8, 30, 2, -19, -30, -3, -22, 35, 19, -9, -70, 46, 2, -21, 14, 31, 8, 2, -34, 14, -55, 13, -25, 8, -26, 38, 0, 16, 8, 37, 47, -78, -109, -35, 53, -93, 41, 16, -22, 123, 62, 6, -28, -10, -43, -83, -14, -23, 2, -11, 36, 64, -28, -1, 10, 26, -46, 12, -19, 13, -35, -9, 19, 68, -11, 52, 18, -16, -50, -6, -7, -30, 34, -19, 38, 21, -20, 21, 10, -11, -30, -24, -1, -27, -29, -34, 4, 4, -39, 71, -16, 67, 2, -10, -78, -5, 15, -49, -98, 41, -28, -49, -17, 27, -57, 20, -45, 23, 28, -16, -30, 0, -27, -20, 40, 0, -12, -43, -16, 9, 10, 25, -4, 17, -28, -9, -9, 88, -49, 1, -9, 44, -33, 17, 0, -65, -6, -14, 15, 9, -3, 12, -8, 26, 12, -18, 32, 29, 24, 23, -24, -27, 38, -16, -28, 39, -66, 32, -47, 84, 15, -60, 3, -36, -27, -31, -15, -58, -36, -90, -50, 0, -69, 12, -27, 31, 45, -10, -23, -5, -56, -36, 27, 15, -70, -10, 14, -5, -33, -56, -32, 6, 18, -16, 2, -58, -11, -74, -46, 82, -48, 13, 22, 79, 9, 13, 70, 30, 18, 12, 13, 9, -41, -34, 57, -2, -15, -27, 97, -21, 54, -56, 19, 58, 32, -30, -26, 79, -19, -43, -26, -20, -47, 36, -36, 4, -2, -35, -1, -79, 74, -51, 20, -42, -37, -66, 26, 28, 9, -29, 21, -6, 23, 27, -47, -24, 46, 66, 99, 18, 12, -17, -62, -43, -1, -73, -6, -13, -13, -13, 26, 24, 9, 22, -45, 0, 54, -45, 0, -35, -27, -14, -49, 28, 18, 50, -20, -6, 20, 42, 4, -2, 81, -10, -20, -33, 27, -35, -8, -27, -9, 10, -51, -13, -6, 31, -51, -6, -17, 30, 13, 45, -1, 1, 20, 62, -61, 62, -65, 63, 11, 55, -34, 74, -37, -18, 44, -6, -18, -67, 25, -48, -62, 16, -2, 6, -16, -27, 0, -2, -17, -27, 23, -67, -25, -1, -5, -38, -68, 68, 23, -22, 38, 22, -21, -2, -99, 19, 0, -15, 28, -60, 15, 57, -4, -11, -28, 9, 12, -49, 4, 27, 22, 8, -63, 1, -34, 0, 7, 29, 23, 47, 24, -43, 55, 47, -21, 24, 0, -49, 74, 112, 33, -18, 29, 32, -29, 11, -1, 2, 16, 54, -42, 57, 33, 9, 20, 7, 0, 22, -19, 39, 37, 0, 21, -47, -42, 14, -5, -26, -2, 3, -17, -51, -5, -27, -49, -69, 29, 7, 0, -32, 13, -51, 22, -16, -1, -75, -51, -6, -48, 55, -69, 2, 4, -55, -22, -4, 38, -14, -11, -8, 21, 15, -8, 24, -32, -22, 0, 25, 26, -25, 16, 47, -8, -115, -48, 39, -19, -65, -17, -5, -4, -60, -107, 86, -18, -33, -61, -2, 37, -49, -37, -20, -96, 15, -74, 80, 31, -44, -17, -31, -25, -17, 55, -21, 24, 38, -75, -44, -58, 22, 32, 50, -13, -21, -114, 63, -30, 1, 43, -23, -21, -32, -39, 5, -1, -34, 16, 3, -25, 11, -42, 35, -34, 3, 36, 127, -60, 28, -20, 13, 76, -36, 4, -19, 30, 31, 40, 6, 38, -14, -4, 14, 41, 23, -31, 46, -8, -36, -5, -61, -13, 39, -55, 6, -25, -47, -20, -34, -70, -91, 47, 42, -38, 59]}]}}, 'Ingredients': \"['1/3 cup creamy peanut butter (do not use old-fashioned style or freshly ground)', '1/4 cup soy sauce', '2 tablespoons unseasoned rice vinegar', '2 tablespoons chili-garlic sauce', '1 tablespoon (packed) golden brown sugar', '1 tablespoon minced peeled fresh ginger', '3 tablespoons (or more) low-salt chicken broth', '3/4 pound linguine or dried chow mein udon noodles', '4 cups thinly sliced cooked chicken, cut into strips', '2 large carrots, coarsely grated (about 1 1/4 cups)', '6 green onions, chopped', '1 red bell pepper, cut into matchstick-size strips', '1/2 cup fresh cilantro leaves']\", 'Title': 'Spicy Asian Noodle and Chicken Salad', 'Instructions': 'Combine peanut butter, soy sauce, rice vinegar, chili-garlic sauce, brown sugar, ginger, and 3 tablespoons broth in processor; blend until smooth. Season dressing to taste with salt and pepper.\\nCook pasta in large pot of boiling salted water until tender but still firm to bite, stirring occasionally. Drain pasta; rinse with cold water to cool and drain again. Transfer pasta to large bowl. Add chicken, carrots, green onions, bell pepper, and cilantro; toss to blend. Pour dressing over and toss to coat, adding more broth by tablespoonfuls if dressing is too thick. Season salad to taste with salt and pepper.', 'ID': '12997', 'Image_Name': 'spicy-asian-noodle-and-chicken-salad-230922', 'Cleaned_Ingredients': \"['1/3 cup creamy peanut butter (do not use old-fashioned style or freshly ground)', '1/4 cup soy sauce', '2 tablespoons unseasoned rice vinegar', '2 tablespoons chili-garlic sauce', '1 tablespoon (packed) golden brown sugar', '1 tablespoon minced peeled fresh ginger', '3 tablespoons (or more) low-salt chicken broth', '3/4 pound linguine or dried chow mein udon noodles', '4 cups thinly sliced cooked chicken, cut into strips', '2 large carrots, coarsely grated (about 1 1/4 cups)', '6 green onions, chopped', '1 red bell pepper, cut into matchstick-size strips', '1/2 cup fresh cilantro leaves']\"}}, {'_index': 'recipes-index', '_id': '_sGte5EBXCyFCBTswl2H', '_score': 0.039787807, '_rank': 9, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Sesame Noodles with Chili Oil and Scallions', 'embeddings': [39, -6, -62, -65, -9, -36, 5, 22, -53, 36, -5, 18, -8, -38, 30, -26, 12, -24, -24, -17, -2, -16, -15, -32, 22, -54, -72, -18, 4, -39, -10, 56, 75, 51, -100, 69, -128, 48, -14, -2, 67, -27, 13, 23, -27, -33, 47, -33, 21, -52, 0, 7, 2, -52, -34, -23, 50, 119, 61, -107, -125, 17, 59, 23, 59, -3, 34, 25, -67, 49, 93, -73, 10, -26, 11, -9, 7, 2, 12, 23, -61, -19, 22, -31, -35, -54, -42, 46, 18, -4, 11, -15, 41, 28, 14, -50, 15, 23, 13, 63, 22, -63, 92, -57, -21, 8, 22, 68, 40, 31, -17, 50, 26, -10, -47, -9, -21, 13, 0, -9, 3, 40, -1, 5, -9, 17, 16, -81, 11, 43, -37, 13, 17, 14, -12, -7, -1, -76, -7, -4, 53, -22, 54, 16, -39, 0, 14, 36, 8, 4, -25, 18, -13, 42, 0, 10, -24, 14, 29, 36, -53, 3, 27, -7, -27, -5, 56, 6, 21, 70, 3, -70, -11, -9, -30, 27, 42, -11, -27, 96, 31, -16, -25, 11, -18, -21, -8, 9, 43, -2, -13, 10, -90, 39, 8, 60, 0, 72, 2, -116, -50, 21, -50, 30, -21, -45, 0, 14, 73, 6, -27, 5, -10, -13, -70, 24, -35, 4, 20, 1, 61, -29, 33, -13, 17, -2, -13, -28, 8, 15, -40, 6, -34, -8, -95, -11, -14, 75, 20, 7, 14, -23, -25, -9, 38, 7, 27, -13, -9, -62, 55, -41, 61, 23, 44, 30, -4, 75, -40, 32, -35, 127, 81, 44, -27, 9, 37, 40, -7, 10, -6, 11, -3, -18, -65, -72, -50, 58, -31, -50, -5, 23, 40, -5, -15, 38, 69, 34, -24, 16, 33, 70, 37, 17, 12, 16, 63, 118, -66, 32, -66, -16, 67, -109, -6, 45, 11, 25, 0, -52, -12, -38, 31, -9, 4, -36, -26, 17, -69, -50, -32, 90, 13, 5, 63, -13, -32, 7, -36, 22, -25, -13, -18, 24, -18, 7, 50, -51, 3, 0, 69, -45, -6, 7, 40, -27, -39, -12, -16, 14, -19, -10, 32, 8, 79, -70, -101, 74, 6, -29, -39, 12, -46, -18, 5, -18, -17, 16, 1, 41, 35, 13, -72, -29, -65, -8, 21, -23, -18, -4, 10, -55, 112, -52, 57, 0, -52, 43, 7, 20, -52, -22, -45, -63, 11, 36, -32, 0, 3, -14, -11, 1, 34, -10, -25, -36, -34, -25, 25, 19, -38, 75, -53, 37, -15, -24, -1, -21, -82, 39, 101, -81, 23, 13, -71, -11, -17, 88, -60, -31, -31, -46, -6, -8, 28, 44, -48, 19, -41, -30, -25, -26, -13, 45, -22, -10, -24, -28, -5, 61, 5, 0, 9, 4, -45, -8, -4, 13, 32, 21, 2, -7, -15, 11, -30, -23, 54, -4, -39, 26, -18, 51, -1, -3, -8, -25, 31, 32, -46, -30, -39, 3, -8, 84, 15, 8, 56, 56, 28, -120, -96, -37, 42, -104, 34, -13, -17, 55, 53, 0, 3, -33, -15, -60, -33, -12, 26, 6, 50, 28, -30, 0, -30, 12, -41, 51, 13, -6, 9, -18, -3, 12, 2, 37, 17, 0, -71, 33, -20, -24, 46, 28, 13, -26, -32, -4, -1, -18, -48, -19, -7, -1, 2, -14, 16, 28, 24, 49, -13, 9, 10, 21, -46, 2, -24, -81, -83, 52, 5, -43, -11, -23, -31, 27, -30, 27, -7, -42, -54, -3, -23, -16, 51, 23, -51, -27, 38, 30, 5, -24, 9, -7, 2, 28, -8, 54, -31, -17, -1, 43, 4, -9, -40, -73, 19, 42, 28, 21, -8, 30, -25, 25, 8, -20, 27, 32, 6, 26, -13, -43, 14, -4, -22, 30, -53, -17, 12, 12, 11, -23, -9, -18, -12, -15, -23, -88, -33, -94, -39, 10, -53, 0, -25, 24, 56, 21, -20, 29, -50, -37, 18, 22, -9, -4, 46, -22, -14, -8, -43, -20, 14, -7, 6, -70, -21, -80, -15, 82, -70, 25, 16, 55, -39, 4, 81, -11, 10, -7, -7, 34, -70, -37, 79, -5, -15, -38, 47, -35, 6, -41, 22, 28, 18, 24, -46, 56, 7, -12, -16, -58, -9, 54, -41, 21, 18, -40, -26, -27, 75, -46, -11, 20, -44, -20, -7, 5, 31, 1, 32, -16, 32, 44, 6, -30, 93, 46, 108, -12, -28, -25, -68, 10, 2, -64, 22, -11, -54, -8, 11, 23, 20, 17, -3, -1, 10, -46, -7, -18, -21, -14, -53, 15, 18, 29, -18, -15, 36, 0, 13, 15, 80, -51, -25, -30, 19, -23, 7, -39, -35, 12, -5, -7, 2, 35, -37, 50, -14, -14, 22, 40, -2, -36, 2, 60, 10, 100, 7, -32, 8, 63, -25, 47, -97, -20, 65, -25, 50, -95, 73, 21, 15, -8, 32, 20, 28, -5, -19, -5, -12, -36, 2, -50, 9, 52, -19, 18, -68, 98, 1, 33, 12, 18, 6, -33, -55, 1, 31, 16, 25, -45, -26, 26, -11, 28, -37, -19, 37, -8, -32, 33, 31, -19, -13, -1, 5, 20, 11, -14, 12, 24, 56, -62, 58, 53, -57, -10, 2, -31, 64, 69, 24, -53, 0, -10, 1, 38, -9, -25, -12, 42, -23, 12, 44, 64, 15, -26, -22, 24, -40, 36, 33, -21, 35, 14, -34, 84, -17, 52, 34, -37, 11, -53, -41, -102, -66, -4, 40, 28, 40, -32, 11, -34, 10, -14, -6, -72, -23, -10, -58, 49, -60, -27, 31, -46, -67, 25, 55, 46, 19, 3, 0, 41, -13, 40, -14, -33, -23, 15, 30, -15, -18, 10, 30, -44, -98, -6, -28, -16, -17, 16, 18, -39, -113, 73, -27, -39, -49, 51, 40, -39, -20, -3, -55, -6, -67, 10, 64, -70, -36, -50, -12, -30, 43, -67, 67, 50, -49, -47, 5, -3, 24, -18, 15, -10, -93, 40, -27, -14, 104, 48, -39, 5, -5, 12, -26, -10, 0, 9, 5, 2, -32, 26, -58, -1, 3, 100, -52, -11, -41, 36, 35, -63, -6, -83, 96, 44, 32, 21, 78, -9, -10, 15, 50, 23, -60, 70, 18, -20, -24, -114, -13, -7, -65, 23, -1, -38, -30, -52, -128, -60, -6, -48, -89, 36]}]}}, 'Ingredients': '[\\'4 scallions, whites and greens separated, thinly sliced\\', \\'1/2 cup vegetable oil\\', \\'1 tablespoon crushed red pepper flakes\\', \\'2 teaspoons sesame seeds\\', \\'2 teaspoons Sichuan pepper, coarsely chopped\\', \\'12 ounces thin ramen noodles or spaghettini\\', \\'Kosher salt\\', \\'1/4 cup tahini (sesame seed paste)\\', \\'1/4 cup unseasoned rice vinegar\\', \\'3 tablespoons reduced-sodium soy sauce\\', \\'2 teaspoons toasted sesame oil\\', \\'1 teaspoon sugar\\', \"ingredient info: Sichuan pepper is available at Asian markets and some specialty foods stores. If you can\\'t find it, add an extra teaspoon each of red pepper and tahini.\"]', 'Title': 'Sesame Noodles with Chili Oil and Scallions', 'Instructions': 'Cook scallion whites, vegetable oil, red pepper flakes, sesame seeds, and pepper in a small saucepan over low heat, stirring occasionally, until oil is sizzling and scallions are golden brown, 12-15 minutes; let chili oil cool in saucepan.\\nMeanwhile, cook noodles in a large pot of salted boiling water until al dente; drain. Rinse under cold water and drain well.\\nWhisk tahini, vinegar, soy sauce, sesame oil, sugar, and 2-3 tablespoons chili oil (depending on desired heat) in a large bowl; season with salt. Add noodles and toss to coat. Top with scallion greens and drizzle with more chili oil.', 'ID': '5486', 'Image_Name': 'sesame-noodles-with-chili-oil-and-scallions-51170210', 'Cleaned_Ingredients': '[\\'4 scallions, whites and greens separated, thinly sliced\\', \\'1/2 cup vegetable oil\\', \\'1 tablespoon crushed red pepper flakes\\', \\'2 teaspoons sesame seeds\\', \\'2 teaspoons Sichuan pepper, coarsely chopped\\', \\'12 ounces thin ramen noodles or spaghettini\\', \\'Kosher salt\\', \\'1/4 cup tahini (sesame seed paste)\\', \\'1/4 cup unseasoned rice vinegar\\', \\'3 tablespoons reduced-sodium soy sauce\\', \\'2 teaspoons toasted sesame oil\\', \\'1 teaspoon sugar\\', \\'\"ingredient info: Sichuan pepper is available at Asian markets and some specialty foods stores. If you cant find it\\', \\'add an extra teaspoon each of red pepper and tahini.\"\\']'}}, {'_index': 'recipes-index', '_id': '5cGte5EBXCyFCBTsk0ka', '_score': 0.037963696, '_rank': 10, '_ignored': ['Cleaned_Ingredients.keyword', 'Ingredients.keyword', 'Instructions.keyword'], '_source': {'infer_field': {'inference': {'inference_id': 'cohere_embeddings', 'model_settings': {'task_type': 'text_embedding', 'dimensions': 1024, 'similarity': 'dot_product', 'element_type': 'byte'}, 'chunks': [{'text': 'Bright and Spicy Shrimp Noodle Salad', 'embeddings': [56, 2, -80, -81, 23, -29, -3, 16, -68, 32, -79, 53, -35, -10, 33, -54, 36, -6, 36, 9, 8, 24, -3, -30, 41, -12, -116, -41, 27, -6, 2, 19, 70, 10, -66, -16, -37, 20, -49, 37, 48, -39, -57, 24, -63, -33, 25, -10, 24, -74, 10, 0, 14, -46, -41, 7, 51, 33, 78, -98, -102, -33, 71, 11, 10, 8, -22, 29, -21, 9, 37, -59, 10, -13, -41, 5, 6, -8, 23, -27, 4, 39, 78, -38, 13, -62, -26, 8, 13, -32, -5, 21, 9, 4, -41, -33, -2, 55, -38, 40, -43, -1, 32, -57, -25, 23, 35, 72, 14, 11, -18, 14, 8, -14, -35, -24, -38, 27, -16, 11, 26, 62, 14, -12, -48, -12, -5, -69, -50, -7, -18, 67, 0, 0, -38, 1, 5, -28, -3, -38, 92, -27, -5, 43, -50, -8, 2, 23, 18, -37, -26, -32, 1, 49, 3, 53, -12, 18, -15, 43, -12, 12, 1, -20, -22, -48, 32, 25, 29, 95, 24, -60, 8, 1, -34, -12, 53, 19, -16, 41, -12, -70, -12, -6, -9, -40, -9, 38, 72, 43, -31, -50, -88, -16, 46, 65, 23, 37, 40, -80, -82, 25, -46, 56, 6, -5, -15, 16, 75, -1, -43, -14, 20, -76, -76, 25, -20, -28, 24, -13, 14, 53, 1, -14, 54, -5, 11, -32, 85, 21, -8, -11, 24, -14, -100, 7, -10, 6, 4, 35, 32, -19, -46, -81, 83, -30, -21, -25, 7, -22, 0, -40, 43, 14, 61, 10, 2, 38, -4, 55, -27, 127, 68, 60, -14, -16, 20, 29, 4, -29, 18, 13, -13, 6, 22, -67, -48, 5, -18, -33, -30, 25, 23, -3, -12, 7, 34, -9, -22, 0, -4, 119, 31, 14, 33, 33, 33, 99, -38, 16, -55, -8, 31, -77, -19, 48, 8, 16, -6, -92, 67, 42, 53, 78, 9, -59, 10, 58, -49, -69, -52, 99, 0, 9, 71, -21, -41, -4, -16, -27, 20, 14, -4, 71, 23, -18, 32, 38, 12, -81, 34, -80, -33, 30, 39, -55, -17, -23, 20, 21, -14, -9, 20, 92, 59, -110, -36, 84, -73, -25, 26, 1, -8, 21, 48, -59, -44, 1, 39, 20, 14, -14, -11, 15, -6, -32, -24, -73, 57, -18, -24, -35, 66, 9, 70, 24, -45, 23, -1, 5, -44, -12, -57, -48, 0, 27, -82, -15, -45, 0, -71, 41, 3, 33, -33, 27, -69, -43, 35, 33, -21, -5, -18, -15, -15, 15, 33, -4, -102, -8, 88, -69, 0, -8, -50, 17, -17, 46, -64, -4, -6, -46, 3, -44, -2, 22, -49, 22, -58, -13, -44, -17, 2, 4, 0, -43, 2, -22, 0, -4, 22, 6, 47, 10, -4, -3, -16, 51, 40, 18, -2, -51, 7, 39, -36, 27, 0, -19, -80, 47, -18, 27, 35, 38, -23, 6, -13, 31, -70, 0, -35, 19, -14, 85, 5, 10, 25, 16, 31, -37, -48, 1, 56, -51, 36, -8, 0, 60, 15, 9, -91, -6, -37, -67, 12, 3, -1, -6, -7, 18, -6, -32, 52, 13, -24, 45, -28, 30, -38, -31, -1, 26, -4, 53, 26, -21, -47, 10, -16, -12, 30, 16, 61, 10, -39, -24, -11, -16, -15, 0, -18, -55, -29, 9, 4, 9, 0, 98, -60, 83, 5, -7, -108, 0, 17, -15, -96, 48, -56, -51, -11, 14, -53, 9, -29, 14, 30, -15, -31, 1, -43, -30, 43, 1, -24, -41, -2, -3, 27, 39, -3, 39, 2, 0, -8, 36, -58, -25, -50, 3, -5, 21, -2, -64, 8, -14, 12, 1, 5, 10, -10, 17, 17, -28, 6, 17, 25, 5, -1, 1, 31, -10, -45, 30, -54, 0, -30, 47, -6, -59, 1, -30, -10, 22, -51, -38, 2, -90, -61, 21, -65, 14, -15, -5, 40, 24, -10, 4, -50, 7, 28, 26, -43, 6, 3, -8, -28, -56, -25, 5, 52, 3, -28, -36, 14, -36, -35, 88, -66, 24, -5, 54, 17, -10, 70, 40, -11, 30, 15, 23, -30, -35, 57, -1, -5, -8, 54, -16, 36, -31, -3, 3, 66, -86, 6, 62, 45, -18, -31, -72, -20, 75, -60, 35, 39, -47, -6, -104, 28, -55, 36, -49, -20, -74, 23, 15, 8, -74, 10, -5, -11, 8, -15, -17, 38, 71, 118, 13, 11, 0, -66, -50, -27, -35, 9, -17, -54, -18, 27, 47, 32, -28, 10, 2, 32, -116, 3, -8, 8, -46, -69, 16, 27, 62, -32, -46, 1, 50, -6, -46, 88, -4, -6, -2, 52, -16, -49, -42, 10, 1, -90, -8, -28, 25, -36, -22, -65, 14, -13, 31, 0, 19, 0, 17, -45, 28, -67, 66, 6, 49, -14, 67, -32, -22, 53, -30, -1, -83, 61, -16, -10, 5, 9, -48, -60, -38, 31, -3, -18, -11, 38, -87, 17, 30, -15, -24, -105, 113, 4, -11, 16, 13, 18, 0, -75, 5, -62, -60, 53, -35, 46, 64, -4, -15, -61, 30, 7, -76, 5, 36, 18, 19, -46, -15, 11, 15, -12, 3, 33, 16, 15, -19, 6, 32, -25, 6, 17, -26, 54, 86, 26, -24, 9, 30, -22, 39, 1, 4, 25, 75, -19, 50, 34, -7, 21, 4, -29, 15, -63, 47, 38, 14, 30, -55, -54, 37, -27, -33, -8, -10, 9, -80, -32, -72, -70, -28, 37, 4, 36, -27, -10, -36, 9, -30, -6, -71, 0, 7, -35, 30, -62, 0, 61, -43, -61, -15, 25, 29, -20, -20, 47, 11, -10, 25, -8, 16, -29, 2, 12, -38, 14, 44, -7, -76, -42, 27, -32, -55, 1, -25, -19, -61, -128, 62, -7, -47, -5, -7, 11, -31, -9, -20, -77, -3, -65, 56, 12, -33, -37, 4, 9, -8, 19, -4, -24, 9, -72, -67, -59, 38, 37, 28, 6, -11, -124, 30, -22, 4, 16, -10, -38, -17, -29, 0, -3, -40, 10, 3, -9, 5, -33, 58, -37, 2, -45, 111, -42, 14, -39, 66, 59, -28, 8, -50, 39, 35, 34, 5, 53, -38, -21, 22, 30, 14, -5, 76, 10, -28, -23, -51, -33, 34, -70, 25, -31, -33, -10, -38, -64, -83, 46, 18, -53, 46]}]}}, 'Ingredients': \"['⅓ cup fresh lime juice', '2 tsp. honey', '1 serrano chile, very thinly sliced', '1 (1-inch) piece ginger, peeled, finely grated', '1 garlic clove, finely grated', '1 Tbsp. plus 1½ tsp. fish sauce', '4 Tbsp. extra-virgin olive oil, divided', 'Kosher salt', '1 lb. large shrimp (preferably wild), peeled, deveined', '6 oz. bean thread (cellophane or glass) noodles', '1 English hothouse cucumber, halved lengthwise, thinly sliced crosswise', '½ cup salted, roasted peanuts, crushed, divided', '1 cup basil leaves']\", 'Title': 'Bright and Spicy Shrimp Noodle Salad', 'Instructions': 'Stir lime juice and honey in a small bowl until honey dissolves. Mix in chile, ginger, garlic, fish sauce, and 3 Tbsp. oil; season dressing with salt.\\nToss shrimp and 2 Tbsp. dressing in a medium bowl to coat; let sit 10 minutes.\\nMeanwhile, cook noodles according to package directions. Drain and add to bowl with remaining dressing along with cucumber and ¼ cup peanuts; toss well.\\nHeat remaining 1 Tbsp. oil in a large nonstick skillet over medium-high. Pour off any liquid from shrimp and pat dry; season all over with salt. Cook shrimp, tossing occasionally, until browned and bright pink, about 5 minutes. Transfer to bowl with noodles, add basil, and toss well to combine.\\nDivide noodle salad among bowls and top with remaining peanuts.', 'ID': '341', 'Image_Name': 'bright-and-spicy-shrimp-noodle-salad', 'Cleaned_Ingredients': \"['⅓ cup fresh lime juice', '2 tsp. honey', '1 serrano chile, very thinly sliced', '1 (1-inch) piece ginger, peeled, finely grated', '1 garlic clove, finely grated', '1 Tbsp. plus 1½ tsp. fish sauce', '4 Tbsp. extra-virgin olive oil, divided', 'Kosher salt', '1 lb. large shrimp (preferably wild), peeled, deveined', '6 oz. bean thread (cellophane or glass) noodles', '1 English hothouse cucumber, halved lengthwise, thinly sliced crosswise', '½ cup salted, roasted peanuts, crushed, divided', '1 cup basil leaves']\"}}]}}\n" + ] + } + ], + "source": [ + "noodles = semantic_search_with_reranking(\"best easy spicy noodles\")\n", + "print(noodles)" + ] + }, + { + "cell_type": "markdown", + "id": "588935b4", + "metadata": {}, + "source": [ + "## Extract the Data" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ba8cdb9b", + "metadata": {}, + "outputs": [], + "source": [ + "def pretty_print_recipe(recipes):\n", + " hits = recipes[\"hits\"][\"hits\"]\n", + " if len(hits) > 0:\n", + " for hit in hits:\n", + " source = hit[\"_source\"]\n", + " print(\n", + " \"Title:\",\n", + " source[\"Title\"] + \";\\t Ingredients:\",\n", + " source[\"Ingredients\"],\n", + " \";\\t Instructions:\",\n", + " source[\"Instructions\"],\n", + " )\n", + " print()\n", + " else:\n", + " print(\"No hits\")\n", + "\n", + "\n", + "def extract_recipe_as_string(recipes):\n", + " hits = recipes[\"hits\"][\"hits\"]\n", + " recipes = []\n", + " if len(hits) > 0:\n", + " for hit in hits:\n", + " source = hit[\"_source\"]\n", + " recipes.append(\n", + " \"Title: \"\n", + " + source[\"Title\"]\n", + " + \";\\t Ingredients: \"\n", + " + source[\"Ingredients\"]\n", + " + \";\\t Instructions: \"\n", + " + source[\"Instructions\"]\n", + " )\n", + " else:\n", + " return []\n", + " return recipes" ] }, { "cell_type": "code", - "execution_count": 83, + "execution_count": 11, "id": "3f0fc7e1", "metadata": {}, "outputs": [ @@ -508,36 +503,58 @@ "name": "stdout", "output_type": "stream", "text": [ - "Title: Sarah Connor (Terminator Genisys) (Origin: {{W|Terminator Genisys|Terminator Genisys)\n", - "Title: Malachi (Babylon 5) (Origin: ''Babylon 5'' episode ''The Coming of Shadows'')\n", - "Title: Michael (E.T.) (Origin: ''E.T. the Extra-Terrestrial'')\n", - "Title: Jack (Mass Effect) (Origin: ''{{w|Mass Effect 2)\n", - "Title: Jane (Babylon 5) (Origin: ''Babylon 5'')\n", - "Title: Jean-Luc Picard (Origin: ''Star Trek: The Next Generation'')\n", - "Title: Data (Star Trek) (Origin: ''Star Trek: The Next Generation'')\n", - "Title: Walter (Alien Covenant) (Origin: ''Alien: Covenant'')\n", - "Title: Adam Warlock (Marvel's Guardians of the Galaxy) (Origin: ''{{w|Marvel's Guardians of the Galaxy)\n", - "Title: Cooper (Jurassic Park) (Origin: ''Jurassic Park III'')\n", - "\n", - "Title: Abraham Van Helsing (Hotel Transylvania) (Origin: ''Hotel Transylvania 3: Summer Vacation'')\n", - "Title: Rand al'Thor (Origin: ''The Wheel of Time'')\n", - "Title: Draco Malfoy (Origin: ''Harry Potter'' series)\n", - "Title: Arthur Pendragon (Shrek) (Origin: ''{{W|Shrek the Third)\n", - "Title: Robin Hood (Prince of Thieves) (Origin: 1991 film ''Robin Hood: Prince of Thieves'')\n", - "Title: Christopher Robin (Disney) (Origin: ''Winnie the Pooh'')\n", - "Title: Remus Lupin (Origin: ''Harry Potter and the Prisoner of Azkaban'')\n", - "Title: Wade (Hotel Transylvania) (Origin: ''Hotel Transylvania'')\n", - "Title: Wilbur (Hotel Transylvania) (Origin: ''Hotel Transylvania'')\n", - "Title: Helga Hufflepuff (Origin: ''Harry Potter and the Philosopher's Stone'')\n" + "Title: Spicy Sesame Noodles with Chopped Peanuts and Thai Basil;\t Ingredients: ['1 tablespoon peanut oil', '2 tablespoons minced peeled fresh ginger', '2 garlic cloves, minced', '3 tablespoons Asian sesame oil', '2 tablespoons soy sauce', '2 tablespoons balsamic vinegar', '1 1/2 tablespoons sugar', '1 tablespoon (or more) hot chili oil*', '1 1/2 teaspoons salt', '1 pound fresh Chinese egg noodles or fresh angel hair pasta', '12 green onions (white and pale green parts only), thinly sliced', '1/2 cup coarsely chopped roasted peanuts', '1/4 cup thinly sliced fresh Thai basil leaves', '*Available in the Asian foods section of many supermarkets and at Asian markets.'] ;\t Instructions: Heat peanut oil in small skillet over medium heat. Add ginger and garlic; sauté 1 minute. Transfer to large bowl. Add next 6 ingredients; whisk to blend.\n", + "Place noodles in sieve over sink. Separate noodles with fingers and shake to remove excess starch. Cook in large pot of boiling salted water until just tender, stirring occasionally. Drain and rinse under cold water until cool. Drain thoroughly and transfer to bowl with sauce. Add sliced green onions and toss to coat noodles. Let stand at room temperature until noodles have absorbed dressing, tossing occasionally, about 1 hour. Stir in peanuts and Thai basil; toss again. Season to taste with salt and pepper. Serve at room temperature.\n", + "\n", + "Title: Liu Shaokun's Spicy Buckwheat Noodles with Chicken;\t Ingredients: ['3 cups chicken broth or water (24 fl oz)', '1 lb skinless boneless chicken breast halves (2)', '1/2 lb dried buckwheat noodles such as soba noodles', '1 tablespoon peanut oil', '3 tablespoons Chinese black vinegar', '1 tablespoon light soy sauce', '1 tablespoon dark soy sauce', '1 tablespoon chile oil containing sesame oil (such as Chiu Chow Chili Oil from Lee Kum Kee) plus some of sediment from jar', '2 garlic cloves, minced', '1/2 teaspoon sugar', '1/8 teaspoon salt', '3 scallions (green parts only), thinly sliced', '2 tablespoons soy nuts (roasted salted soybeans)'] ;\t Instructions: Bring broth to a simmer in a 3-quart saucepan, then add chicken and simmer, uncovered, 6 minutes. Remove pan from heat and cover, then let stand until chicken is cooked through, about 15 minutes. Transfer chicken to a plate and cool at least 10 minutes, reserving broth for another use.\n", + "While chicken is poaching, bring 4 quarts salted cold water to a boil in a 5- to 6-quart saucepan over moderately high heat. Stir in noodles, then 1/2 cup cold water. When water returns to a boil, add another 1/2 cup cold water and bring to a boil again, stirring, then repeat once more, or until noodles are just tender but still firm and chewy throughout.\n", + "Drain noodles in a colander and rinse well under cold water to cool, then drain well. Toss noodles with peanut oil in a large bowl.\n", + "Stir together vinegar, soy sauces, chile oil with sediment, garlic, sugar, and salt in another bowl until sugar is dissolved, then add to noodles and toss until coated.\n", + "Shred chicken with your fingers into 1/4-inch-wide strips and add to noodles, tossing to combine. Sprinkle with scallions and soy nuts.\n", + "\n", + "Title: Spicy Spaghetti with Fennel and Herbs;\t Ingredients: ['1 3-ounce package pancetta (Italian bacon), chopped', '1 tablespoon olive oil', '3 garlic cloves, chopped', '2 large red jalapeño chiles, seeded, finely chopped (about 1/4 cup)', '2 large fennel bulbs, stalks trimmed, cut into thin wedges with some core attached', '1 1/2 cups low-salt chicken broth', '4 tablespoons finely chopped fresh Italian parsley, divided', '2 tablespoons fresh lemon juice', '11/2 teaspoons crushed fennel seeds', '1 pound spaghetti', '2 tablespoons extra-virgin olive oil', '1 1/2 cups finely grated Pecorino Romano or Pecorino Toscano cheese, divided'] ;\t Instructions: Sauté pancetta in large skillet over medium heat until pancetta is golden. Using slotted spoon, transfer pancetta to paper towels. Add 1 tablespoon oil to drippings in skillet. Add garlic and chiles; sauté over medium heat 1 minute. Add fennel; cook until beginning to soften, 5 minutes. Mix in broth, 2 tablespoons parsley, lemon juice, and fennel seeds. Bring to boil. Reduce heat to low, cover, and cook until fennel is very tender, 20 minutes. Remove from heat. Season with salt and pepper.\n", + "Cook pasta until tender; drain. Reserve 1 cup cooking liquid. Return pasta to pot.\n", + "Uncover skillet with fennel mixture and return to high heat. Cook until almost all liquid is absorbed, about 4 minutes. Add fennel to pasta. Stir in 2 tablespoons oil, 1/2 cup cheese, and pancetta. Add cooking liquid by 1/4 cupfuls if dry. Toss pasta; transfer to serving bowl. Sprinkle 2 tablespoons parsley over. Serve with cheese.\n", + "\n", + "Title: Spicy Soba Noodles with Shiitakes and Cabbage;\t Ingredients: ['1/3 cup water', '1/3 cup soy sauce', '2 to 3 teaspoons Korean hot-pepper paste (sometimes labeled \"gochujang\")', '1 tablespoon packed brown sugar', '3 tablespoons sesame seeds', '1/4 cup vegetable oil', '2 tablespoons finely chopped peeled ginger', '1 tablespoon finely chopped garlic', '10 oz fresh shiitake mushrooms, stemmed and thinly sliced', '1 1/4 pound Napa cabbage, thinly sliced (8 cups)', '6 scallions, thinly sliced', '8 to 9 ounces soba (buckwheat noodles)', '1 cup frozen shelled edamame'] ;\t Instructions: Stir together all sauce ingredients until brown sugar is dissolved, then set aside.\n", + "Toast sesame seeds in a dry 12-inch heavy skillet (not nonstick) over medium heat, stirring, until pale golden, then transfer to a small bowl.\n", + "Heat oil in skillet over medium-high heat until it shimmers, then sauté ginger and garlic, stirring, until fragrant, about 30 seconds. Add shiitakes and sauté, stirring frequently, until tender and starting to brown, about 6 minutes. Reduce heat to medium, then add cabbage and most of scallions (reserve about a tablespoon for garnish) and cook, stirring occasionally, until cabbage is crisp-tender, about 6 minutes. Add sauce and simmer 2 minutes.\n", + "While cabbage is cooking, cook soba and edamame together in a pasta pot of boiling salted water (2 tablespoons salt for 6 quarts water) until noodles are just tender, about 6 minutes. Drain in a colander and rinse under cool water to stop cooking and remove excess starch, then drain well again. Transfer to a large bowl and toss with sesame seeds and vegetable mixture. Serve sprinkled with reserved scallions.\n", + "\n", + "Title: Spicy Curry Noodle Soup with Chicken and Sweet Potato;\t Ingredients: ['2 tablespoons vegetable oil', '3 tablespoons chopped shallots', '3 garlic cloves, chopped', '2 tablespoons minced lemongrass* (from bottom 4 inches of about 3 stalks, tough outer leaves discarded)', '2 tablespoons minced peeled fresh ginger', '2 tablespoons Thai yellow curry paste*', '2 tablespoons curry powder', '1 teaspoon hot chili paste (such as sambal oelek)*', '2 13.5- to 14-ounce cans unsweetened coconut milk,* divided', '5 cups low-salt chicken broth', '2 1/2 tablespoons fish sauce (such as nam pla or nuoc nam)*', '2 teaspoons sugar', '3 cups snow peas, trimmed', '2 cups 1/2-inch cubes peeled red-skinned sweet potato (yam; from about 1 large)', '1 pound dried rice vermicelli noodles or rice stick noodles*', '3/4 pound skinless boneless chicken thighs, thinly sliced', '1/2 cup thinly sliced red onion', '1/4 cup thinly sliced green onions', '1/4 cup chopped fresh cilantro', '3 red Thai bird chiles or 2 red jalapeño chiles, thinly sliced with seeds', '1 lime, cut into 6 wedges'] ;\t Instructions: Heat oil in heavy large saucepan over medium heat. Add next 4 ingredients; stir until fragrant, about 1 minute. Reduce heat to medium-low. Stir in curry paste, curry powder, and chili paste. Add 1/2 cup coconut milk (scooped from thick liquid at top of can). Stir until thick and fragrant, about 2 minutes. Add remaining coconut milk, broth, fish sauce, and sugar; bring broth to boil. Keep warm. DO AHEAD: Can be made 1 day ahead. Refrigerate until cold, then cover and keep chilled.\n", + "Cook snow peas in large pot of boiling salted water until bright green, about 20 seconds. Using strainer, remove peas from pot; rinse under cold water to cool. Place peas in medium bowl. Bring water in same pot back to boil. Add sweet potato and cook until tender, about 7 minutes. Using strainer, remove sweet potato from pot and rinse under cold water to cool. Place in small bowl. Bring water in same pot back to boil and cook noodles until just tender but still firm to bite, about 6 minutes. Drain; rinse under cold water to cool. Transfer to microwave-safe bowl. DO AHEAD: Can be made 1 hour ahead. Let stand at room temperature.\n", + "Bring broth to simmer. Add chicken; simmer until chicken is cooked through, about 10 minutes. Add sweet potato; stir to heat through, about 1 minute. Heat noodles in microwave in 30-second intervals to rewarm. Cut noodles with scissors if too long. Divide noodles among bowls. Divide snow peas and hot soup among bowls. Scatter red onion, green onions, cilantro, and chiles over soup. Garnish with lime wedges and serve.\n", + "*Available at some supermarkets, at specialty foods stores and Asian markets, and online from adrianascaravan.com.\n", + "\n", + "Title: Sweet and Spicy Peanut Noodles;\t Ingredients: ['1 teaspoon sesame oil', '1 garlic clove, finely chopped', '2 teaspoons finely chopped ginger', '1/4 cup natural chunky peanut butter', '2 tablespoons low-sodium soy sauce', '1 tablespoon hoisin sauce', '1 tablespoon brown sugar', '1 tablespoon rice vinegar', '1/2 teaspoon Asian chile paste (or to taste)', '6 ounces cooked linguine', '1/3 cup sliced scallions'] ;\t Instructions: In a small saucepan, heat oil over medium heat. Add garlic and ginger; cook, stirring, until just soft, 1 minute. Add 3 tablespoons water, peanut butter, soy sauce, hoisin, sugar, vinegar and chile paste; cook, stirring often, until sauce is thick, about 4 minutes. Toss in noodles and scallions; serve at room temperature.\n", + "\n", + "Title: Spicy Tomato–Tuna Noodle Skillet Casserole With Aioli;\t Ingredients: ['1 large egg yolk', '1 garlic clove, finely grated', '¼ tsp. kosher salt, plus more', '½ cup (or more) extra-virgin olive oil', '1 medium onion, cut into large pieces', '2 garlic cloves', '½ cup coarsely chopped roasted red peppers from a jar', '3 Tbsp. extra-virgin olive oil, plus more for drizzling', '12 oz. rigatoni, mezzi rigatoni, ditali, or other short or medium-length straight tube pasta', '2 (5–6-oz.) cans or jars oil-packed tuna', '1 oil-packed anchovy fillet, coarsely chopped', '1 tsp. kosher salt, divided', 'Freshly ground black pepper', '2 Tbsp. double-concentrated or regular tomato paste', '1 (14.5-oz.) can crushed tomatoes or whole peeled tomatoes with their juices, crushed', '1 tsp. ground turmeric', '¼ tsp. crushed red pepper flakes', 'Coarsely chopped parsley (for serving; optional)'] ;\t Instructions: Whisk egg yolk, garlic, ¼ tsp. salt, and 2 tsp. water in a small bowl to combine. Place bowl on a kitchen towel so it won’t slide around as you whisk and gradually stream in oil, whisking constantly until thick and emulsified. Aioli should be thick but pourable; gradually whisk in more oil if needed. Taste and season with more salt if desired.\n", + "Place rack in upper third of oven; preheat to 375°F. Pulse onion, garlic, and roasted red peppers in a food processor until finely chopped; set aside.\n", + "Heat 3 Tbsp. olive oil in a 10” ovenproof skillet, preferably cast iron, over medium-low. Add pasta and cook, stirring often, until evenly coated in oil and lightly browned, about 5 minutes (depending on the size and shape of your pasta, you may need to work in batches). Using a slotted spoon, transfer to a large bowl. Reserve pan.\n", + "Drain tuna, reserving 2 Tbsp. tuna oil. place oil in reserved pan and increase heat to medium. Add anchovy, ½ tsp. salt, and reserved chopped vegetable mixture and season with pepper. Cook, stirring occasionally, until vegetables soften, 5–7 minutes. Add tomato paste and cook, stirring, until slightly darkened in color, about 3 minutes. Mix in toasted pasta, tomatoes, turmeric, red pepper flakes, remaining ½ tsp. salt, and 2½ cups water and bring to a boil. Cook, stirring occasionally, until pasta is slightly softened, 8–10 minutes. Remove from heat and stir in drained tuna and ¼ cup water.\n", + "Transfer skillet to oven and bake casserole until pasta is tender and juices at the edges are bubbling, about 15 minutes. Remove from oven.\n", + "Heat broiler. Drizzle casserole with a little olive oil and broil until browned and crisped in spots, about 4 minutes.\n", + "Spoon some aioli over casserole and top with parsley if desired. Serve remaining aioli alongside.\n", + "\n", + "Title: Spicy Asian Noodle and Chicken Salad;\t Ingredients: ['1/3 cup creamy peanut butter (do not use old-fashioned style or freshly ground)', '1/4 cup soy sauce', '2 tablespoons unseasoned rice vinegar', '2 tablespoons chili-garlic sauce', '1 tablespoon (packed) golden brown sugar', '1 tablespoon minced peeled fresh ginger', '3 tablespoons (or more) low-salt chicken broth', '3/4 pound linguine or dried chow mein udon noodles', '4 cups thinly sliced cooked chicken, cut into strips', '2 large carrots, coarsely grated (about 1 1/4 cups)', '6 green onions, chopped', '1 red bell pepper, cut into matchstick-size strips', '1/2 cup fresh cilantro leaves'] ;\t Instructions: Combine peanut butter, soy sauce, rice vinegar, chili-garlic sauce, brown sugar, ginger, and 3 tablespoons broth in processor; blend until smooth. Season dressing to taste with salt and pepper.\n", + "Cook pasta in large pot of boiling salted water until tender but still firm to bite, stirring occasionally. Drain pasta; rinse with cold water to cool and drain again. Transfer pasta to large bowl. Add chicken, carrots, green onions, bell pepper, and cilantro; toss to blend. Pour dressing over and toss to coat, adding more broth by tablespoonfuls if dressing is too thick. Season salad to taste with salt and pepper.\n", + "\n", + "Title: Sesame Noodles with Chili Oil and Scallions;\t Ingredients: ['4 scallions, whites and greens separated, thinly sliced', '1/2 cup vegetable oil', '1 tablespoon crushed red pepper flakes', '2 teaspoons sesame seeds', '2 teaspoons Sichuan pepper, coarsely chopped', '12 ounces thin ramen noodles or spaghettini', 'Kosher salt', '1/4 cup tahini (sesame seed paste)', '1/4 cup unseasoned rice vinegar', '3 tablespoons reduced-sodium soy sauce', '2 teaspoons toasted sesame oil', '1 teaspoon sugar', \"ingredient info: Sichuan pepper is available at Asian markets and some specialty foods stores. If you can't find it, add an extra teaspoon each of red pepper and tahini.\"] ;\t Instructions: Cook scallion whites, vegetable oil, red pepper flakes, sesame seeds, and pepper in a small saucepan over low heat, stirring occasionally, until oil is sizzling and scallions are golden brown, 12-15 minutes; let chili oil cool in saucepan.\n", + "Meanwhile, cook noodles in a large pot of salted boiling water until al dente; drain. Rinse under cold water and drain well.\n", + "Whisk tahini, vinegar, soy sauce, sesame oil, sugar, and 2-3 tablespoons chili oil (depending on desired heat) in a large bowl; season with salt. Add noodles and toss to coat. Top with scallion greens and drizzle with more chili oil.\n", + "\n", + "Title: Bright and Spicy Shrimp Noodle Salad;\t Ingredients: ['⅓ cup fresh lime juice', '2 tsp. honey', '1 serrano chile, very thinly sliced', '1 (1-inch) piece ginger, peeled, finely grated', '1 garlic clove, finely grated', '1 Tbsp. plus 1½ tsp. fish sauce', '4 Tbsp. extra-virgin olive oil, divided', 'Kosher salt', '1 lb. large shrimp (preferably wild), peeled, deveined', '6 oz. bean thread (cellophane or glass) noodles', '1 English hothouse cucumber, halved lengthwise, thinly sliced crosswise', '½ cup salted, roasted peanuts, crushed, divided', '1 cup basil leaves'] ;\t Instructions: Stir lime juice and honey in a small bowl until honey dissolves. Mix in chile, ginger, garlic, fish sauce, and 3 Tbsp. oil; season dressing with salt.\n", + "Toss shrimp and 2 Tbsp. dressing in a medium bowl to coat; let sit 10 minutes.\n", + "Meanwhile, cook noodles according to package directions. Drain and add to bowl with remaining dressing along with cucumber and ¼ cup peanuts; toss well.\n", + "Heat remaining 1 Tbsp. oil in a large nonstick skillet over medium-high. Pour off any liquid from shrimp and pat dry; season all over with salt. Cook shrimp, tossing occasionally, until browned and bright pink, about 5 minutes. Transfer to bowl with noodles, add basil, and toss well to combine.\n", + "Divide noodle salad among bowls and top with remaining peanuts.\n", + "\n" ] } ], "source": [ - "sci_fi_characters = semantic_search_with_reranking(\"Characters from sci-fi movies\")\n", - "pretty_print_characters(sci_fi_characters)\n", - "print()\n", - "fantasy_characters = semantic_search_with_reranking(\"Characters from fantasy movies\")\n", - "pretty_print_characters(fantasy_characters)" + "noodles = semantic_search_with_reranking(\"best easy spicy noodles\")\n", + "pretty_print_recipe(noodles)" ] }, { @@ -562,7 +579,7 @@ }, { "cell_type": "code", - "execution_count": 96, + "execution_count": 12, "id": "f0cd13fe", "metadata": {}, "outputs": [ @@ -572,13 +589,12 @@ "ObjectApiResponse({'model_id': 'cohere_completion', 'inference_id': 'cohere_completion', 'task_type': 'completion', 'service': 'cohere', 'service_settings': {'model_id': 'command-r-plus', 'rate_limit': {'requests_per_minute': 10000}}, 'task_settings': {}})" ] }, - "execution_count": 96, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "client.inference.delete(inference_id=\"cohere_completion\")\n", "client.inference.put(\n", " task_type=\"completion\",\n", " inference_id=\"cohere_completion\",\n", @@ -594,92 +610,295 @@ }, { "cell_type": "code", - "execution_count": 107, - "id": "2a9333e5", + "execution_count": 13, + "id": "0f843238", + "metadata": {}, + "outputs": [], + "source": [ + "def RAG(query):\n", + " input = [\n", + " \"\"\"Context: you are a personal assistant helping to explain the best recipes for users based on their query and the supplied recipes (seperated by \\n\\n). \n", + " You must pick one recipe which best fits the query, and print out the title, ingredients, and instructions in an easy to understand way.\n", + " If none of the recipes fit the query, supply a query the user might be able to use to find a recipe.\n", + " Feel free to provide comments about the recipe that are related to the query, including alternative query.\"\"\"\n", + " ]\n", + "\n", + " input.append(\"Query:\" + str(query))\n", + "\n", + " recipes = extract_recipe_as_string(semantic_search_with_reranking(query))\n", + " if len(recipes) > 0:\n", + " input.append(\"Recipes:\" + \"\\n\\n\".join(recipes))\n", + "\n", + " chat_completion = client.inference.inference(\n", + " inference_id=\"cohere_completion\", input=\"\\n\\n\\n\".join(input)\n", + " )\n", + " print(chat_completion[\"completion\"][0][\"result\"])\n", + " else:\n", + " print(\"No hits\")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "5f4a3373", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['Abraham Van Helsing (Hotel Transylvania)', \"Adam Warlock (Marvel's Guardians of the Galaxy)\", 'Arthur Pendragon (Shrek)', 'Christopher Robin (Disney)', 'Cooper (Jurassic Park)', 'Data (Star Trek)', 'Draco Malfoy', 'Helga Hufflepuff', 'Jack (Mass Effect)', 'Jane (Babylon 5)', 'Jean-Luc Picard', 'Malachi (Babylon 5)', 'Michael (E.T.)', \"Rand al'Thor\", 'Remus Lupin', 'Robin Hood (Prince of Thieves)', 'Sarah Connor (Terminator Genisys)', 'Wade (Hotel Transylvania)', 'Walter (Alien Covenant)', 'Wilbur (Hotel Transylvania)']\n" + "Here is a recipe that fits your query:\n", + "\n", + "## Spicy Soba Noodles with Shiitakes and Cabbage\n", + "\n", + "### Ingredients:\n", + "- 1/3 cup water\n", + "- 1/3 cup soy sauce\n", + "- 2 to 3 teaspoons Korean hot-pepper paste (gochujang)\n", + "- 1 tablespoon packed brown sugar\n", + "- 3 tablespoons sesame seeds\n", + "- 1/4 cup vegetable oil\n", + "- 2 tablespoons finely chopped peeled ginger\n", + "- 1 tablespoon finely chopped garlic\n", + "- 10 oz fresh shiitake mushrooms, stemmed and thinly sliced\n", + "- 1 1/4 pound Napa cabbage, thinly sliced (about 8 cups)\n", + "- 6 scallions, thinly sliced\n", + "- 8 to 9 ounces soba (buckwheat noodles)\n", + "- 1 cup frozen shelled edamame\n", + "\n", + "### Instructions:\n", + "1. Stir together all sauce ingredients until the brown sugar is dissolved, and set aside.\n", + "2. Toast the sesame seeds in a dry skillet over medium heat until pale golden, then transfer to a bowl.\n", + "3. Heat oil in the skillet over medium-high heat, then add ginger and garlic, stirring until fragrant (about 30 seconds).\n", + "4. Add shiitake mushrooms and sauté until tender and browned (about 6 minutes).\n", + "5. Reduce heat to medium, then add cabbage and most of the scallions (reserve some for garnish). Cook until the cabbage is crisp-tender (about 6 minutes).\n", + "6. Pour in the sauce and simmer for 2 minutes.\n", + "7. In a separate pot, cook the soba noodles and edamame in boiling salted water until just tender (about 6 minutes). Drain and rinse with cool water to stop the cooking process.\n", + "8. Transfer the noodles and edamame to a large bowl, and toss with the sesame seeds and vegetable mixture.\n", + "9. Serve, garnished with the remaining scallions.\n", + "\n", + "This recipe is a great choice for an easy spicy noodle dish, as it requires minimal prep work and comes together quickly. The gochujang (Korean hot-pepper paste) adds a nice kick, and the shiitake mushrooms and cabbage provide a delicious umami flavor. If you want an even spicier dish, feel free to add more gochujang or include some chili flakes or fresh chili peppers. Enjoy!\n" ] } ], "source": [ - "characters = []\n", - "for hit in sci_fi_characters[\"hits\"][\"hits\"]:\n", - " characters.append(hit[\"_source\"][\"title\"])\n", - "for hit in fantasy_characters[\"hits\"][\"hits\"]:\n", - " characters.append(hit[\"_source\"][\"title\"])\n", - "\n", - "\n", - "characters.sort()\n", - "print(characters)\n", - "\n", - "query = \"What generes of movies are these characters from?\"\n", - "input = [\n", - " query,\n", - " \"characters\",\n", - " characters,\n", - "]" + "RAG(\"best easy spicy noodles\")" ] }, { "cell_type": "code", - "execution_count": 108, - "id": "39badebf", + "execution_count": 15, + "id": "50399e8e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Title: Roman Style Pizza with Roasted Cherry Tomatoes;\t Ingredients: ['2 teaspoons sugar', '1 1/2 teaspoon active dry yeast', '7 1/2 tablespoons extra-virgin olive oil, divided', '1 teaspoon kosher salt, plus more', '2 1/4 cups (or more) all-purpose flour', '1½ pound cherry or grape tomatoes', 'Freshly ground black pepper', 'Semolina (for dusting)', '2/3 cup freshly grated Parmesan, divided', '2 cups grated mozzarella (about 8 ounces), or 6 ounces buffalo mozzarella, thinly sliced, divided', 'Chopped fresh basil'] ;\t Instructions: Combine 3/4 cup warm water (105°-115°F), sugar, and yeast in a large bowl; let sit until spongy, 4-5 minutes. Mix in 1 1/2 tablespoons oil and 1 teaspoon salt. Stir in 2 1/4 cups flour. Turn out onto a work surface; knead until smooth and elastic, adding more flour if sticking, about 6 minutes. Grease a large bowl with 1 tablespoon oil. Add dough, cover bowl with plastic; let rise until doubled, about 1 1/2 hours.\n", + "Meanwhile, position one rack in top third of oven and another in bottom third; place a pizza stone on top rack and preheat oven to 500°F. Scatter tomatoes on a large rimmed baking sheet. Add 1 tablespoon oil, toss, and season with salt and pepper. Place on lower rack; roast until skins split, 10-12 minutes. Let cool on rack. Continue heating pizza stone for 45 more minutes.\n", + "Sprinkle a pizza peel or rimless baking sheet with semolina. Divide dough in half; roll or stretch each into a 13x9\" rectangle. Cover with kitchen towels; let stand for 15 minutes. Transfer 1 rectangle to prepared pizza peel. Brush with 2 tablespoons oil, sprinkle with half of the Parmesan, then mozzarella, and top with half of the tomatoes. Season with salt and pepper.\n", + "Set front of peel at far edge of stone; gently jiggle peel side to side, sliding pizza onto stone as you remove peel. Bake until crust is browned and crisp, 9-10 minutes. Using peel, transfer pizza to work surface. Garnish with basil. Slice and Serve.\n", + "Repeat to make second pizza.\n", + "\n", + "Title: Phyllo Pizza with Smoked Mozzarella and Cherry Tomatoes;\t Ingredients: ['12 to 13 ounces cherry tomatoes and/or pear tomatoes', '1 tablespoon extra-virgin olive oil', '3/4 teaspoon coarse kosher salt', '1/2 teaspoon dried oregano', '12 12x9-inch sheets fresh phyllo pastry or frozen, thawed', '6 tablespoons (3/4 stick) unsalted butter, melted', '4 tablespoons finely grated Parmesan cheese, divided', '3/4 cup (packed) coarsely grated smoked mozzarella cheese* (about 3 ounces)', '1/2 yellow bell pepper, cut into thin strips', '1/4 cup quartered pitted Kalamata olives', '2 teaspoons coarsely chopped fresh oregano'] ;\t Instructions: Preheat oven to 400°F. Toss tomatoes, olive oil, salt, and oregano in medium bowl. Scatter tomatoes on large rimmed baking sheet; roast until soft and beginning to collapse, about 22 minutes. Remove from oven and let tomato mixture cool. Maintain oven temperature.\n", + "Place stack of phyllo sheets on work surface and cover with plastic wrap, then damp kitchen towel to prevent drying.\n", + "Brush another large rimmed baking sheet with some of melted butter. Place 1 phyllo sheet on baking sheet. Brush lightly with melted butter and top with second phyllo sheet. Brush with butter and top with third sheet; brush with butter. Sprinkle with 1 tablespoon Parmesan. Repeat 3 more times for total of 12 phyllo sheets and 4 tablespoons Parmesan. Sprinkle stacked phyllo sheets with grated mozzarella, leaving 1/2-inch plain border. Top with roasted tomatoes, pepper strips, and olives.\n", + "Bake pizza until phyllo is crisp, 25 to 27 minutes. Sprinkle 2 teaspoons fresh oregano over, loosen pizza from sheet with large metal spatula, and slide onto cutting board.\n", + "*Also called mozzarella affumicata; sold at some specialty foods stores and at cheese shops. If unavailable, use regular (not fresh) whole-milk mozzarella.\n", + "\n", + "Title: French Bread Pizzas With Ricotta, Roasted Tomatoes, and Pesto;\t Ingredients: ['1 1/2 pints cherry tomatoes, halved (about 3 cups)', '1 tablespoon plus 2 teaspoons olive oil, divided', '1/4 teaspoon kosher salt, plus more to taste', '1/4 teaspoon freshly ground black pepper, plus more to taste', '1 (12–14\") soft loaf French or Italian bread, split in half lengthwise', '1 garlic clove, smashed', '1/2 cup fresh ricotta (about 5 ounces)', '3/4 cup coarsely grated Parmesan (about 3 ounces)', '2 tablespoons fresh store-bought or homemade basil pesto'] ;\t Instructions: Position rack in top third of oven and preheat to 425°F. Toss tomatoes, 1 Tbsp. oil, 1/4 tsp. salt, and 1/4 tsp. pepper on a rimmed baking sheet. Roast until tomatoes start to blister, about 13 minutes.\n", + "Place bread, cut side up, on another rimmed baking sheet and bake 5 minutes. Remove from oven and rub cut sides with garlic.\n", + "Dollop ricotta on cut sides of bread. Top evenly with tomato mixture, then sprinkle with Parmesan. Bake until Parmesan melts, about 10 minutes.\n", + "Whisk pesto and remaining 2 tsp. oil in a small bowl until smooth. Drizzle on pizzas and season with salt and pepper.\n", + "\n", + "Title: Cauliflower-Crust Pizza with Tomatoes and Mozzarella;\t Ingredients: ['1 small head of cauliflower (about 1 pound), coarsely chopped', '1 large egg, lightly beaten', '1 cup grated Parmesan (about 3 ounces)', '3/4 cup finely ground almond meal or almond flour', '1 garlic clove, finely chopped', '1/2 teaspoon dried Italian seasoning', '1/2 teaspoon kosher salt', '1/4 teaspoon freshly ground black pepper', '1 1/2 cups shredded part-skim mozzarella (about 5 ounces), divided', 'Vegetable oil (for brushing)', '1/2 cup marinara sauce', '1/4 cup basil leaves, torn', '1/2 teaspoon red pepper flakes (optional)', 'A pizza stone and peel, or 2 baking sheets'] ;\t Instructions: Arrange a rack in middle of oven; place pizza stone or inverted (if rimmed) baking sheet on rack. Preheat to 425°F.\n", + "Working in batches if needed, pulse cauliflower in a food processor fitted with the blade, or grate using the medium holes of a box grater, until fine crumbs form and are rice-like in texture. Transfer to a clean kitchen towel and tightly squeeze to remove as much liquid as possible.\n", + "Mix cauliflower, egg, Parmesan, almond meal, garlic, Italian seasoning, salt, and black pepper in a medium bowl until mixture holds together when pinched.\n", + "Line pizza peel or second baking sheet with parchment paper; generously brush with oil. Form cauliflower mixture into a 12\" circle with your hands on parchment. Using a rolling pin, make thickness as even as possible. Carefully slide parchment onto preheated pizza stone or baking sheet.\n", + "Bake cauliflower crust until golden brown and firm to the touch, rotating halfway through, 20–22 minutes.\n", + "Remove from oven. Sprinkle with 1 1/4 cups mozzarella. Top with sauce, using the back of a spoon to spread over cheese. Sprinkle with remaining 1/4 cup mozzarella.\n", + "Slide pizza back onto pizza stone or baking sheet and continue to bake until bubbly and browned in spots, 5–7 minutes. Top with basil and red pepper, if using. Let sit 5 minutes, then cut into 6–8 wedges.\n", + "Pizza can be made 3 days ahead; transfer to a resealable container and chill. Reheat in a 350°F oven until warmed through.\n", + "\n", + "Title: Summer Pizza with Salami, Zucchini, and Tomatoes;\t Ingredients: ['5 Tbsp. extra-virgin olive oil, divided', '2 lb. store-bought pizza dough, room temperature', '2 cups whole-milk fresh ricotta (about 1 lb.)', '1 1/2 tsp. kosher salt, divided', '1 tsp. freshly ground black pepper, divided', '4 oz. thinly sliced soppressata', '1 medium shallot, finely chopped', '2 Tbsp. red wine vinegar', '2 medium zucchini (about 1 lb. total), thinly shaved lengthwise on a mandoline or with a vegetable peeler', '1 pint grape tomatoes, halved', '1 cup basil leaves'] ;\t Instructions: Preheat oven to 425°F. Brush an 18x13\" rimmed baking pan with 1 Tbsp. oil. Gently stretch dough to a 16x12\" oval and place in prepared baking sheet, pressing dough into edges of pan. (If dough springs back, cover with plastic wrap and let rest 10 minutes before stretching again.) Brush dough with 1 Tbsp. oil, then bake until golden and dry, 15–18 minutes.\n", + "Meanwhile, whisk ricotta, 1 Tbsp. oil, 1 tsp. salt, and 1/2 tsp. pepper in a medium bowl until mixture looks a little whipped and fluffy. (If your ricotta is on the drier side, add another tablespoonful of oil.)\n", + "Spread ricotta mixture over crust, leaving about a 1/2\" margin on all sides. Top with a single layer of soppressata, overlapping slightly if needed. Bake pizza until ricotta mixture is golden and edges of soppressata are curled up and crisp, about 15 minutes.\n", + "Whisk shallot, vinegar, and remaining 2 Tbsp. oil, 1/2 tsp. salt, and 1/2 tsp. pepper in a small bowl. Gently toss zucchini, tomatoes, and basil in a large bowl. Drizzle about one-third of the dressing over and toss again. Pile onto pizza with your hands. Drizzle remaining dressing over pizza and cut into slices.\n", + "\n", + "Title: Pizza with Sausage, Tomatoes and Basil;\t Ingredients: ['1 1/4 cups all-purpose enriched flour', '1 1/2 teaspoons active dry yeast', '1 teaspoon salt', 'Vegetable oil cooking spray', '1 pound red and yellow cherry tomatoes, halved', '1/2 pound turkey sausage, cooked and thinly sliced', '1 cup grated part-skim mozzarella', '1 tablespoon chopped fresh basil', '1 tablespoon balsamic vinegar', '1 tablespoon olive oil', '1/2 teaspoon salt', '1/2 teaspoon red pepper flakes'] ;\t Instructions: Mix flour, yeast and salt in a bowl. Gradually add 1/2 cup warm (110°F) water until a soft dough forms. Divide dough into 4 portions. Using hands, roll dough into balls. Coat with cooking spray, cover with plastic wrap and set aside to rise, 30 to 45 minutes. When ready to cook, place each ball of dough on a piece of wax paper and flatten into a 4-inch circle. Coat grill with cooking spray and heat on high. Gently place dough onto grill and cook until dough puffs and underside stiffens (about 30 seconds); flip and reduce heat to low. Mix topping ingredients, then divide among crusts. Cover grill. Cook until cheese melts, 5 to 6 minutes more. Slice and serve.\n", + "\n", + "Title: Pesto–Heirloom Tomato Pizza;\t Ingredients: ['1 to 2 cloves garlic, crushed (optional)', '1/2 to 1 cup firmly packed fresh basil leaves, or to taste', 'Juice of 1/2 lemon or 2 tablespoons bottled lemon juice, or more to taste', '1/2 cup walnut halves or shelled unsalted pistachios or 1/4 cup pine nuts (omit nuts if you’d like a less caloric pesto)', '6 ounces baby spinach, arugula, watercress, or a combination', 'Salt and freshly ground pepper to taste', 'Whole-Wheat Pizza Crust', 'Heirloom tomatoes, sliced, to taste (preferably a mix of yellow and red varieties)', 'Basil leaves, thinly sliced, for topping', 'Vegan Parmesan-style cheese and fresh oregano for topping (optional)'] ;\t Instructions: Combine the first five ingredients in a food processor and pulse until the mixture is evenly combined yet still coarse in texture. You may need to add the spinach in batches if your processor has a small or medium-size container.\n", + "Stop the machine and season the mixture gently with salt and pepper; taste to see if you'd like to add more lemon juice, then pulse a few times to mix.\n", + "Bake pizza dough rounds in a preheated 425°F oven for 15 minutes, until crust is golden.\n", + "Spread pizza crust with pesto, then load up with sliced heirloom tomatoes. Sprinkle with salt and pepper and top with plenty of thinly sliced basil leaves. Some Vegan Parmesan-style cheese and fresh oregano leaves would add a nice touch, too. This can be served at room temperature.\n", + "\n", + "Title: Polish-Style Pizza with Mushrooms and Chives (Zapiekanka);\t Ingredients: ['1 (8–9\") soft hoagie roll or small Italian loaf, split in half lengthwise', '1 tablespoon unsalted butter', '1 small onion, finely chopped', '8 ounces white or crimini mushrooms, trimmed, finely chopped', 'Kosher salt, freshly ground black pepper', '1/4 cup ketchup', '1 cup grated part-skim mozzarella', '2 slices deli ham, torn in half', \"Mayonnaise, thinly sliced chives, french fried onions (such as French's), drained canned corn kernels, and/or chopped pickles (for serving)\"] ;\t Instructions: Preheat oven to 375°F; line a rimmed baking sheet with foil. Place bread halves cut side up on sheet.\n", + "Melt butter in a medium skillet over medium heat. Cook onion, stirring, until translucent, 3–4 minutes. Add mushrooms and lightly season with salt and pepper; cook, stirring occasionally, until liquid is evaporated and mixture cooks down to a spreadable consistency, about 10 minutes more. Let cool.\n", + "Spread 2 Tbsp. ketchup on each piece of bread. Divide mushroom mixture between pieces. Sprinkle mozzarella over each, leaving a bit in reserve. Top cheese with ham, then sprinkle ham with remaining cheese. Bake zapiekanki until bread is golden and crisp and cheese is lightly browned and bubbly, 12–14 minutes. Top with mayonnaise and your choice of toppings.\n", + "\n", + "Title: Cherry Tomato Pizza Margherita;\t Ingredients: ['1 13.8-ounce tube refrigerated pizza dough', '1 tablespoon extra-virgin olive oil', '1 12-ounce bag cherry tomatoes, stemmed', '1 garlic clove, pressed', '1/2 teaspoon fennel seeds, coarsely crushed in plastic bag', '1/4 teaspoon dried crushed red pepper', '1 4-ounce ball fresh mozzarella in water (ovoline), diced', '4 ounces whole-milk mozzarella, diced', '1/3 cup chopped fresh basil leaves plus small leaves for garnish'] ;\t Instructions: Position rack in top third of oven and preheat to 425°F. Unroll dough on heavy large baking sheet; pull to about 12x8-inch rectangle, pinching any tears to seal. Fold over edge of dough to make border.\n", + "Heat large skillet over high heat 2 minutes. Add oil, then tomatoes; sprinkle with salt and pepper. Sauté until tomatoes are charred and beginning to break down, about 5 minutes. Transfer to large bowl. Mix in garlic, fennel, and crushed red pepper. Using back of fork, crush tomatoes in bowl, leaving large chunks intact. Season mixture with salt and pepper. Toss cheeses and chopped basil in medium bowl.\n", + "Sprinkle cheese mixture evenly over dough, right up to border. Spoon on tomato mixture in dollops, leaving some cheese uncovered. Bake pizza until crust is crisp and brown, 25 to 30 minutes.\n", + "Loosen pizza with metal spatula and slide onto board. Garnish with basil leaves.\n", + "\n", + "Title: Orecchiette with Fresh Mozzarella, Grape Tomatoes, and Garlic Chives;\t Ingredients: ['10 ounces orecchiette (little ear-shaped pasta; about 3 cups uncooked)', '1 pound pea-size mozzarella or fresh mozzarella, diced', '1 pound grape tomatoes or pear tomatoes in assorted colors, halved', '6 tablespoons extra-virgin olive oil', '3 tablespoons white balsamic vinegar', '3 tablespoons minced fresh garlic chives or regular chives', '2 tablespoons minced fresh oregano'] ;\t Instructions: Cook pasta in large pot of boiling salted water until tender but still firm to bite, stirring occasionally. Drain; return pasta to pot. Add mozzarella; stir until cheese begins to melt, about 30 seconds. Add tomatoes and all remaining ingredients; toss to blend evenly. Season to taste with salt and pepper.\n", + "\n" + ] + } + ], "source": [ - "response = client.inference.inference(\n", - " inference_id=\"cohere_completion\", input=str(input)\n", - ")" + "noodles = semantic_search_with_reranking(\"best pizza without tomatoes\")\n", + "pretty_print_recipe(noodles)" ] }, { "cell_type": "code", - "execution_count": 109, - "id": "ea437663", + "execution_count": 16, + "id": "56a2064b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Query: What generes of movies are these characters from?\n", - "Here is a list of the movie genres that the characters in your list are from:\n", - "\n", - "- Abraham Van Helsing, Wade, and Wilbur (Hotel Transylvania): Animated comedy, Fantasy, Horror\n", - "- Adam Warlock (Marvel's Guardians of the Galaxy): Sci-fi, Action, Superhero\n", - "- Arthur Pendragon (Shrek): Animated comedy, Fantasy\n", - "- Christopher Robin (Disney): Live-action adaptation of animated characters, Fantasy\n", - "- Cooper (Jurassic Park): Sci-fi, Adventure, Thriller\n", - "- Data and Jean-Luc Picard (Star Trek): Sci-fi, Adventure\n", - "- Draco Malfoy, Remus Lupin (Harry Potter series): Fantasy, Magical realism\n", - "- Helga Hufflepuff (Harry Potter series): Fantasy, Magical realism\n", - "- Jack (Mass Effect): Sci-fi, Action, Military fiction\n", - "- Jane and Malachi (Babylon 5): Sci-fi, Drama\n", - "- Michael (E.T.): Sci-fi, Fantasy, Family drama\n", - "- Rand al'Thor (The Wheel of Time): Fantasy\n", - "- Robin Hood (Prince of Thieves): Adventure, Historical fiction\n", - "- Sarah Connor (Terminator Genisys): Sci-fi, Action, Thriller\n", - "- Walter (Alien Covenant): Sci-fi, Horror\n", - "\n", - "Please note that some of these characters may appear in multiple genres depending on their appearances in different adaptations or franchise entries. This list considers the primary genre associated with each character's most well-known portrayal.\n" + "Here is a pizza recipe that does not include tomatoes in the ingredients:\n", + "\n", + "**Polish-Style Pizza with Mushrooms and Chives (Zapiekanka)**\n", + "\n", + "**Ingredients:**\n", + "- 1 (8–9\") soft hoagie roll or small Italian loaf, split in half lengthwise\n", + "- 1 tablespoon unsalted butter\n", + "- 1 small onion, finely chopped\n", + "- 8 ounces white or crimini mushrooms, trimmed, finely chopped\n", + "- Kosher salt, freshly ground black pepper\n", + "- 1/4 cup ketchup\n", + "- 1 cup grated part-skim mozzarella\n", + "- 2 slices deli ham, torn in half\n", + "- Mayonnaise, thinly sliced chives, french fried onions (such as French's), drained canned corn kernels, and/or chopped pickles (for serving)\n", + "\n", + "**Instructions:**\n", + "1. Preheat your oven to 375°F and line a rimmed baking sheet with foil.\n", + "2. Place the bread halves cut side up on the prepared baking sheet.\n", + "3. Melt the butter in a skillet over medium heat. Add the onion and cook until translucent, stirring occasionally (about 3-4 minutes).\n", + "4. Add the mushrooms to the skillet and season lightly with salt and pepper. Cook until the liquid evaporates and the mixture becomes spreadable, about 10 minutes, stirring occasionally. Let it cool.\n", + "5. Spread 2 tablespoons of ketchup on each piece of bread. Divide the mushroom mixture between the two pieces.\n", + "6. Sprinkle mozzarella over each piece, leaving a small amount for later.\n", + "7. Top the cheese with ham, and then sprinkle the remaining cheese on top.\n", + "8. Bake for 12-14 minutes, until the bread is golden and crisp, and the cheese is lightly browned and bubbly.\n", + "9. Top with mayonnaise and your choice of toppings, such as thinly sliced chives, french fried onions, corn kernels, or chopped pickles.\n", + "\n", + "Enjoy your pizza! If you are interested in a more traditional pizza base, you could try searching for \"best pizza dough alternatives\" to find a base that suits your taste.\n" ] } ], "source": [ - "print(f\"Query: {query}\")\n", - "completion_response = response[\"completion\"][0][\"result\"]\n", - "print(completion_response)" + "RAG(\"best pizza without tomatoes\")" ] }, + { + "cell_type": "code", + "execution_count": 17, + "id": "ee23317f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Here is a recipe that fits your query: \n", + "\n", + "## Title: White Four-Cheese Pizza with Basil and Garlic\n", + "\n", + "### Ingredients:\n", + "- 3 tablespoons extra-virgin olive oil\n", + "- 1 garlic clove, minced\n", + "- 1 13.8-ounce tube refrigerated pizza dough\n", + "- All-purpose flour\n", + "- 6 ounces fresh mozzarella cheese, cut into 1/4-inch-thick slices, then coarsely chopped\n", + "- 3 ounces soft fresh goat cheese, crumbled\n", + "- 1/2 cup part-skim ricotta cheese\n", + "- 3 tablespoons freshly grated Parmesan cheese\n", + "- 3 tablespoons thinly sliced fresh basil\n", + "\n", + "### Instructions:\n", + "1. Position a rack in the center of the oven and preheat to 450°F. \n", + "2. Brush a 13x9-inch metal baking pan with 1 tablespoon of olive oil. \n", + "3. Mix the remaining 2 tablespoons of olive oil and garlic in a small bowl. \n", + "4. Roll out the pizza dough on a lightly floured work surface into a 14x10-inch rectangle. \n", + "5. Transfer the dough to the prepared pan and brush lightly with some of the garlic oil. \n", + "6. Top with mozzarella cheese and goat cheese, leaving a 1/2-inch plain border. \n", + "7. Crumble the ricotta cheese over, then sprinkle with Parmesan. \n", + "8. Bake the pizza until the crust is golden brown and the cheese melts, about 18 minutes. \n", + "9. Drizzle the remaining garlic oil over the baked pizza. \n", + "10. Let the pizza stand for 3 minutes before cutting. \n", + "11. Cut the pizza crosswise into 8 strips, then cut each strip crosswise into 4 pieces to make 32 pieces total. \n", + "12. Sprinkle with basil and transfer to a platter. Serve hot. \n", + "\n", + "This recipe is a delicious take on a classic white pizza, featuring a combination of four cheeses: mozzarella, goat cheese, ricotta, and Parmesan. The addition of garlic and basil provides a flavorful boost, making this a tasty option for your white pizza craving!\n" + ] + } + ], + "source": [ + "RAG(\"white pizza\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "95b56917", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Here is a recipe for Pizza Bianca: \n", + "\n", + "## Title: Pizza Bianca\n", + "### Ingredients:\n", + "- 3 cups all-purpose flour, plus more for parchment\n", + "- 1 teaspoon white granulated sugar\n", + "- 2 teaspoons kosher salt\n", + "- 1 1/2 teaspoons instant yeast (also called bread machine or rapid rise yeast)\n", + "- 4 tablespoons olive oil, divided\n", + "- 1 tablespoon roughly chopped fresh rosemary\n", + "- 1 teaspoon coarse sea salt (e.g. Maldon or fleur de sel)\n", + "- A pizza stone or double-stacked baking sheets\n", + "\n", + "### Instructions:\n", + "1. Combine flour, sugar, salt, and yeast in a food processor, pulsing until well combined. \n", + "2. Add 1 tablespoon of olive oil and 1 1/2 cups of room-temperature water. Process for 15 seconds, scrape down the sides, then process for another 15 seconds until thoroughly mixed. The dough will be wet, sticky, and fluid. \n", + "3. Coat a large bowl with 1/2 tablespoon of olive oil. Scrape the dough into the bowl, turning it to coat with oil. Cover with plastic and a towel, and let rise in a warm place until almost tripled in volume (2 to 2 1/2 hours). Alternatively, you can refrigerate the dough overnight and let it come to room temperature before rising. \n", + "4. Place a rack in the middle of the oven and preheat to 500°F. Use a pizza stone or double stack of baking sheets for best results. \n", + "5. Line a rimmed baking sheet with parchment and sprinkle with flour. Transfer the dough to the parchment and stretch it to the corners, forming a rectangle. If the dough shrinks back, let it rest for 5-10 minutes before trying again. Once the rectangle is formed, let it rest for another 5-10 minutes to puff slightly. \n", + "6. Use your fingertips to stipple the surface, then prick the dough all over with a fork (20-30 times). Drizzle with 1 tablespoon of olive oil and sprinkle with rosemary. \n", + "7. Bake for 5 minutes, then remove the pan. Slide the pizza from the parchment onto a pizza peel or cutting board, and then back onto the preheated surface in the oven. Discard the parchment. \n", + "8. Bake for an additional 8 to 12 minutes, until golden brown and crispy. \n", + "9. Transfer to a cutting board, drizzle with the remaining olive oil, sprinkle with sea salt, and serve immediately. \n", + "\n", + "This recipe for Pizza Bianca creates a delicious, crispy, and aromatic flatbread with a hint of rosemary. It's a great base for further toppings, or enjoy it as is for a simpler, yet flavorful, pizza experience. \n", + "\n", + "If you're interested in a more traditional tomato-based pizza, you might want to search for \"classic tomato sauce pizza\" or \"margherita pizza.\"\n" + ] + } + ], + "source": [ + "RAG(\"pizza bianca\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d9553550", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, - "id": "20fffc2c", + "id": "02d2bc82", "metadata": {}, "outputs": [], "source": [] From cbe7c5c2673a5195787ad9a17d5604cfae9796ea Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Wed, 28 Aug 2024 16:09:27 -0400 Subject: [PATCH 4/6] Fix colab link --- ...d-cohere-elasticsearch-inference-api.ipynb | 231 ++---------------- 1 file changed, 14 insertions(+), 217 deletions(-) diff --git a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb index bf4c39b6..b6f44fa9 100644 --- a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb +++ b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb @@ -7,7 +7,7 @@ "source": [ "# Tutorial: Retrieval Augmented Generation (RAG) with Cohere via the elastic open inference API\n", "\n", - "## [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)]()\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/elastic/elasticsearch-labs/blob/main/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb)\n", "\n", "This tutorial shows you how to compute embeddings with\n", "Cohere using the elastic open inference API and store them for efficient vector or hybrid\n", @@ -155,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 22, "id": "ae8ae88c", "metadata": {}, "outputs": [], @@ -165,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 24, "id": "6e524ce4", "metadata": {}, "outputs": [ @@ -175,7 +175,7 @@ "ObjectApiResponse({'model_id': 'cohere_embeddings', 'inference_id': 'cohere_embeddings', 'task_type': 'text_embedding', 'service': 'cohere', 'service_settings': {'similarity': 'dot_product', 'dimensions': 1024, 'model_id': 'embed-english-v3.0', 'rate_limit': {'requests_per_minute': 10000}, 'embedding_type': 'byte'}, 'task_settings': {}})" ] }, - "execution_count": 4, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -357,7 +357,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 25, "id": "886c4d15", "metadata": {}, "outputs": [ @@ -367,7 +367,7 @@ "ObjectApiResponse({'model_id': 'cohere_rerank', 'inference_id': 'cohere_rerank', 'task_type': 'rerank', 'service': 'cohere', 'service_settings': {'model_id': 'rerank-english-v3.0', 'rate_limit': {'requests_per_minute': 10000}}, 'task_settings': {'top_n': 100, 'return_documents': True}})" ] }, - "execution_count": 7, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -495,7 +495,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 43, "id": "3f0fc7e1", "metadata": {}, "outputs": [ @@ -579,7 +579,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 44, "id": "f0cd13fe", "metadata": {}, "outputs": [ @@ -589,7 +589,7 @@ "ObjectApiResponse({'model_id': 'cohere_completion', 'inference_id': 'cohere_completion', 'task_type': 'completion', 'service': 'cohere', 'service_settings': {'model_id': 'command-r-plus', 'rate_limit': {'requests_per_minute': 10000}}, 'task_settings': {}})" ] }, - "execution_count": 12, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -610,7 +610,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 45, "id": "0f843238", "metadata": {}, "outputs": [], @@ -639,7 +639,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 46, "id": "5f4a3373", "metadata": {}, "outputs": [ @@ -673,11 +673,10 @@ "4. Add shiitake mushrooms and sauté until tender and browned (about 6 minutes).\n", "5. Reduce heat to medium, then add cabbage and most of the scallions (reserve some for garnish). Cook until the cabbage is crisp-tender (about 6 minutes).\n", "6. Pour in the sauce and simmer for 2 minutes.\n", - "7. In a separate pot, cook the soba noodles and edamame in boiling salted water until just tender (about 6 minutes). Drain and rinse with cool water to stop the cooking process.\n", - "8. Transfer the noodles and edamame to a large bowl, and toss with the sesame seeds and vegetable mixture.\n", - "9. Serve, garnished with the remaining scallions.\n", + "7. Cook the soba noodles and edamame in boiling salted water until just tender (about 6 minutes). Drain, rinse with cool water, and drain again.\n", + "8. Toss the noodles and vegetables with the sesame seeds. Serve, garnished with the remaining scallions.\n", "\n", - "This recipe is a great choice for an easy spicy noodle dish, as it requires minimal prep work and comes together quickly. The gochujang (Korean hot-pepper paste) adds a nice kick, and the shiitake mushrooms and cabbage provide a delicious umami flavor. If you want an even spicier dish, feel free to add more gochujang or include some chili flakes or fresh chili peppers. Enjoy!\n" + "This recipe is a great choice for an easy, spicy noodle dish. It requires simple ingredients and has a straightforward preparation method. The Korean hot-pepper paste (gochujang) adds a nice kick, and the sesame seeds provide a tasty, nutty flavor and texture. If you want an even spicier dish, you could consider adding more gochujang or some chili flakes. Enjoy!\n" ] } ], @@ -685,208 +684,6 @@ "RAG(\"best easy spicy noodles\")" ] }, - { - "cell_type": "code", - "execution_count": 15, - "id": "50399e8e", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Title: Roman Style Pizza with Roasted Cherry Tomatoes;\t Ingredients: ['2 teaspoons sugar', '1 1/2 teaspoon active dry yeast', '7 1/2 tablespoons extra-virgin olive oil, divided', '1 teaspoon kosher salt, plus more', '2 1/4 cups (or more) all-purpose flour', '1½ pound cherry or grape tomatoes', 'Freshly ground black pepper', 'Semolina (for dusting)', '2/3 cup freshly grated Parmesan, divided', '2 cups grated mozzarella (about 8 ounces), or 6 ounces buffalo mozzarella, thinly sliced, divided', 'Chopped fresh basil'] ;\t Instructions: Combine 3/4 cup warm water (105°-115°F), sugar, and yeast in a large bowl; let sit until spongy, 4-5 minutes. Mix in 1 1/2 tablespoons oil and 1 teaspoon salt. Stir in 2 1/4 cups flour. Turn out onto a work surface; knead until smooth and elastic, adding more flour if sticking, about 6 minutes. Grease a large bowl with 1 tablespoon oil. Add dough, cover bowl with plastic; let rise until doubled, about 1 1/2 hours.\n", - "Meanwhile, position one rack in top third of oven and another in bottom third; place a pizza stone on top rack and preheat oven to 500°F. Scatter tomatoes on a large rimmed baking sheet. Add 1 tablespoon oil, toss, and season with salt and pepper. Place on lower rack; roast until skins split, 10-12 minutes. Let cool on rack. Continue heating pizza stone for 45 more minutes.\n", - "Sprinkle a pizza peel or rimless baking sheet with semolina. Divide dough in half; roll or stretch each into a 13x9\" rectangle. Cover with kitchen towels; let stand for 15 minutes. Transfer 1 rectangle to prepared pizza peel. Brush with 2 tablespoons oil, sprinkle with half of the Parmesan, then mozzarella, and top with half of the tomatoes. Season with salt and pepper.\n", - "Set front of peel at far edge of stone; gently jiggle peel side to side, sliding pizza onto stone as you remove peel. Bake until crust is browned and crisp, 9-10 minutes. Using peel, transfer pizza to work surface. Garnish with basil. Slice and Serve.\n", - "Repeat to make second pizza.\n", - "\n", - "Title: Phyllo Pizza with Smoked Mozzarella and Cherry Tomatoes;\t Ingredients: ['12 to 13 ounces cherry tomatoes and/or pear tomatoes', '1 tablespoon extra-virgin olive oil', '3/4 teaspoon coarse kosher salt', '1/2 teaspoon dried oregano', '12 12x9-inch sheets fresh phyllo pastry or frozen, thawed', '6 tablespoons (3/4 stick) unsalted butter, melted', '4 tablespoons finely grated Parmesan cheese, divided', '3/4 cup (packed) coarsely grated smoked mozzarella cheese* (about 3 ounces)', '1/2 yellow bell pepper, cut into thin strips', '1/4 cup quartered pitted Kalamata olives', '2 teaspoons coarsely chopped fresh oregano'] ;\t Instructions: Preheat oven to 400°F. Toss tomatoes, olive oil, salt, and oregano in medium bowl. Scatter tomatoes on large rimmed baking sheet; roast until soft and beginning to collapse, about 22 minutes. Remove from oven and let tomato mixture cool. Maintain oven temperature.\n", - "Place stack of phyllo sheets on work surface and cover with plastic wrap, then damp kitchen towel to prevent drying.\n", - "Brush another large rimmed baking sheet with some of melted butter. Place 1 phyllo sheet on baking sheet. Brush lightly with melted butter and top with second phyllo sheet. Brush with butter and top with third sheet; brush with butter. Sprinkle with 1 tablespoon Parmesan. Repeat 3 more times for total of 12 phyllo sheets and 4 tablespoons Parmesan. Sprinkle stacked phyllo sheets with grated mozzarella, leaving 1/2-inch plain border. Top with roasted tomatoes, pepper strips, and olives.\n", - "Bake pizza until phyllo is crisp, 25 to 27 minutes. Sprinkle 2 teaspoons fresh oregano over, loosen pizza from sheet with large metal spatula, and slide onto cutting board.\n", - "*Also called mozzarella affumicata; sold at some specialty foods stores and at cheese shops. If unavailable, use regular (not fresh) whole-milk mozzarella.\n", - "\n", - "Title: French Bread Pizzas With Ricotta, Roasted Tomatoes, and Pesto;\t Ingredients: ['1 1/2 pints cherry tomatoes, halved (about 3 cups)', '1 tablespoon plus 2 teaspoons olive oil, divided', '1/4 teaspoon kosher salt, plus more to taste', '1/4 teaspoon freshly ground black pepper, plus more to taste', '1 (12–14\") soft loaf French or Italian bread, split in half lengthwise', '1 garlic clove, smashed', '1/2 cup fresh ricotta (about 5 ounces)', '3/4 cup coarsely grated Parmesan (about 3 ounces)', '2 tablespoons fresh store-bought or homemade basil pesto'] ;\t Instructions: Position rack in top third of oven and preheat to 425°F. Toss tomatoes, 1 Tbsp. oil, 1/4 tsp. salt, and 1/4 tsp. pepper on a rimmed baking sheet. Roast until tomatoes start to blister, about 13 minutes.\n", - "Place bread, cut side up, on another rimmed baking sheet and bake 5 minutes. Remove from oven and rub cut sides with garlic.\n", - "Dollop ricotta on cut sides of bread. Top evenly with tomato mixture, then sprinkle with Parmesan. Bake until Parmesan melts, about 10 minutes.\n", - "Whisk pesto and remaining 2 tsp. oil in a small bowl until smooth. Drizzle on pizzas and season with salt and pepper.\n", - "\n", - "Title: Cauliflower-Crust Pizza with Tomatoes and Mozzarella;\t Ingredients: ['1 small head of cauliflower (about 1 pound), coarsely chopped', '1 large egg, lightly beaten', '1 cup grated Parmesan (about 3 ounces)', '3/4 cup finely ground almond meal or almond flour', '1 garlic clove, finely chopped', '1/2 teaspoon dried Italian seasoning', '1/2 teaspoon kosher salt', '1/4 teaspoon freshly ground black pepper', '1 1/2 cups shredded part-skim mozzarella (about 5 ounces), divided', 'Vegetable oil (for brushing)', '1/2 cup marinara sauce', '1/4 cup basil leaves, torn', '1/2 teaspoon red pepper flakes (optional)', 'A pizza stone and peel, or 2 baking sheets'] ;\t Instructions: Arrange a rack in middle of oven; place pizza stone or inverted (if rimmed) baking sheet on rack. Preheat to 425°F.\n", - "Working in batches if needed, pulse cauliflower in a food processor fitted with the blade, or grate using the medium holes of a box grater, until fine crumbs form and are rice-like in texture. Transfer to a clean kitchen towel and tightly squeeze to remove as much liquid as possible.\n", - "Mix cauliflower, egg, Parmesan, almond meal, garlic, Italian seasoning, salt, and black pepper in a medium bowl until mixture holds together when pinched.\n", - "Line pizza peel or second baking sheet with parchment paper; generously brush with oil. Form cauliflower mixture into a 12\" circle with your hands on parchment. Using a rolling pin, make thickness as even as possible. Carefully slide parchment onto preheated pizza stone or baking sheet.\n", - "Bake cauliflower crust until golden brown and firm to the touch, rotating halfway through, 20–22 minutes.\n", - "Remove from oven. Sprinkle with 1 1/4 cups mozzarella. Top with sauce, using the back of a spoon to spread over cheese. Sprinkle with remaining 1/4 cup mozzarella.\n", - "Slide pizza back onto pizza stone or baking sheet and continue to bake until bubbly and browned in spots, 5–7 minutes. Top with basil and red pepper, if using. Let sit 5 minutes, then cut into 6–8 wedges.\n", - "Pizza can be made 3 days ahead; transfer to a resealable container and chill. Reheat in a 350°F oven until warmed through.\n", - "\n", - "Title: Summer Pizza with Salami, Zucchini, and Tomatoes;\t Ingredients: ['5 Tbsp. extra-virgin olive oil, divided', '2 lb. store-bought pizza dough, room temperature', '2 cups whole-milk fresh ricotta (about 1 lb.)', '1 1/2 tsp. kosher salt, divided', '1 tsp. freshly ground black pepper, divided', '4 oz. thinly sliced soppressata', '1 medium shallot, finely chopped', '2 Tbsp. red wine vinegar', '2 medium zucchini (about 1 lb. total), thinly shaved lengthwise on a mandoline or with a vegetable peeler', '1 pint grape tomatoes, halved', '1 cup basil leaves'] ;\t Instructions: Preheat oven to 425°F. Brush an 18x13\" rimmed baking pan with 1 Tbsp. oil. Gently stretch dough to a 16x12\" oval and place in prepared baking sheet, pressing dough into edges of pan. (If dough springs back, cover with plastic wrap and let rest 10 minutes before stretching again.) Brush dough with 1 Tbsp. oil, then bake until golden and dry, 15–18 minutes.\n", - "Meanwhile, whisk ricotta, 1 Tbsp. oil, 1 tsp. salt, and 1/2 tsp. pepper in a medium bowl until mixture looks a little whipped and fluffy. (If your ricotta is on the drier side, add another tablespoonful of oil.)\n", - "Spread ricotta mixture over crust, leaving about a 1/2\" margin on all sides. Top with a single layer of soppressata, overlapping slightly if needed. Bake pizza until ricotta mixture is golden and edges of soppressata are curled up and crisp, about 15 minutes.\n", - "Whisk shallot, vinegar, and remaining 2 Tbsp. oil, 1/2 tsp. salt, and 1/2 tsp. pepper in a small bowl. Gently toss zucchini, tomatoes, and basil in a large bowl. Drizzle about one-third of the dressing over and toss again. Pile onto pizza with your hands. Drizzle remaining dressing over pizza and cut into slices.\n", - "\n", - "Title: Pizza with Sausage, Tomatoes and Basil;\t Ingredients: ['1 1/4 cups all-purpose enriched flour', '1 1/2 teaspoons active dry yeast', '1 teaspoon salt', 'Vegetable oil cooking spray', '1 pound red and yellow cherry tomatoes, halved', '1/2 pound turkey sausage, cooked and thinly sliced', '1 cup grated part-skim mozzarella', '1 tablespoon chopped fresh basil', '1 tablespoon balsamic vinegar', '1 tablespoon olive oil', '1/2 teaspoon salt', '1/2 teaspoon red pepper flakes'] ;\t Instructions: Mix flour, yeast and salt in a bowl. Gradually add 1/2 cup warm (110°F) water until a soft dough forms. Divide dough into 4 portions. Using hands, roll dough into balls. Coat with cooking spray, cover with plastic wrap and set aside to rise, 30 to 45 minutes. When ready to cook, place each ball of dough on a piece of wax paper and flatten into a 4-inch circle. Coat grill with cooking spray and heat on high. Gently place dough onto grill and cook until dough puffs and underside stiffens (about 30 seconds); flip and reduce heat to low. Mix topping ingredients, then divide among crusts. Cover grill. Cook until cheese melts, 5 to 6 minutes more. Slice and serve.\n", - "\n", - "Title: Pesto–Heirloom Tomato Pizza;\t Ingredients: ['1 to 2 cloves garlic, crushed (optional)', '1/2 to 1 cup firmly packed fresh basil leaves, or to taste', 'Juice of 1/2 lemon or 2 tablespoons bottled lemon juice, or more to taste', '1/2 cup walnut halves or shelled unsalted pistachios or 1/4 cup pine nuts (omit nuts if you’d like a less caloric pesto)', '6 ounces baby spinach, arugula, watercress, or a combination', 'Salt and freshly ground pepper to taste', 'Whole-Wheat Pizza Crust', 'Heirloom tomatoes, sliced, to taste (preferably a mix of yellow and red varieties)', 'Basil leaves, thinly sliced, for topping', 'Vegan Parmesan-style cheese and fresh oregano for topping (optional)'] ;\t Instructions: Combine the first five ingredients in a food processor and pulse until the mixture is evenly combined yet still coarse in texture. You may need to add the spinach in batches if your processor has a small or medium-size container.\n", - "Stop the machine and season the mixture gently with salt and pepper; taste to see if you'd like to add more lemon juice, then pulse a few times to mix.\n", - "Bake pizza dough rounds in a preheated 425°F oven for 15 minutes, until crust is golden.\n", - "Spread pizza crust with pesto, then load up with sliced heirloom tomatoes. Sprinkle with salt and pepper and top with plenty of thinly sliced basil leaves. Some Vegan Parmesan-style cheese and fresh oregano leaves would add a nice touch, too. This can be served at room temperature.\n", - "\n", - "Title: Polish-Style Pizza with Mushrooms and Chives (Zapiekanka);\t Ingredients: ['1 (8–9\") soft hoagie roll or small Italian loaf, split in half lengthwise', '1 tablespoon unsalted butter', '1 small onion, finely chopped', '8 ounces white or crimini mushrooms, trimmed, finely chopped', 'Kosher salt, freshly ground black pepper', '1/4 cup ketchup', '1 cup grated part-skim mozzarella', '2 slices deli ham, torn in half', \"Mayonnaise, thinly sliced chives, french fried onions (such as French's), drained canned corn kernels, and/or chopped pickles (for serving)\"] ;\t Instructions: Preheat oven to 375°F; line a rimmed baking sheet with foil. Place bread halves cut side up on sheet.\n", - "Melt butter in a medium skillet over medium heat. Cook onion, stirring, until translucent, 3–4 minutes. Add mushrooms and lightly season with salt and pepper; cook, stirring occasionally, until liquid is evaporated and mixture cooks down to a spreadable consistency, about 10 minutes more. Let cool.\n", - "Spread 2 Tbsp. ketchup on each piece of bread. Divide mushroom mixture between pieces. Sprinkle mozzarella over each, leaving a bit in reserve. Top cheese with ham, then sprinkle ham with remaining cheese. Bake zapiekanki until bread is golden and crisp and cheese is lightly browned and bubbly, 12–14 minutes. Top with mayonnaise and your choice of toppings.\n", - "\n", - "Title: Cherry Tomato Pizza Margherita;\t Ingredients: ['1 13.8-ounce tube refrigerated pizza dough', '1 tablespoon extra-virgin olive oil', '1 12-ounce bag cherry tomatoes, stemmed', '1 garlic clove, pressed', '1/2 teaspoon fennel seeds, coarsely crushed in plastic bag', '1/4 teaspoon dried crushed red pepper', '1 4-ounce ball fresh mozzarella in water (ovoline), diced', '4 ounces whole-milk mozzarella, diced', '1/3 cup chopped fresh basil leaves plus small leaves for garnish'] ;\t Instructions: Position rack in top third of oven and preheat to 425°F. Unroll dough on heavy large baking sheet; pull to about 12x8-inch rectangle, pinching any tears to seal. Fold over edge of dough to make border.\n", - "Heat large skillet over high heat 2 minutes. Add oil, then tomatoes; sprinkle with salt and pepper. Sauté until tomatoes are charred and beginning to break down, about 5 minutes. Transfer to large bowl. Mix in garlic, fennel, and crushed red pepper. Using back of fork, crush tomatoes in bowl, leaving large chunks intact. Season mixture with salt and pepper. Toss cheeses and chopped basil in medium bowl.\n", - "Sprinkle cheese mixture evenly over dough, right up to border. Spoon on tomato mixture in dollops, leaving some cheese uncovered. Bake pizza until crust is crisp and brown, 25 to 30 minutes.\n", - "Loosen pizza with metal spatula and slide onto board. Garnish with basil leaves.\n", - "\n", - "Title: Orecchiette with Fresh Mozzarella, Grape Tomatoes, and Garlic Chives;\t Ingredients: ['10 ounces orecchiette (little ear-shaped pasta; about 3 cups uncooked)', '1 pound pea-size mozzarella or fresh mozzarella, diced', '1 pound grape tomatoes or pear tomatoes in assorted colors, halved', '6 tablespoons extra-virgin olive oil', '3 tablespoons white balsamic vinegar', '3 tablespoons minced fresh garlic chives or regular chives', '2 tablespoons minced fresh oregano'] ;\t Instructions: Cook pasta in large pot of boiling salted water until tender but still firm to bite, stirring occasionally. Drain; return pasta to pot. Add mozzarella; stir until cheese begins to melt, about 30 seconds. Add tomatoes and all remaining ingredients; toss to blend evenly. Season to taste with salt and pepper.\n", - "\n" - ] - } - ], - "source": [ - "noodles = semantic_search_with_reranking(\"best pizza without tomatoes\")\n", - "pretty_print_recipe(noodles)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "56a2064b", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here is a pizza recipe that does not include tomatoes in the ingredients:\n", - "\n", - "**Polish-Style Pizza with Mushrooms and Chives (Zapiekanka)**\n", - "\n", - "**Ingredients:**\n", - "- 1 (8–9\") soft hoagie roll or small Italian loaf, split in half lengthwise\n", - "- 1 tablespoon unsalted butter\n", - "- 1 small onion, finely chopped\n", - "- 8 ounces white or crimini mushrooms, trimmed, finely chopped\n", - "- Kosher salt, freshly ground black pepper\n", - "- 1/4 cup ketchup\n", - "- 1 cup grated part-skim mozzarella\n", - "- 2 slices deli ham, torn in half\n", - "- Mayonnaise, thinly sliced chives, french fried onions (such as French's), drained canned corn kernels, and/or chopped pickles (for serving)\n", - "\n", - "**Instructions:**\n", - "1. Preheat your oven to 375°F and line a rimmed baking sheet with foil.\n", - "2. Place the bread halves cut side up on the prepared baking sheet.\n", - "3. Melt the butter in a skillet over medium heat. Add the onion and cook until translucent, stirring occasionally (about 3-4 minutes).\n", - "4. Add the mushrooms to the skillet and season lightly with salt and pepper. Cook until the liquid evaporates and the mixture becomes spreadable, about 10 minutes, stirring occasionally. Let it cool.\n", - "5. Spread 2 tablespoons of ketchup on each piece of bread. Divide the mushroom mixture between the two pieces.\n", - "6. Sprinkle mozzarella over each piece, leaving a small amount for later.\n", - "7. Top the cheese with ham, and then sprinkle the remaining cheese on top.\n", - "8. Bake for 12-14 minutes, until the bread is golden and crisp, and the cheese is lightly browned and bubbly.\n", - "9. Top with mayonnaise and your choice of toppings, such as thinly sliced chives, french fried onions, corn kernels, or chopped pickles.\n", - "\n", - "Enjoy your pizza! If you are interested in a more traditional pizza base, you could try searching for \"best pizza dough alternatives\" to find a base that suits your taste.\n" - ] - } - ], - "source": [ - "RAG(\"best pizza without tomatoes\")" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "ee23317f", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here is a recipe that fits your query: \n", - "\n", - "## Title: White Four-Cheese Pizza with Basil and Garlic\n", - "\n", - "### Ingredients:\n", - "- 3 tablespoons extra-virgin olive oil\n", - "- 1 garlic clove, minced\n", - "- 1 13.8-ounce tube refrigerated pizza dough\n", - "- All-purpose flour\n", - "- 6 ounces fresh mozzarella cheese, cut into 1/4-inch-thick slices, then coarsely chopped\n", - "- 3 ounces soft fresh goat cheese, crumbled\n", - "- 1/2 cup part-skim ricotta cheese\n", - "- 3 tablespoons freshly grated Parmesan cheese\n", - "- 3 tablespoons thinly sliced fresh basil\n", - "\n", - "### Instructions:\n", - "1. Position a rack in the center of the oven and preheat to 450°F. \n", - "2. Brush a 13x9-inch metal baking pan with 1 tablespoon of olive oil. \n", - "3. Mix the remaining 2 tablespoons of olive oil and garlic in a small bowl. \n", - "4. Roll out the pizza dough on a lightly floured work surface into a 14x10-inch rectangle. \n", - "5. Transfer the dough to the prepared pan and brush lightly with some of the garlic oil. \n", - "6. Top with mozzarella cheese and goat cheese, leaving a 1/2-inch plain border. \n", - "7. Crumble the ricotta cheese over, then sprinkle with Parmesan. \n", - "8. Bake the pizza until the crust is golden brown and the cheese melts, about 18 minutes. \n", - "9. Drizzle the remaining garlic oil over the baked pizza. \n", - "10. Let the pizza stand for 3 minutes before cutting. \n", - "11. Cut the pizza crosswise into 8 strips, then cut each strip crosswise into 4 pieces to make 32 pieces total. \n", - "12. Sprinkle with basil and transfer to a platter. Serve hot. \n", - "\n", - "This recipe is a delicious take on a classic white pizza, featuring a combination of four cheeses: mozzarella, goat cheese, ricotta, and Parmesan. The addition of garlic and basil provides a flavorful boost, making this a tasty option for your white pizza craving!\n" - ] - } - ], - "source": [ - "RAG(\"white pizza\")" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "95b56917", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here is a recipe for Pizza Bianca: \n", - "\n", - "## Title: Pizza Bianca\n", - "### Ingredients:\n", - "- 3 cups all-purpose flour, plus more for parchment\n", - "- 1 teaspoon white granulated sugar\n", - "- 2 teaspoons kosher salt\n", - "- 1 1/2 teaspoons instant yeast (also called bread machine or rapid rise yeast)\n", - "- 4 tablespoons olive oil, divided\n", - "- 1 tablespoon roughly chopped fresh rosemary\n", - "- 1 teaspoon coarse sea salt (e.g. Maldon or fleur de sel)\n", - "- A pizza stone or double-stacked baking sheets\n", - "\n", - "### Instructions:\n", - "1. Combine flour, sugar, salt, and yeast in a food processor, pulsing until well combined. \n", - "2. Add 1 tablespoon of olive oil and 1 1/2 cups of room-temperature water. Process for 15 seconds, scrape down the sides, then process for another 15 seconds until thoroughly mixed. The dough will be wet, sticky, and fluid. \n", - "3. Coat a large bowl with 1/2 tablespoon of olive oil. Scrape the dough into the bowl, turning it to coat with oil. Cover with plastic and a towel, and let rise in a warm place until almost tripled in volume (2 to 2 1/2 hours). Alternatively, you can refrigerate the dough overnight and let it come to room temperature before rising. \n", - "4. Place a rack in the middle of the oven and preheat to 500°F. Use a pizza stone or double stack of baking sheets for best results. \n", - "5. Line a rimmed baking sheet with parchment and sprinkle with flour. Transfer the dough to the parchment and stretch it to the corners, forming a rectangle. If the dough shrinks back, let it rest for 5-10 minutes before trying again. Once the rectangle is formed, let it rest for another 5-10 minutes to puff slightly. \n", - "6. Use your fingertips to stipple the surface, then prick the dough all over with a fork (20-30 times). Drizzle with 1 tablespoon of olive oil and sprinkle with rosemary. \n", - "7. Bake for 5 minutes, then remove the pan. Slide the pizza from the parchment onto a pizza peel or cutting board, and then back onto the preheated surface in the oven. Discard the parchment. \n", - "8. Bake for an additional 8 to 12 minutes, until golden brown and crispy. \n", - "9. Transfer to a cutting board, drizzle with the remaining olive oil, sprinkle with sea salt, and serve immediately. \n", - "\n", - "This recipe for Pizza Bianca creates a delicious, crispy, and aromatic flatbread with a hint of rosemary. It's a great base for further toppings, or enjoy it as is for a simpler, yet flavorful, pizza experience. \n", - "\n", - "If you're interested in a more traditional tomato-based pizza, you might want to search for \"classic tomato sauce pizza\" or \"margherita pizza.\"\n" - ] - } - ], - "source": [ - "RAG(\"pizza bianca\")" - ] - }, { "cell_type": "code", "execution_count": null, From 0e3587e0b970ad55532fda493642a8724c0561ba Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Wed, 28 Aug 2024 16:25:27 -0400 Subject: [PATCH 5/6] exempt notebook from tests --- bin/find-notebooks-to-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/find-notebooks-to-test.sh b/bin/find-notebooks-to-test.sh index 5158efd8..97b428dd 100755 --- a/bin/find-notebooks-to-test.sh +++ b/bin/find-notebooks-to-test.sh @@ -31,7 +31,7 @@ EXEMPT_NOTEBOOKS=( "notebooks/enterprise-search/app-search-engine-exporter.ipynb", "notebooks/playground-examples/bedrock-anthropic-elasticsearch-client.ipynb", "notebooks/playground-examples/openai-elasticsearch-client.ipynb", - + "notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb", ) # Per-version testing exceptions From 2737b60c97816a36182feaf163da9813a509b793 Mon Sep 17 00:00:00 2001 From: Max Hniebergall Date: Thu, 29 Aug 2024 09:54:27 -0400 Subject: [PATCH 6/6] autoformatting --- .../updated-cohere-elasticsearch-inference-api.ipynb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb index b6f44fa9..08ee2f74 100644 --- a/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb +++ b/notebooks/integrations/cohere/updated-cohere-elasticsearch-inference-api.ipynb @@ -104,7 +104,7 @@ "source": [ "Now you can instantiate the Python Elasticsearch client.\n", "\n", - "First provide your password and Cloud ID.\n", + "First provide your API key and Serverless Endpoint.\n", "Then create a `client` object that instantiates an instance of the `Elasticsearch` class." ] }, @@ -625,13 +625,21 @@ "\n", " input.append(\"Query:\" + str(query))\n", "\n", + " # Use semantic search with our previously configured reranker to find our small set of matching recipes\n", " recipes = extract_recipe_as_string(semantic_search_with_reranking(query))\n", " if len(recipes) > 0:\n", + " # if at least one recipe matched our query, combine them into a single string, with each recipe seperated by two new lines.\n", " input.append(\"Recipes:\" + \"\\n\\n\".join(recipes))\n", "\n", + " # combine the Context, Query, and Recipes sections (each seperated by three new lines) into a single string\n", + " input_as_string = \"\\n\\n\\n\".join(input)\n", + "\n", + " # pass the full combined instructions and recipes to the Command+R model\n", " chat_completion = client.inference.inference(\n", - " inference_id=\"cohere_completion\", input=\"\\n\\n\\n\".join(input)\n", + " inference_id=\"cohere_completion\", input=input_as_string\n", " )\n", + "\n", + " # print the response which should contain our recipe\n", " print(chat_completion[\"completion\"][0][\"result\"])\n", " else:\n", " print(\"No hits\")"