ModelScopeEmbeddings#

class langchain_community.embeddings.modelscope_hub.ModelScopeEmbeddings[source]#

Bases: BaseModel, Embeddings

ModelScopeHub embedding models.

To use, you should have the modelscope python package installed.

Example

from langchain_community.embeddings import ModelScopeEmbeddings
model_id = "damo/nlp_corom_sentence-embedding_english-base"
embed = ModelScopeEmbeddings(model_id=model_id, model_revision="v1.0.0")

Initialize the modelscope

param embed: Any = None#
param model_id: str = 'damo/nlp_corom_sentence-embedding_english-base'#

Model name to use.

param model_revision: 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]#

Compute doc embeddings using a modelscope embedding 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]#

Compute query embeddings using a modelscope embedding model.

Parameters:

text (str) – The text to embed.

Returns:

Embeddings for the text.

Return type:

List[float]

Examples using ModelScopeEmbeddings