Skip to content

Commit ae714e9

Browse files
Milvus-doc-botMilvus-doc-bot
Milvus-doc-bot
authored and
Milvus-doc-bot
committed
Generate en docs
1 parent bd97d05 commit ae714e9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"codeList":["pip install --upgrade pymilvus\npip install \"pymilvus[model]\"\n","cohere_ef = CohereEmbeddingFunction(\n model_name=\"embed-english-light-v3.0\",\n api_key=\"YOUR_COHERE_API_KEY\",\n input_type=\"search_document\",\n embedding_types=[\"float\"]\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 = cohere_ef.encode_documents(docs)\n\n# Print embeddings\nprint(\"Embeddings:\", docs_embeddings)\n# Print dimension and shape of embeddings\nprint(\"Dim:\", cohere_ef.dim, docs_embeddings[0].shape)\n","Embeddings: [array([ 3.43322754e-02, 1.16252899e-03, -5.25207520e-02, 1.32846832e-03,\n -6.80541992e-02, 6.10961914e-02, -7.06176758e-02, 1.48925781e-01,\n 1.54174805e-01, 1.98516846e-02, 2.43835449e-02, 3.55224609e-02,\n 1.82952881e-02, 7.57446289e-02, -2.40783691e-02, 4.40063477e-02,\n...\n 0.06359863, -0.01971436, -0.02253723, 0.00354195, 0.00222015,\n 0.00184727, 0.03408813, -0.00777817, 0.04919434, 0.01519775,\n -0.02862549, 0.04760742, -0.07891846, 0.0124054 ], dtype=float32)]\nDim: 384 (384,)\n","queries = [\"When was artificial intelligence founded\", \n \"Where was Alan Turing born?\"]\n\nquery_embeddings = cohere_ef.encode_queries(queries)\n\nprint(\"Embeddings:\", query_embeddings)\nprint(\"Dim\", cohere_ef.dim, query_embeddings[0].shape)\n","Embeddings: [array([-1.33361816e-02, 9.79423523e-04, -7.28759766e-02, -1.93786621e-02,\n -9.71679688e-02, 4.34875488e-02, -9.81445312e-02, 1.16882324e-01,\n 5.89904785e-02, -4.19921875e-02, 4.95910645e-02, 5.83496094e-02,\n 3.47595215e-02, -5.87463379e-03, -7.30514526e-03, 2.92816162e-02,\n...\n 0.00749969, -0.01192474, 0.02719116, 0.03347778, 0.07696533,\n 0.01409149, 0.00964355, -0.01681519, -0.0073204 , 0.00043154,\n -0.04577637, 0.03591919, -0.02807617, -0.04812622], dtype=float32)]\nDim 384 (384,)\n"],"headingContent":"Cohere","anchorList":[{"label":"Cohere","href":"Cohere","type":1,"isActive":false}]}
1+
{"codeList":["pip install --upgrade pymilvus\npip install \"pymilvus[model]\"\n","from pymilvus.model.dense import CohereEmbeddingFunction\n\ncohere_ef = CohereEmbeddingFunction(\n model_name=\"embed-english-light-v3.0\",\n api_key=\"YOUR_COHERE_API_KEY\",\n input_type=\"search_document\",\n embedding_types=[\"float\"]\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 = cohere_ef.encode_documents(docs)\n\n# Print embeddings\nprint(\"Embeddings:\", docs_embeddings)\n# Print dimension and shape of embeddings\nprint(\"Dim:\", cohere_ef.dim, docs_embeddings[0].shape)\n","Embeddings: [array([ 3.43322754e-02, 1.16252899e-03, -5.25207520e-02, 1.32846832e-03,\n -6.80541992e-02, 6.10961914e-02, -7.06176758e-02, 1.48925781e-01,\n 1.54174805e-01, 1.98516846e-02, 2.43835449e-02, 3.55224609e-02,\n 1.82952881e-02, 7.57446289e-02, -2.40783691e-02, 4.40063477e-02,\n...\n 0.06359863, -0.01971436, -0.02253723, 0.00354195, 0.00222015,\n 0.00184727, 0.03408813, -0.00777817, 0.04919434, 0.01519775,\n -0.02862549, 0.04760742, -0.07891846, 0.0124054 ], dtype=float32)]\nDim: 384 (384,)\n","queries = [\"When was artificial intelligence founded\", \n \"Where was Alan Turing born?\"]\n\nquery_embeddings = cohere_ef.encode_queries(queries)\n\nprint(\"Embeddings:\", query_embeddings)\nprint(\"Dim\", cohere_ef.dim, query_embeddings[0].shape)\n","Embeddings: [array([-1.33361816e-02, 9.79423523e-04, -7.28759766e-02, -1.93786621e-02,\n -9.71679688e-02, 4.34875488e-02, -9.81445312e-02, 1.16882324e-01,\n 5.89904785e-02, -4.19921875e-02, 4.95910645e-02, 5.83496094e-02,\n 3.47595215e-02, -5.87463379e-03, -7.30514526e-03, 2.92816162e-02,\n...\n 0.00749969, -0.01192474, 0.02719116, 0.03347778, 0.07696533,\n 0.01409149, 0.00964355, -0.01681519, -0.0073204 , 0.00043154,\n -0.04577637, 0.03591919, -0.02807617, -0.04812622], dtype=float32)]\nDim 384 (384,)\n"],"headingContent":"Cohere","anchorList":[{"label":"Cohere","href":"Cohere","type":1,"isActive":false}]}

localization/v2.4.x/site/en/embeddings/embed-with-cohere.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ title: Embed Cohere
2828
pip install <span class="hljs-string">&quot;pymilvus[model]&quot;</span>
2929
<button class="copy-code-btn"></button></code></pre>
3030
<p>Then, instantiate the <code translate="no">CohereEmbeddingFunction</code>:</p>
31-
<pre><code translate="no" class="language-python">cohere_ef = <span class="hljs-title class_">CohereEmbeddingFunction</span>(
31+
<pre><code translate="no" class="language-python"><span class="hljs-keyword">from</span> pymilvus.<span class="hljs-property">model</span>.<span class="hljs-property">dense</span> <span class="hljs-keyword">import</span> <span class="hljs-title class_">CohereEmbeddingFunction</span>
32+
33+
cohere_ef = <span class="hljs-title class_">CohereEmbeddingFunction</span>(
3234
model_name=<span class="hljs-string">&quot;embed-english-light-v3.0&quot;</span>,
3335
api_key=<span class="hljs-string">&quot;YOUR_COHERE_API_KEY&quot;</span>,
3436
input_type=<span class="hljs-string">&quot;search_document&quot;</span>,

0 commit comments

Comments
 (0)