-{"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}]}
0 commit comments