mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-07 18:35:22 +03:00
7.9 KiB
7.9 KiB
In [1]:
from langchain.embeddings import OpenAIEmbeddingsIn [2]:
embeddings = OpenAIEmbeddings()In [3]:
text = "This is a test document."In [4]:
query_result = embeddings.embed_query(text)In [5]:
doc_result = embeddings.embed_documents([text])In [1]:
from langchain.embeddings import CohereEmbeddingsIn [2]:
embeddings = CohereEmbeddings(cohere_api_key= cohere_api_key)In [3]:
text = "This is a test document."In [4]:
query_result = embeddings.embed_query(text)In [5]:
doc_result = embeddings.embed_documents([text])In [7]:
from langchain.embeddings import HuggingFaceEmbeddingsIn [16]:
embeddings = HuggingFaceEmbeddings()In [12]:
text = "This is a test document."In [13]:
query_result = embeddings.embed_query(text)In [14]:
doc_result = embeddings.embed_documents([text])In [1]:
from langchain.embeddings import TensorflowHubEmbeddingsIn [5]:
embeddings = TensorflowHubEmbeddings()2023-01-30 23:53:01.652176: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-01-30 23:53:34.362802: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
In [6]:
text = "This is a test document."In [7]:
query_result = embeddings.embed_query(text)In [8]:
from langchain.embeddings import HuggingFaceInstructEmbeddingsIn [9]:
embeddings = HuggingFaceInstructEmbeddings(query_instruction="Represent the query for retrieval: ")load INSTRUCTOR_Transformer max_seq_length 512
In [10]:
text = "This is a test document."In [11]:
query_result = embeddings.embed_query(text)In [ ]: