SpacyEmbeddings#

class langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings[source]#

Bases: BaseModel, Embeddings

Embeddings by spaCy models.

model_name#

Name of a spaCy model.

Type:

str

nlp#

The spaCy model loaded into memory.

Type:

Any

embed_documents(texts

List[str]) -> List[List[float]]: Generates embeddings for a list of documents.

embed_query(text

str) -> List[float]: Generates an embedding for a single piece of text.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param model_name: str = 'en_core_web_sm'#
param nlp: Any | None = None#
async aembed_documents(texts: List[str]) List[List[float]][source]#

Asynchronously generates embeddings for a list of documents. This method is not implemented and raises a NotImplementedError.

Parameters:

texts (List[str]) – The documents to generate embeddings for.

Raises:

NotImplementedError – This method is not implemented.

Return type:

List[List[float]]

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

Asynchronously generates an embedding for a single piece of text. This method is not implemented and raises a NotImplementedError.

Parameters:

text (str) – The text to generate an embedding for.

Raises:

NotImplementedError – This method is not implemented.

Return type:

List[float]

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

Generates embeddings for a list of documents.

Parameters:

texts (List[str]) – The documents to generate embeddings for.

Returns:

A list of embeddings, one for each document.

Return type:

List[List[float]]

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

Generates an embedding for a single piece of text.

Parameters:

text (str) – The text to generate an embedding for.

Returns:

The embedding for the text.

Return type:

List[float]

Examples using SpacyEmbeddings