From 4680df6ff624e91e0194d55afe37ddbb7959ca35 Mon Sep 17 00:00:00 2001 From: Milvus-doc-bot Date: Thu, 19 Sep 2024 02:13:01 +0000 Subject: [PATCH] Generate en docs --- .../site/en/embeddings/embed-with-jina.json | 2 +- .../site/en/embeddings/embed-with-jina.md | 85 ++++++++++++++----- .../en/integrations/integrate_with_jina.json | 2 +- .../en/integrations/integrate_with_jina.md | 27 ++++-- 4 files changed, 84 insertions(+), 32 deletions(-) diff --git a/localization/v2.4.x/site/en/embeddings/embed-with-jina.json b/localization/v2.4.x/site/en/embeddings/embed-with-jina.json index 9a9e75250..4cee744ff 100644 --- a/localization/v2.4.x/site/en/embeddings/embed-with-jina.json +++ b/localization/v2.4.x/site/en/embeddings/embed-with-jina.json @@ -1 +1 @@ -{"codeList":["pip install --upgrade pymilvus\npip install \"pymilvus[model]\"\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_ef = JinaEmbeddingFunction(\n model_name=\"jina-embeddings-v2-base-en\", # Defaults to `jina-embeddings-v2-base-en`\n api_key=JINAAI_API_KEY # Provide your Jina AI API key\n)\n","docs = [\n \"Artificial intelligence was founded as an academic discipline in 1956.\",\n \"Alan Turing was the first person to conduct substantial research in AI.\",\n \"Born in Maida Vale, London, Turing was raised in southern England.\",\n]\n\ndocs_embeddings = jina_ef.encode_documents(docs)\n\n# Print embeddings\nprint(\"Embeddings:\", docs_embeddings)\n# Print dimension and shape of embeddings\nprint(\"Dim:\", jina_ef.dim, docs_embeddings[0].shape)\n","Embeddings: [array([-4.88487840e-01, -4.28095880e-01, 4.90086500e-01, -1.63274320e-01,\n 3.43437800e-01, 3.21476880e-01, 2.83173790e-02, -3.10403670e-01,\n 4.76985040e-01, -1.77410420e-01, -3.84803180e-01, -2.19224200e-01,\n -2.52898000e-01, 6.62411900e-02, -8.58173100e-01, 1.05221800e+00,\n...\n -2.04462400e-01, 7.14229800e-01, -1.66823000e-01, 8.72551440e-01,\n 5.53560140e-01, 8.92506300e-01, -2.39408610e-01, -4.22413560e-01,\n -3.19551350e-01, 5.59153850e-01, 2.44338100e-01, -8.60452100e-01])]\nDim: 768 (768,)\n","queries = [\"When was artificial intelligence founded\", \n \"Where was Alan Turing born?\"]\n\nquery_embeddings = jina_ef.encode_queries(queries)\n\nprint(\"Embeddings:\", query_embeddings)\nprint(\"Dim\", jina_ef.dim, query_embeddings[0].shape)\n","Embeddings: [array([-5.99164660e-01, -3.49827350e-01, 8.22405160e-01, -1.18632730e-01,\n 5.78107540e-01, 1.09789170e-01, 2.91604200e-01, -3.29306450e-01,\n 2.93779640e-01, -2.17880800e-01, -6.84535440e-01, -3.79752000e-01,\n -3.47541800e-01, 9.20846100e-02, -6.13804400e-01, 6.31312800e-01,\n...\n -1.84993740e-02, 9.38629150e-01, 2.74858470e-02, 1.09396360e+00,\n 3.96270750e-01, 7.44445800e-01, -1.95404050e-01, -6.08383200e-01,\n -3.75076300e-01, 3.87512200e-01, 8.11889650e-01, -3.76407620e-01])]\nDim 768 (768,)\n"],"headingContent":"Jina AI","anchorList":[{"label":"Jina AI","href":"Jina-AI","type":1,"isActive":false}]} \ No newline at end of file +{"codeList":["pip install --upgrade pymilvus\npip install \"pymilvus[model]\"\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_ef = JinaEmbeddingFunction(\n model_name=\"jina-embeddings-v3\", # Defaults to `jina-embeddings-v3`\n api_key=JINAAI_API_KEY, # Provide your Jina AI API key\n task=\"retrieval.passage\", # Specify the task\n dimensions=1024, # Defaults to 1024\n)\n","\n```python\ndocs = [\n \"Artificial intelligence was founded as an academic discipline in 1956.\",\n \"Alan Turing was the first person to conduct substantial research in AI.\",\n \"Born in Maida Vale, London, Turing was raised in southern England.\",\n]\n\ndocs_embeddings = jina_ef.encode_documents(docs)\n\n# Print embeddings\nprint(\"Embeddings:\", docs_embeddings)\n# Print dimension and shape of embeddings\nprint(\"Dim:\", jina_ef.dim, docs_embeddings[0].shape)\n","Embeddings: [array([9.80641991e-02, -8.51697400e-02, 7.36531913e-02, 1.42558888e-02,\n -2.23589484e-02, 1.68494112e-03, -3.50753777e-02, -3.11530549e-02,\n -3.26012149e-02, 5.04568312e-03, 3.69836427e-02, 3.48948985e-02,\n 8.19722563e-03, 5.88679723e-02, -6.71099266e-03, -1.82369724e-02,\n...\n 2.48654783e-02, 3.43279652e-02, -1.66154150e-02, -9.90478322e-03,\n -2.96043139e-03, -8.57473817e-03, -7.39028037e-04, 6.25024503e-03,\n -1.08831357e-02, -4.00776342e-02, 3.25369164e-02, -1.42691191e-03])]\nDim: 1024 (1024,)\n","queries = [\"When was artificial intelligence founded\", \n \"Where was Alan Turing born?\"]\n\nquery_embeddings = jina_ef.encode_queries(queries)\n\nprint(\"Embeddings:\", query_embeddings)\nprint(\"Dim\", jina_ef.dim, query_embeddings[0].shape)\n","Embeddings: [array([8.79201014e-03, 1.47551354e-02, 4.02722731e-02, -2.52991207e-02,\n 1.12719582e-02, 3.75947170e-02, 3.97946090e-02, -7.36681819e-02,\n -2.17952449e-02, -1.16298944e-02, -6.83426252e-03, -5.12507409e-02,\n 5.26071340e-02, 6.75181448e-02, 3.92445624e-02, -1.40817231e-02,\n...\n 8.81703943e-03, 4.24629413e-02, -2.32944116e-02, -2.05193572e-02,\n -3.22035812e-02, 2.81896023e-03, 3.85326855e-02, 3.64372656e-02,\n -1.65050142e-02, -4.26847413e-02, 2.02664156e-02, -1.72684863e-02])]\nDim 1024 (1024,)\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_ef = JinaEmbeddingFunction(\n model_name=\"jina-embeddings-v3\", # Defaults to `jina-embeddings-v3`\n api_key=JINA_API_KEY, # Provide your Jina AI API key\n task=\"text-matching\",\n dimensions=1024, # Defaults to 1024\n)\n\ntexts = [\n \"Follow the white rabbit.\", # English\n \"Sigue al conejo blanco.\", # Spanish\n \"Suis le lapin blanc.\", # French\n \"跟着白兔走。\", # Chinese\n \"اتبع الأرنب الأبيض.\", # Arabic\n \"Folge dem weißen Kaninchen.\", # German\n]\n\nembeddings = jina_ef(texts)\n\n# Compute similarities\nprint(embeddings[0] @ embeddings[1].T)\n"],"headingContent":"Jina AI","anchorList":[{"label":"Jina AI","href":"Jina-AI","type":1,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/en/embeddings/embed-with-jina.md b/localization/v2.4.x/site/en/embeddings/embed-with-jina.md index a93d84af5..d9d18b1fd 100644 --- a/localization/v2.4.x/site/en/embeddings/embed-with-jina.md +++ b/localization/v2.4.x/site/en/embeddings/embed-with-jina.md @@ -31,19 +31,36 @@ pip install "pymilvus[model]"
from pymilvus.model.dense import JinaEmbeddingFunction
 
 jina_ef = JinaEmbeddingFunction(
-    model_name="jina-embeddings-v2-base-en", # Defaults to `jina-embeddings-v2-base-en`
-    api_key=JINAAI_API_KEY # Provide your Jina AI API key
+    model_name="jina-embeddings-v3", # Defaults to `jina-embeddings-v3`
+    api_key=JINAAI_API_KEY, # Provide your Jina AI API key
+    task="retrieval.passage", # Specify the task
+    dimensions=1024, # Defaults to 1024
 )
 

Parameters:

-

To create embeddings for documents, use the encode_documents() method:

-
docs = [
+

To create embeddings for documents, use the encode_documents() method. This method is designed for documents embeddings in asymmetric retrieval tasks, such as indexing documents for search or recommendation tasks. This method uses retrieval.passage as the task.

+

+```python
+docs = [
     "Artificial intelligence was founded as an academic discipline in 1956.",
     "Alan Turing was the first person to conduct substantial research in AI.",
     "Born in Maida Vale, London, Turing was raised in southern England.",
@@ -57,17 +74,17 @@ docs_embeddings = jina_ef.encode_documents(docs)
 print("Dim:", jina_ef.dim, docs_embeddings[0].shape)
 

The expected output is similar to the following:

-
Embeddings: [array([-4.88487840e-01, -4.28095880e-01,  4.90086500e-01, -1.63274320e-01,
-        3.43437800e-01,  3.21476880e-01,  2.83173790e-02, -3.10403670e-01,
-        4.76985040e-01, -1.77410420e-01, -3.84803180e-01, -2.19224200e-01,
-       -2.52898000e-01,  6.62411900e-02, -8.58173100e-01,  1.05221800e+00,
+
Embeddings: [array([9.80641991e-02, -8.51697400e-02,  7.36531913e-02,  1.42558888e-02,
+       -2.23589484e-02,  1.68494112e-03, -3.50753777e-02, -3.11530549e-02,
+       -3.26012149e-02,  5.04568312e-03,  3.69836427e-02,  3.48948985e-02,
+        8.19722563e-03,  5.88679723e-02, -6.71099266e-03, -1.82369724e-02,
 ...
-       -2.04462400e-01,  7.14229800e-01, -1.66823000e-01,  8.72551440e-01,
-        5.53560140e-01,  8.92506300e-01, -2.39408610e-01, -4.22413560e-01,
-       -3.19551350e-01,  5.59153850e-01,  2.44338100e-01, -8.60452100e-01])]
-Dim: 768 (768,)
+        2.48654783e-02,  3.43279652e-02, -1.66154150e-02, -9.90478322e-03,
+       -2.96043139e-03, -8.57473817e-03, -7.39028037e-04,  6.25024503e-03,
+       -1.08831357e-02, -4.00776342e-02,  3.25369164e-02, -1.42691191e-03])]
+Dim: 1024 (1024,)
 
-

To create embeddings for queries, use the encode_queries() method:

+

To create embeddings for queries, use the encode_queries() method. This method is designed for query embeddings in asymmetric retrieval tasks, such as search queries or questions. This method uses retrieval.query as the task.

queries = ["When was artificial intelligence founded", 
            "Where was Alan Turing born?"]
 
@@ -77,13 +94,37 @@ query_embeddings = jina_ef.encode_queries(queries)
 print("Dim", jina_ef.dim, query_embeddings[0].shape)
 

The expected output is similar to the following:

-
Embeddings: [array([-5.99164660e-01, -3.49827350e-01,  8.22405160e-01, -1.18632730e-01,
-        5.78107540e-01,  1.09789170e-01,  2.91604200e-01, -3.29306450e-01,
-        2.93779640e-01, -2.17880800e-01, -6.84535440e-01, -3.79752000e-01,
-       -3.47541800e-01,  9.20846100e-02, -6.13804400e-01,  6.31312800e-01,
+
Embeddings: [array([8.79201014e-03,  1.47551354e-02,  4.02722731e-02, -2.52991207e-02,
+        1.12719582e-02,  3.75947170e-02,  3.97946090e-02, -7.36681819e-02,
+       -2.17952449e-02, -1.16298944e-02, -6.83426252e-03, -5.12507409e-02,
+        5.26071340e-02,  6.75181448e-02,  3.92445624e-02, -1.40817231e-02,
 ...
-       -1.84993740e-02,  9.38629150e-01,  2.74858470e-02,  1.09396360e+00,
-        3.96270750e-01,  7.44445800e-01, -1.95404050e-01, -6.08383200e-01,
-       -3.75076300e-01,  3.87512200e-01,  8.11889650e-01, -3.76407620e-01])]
-Dim 768 (768,)
+        8.81703943e-03,  4.24629413e-02, -2.32944116e-02, -2.05193572e-02,
+       -3.22035812e-02,  2.81896023e-03,  3.85326855e-02,  3.64372656e-02,
+       -1.65050142e-02, -4.26847413e-02,  2.02664156e-02, -1.72684863e-02])]
+Dim 1024 (1024,)
+
+

To create embeddings of inputs for similarity matching (such as STS or symmetric retrieval tasks), text classification, clustering, or reranking tasks, use the appropriate task parameter value when instantiating the JinaEmbeddingFunction class.

+
from pymilvus.model.dense import JinaEmbeddingFunction
+
+jina_ef = JinaEmbeddingFunction(
+    model_name="jina-embeddings-v3", # Defaults to `jina-embeddings-v3`
+    api_key=JINA_API_KEY, # Provide your Jina AI API key
+    task="text-matching",
+    dimensions=1024, # Defaults to 1024
+)
+
+texts = [
+    "Follow the white rabbit.",  # English
+    "Sigue al conejo blanco.",  # Spanish
+    "Suis le lapin blanc.",  # French
+    "跟着白兔走。",  # Chinese
+    "اتبع الأرنب الأبيض.",  # Arabic
+    "Folge dem weißen Kaninchen.",  # German
+]
+
+embeddings = jina_ef(texts)
+
+# Compute similarities
+print(embeddings[0] @ embeddings[1].T)
 
diff --git a/localization/v2.4.x/site/en/integrations/integrate_with_jina.json b/localization/v2.4.x/site/en/integrations/integrate_with_jina.json index 3bffe3d68..56e891cbd 100644 --- a/localization/v2.4.x/site/en/integrations/integrate_with_jina.json +++ b/localization/v2.4.x/site/en/integrations/integrate_with_jina.json @@ -1 +1 @@ -{"codeList":["$ pip install -U pymilvus\n$ pip install \"pymilvus[model]\"\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\"jina-embeddings-v2-base-en\", jina_api_key)\n\nquery = \"what is information retrieval?\"\ndoc = \"Information retrieval is the process of finding relevant information from a large collection of data or documents.\"\n\nqvecs = ef.encode_queries([query])\ndvecs = ef.encode_documents([doc])\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\"jina-embeddings-v2-base-de\", jina_api_key)\n\nquery = \"what is information retrieval?\"\ndoc = \"Information Retrieval ist der Prozess, relevante Informationen aus einer großen Sammlung von Daten oder Dokumenten zu finden.\"\n\nqvecs = ef.encode_queries([query])\ndvecs = ef.encode_documents([doc])\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\"jina-embeddings-v2-base-code\", jina_api_key)\n\n# Case1: Enhanced Code Navigation\n# query: text description of the functionality\n# document: relevant code snippet\n\nquery = \"function to calculate average in Python.\"\ndoc = \"\"\"\ndef calculate_average(numbers):\n total = sum(numbers)\n count = len(numbers)\n return total / count\n\"\"\"\n\n# Case2: Streamlined Code Review\n# query: text description of the programming concept\n# document: relevante code snippet or PR\n\nquery = \"pull quest related to Collection\"\ndoc = \"fix:[restful v2] parameters of create collection ...\"\n\n# Case3: Automatic Documentation Assistance\n# query: code snippet you need explanation\n# document: relevante document or DocsString\n\nquery = \"What is Collection in Milvus\"\ndoc = \"\"\"\nIn Milvus, you store your vector embeddings in collections. All vector embeddings within a collection share the same dimensionality and distance metric for measuring similarity.\nMilvus collections support dynamic fields (i.e., fields not pre-defined in the schema) and automatic incrementation of primary keys.\n\"\"\"\n\nqvecs = ef.encode_queries([query])\ndvecs = ef.encode_documents([doc])\n","from pymilvus.model.dense import JinaEmbeddingFunction\nfrom pymilvus import MilvusClient\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\"jina-embeddings-v2-base-en\", jina_api_key)\nDIMENSION = 768 # size of jina-embeddings-v2-base-en\n\ndoc = [\n \"In 1950, Alan Turing published his seminal paper, 'Computing Machinery and Intelligence,' proposing the Turing Test as a criterion of intelligence, a foundational concept in the philosophy and development of artificial intelligence.\",\n \"The Dartmouth Conference in 1956 is considered the birthplace of artificial intelligence as a field; here, John McCarthy and others coined the term 'artificial intelligence' and laid out its basic goals.\",\n \"In 1951, British mathematician and computer scientist Alan Turing also developed the first program designed to play chess, demonstrating an early example of AI in game strategy.\",\n \"The invention of the Logic Theorist by Allen Newell, Herbert A. Simon, and Cliff Shaw in 1955 marked the creation of the first true AI program, which was capable of solving logic problems, akin to proving mathematical theorems.\",\n]\n\ndvecs = ef.encode_documents(doc)\n\ndata = [\n {\"id\": i, \"vector\": dvecs[i], \"text\": doc[i], \"subject\": \"history\"}\n for i in range(len(dvecs))\n]\n\nmilvus_client = MilvusClient(\"./milvus_jina_demo.db\")\nCOLLECTION_NAME = \"demo_collection\" # Milvus collection name\nif milvus_client.has_collection(collection_name=COLLECTION_NAME):\n milvus_client.drop_collection(collection_name=COLLECTION_NAME)\nmilvus_client.create_collection(collection_name=COLLECTION_NAME, dimension=DIMENSION)\n\nres = milvus_client.insert(collection_name=COLLECTION_NAME, data=data)\n\nprint(res[\"insert_count\"])\n","queries = \"What event in 1956 marked the official birth of artificial intelligence as a discipline?\"\nqvecs = ef.encode_queries([queries])\n\nres = milvus_client.search(\n collection_name=COLLECTION_NAME, # target collection\n data=[qvecs[0]], # query vectors\n limit=3, # number of returned entities\n output_fields=[\"text\", \"subject\"], # specifies fields to be returned\n)[0]\n\nfor result in res:\n print(result)\n","from pymilvus.model.reranker import JinaRerankFunction\n\njina_api_key = \"\"\n\nrf = JinaRerankFunction(\"jina-reranker-v1-base-en\", jina_api_key)\n\nquery = \"What event in 1956 marked the official birth of artificial intelligence as a discipline?\"\n\ndocuments = [\n \"In 1950, Alan Turing published his seminal paper, 'Computing Machinery and Intelligence,' proposing the Turing Test as a criterion of intelligence, a foundational concept in the philosophy and development of artificial intelligence.\",\n \"The Dartmouth Conference in 1956 is considered the birthplace of artificial intelligence as a field; here, John McCarthy and others coined the term 'artificial intelligence' and laid out its basic goals.\",\n \"In 1951, British mathematician and computer scientist Alan Turing also developed the first program designed to play chess, demonstrating an early example of AI in game strategy.\",\n \"The invention of the Logic Theorist by Allen Newell, Herbert A. Simon, and Cliff Shaw in 1955 marked the creation of the first true AI program, which was capable of solving logic problems, akin to proving mathematical theorems.\",\n]\n\nrf(query, documents)\n"],"headingContent":"Integrate Milvus with Jina AI","anchorList":[{"label":"Integrate Milvus with Jina AI","href":"Integrate-Milvus-with-Jina-AI","type":1,"isActive":false},{"label":"Who is Jina AI","href":"Who-is-Jina-AI","type":2,"isActive":false},{"label":"Milvus and Jina AI's Embedding","href":"Milvus-and-Jina-AIs-Embedding","type":2,"isActive":false},{"label":"Examples","href":"Examples","type":2,"isActive":false},{"label":"General-Purpose Embedding","href":"General-Purpose-Embedding","type":2,"isActive":false},{"label":"Bilingual Embeddings","href":"Bilingual-Embeddings","type":2,"isActive":false},{"label":"Code Embeddings","href":"Code-Embeddings","type":2,"isActive":false},{"label":"Semantic Search with Jina & Milvus","href":"Semantic-Search-with-Jina--Milvus","type":2,"isActive":false},{"label":"Jina Reranker","href":"Jina-Reranker","type":2,"isActive":false}]} \ No newline at end of file +{"codeList":["$ pip install -U pymilvus\n$ pip install \"pymilvus[model]\"\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\n \"jina-embeddings-v3\", \n jina_api_key,\n task=\"retrieval.passage\",\n dimensions=1024\n)\n\nquery = \"what is information retrieval?\"\ndoc = \"Information retrieval is the process of finding relevant information from a large collection of data or documents.\"\n\nqvecs = ef.encode_queries([query]) # This method uses `retrieval.query` as the task\ndvecs = ef.encode_documents([doc]) # This method uses `retrieval.passage` as the task\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\"jina-embeddings-v2-base-de\", jina_api_key)\n\nquery = \"what is information retrieval?\"\ndoc = \"Information Retrieval ist der Prozess, relevante Informationen aus einer großen Sammlung von Daten oder Dokumenten zu finden.\"\n\nqvecs = ef.encode_queries([query])\ndvecs = ef.encode_documents([doc])\n","from pymilvus.model.dense import JinaEmbeddingFunction\n\njina_api_key = \"\"\nef = JinaEmbeddingFunction(\"jina-embeddings-v2-base-code\", jina_api_key)\n\n# Case1: Enhanced Code Navigation\n# query: text description of the functionality\n# document: relevant code snippet\n\nquery = \"function to calculate average in Python.\"\ndoc = \"\"\"\ndef calculate_average(numbers):\n total = sum(numbers)\n count = len(numbers)\n return total / count\n\"\"\"\n\n# Case2: Streamlined Code Review\n# query: text description of the programming concept\n# document: relevante code snippet or PR\n\nquery = \"pull quest related to Collection\"\ndoc = \"fix:[restful v2] parameters of create collection ...\"\n\n# Case3: Automatic Documentation Assistance\n# query: code snippet you need explanation\n# document: relevante document or DocsString\n\nquery = \"What is Collection in Milvus\"\ndoc = \"\"\"\nIn Milvus, you store your vector embeddings in collections. All vector embeddings within a collection share the same dimensionality and distance metric for measuring similarity.\nMilvus collections support dynamic fields (i.e., fields not pre-defined in the schema) and automatic incrementation of primary keys.\n\"\"\"\n\nqvecs = ef.encode_queries([query])\ndvecs = ef.encode_documents([doc])\n","from pymilvus.model.dense import JinaEmbeddingFunction\nfrom pymilvus import MilvusClient\n\njina_api_key = \"\"\nDIMENSION = 1024 # `jina-embeddings-v3` supports flexible embedding sizes (32, 64, 128, 256, 512, 768, 1024), allowing for truncating embeddings to fit your application. \nef = JinaEmbeddingFunction(\n \"jina-embeddings-v3\", \n jina_api_key,\n task=\"retrieval.passage\",\n dimensions=DIMENSION,\n)\n\n\ndoc = [\n \"In 1950, Alan Turing published his seminal paper, 'Computing Machinery and Intelligence,' proposing the Turing Test as a criterion of intelligence, a foundational concept in the philosophy and development of artificial intelligence.\",\n \"The Dartmouth Conference in 1956 is considered the birthplace of artificial intelligence as a field; here, John McCarthy and others coined the term 'artificial intelligence' and laid out its basic goals.\",\n \"In 1951, British mathematician and computer scientist Alan Turing also developed the first program designed to play chess, demonstrating an early example of AI in game strategy.\",\n \"The invention of the Logic Theorist by Allen Newell, Herbert A. Simon, and Cliff Shaw in 1955 marked the creation of the first true AI program, which was capable of solving logic problems, akin to proving mathematical theorems.\",\n]\n\ndvecs = ef.encode_documents(doc) # This method uses `retrieval.passage` as the task\n\ndata = [\n {\"id\": i, \"vector\": dvecs[i], \"text\": doc[i], \"subject\": \"history\"}\n for i in range(len(dvecs))\n]\n\nmilvus_client = MilvusClient(\"./milvus_jina_demo.db\")\nCOLLECTION_NAME = \"demo_collection\" # Milvus collection name\nif milvus_client.has_collection(collection_name=COLLECTION_NAME):\n milvus_client.drop_collection(collection_name=COLLECTION_NAME)\nmilvus_client.create_collection(collection_name=COLLECTION_NAME, dimension=DIMENSION)\n\nres = milvus_client.insert(collection_name=COLLECTION_NAME, data=data)\n\nprint(res[\"insert_count\"])\n","queries = \"What event in 1956 marked the official birth of artificial intelligence as a discipline?\"\nqvecs = ef.encode_queries([queries]) # This method uses `retrieval.query` as the task\n\nres = milvus_client.search(\n collection_name=COLLECTION_NAME, # target collection\n data=[qvecs[0]], # query vectors\n limit=3, # number of returned entities\n output_fields=[\"text\", \"subject\"], # specifies fields to be returned\n)[0]\n\nfor result in res:\n print(result)\n","from pymilvus.model.reranker import JinaRerankFunction\n\njina_api_key = \"\"\n\nrf = JinaRerankFunction(\"jina-reranker-v1-base-en\", jina_api_key)\n\nquery = \"What event in 1956 marked the official birth of artificial intelligence as a discipline?\"\n\ndocuments = [\n \"In 1950, Alan Turing published his seminal paper, 'Computing Machinery and Intelligence,' proposing the Turing Test as a criterion of intelligence, a foundational concept in the philosophy and development of artificial intelligence.\",\n \"The Dartmouth Conference in 1956 is considered the birthplace of artificial intelligence as a field; here, John McCarthy and others coined the term 'artificial intelligence' and laid out its basic goals.\",\n \"In 1951, British mathematician and computer scientist Alan Turing also developed the first program designed to play chess, demonstrating an early example of AI in game strategy.\",\n \"The invention of the Logic Theorist by Allen Newell, Herbert A. Simon, and Cliff Shaw in 1955 marked the creation of the first true AI program, which was capable of solving logic problems, akin to proving mathematical theorems.\",\n]\n\nrf(query, documents)\n"],"headingContent":"Integrate Milvus with Jina AI","anchorList":[{"label":"Integrate Milvus with Jina AI","href":"Integrate-Milvus-with-Jina-AI","type":1,"isActive":false},{"label":"Who is Jina AI","href":"Who-is-Jina-AI","type":2,"isActive":false},{"label":"Milvus and Jina AI's Embedding","href":"Milvus-and-Jina-AIs-Embedding","type":2,"isActive":false},{"label":"Examples","href":"Examples","type":2,"isActive":false},{"label":"General-Purpose Embedding","href":"General-Purpose-Embedding","type":2,"isActive":false},{"label":"Bilingual Embeddings","href":"Bilingual-Embeddings","type":2,"isActive":false},{"label":"Code Embeddings","href":"Code-Embeddings","type":2,"isActive":false},{"label":"Semantic Search with Jina & Milvus","href":"Semantic-Search-with-Jina--Milvus","type":2,"isActive":false},{"label":"Jina Reranker","href":"Jina-Reranker","type":2,"isActive":false}]} \ No newline at end of file diff --git a/localization/v2.4.x/site/en/integrations/integrate_with_jina.md b/localization/v2.4.x/site/en/integrations/integrate_with_jina.md index 934c5f229..970fd9d83 100644 --- a/localization/v2.4.x/site/en/integrations/integrate_with_jina.md +++ b/localization/v2.4.x/site/en/integrations/integrate_with_jina.md @@ -94,16 +94,21 @@ $ pip install "pymilvus[model]" >

Jina AI’s core embedding model, excels in understanding detailed text, making it ideal for semantic search, content classification thus supports advanced sentiment analysis, text summarization, and personalized recommendation systems.

-
from pymilvus.model.dense import JinaEmbeddingFunction
+
from pymilvus.model.dense import JinaEmbeddingFunction
 
 jina_api_key = "<YOUR_JINA_API_KEY>"
-ef = JinaEmbeddingFunction("jina-embeddings-v2-base-en", jina_api_key)
+ef = JinaEmbeddingFunction(
+    "jina-embeddings-v3", 
+    jina_api_key,
+    task="retrieval.passage",
+    dimensions=1024
+)
 
 query = "what is information retrieval?"
 doc = "Information retrieval is the process of finding relevant information from a large collection of data or documents."
 
-qvecs = ef.encode_queries([query])
-dvecs = ef.encode_documents([doc])
+qvecs = ef.encode_queries([query])  # This method uses `retrieval.query` as the task
+dvecs = ef.encode_documents([doc])  # This method uses `retrieval.passage` as the task
 

Bilingual Embeddings