langchain.embeddings.tensorflow_hub.TensorflowHubEmbeddings¶

class langchain.embeddings.tensorflow_hub.TensorflowHubEmbeddings(*, embed: Any = None, model_url: str = 'https://tfhub.dev/google/universal-sentence-encoder-multilingual/3')[source]¶

Bases: BaseModel, Embeddings

TensorflowHub embedding models.

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

Example

from langchain.embeddings import TensorflowHubEmbeddings
url = "https://tfhub.dev/google/universal-sentence-encoder-multilingual/3"
tf = TensorflowHubEmbeddings(model_url=url)

Initialize the tensorflow_hub and tensorflow_text.

param model_url: str = 'https://tfhub.dev/google/universal-sentence-encoder-multilingual/3'¶

Model name to use.

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

Compute doc embeddings using a TensorflowHub embedding model.

Parameters

texts – The list of texts to embed.

Returns

List of embeddings, one for each text.

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

Compute query embeddings using a TensorflowHub embedding model.

Parameters

text – The text to embed.

Returns

Embeddings for the text.

model Config[source]¶

Bases: object

Configuration for this pydantic object.

extra = 'forbid'¶

Examples using TensorflowHubEmbeddings¶