Text2vecEmbeddings#

class langchain_community.embeddings.text2vec.Text2vecEmbeddings[source]#

Bases: Embeddings, BaseModel

text2vec embedding models.

Install text2vec first, run ‘pip install -U text2vec’. The gitbub repository for text2vec is : shibing624/text2vec

Example

from langchain_community.embeddings.text2vec import Text2vecEmbeddings

embedding = Text2vecEmbeddings()
embedding.embed_documents([
    "This is a CoSENT(Cosine Sentence) model.",
    "It maps sentences to a 768 dimensional dense vector space.",
])
embedding.embed_query(
    "It can be used for text matching or semantic search."
)
param device: str | None = None#
param encoder_type: Any = 'MEAN'#
param max_seq_length: int = 256#
param model: Any = None#
param model_name_or_path: str | None = None#
async aembed_documents(texts: List[str]) → List[List[float]]#

Asynchronous Embed search docs.

Parameters:

texts (List[str]) – List of text to embed.

Returns:

List of embeddings.

Return type:

List[List[float]]

async aembed_query(text: str) → List[float]#

Asynchronous Embed query text.

Parameters:

text (str) – Text to embed.

Returns:

Embedding.

Return type:

List[float]

embed_documents(texts: List[str]) → List[List[float]][source]#

Embed documents using the text2vec embeddings model.

Parameters:

texts (List[str]) – The list of texts to embed.

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

embed_query(text: str) → List[float][source]#

Embed a query using the text2vec embeddings model.

Parameters:

text (str) – The text to embed.

Returns:

Embeddings for the text.

Return type:

List[float]