id
stringlengths
14
16
text
stringlengths
20
3.26k
source
stringlengths
65
181
9ea4603c1806-2
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed(texts: List[str], *, input_type: Optional[str] = None) → List[List[float]][source]¶ Parameters texts (List[str]) – input_type (Optional[str]) – Return type List[List[float]] embed_documents(texts: List[str]) → List[List[float]][source]¶ Embed a list of document texts. Parameters texts (List[str]) – The list of texts to embed. Returns
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.cohere.CohereEmbeddings.html
9ea4603c1806-3
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]¶ Call out to Cohere’s embedding endpoint. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] embed_with_retry(**kwargs: Any) → Any[source]¶ Use tenacity to retry the embed call. Parameters kwargs (Any) – Return type Any classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.cohere.CohereEmbeddings.html
9ea4603c1806-4
encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.cohere.CohereEmbeddings.html
9ea4603c1806-5
Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using CohereEmbeddings¶ Cohere reranker
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.cohere.CohereEmbeddings.html
e2bc84fcfaca-0
langchain_google_vertexai.embeddings.GoogleEmbeddingModelVersion¶ class langchain_google_vertexai.embeddings.GoogleEmbeddingModelVersion(value)[source]¶ An enumeration. EMBEDDINGS_JUNE_2023 = '1'¶ EMBEDDINGS_NOV_2023 = '2'¶ EMBEDDINGS_DEC_2023 = '3'¶ EMBEDDINGS_MAY_2024 = '4'¶ task_type_supported¶ Checks if the model generation supports task type. output_dimensionality_supported¶ Checks if the model generation supports output dimensionality.
https://api.python.langchain.com/en/latest/embeddings/langchain_google_vertexai.embeddings.GoogleEmbeddingModelVersion.html
5e499bfd8572-0
langchain_elasticsearch.embeddings.ElasticsearchEmbeddings¶ class langchain_elasticsearch.embeddings.ElasticsearchEmbeddings(client: MlClient, model_id: str, *, input_field: str = 'text_field')[source]¶ Elasticsearch embedding models. This class provides an interface to generate embeddings using a model deployed in an Elasticsearch cluster. It requires an Elasticsearch connection object and the model_id of the model deployed in the cluster. In Elasticsearch you need to have an embedding model loaded and deployed. - https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-trained-model.html - https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-deploy-models.html Initialize the ElasticsearchEmbeddings instance. Parameters client (MlClient) – An Elasticsearch ML client object. model_id (str) – The model_id of the model deployed in the Elasticsearch cluster. input_field (str) – The name of the key for the input text field in the document. Defaults to ‘text_field’. Methods __init__(client, model_id, *[, input_field]) Initialize the ElasticsearchEmbeddings instance. aembed_documents(texts) Asynchronous Embed search docs. aembed_query(text) Asynchronous Embed query text. embed_documents(texts) Generate embeddings for a list of documents. embed_query(text) Generate an embedding for a single query text. from_credentials(model_id, *[, es_cloud_id, ...]) Instantiate embeddings from Elasticsearch credentials. from_es_connection(model_id, es_connection) Instantiate embeddings from an existing Elasticsearch connection. __init__(client: MlClient, model_id: str, *, input_field: str = 'text_field')[source]¶ Initialize the ElasticsearchEmbeddings instance. Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_elasticsearch.embeddings.ElasticsearchEmbeddings.html
5e499bfd8572-1
Initialize the ElasticsearchEmbeddings instance. Parameters client (MlClient) – An Elasticsearch ML client object. model_id (str) – The model_id of the model deployed in the Elasticsearch cluster. input_field (str) – The name of the key for the input text field in the document. Defaults to ‘text_field’. async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] embed_documents(texts: List[str]) → List[List[float]][source]¶ Generate embeddings for a list of documents. Parameters texts (List[str]) – A list of document text strings to generate embeddings for. Returns A list of embeddings, one for each document in the inputlist. Return type List[List[float]] embed_query(text: str) → List[float][source]¶ Generate an embedding for a single query text. Parameters text (str) – The query text to generate an embedding for. Returns The embedding for the input query text. Return type List[float] classmethod from_credentials(model_id: str, *, es_cloud_id: Optional[str] = None, es_api_key: Optional[str] = None, input_field: str = 'text_field') → ElasticsearchEmbeddings[source]¶ Instantiate embeddings from Elasticsearch credentials. Parameters model_id (str) – The model_id of the model deployed in the Elasticsearch cluster. input_field (str) – The name of the key for the input text field in the document. Defaults to ‘text_field’.
https://api.python.langchain.com/en/latest/embeddings/langchain_elasticsearch.embeddings.ElasticsearchEmbeddings.html
5e499bfd8572-2
document. Defaults to ‘text_field’. es_cloud_id (Optional[str]) – (str, optional): The Elasticsearch cloud ID to connect to. es_user – (str, optional): Elasticsearch username. es_password – (str, optional): Elasticsearch password. es_api_key (Optional[str]) – Return type ElasticsearchEmbeddings Example from langchain_elasticserach.embeddings import ElasticsearchEmbeddings # Define the model ID and input field name (if different from default) model_id = "your_model_id" # Optional, only if different from 'text_field' input_field = "your_input_field" # Credentials can be passed in two ways. Either set the env vars # ES_CLOUD_ID, ES_USER, ES_PASSWORD and they will be automatically # pulled in, or pass them in directly as kwargs. embeddings = ElasticsearchEmbeddings.from_credentials( model_id, input_field=input_field, # es_cloud_id="foo", # es_user="bar", # es_password="baz", ) documents = [ "This is an example document.", "Another example document to generate embeddings for.", ] embeddings_generator.embed_documents(documents) classmethod from_es_connection(model_id: str, es_connection: Elasticsearch, input_field: str = 'text_field') → ElasticsearchEmbeddings[source]¶ Instantiate embeddings from an existing Elasticsearch connection. This method provides a way to create an instance of the ElasticsearchEmbeddings class using an existing Elasticsearch connection. The connection object is used to create an MlClient, which is then used to initialize the ElasticsearchEmbeddings instance. Args: model_id (str): The model_id of the model deployed in the Elasticsearch cluster. es_connection (elasticsearch.Elasticsearch): An existing Elasticsearch
https://api.python.langchain.com/en/latest/embeddings/langchain_elasticsearch.embeddings.ElasticsearchEmbeddings.html
5e499bfd8572-3
es_connection (elasticsearch.Elasticsearch): An existing Elasticsearch connection object. input_field (str, optional): The name of the key for the input text field in the document. Defaults to ‘text_field’. Returns: ElasticsearchEmbeddings: An instance of the ElasticsearchEmbeddings class. Example from elasticsearch import Elasticsearch from langchain_elasticsearch.embeddings import ElasticsearchEmbeddings # Define the model ID and input field name (if different from default) model_id = "your_model_id" # Optional, only if different from 'text_field' input_field = "your_input_field" # Create Elasticsearch connection es_connection = Elasticsearch( hosts=["localhost:9200"], http_auth=("user", "password") ) # Instantiate ElasticsearchEmbeddings using the existing connection embeddings = ElasticsearchEmbeddings.from_es_connection( model_id, es_connection, input_field=input_field, ) documents = [ "This is an example document.", "Another example document to generate embeddings for.", ] embeddings_generator.embed_documents(documents) Parameters model_id (str) – es_connection (Elasticsearch) – input_field (str) – Return type ElasticsearchEmbeddings
https://api.python.langchain.com/en/latest/embeddings/langchain_elasticsearch.embeddings.ElasticsearchEmbeddings.html
d845c8c8580d-0
langchain_community.embeddings.fastembed.FastEmbedEmbeddings¶ class langchain_community.embeddings.fastembed.FastEmbedEmbeddings[source]¶ Bases: BaseModel, Embeddings Qdrant FastEmbedding models. FastEmbed is a lightweight, fast, Python library built for embedding generation. See more documentation at: * https://github.com/qdrant/fastembed/ * https://qdrant.github.io/fastembed/ To use this class, you must install the fastembed Python package. pip install fastembed .. rubric:: Example from langchain_community.embeddings import FastEmbedEmbeddings fastembed = FastEmbedEmbeddings() 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 cache_dir: Optional[str] = None¶ The path to the cache directory. Defaults to local_cache in the parent directory param doc_embed_type: Literal['default', 'passage'] = 'default'¶ Type of embedding to use for documents The available options are: “default” and “passage” param max_length: int = 512¶ The maximum number of tokens. Defaults to 512. Unknown behavior for values > 512. param model_name: str = 'BAAI/bge-small-en-v1.5'¶ Name of the FastEmbedding model to use Defaults to “BAAI/bge-small-en-v1.5” Find the list of supported models at https://qdrant.github.io/fastembed/examples/Supported_Models/ param threads: Optional[int] = None¶ The number of threads single onnxruntime session can use. Defaults to None async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fastembed.FastEmbedEmbeddings.html
d845c8c8580d-1
Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fastembed.FastEmbedEmbeddings.html
d845c8c8580d-2
self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Generate embeddings for documents using FastEmbed. 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]¶ Generate query embeddings using FastEmbed. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fastembed.FastEmbedEmbeddings.html
d845c8c8580d-3
Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fastembed.FastEmbedEmbeddings.html
d845c8c8580d-4
Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using FastEmbedEmbeddings¶ FastEmbed by Qdrant
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.fastembed.FastEmbedEmbeddings.html
eae9c5aa5411-0
langchain_community.embeddings.infinity.InfinityEmbeddings¶ class langchain_community.embeddings.infinity.InfinityEmbeddings[source]¶ Bases: BaseModel, Embeddings Self-hosted embedding models for infinity package. See https://github.com/michaelfeil/infinity This also works for text-embeddings-inference and other self-hosted openai-compatible servers. Infinity is a package to interact with Embedding Models on https://github.com/michaelfeil/infinity Example from langchain_community.embeddings import InfinityEmbeddings InfinityEmbeddings( model="BAAI/bge-small", infinity_api_url="http://localhost:7997", ) 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 client: Any = None¶ Infinity client. param infinity_api_url: str = 'http://localhost:7997'¶ Endpoint URL to use. param model: str [Required]¶ Underlying Infinity model id. async aembed_documents(texts: List[str]) → List[List[float]][source]¶ Async call out to Infinity’s embedding endpoint. Parameters texts (List[str]) – The list of texts to embed. Returns List of embeddings, one for each text. Return type List[List[float]] async aembed_query(text: str) → List[float][source]¶ Async call out to Infinity’s embedding endpoint. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity.InfinityEmbeddings.html
eae9c5aa5411-1
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity.InfinityEmbeddings.html
eae9c5aa5411-2
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Call out to Infinity’s embedding endpoint. 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]¶ Call out to Infinity’s embedding endpoint. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity.InfinityEmbeddings.html
eae9c5aa5411-3
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity.InfinityEmbeddings.html
eae9c5aa5411-4
ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using InfinityEmbeddings¶ Infinity
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.infinity.InfinityEmbeddings.html
a6c86d156db4-0
langchain_community.embeddings.clarifai.ClarifaiEmbeddings¶ class langchain_community.embeddings.clarifai.ClarifaiEmbeddings[source]¶ Bases: BaseModel, Embeddings Clarifai embedding models. To use, you should have the clarifai python package installed, and the environment variable CLARIFAI_PAT set with your personal access token or pass it as a named parameter to the constructor. Example from langchain_community.embeddings import ClarifaiEmbeddings clarifai = ClarifaiEmbeddings(user_id=USER_ID, app_id=APP_ID, model_id=MODEL_ID) (or) Example_URL = "https://clarifai.com/clarifai/main/models/BAAI-bge-base-en-v15" clarifai = ClarifaiEmbeddings(model_url=EXAMPLE_URL) 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 api_base: str = 'https://api.clarifai.com'¶ param app_id: Optional[str] = None¶ Clarifai application id to use. param model_id: Optional[str] = None¶ Model id to use. param model_url: Optional[str] = None¶ Model url to use. param model_version_id: Optional[str] = None¶ Model version id to use. param pat: Optional[str] = None¶ Clarifai personal access token to use. param token: Optional[str] = None¶ Clarifai session token to use. param user_id: Optional[str] = None¶ Clarifai user id to use. async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clarifai.ClarifaiEmbeddings.html
a6c86d156db4-1
Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clarifai.ClarifaiEmbeddings.html
a6c86d156db4-2
self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Call out to Clarifai’s embedding models. 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]¶ Call out to Clarifai’s embedding models. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clarifai.ClarifaiEmbeddings.html
a6c86d156db4-3
Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clarifai.ClarifaiEmbeddings.html
a6c86d156db4-4
Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using ClarifaiEmbeddings¶ Clarifai
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.clarifai.ClarifaiEmbeddings.html
2be0cdced785-0
langchain_community.embeddings.localai.LocalAIEmbeddings¶ class langchain_community.embeddings.localai.LocalAIEmbeddings[source]¶ Bases: BaseModel, Embeddings LocalAI embedding models. Since LocalAI and OpenAI have 1:1 compatibility between APIs, this class uses the openai Python package’s openai.Embedding as its client. Thus, you should have the openai python package installed, and defeat the environment variable OPENAI_API_KEY by setting to a random string. You also need to specify OPENAI_API_BASE to point to your LocalAI service endpoint. Example from langchain_community.embeddings import LocalAIEmbeddings openai = LocalAIEmbeddings( openai_api_key="random-string", openai_api_base="http://localhost:8080" ) 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 allowed_special: Union[Literal['all'], Set[str]] = {}¶ param chunk_size: int = 1000¶ Maximum number of texts to embed in each batch param deployment: str = 'text-embedding-ada-002'¶ param disallowed_special: Union[Literal['all'], Set[str], Sequence[str]] = 'all'¶ param embedding_ctx_length: int = 8191¶ The maximum number of tokens to embed at once. param headers: Any = None¶ param max_retries: int = 6¶ Maximum number of retries to make when generating. param model: str = 'text-embedding-ada-002'¶ param model_kwargs: Dict[str, Any] [Optional]¶ Holds any model parameters valid for create call not explicitly specified. param openai_api_base: Optional[str] = None¶
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html
2be0cdced785-1
param openai_api_base: Optional[str] = None¶ param openai_api_key: Optional[str] = None¶ param openai_api_version: Optional[str] = None¶ param openai_organization: Optional[str] = None¶ param openai_proxy: Optional[str] = None¶ param request_timeout: Optional[Union[float, Tuple[float, float]]] = None¶ Timeout in seconds for the LocalAI request. param show_progress_bar: bool = False¶ Whether to show a progress bar when embedding. async aembed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]][source]¶ Call out to LocalAI’s embedding endpoint async for embedding search docs. Parameters texts (List[str]) – The list of texts to embed. chunk_size (Optional[int]) – The chunk size of embeddings. If None, will use the chunk size specified by the class. Returns List of embeddings, one for each text. Return type List[List[float]] async aembed_query(text: str) → List[float][source]¶ Call out to LocalAI’s embedding endpoint async for embedding query text. Parameters text (str) – The text to embed. Returns Embedding for the text. Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html
2be0cdced785-2
values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html
2be0cdced785-3
exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]][source]¶ Call out to LocalAI’s embedding endpoint for embedding search docs. Parameters texts (List[str]) – The list of texts to embed. chunk_size (Optional[int]) – The chunk size of embeddings. If None, will use the chunk size specified by the class. Returns List of embeddings, one for each text. Return type List[List[float]] embed_query(text: str) → List[float][source]¶ Call out to LocalAI’s embedding endpoint for embedding query text. Parameters text (str) – The text to embed. Returns Embedding for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html
2be0cdced785-4
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html
2be0cdced785-5
ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using LocalAIEmbeddings¶ LocalAI
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.LocalAIEmbeddings.html
79b4f6bf2f05-0
langchain_community.embeddings.openai.OpenAIEmbeddings¶ class langchain_community.embeddings.openai.OpenAIEmbeddings[source]¶ Bases: BaseModel, Embeddings [Deprecated] OpenAI embedding models. To use, you should have the openai python package installed, and the environment variable OPENAI_API_KEY set with your API key or pass it as a named parameter to the constructor. Example from langchain_community.embeddings import OpenAIEmbeddings openai = OpenAIEmbeddings(openai_api_key="my-api-key") In order to use the library with Microsoft Azure endpoints, you need to set the OPENAI_API_TYPE, OPENAI_API_BASE, OPENAI_API_KEY and OPENAI_API_VERSION. The OPENAI_API_TYPE must be set to ‘azure’ and the others correspond to the properties of your endpoint. In addition, the deployment name must be passed as the model parameter. Example import os os.environ["OPENAI_API_TYPE"] = "azure" os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/" os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key" os.environ["OPENAI_API_VERSION"] = "2023-05-15" os.environ["OPENAI_PROXY"] = "http://your-corporate-proxy:8080" from langchain_community.embeddings.openai import OpenAIEmbeddings embeddings = OpenAIEmbeddings( deployment="your-embeddings-deployment-name", model="your-embeddings-model-name", openai_api_base="https://your-endpoint.openai.azure.com/", openai_api_type="azure", ) text = "This is a test query." query_result = embeddings.embed_query(text) Notes Deprecated since version 0.0.9.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-1
Notes Deprecated since version 0.0.9. 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 allowed_special: Union[Literal['all'], Set[str]] = {}¶ param chunk_size: int = 1000¶ Maximum number of texts to embed in each batch param default_headers: Optional[Mapping[str, str]] = None¶ param default_query: Optional[Mapping[str, object]] = None¶ param deployment: Optional[str] = 'text-embedding-ada-002'¶ param disallowed_special: Union[Literal['all'], Set[str], Sequence[str]] = 'all'¶ param embedding_ctx_length: int = 8191¶ The maximum number of tokens to embed at once. param headers: Any = None¶ param http_client: Optional[Any] = None¶ Optional httpx.Client. param max_retries: int = 2¶ Maximum number of retries to make when generating. param model: str = 'text-embedding-ada-002'¶ param model_kwargs: Dict[str, Any] [Optional]¶ Holds any model parameters valid for create call not explicitly specified. param openai_api_base: Optional[str] = None (alias 'base_url')¶ Base URL path for API requests, leave blank if not using a proxy or service emulator. param openai_api_key: Optional[str] = None (alias 'api_key')¶ Automatically inferred from env var OPENAI_API_KEY if not provided. param openai_api_type: Optional[str] = None¶ param openai_api_version: Optional[str] = None (alias 'api_version')¶ Automatically inferred from env var OPENAI_API_VERSION if not provided.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-2
Automatically inferred from env var OPENAI_API_VERSION if not provided. param openai_organization: Optional[str] = None (alias 'organization')¶ Automatically inferred from env var OPENAI_ORG_ID if not provided. param openai_proxy: Optional[str] = None¶ param request_timeout: Optional[Union[float, Tuple[float, float], Any]] = None (alias 'timeout')¶ Timeout for requests to OpenAI completion API. Can be float, httpx.Timeout or None. param retry_max_seconds: int = 20¶ Max number of seconds to wait between retries param retry_min_seconds: int = 4¶ Min number of seconds to wait between retries param show_progress_bar: bool = False¶ Whether to show a progress bar when embedding. param skip_empty: bool = False¶ Whether to skip empty strings when embedding or raise an error. Defaults to not skipping. param tiktoken_enabled: bool = True¶ Set this to False for non-OpenAI implementations of the embeddings API, e.g. the –extensions openai extension for text-generation-webui param tiktoken_model_name: Optional[str] = None¶ The model name to pass to tiktoken when using this class. Tiktoken is used to count the number of tokens in documents to constrain them to be under a certain limit. By default, when set to None, this will be the same as the embedding model name. However, there are some cases where you may want to use this Embedding class with a model name not supported by tiktoken. This can include when using Azure embeddings or when using one of the many model providers that expose an OpenAI-like API but with different models. In those cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-3
when tiktoken is called, you can specify a model name to use here. async aembed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]][source]¶ Call out to OpenAI’s embedding endpoint async for embedding search docs. Parameters texts (List[str]) – The list of texts to embed. chunk_size (Optional[int]) – The chunk size of embeddings. If None, will use the chunk size specified by the class. Returns List of embeddings, one for each text. Return type List[List[float]] async aembed_query(text: str) → List[float][source]¶ Call out to OpenAI’s embedding endpoint async for embedding query text. Parameters text (str) – The text to embed. Returns Embedding for the text. Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-4
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]][source]¶ Call out to OpenAI’s embedding endpoint for embedding search docs. Parameters texts (List[str]) – The list of texts to embed. chunk_size (Optional[int]) – The chunk size of embeddings. If None, will use the chunk size specified by the class. Returns List of embeddings, one for each text. Return type
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-5
Returns List of embeddings, one for each text. Return type List[List[float]] embed_query(text: str) → List[float][source]¶ Call out to OpenAI’s embedding endpoint for embedding query text. Parameters text (str) – The text to embed. Returns Embedding for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-6
dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-7
Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using OpenAIEmbeddings¶ Activeloop Deep Lake Activeloop Deep Memory Alibaba Cloud OpenSearch Amazon Document DB AnalyticDB Apache Cassandra Apache Doris Astra DB Astra DB (Cassandra) Azure AI Search Azure Cosmos DB Azure OpenAI Build a Query Analysis System Build a Question/Answering system over SQL data Build a Retrieval Augmented Generation (RAG) App Build an Agent Caching Cassandra China Mobile ECloud ElasticSearch VectorSearch Chroma ClickHouse Confident Conversational RAG Couchbase Databricks Vector Search Deep Lake DingoDB DocArray DocArray HnswSearch DocArray InMemorySearch Docugami Document Comparison DuckDB Elasticsearch Epsilla Faiss Faiss (Async) FlashRank reranker Fleet AI Context Hippo Hologres How deal with high cardinality categoricals when doing query analysis How to add chat history How to add retrieval to chatbots How to add scores to retriever results How to add values to a chain’s state How to best prompt for Graph-RAG How to better prompt when doing SQL question-answering How to combine results from multiple retrievers How to create and query vector stores How to deal with large databases when doing SQL question-answering How to do “self-querying” retrieval How to do per-user retrieval How to do retrieval with contextual compression How to get a RAG application to add citations How to get your RAG application to return sources How to handle cases where no queries are generated
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-8
How to handle cases where no queries are generated How to handle long text when doing extraction How to handle multiple queries when doing query analysis How to handle multiple retrievers when doing query analysis How to inspect runnables How to invoke runnables in parallel How to load PDFs How to pass through arguments from one step to the next How to retrieve using multiple vectors per document How to route between sub-chains How to select examples by maximal marginal relevance (MMR) How to select examples by similarity How to split text based on semantic similarity How to stream results from your RAG application How to stream runnables How to use a time-weighted vector store retriever How to use a vectorstore as a retriever How to use few shot examples How to use few shot examples in chat models How to use the LangChain indexing API How to use the MultiQueryRetriever How to use the Parent Document Retriever Hybrid Search Jaguar Vector Database JaguarDB Vector Database Javelin AI Gateway KDB.AI Kinetica Vectorstore API Kinetica Vectorstore based Retriever LLMLingua Document Compressor LOTR (Merger Retriever) LanceDB Lantern Meilisearch Milvus Milvus Hybrid Search Model caches Momento Vector Index (MVI) MongoDB Atlas MyScale Neo4j Vector Index OpenAI OpenSearch PGVector (Postgres) Pinecone Pinecone Hybrid Search Postgres Embedding Psychic Qdrant RAGatouille RankLLM Reranker RePhraseQuery Redis Rockset SAP HANA Cloud Vector Engine SVM SingleStoreDB StarRocks Supabase (Postgres)
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
79b4f6bf2f05-9
SVM SingleStoreDB StarRocks Supabase (Postgres) Tencent Cloud VectorDB Text embedding models TiDB Vector Tigris Timescale Vector (Postgres) Timescale Vector (Postgres) Typesense USearch UpTrain Upstash Vector Vector stores and retrievers Weaviate Xata Yellowbrick YouTube audio Zilliz kNN scikit-learn viking DB
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openai.OpenAIEmbeddings.html
5d2d68acb474-0
langchain_community.embeddings.deepinfra.DeepInfraEmbeddings¶ class langchain_community.embeddings.deepinfra.DeepInfraEmbeddings[source]¶ Bases: BaseModel, Embeddings Deep Infra’s embedding inference service. To use, you should have the environment variable DEEPINFRA_API_TOKEN set with your API token, or pass it as a named parameter to the constructor. There are multiple embeddings models available, see https://deepinfra.com/models?type=embeddings. Example from langchain_community.embeddings import DeepInfraEmbeddings deepinfra_emb = DeepInfraEmbeddings( model_id="sentence-transformers/clip-ViT-B-32", deepinfra_api_token="my-api-key" ) r1 = deepinfra_emb.embed_documents( [ "Alpha is the first letter of Greek alphabet", "Beta is the second letter of Greek alphabet", ] ) r2 = deepinfra_emb.embed_query( "What is the second letter of Greek alphabet" ) 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 batch_size: int = 1024¶ Batch size for embedding requests. param deepinfra_api_token: Optional[str] = None¶ API token for Deep Infra. If not provided, the token is fetched from the environment variable ‘DEEPINFRA_API_TOKEN’. param embed_instruction: str = 'passage: '¶ Instruction used to embed documents. param model_id: str = 'sentence-transformers/clip-ViT-B-32'¶ Embeddings model to use. param model_kwargs: Optional[dict] = None¶ Other model keyword args param normalize: bool = False¶ whether to normalize the computed embeddings
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.deepinfra.DeepInfraEmbeddings.html
5d2d68acb474-1
Other model keyword args param normalize: bool = False¶ whether to normalize the computed embeddings param query_instruction: str = 'query: '¶ Instruction used to embed the query. async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.deepinfra.DeepInfraEmbeddings.html
5d2d68acb474-2
the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Embed documents using a Deep Infra deployed embedding model. For larger batches, the input list of texts is chunked into smaller batches to avoid exceeding the maximum request size. 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 a Deep Infra deployed embedding model. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.deepinfra.DeepInfraEmbeddings.html
5d2d68acb474-3
List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.deepinfra.DeepInfraEmbeddings.html
5d2d68acb474-4
Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using DeepInfraEmbeddings¶ DeepInfra
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.deepinfra.DeepInfraEmbeddings.html
93ab5a9f31c9-0
langchain_community.embeddings.localai.embed_with_retry¶ langchain_community.embeddings.localai.embed_with_retry(embeddings: LocalAIEmbeddings, **kwargs: Any) → Any[source]¶ Use tenacity to retry the embedding call. Parameters embeddings (LocalAIEmbeddings) – kwargs (Any) – Return type Any
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.localai.embed_with_retry.html
a13e92e400e6-0
langchain_community.embeddings.huggingface.HuggingFaceEmbeddings¶ class langchain_community.embeddings.huggingface.HuggingFaceEmbeddings[source]¶ Bases: BaseModel, Embeddings [Deprecated] HuggingFace sentence_transformers embedding models. To use, you should have the sentence_transformers python package installed. Example from langchain_community.embeddings import HuggingFaceEmbeddings model_name = "sentence-transformers/all-mpnet-base-v2" model_kwargs = {'device': 'cpu'} encode_kwargs = {'normalize_embeddings': False} hf = HuggingFaceEmbeddings( model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs ) Notes Deprecated since version 0.2.2. Initialize the sentence_transformer. param cache_folder: Optional[str] = None¶ Path to store models. Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable. param encode_kwargs: Dict[str, Any] [Optional]¶ Keyword arguments to pass when calling the encode method of the Sentence Transformer model, such as prompt_name, prompt, batch_size, precision, normalize_embeddings, and more. See also the Sentence Transformer documentation: https://sbert.net/docs/package_reference/SentenceTransformer.html#sentence_transformers.SentenceTransformer.encode param model_kwargs: Dict[str, Any] [Optional]¶ Keyword arguments to pass to the Sentence Transformer model, such as device, prompts, default_prompt_name, revision, trust_remote_code, or token. See also the Sentence Transformer documentation: https://sbert.net/docs/package_reference/SentenceTransformer.html#sentence_transformers.SentenceTransformer param model_name: str = 'sentence-transformers/all-mpnet-base-v2'¶ Model name to use. param multi_process: bool = False¶ Run encode() on multiple GPUs.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html
a13e92e400e6-1
param multi_process: bool = False¶ Run encode() on multiple GPUs. param show_progress: bool = False¶ Whether to show a progress bar. async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html
a13e92e400e6-2
the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Compute doc embeddings using a HuggingFace transformer 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 HuggingFace transformer model. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html
a13e92e400e6-3
Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html
a13e92e400e6-4
Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using HuggingFaceEmbeddings¶ Aerospike Annoy Cross Encoder Reranker Faiss Faiss (Async) How to reorder retrieved results to mitigate the “lost in the middle” effect Hugging Face Infinispan Intel’s Visual Data Management System (VDMS) LOTR (Merger Retriever) Oracle AI Vector Search: Vector Store ScaNN SemaDB Sentence Transformers on Hugging Face Snowflake
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html
a13e92e400e6-5
ScaNN SemaDB Sentence Transformers on Hugging Face Snowflake SurrealDB Text embedding models TileDB VDMS Vald Vearch self-query-qdrant
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.huggingface.HuggingFaceEmbeddings.html
1f926823b70d-0
langchain_community.embeddings.spacy_embeddings.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: Optional[Any] = 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] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings.html
1f926823b70d-1
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings.html
1f926823b70d-2
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny 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] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings.html
1f926823b70d-3
Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings.html
1f926823b70d-4
ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using SpacyEmbeddings¶ SpaCy spaCy
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.spacy_embeddings.SpacyEmbeddings.html
f90032a4c2fc-0
langchain_community.embeddings.xinference.XinferenceEmbeddings¶ class langchain_community.embeddings.xinference.XinferenceEmbeddings(server_url: Optional[str] = None, model_uid: Optional[str] = None)[source]¶ Xinference embedding models. To use, you should have the xinference library installed: pip install xinference If you’re simply using the services provided by Xinference, you can utilize the xinference_client package: pip install xinference_client Check out: https://github.com/xorbitsai/inference To run, you need to start a Xinference supervisor on one server and Xinference workers on the other servers. Example To start a local instance of Xinference, run $ xinference You can also deploy Xinference in a distributed cluster. Here are the steps: Starting the supervisor: $ xinference-supervisor If you’re simply using the services provided by Xinference, you can utilize the xinference_client package: pip install xinference_client Starting the worker: $ xinference-worker Then, launch a model using command line interface (CLI). Example: $ xinference launch -n orca -s 3 -q q4_0 It will return a model UID. Then you can use Xinference Embedding with LangChain. Example: from langchain_community.embeddings import XinferenceEmbeddings xinference = XinferenceEmbeddings( server_url="http://0.0.0.0:9997", model_uid = {model_uid} # replace model_uid with the model UID return from launching the model ) Attributes client server_url URL of the xinference server model_uid UID of the launched model Methods __init__([server_url, model_uid]) aembed_documents(texts)
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.xinference.XinferenceEmbeddings.html
f90032a4c2fc-1
__init__([server_url, model_uid]) aembed_documents(texts) Asynchronous Embed search docs. aembed_query(text) Asynchronous Embed query text. embed_documents(texts) Embed a list of documents using Xinference. embed_query(text) Embed a query of documents using Xinference. Parameters server_url (Optional[str]) – model_uid (Optional[str]) – __init__(server_url: Optional[str] = None, model_uid: Optional[str] = None)[source]¶ Parameters server_url (Optional[str]) – model_uid (Optional[str]) – async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] embed_documents(texts: List[str]) → List[List[float]][source]¶ Embed a list of documents using Xinference. :param texts: The list of texts to embed. Returns List of embeddings, one for each text. Parameters texts (List[str]) – Return type List[List[float]] embed_query(text: str) → List[float][source]¶ Embed a query of documents using Xinference. :param text: The text to embed. Returns Embeddings for the text. Parameters text (str) – Return type List[float] Examples using XinferenceEmbeddings¶ Xorbits inference (Xinference)
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.xinference.XinferenceEmbeddings.html
54ef44936e1f-0
langchain_community.embeddings.embaas.EmbaasEmbeddings¶ class langchain_community.embeddings.embaas.EmbaasEmbeddings[source]¶ Bases: BaseModel, Embeddings Embaas’s embedding service. To use, you should have the environment variable EMBAAS_API_KEY set with your API key, or pass it as a named parameter to the constructor. Example # initialize with default model and instruction from langchain_community.embeddings import EmbaasEmbeddings emb = EmbaasEmbeddings() # initialize with custom model and instruction from langchain_community.embeddings import EmbaasEmbeddings emb_model = "instructor-large" emb_inst = "Represent the Wikipedia document for retrieval" emb = EmbaasEmbeddings( model=emb_model, instruction=emb_inst ) 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 api_url: str = 'https://api.embaas.io/v1/embeddings/'¶ The URL for the embaas embeddings API. param embaas_api_key: Optional[SecretStr] = None¶ max number of retries for requests Constraints type = string writeOnly = True format = password param instruction: Optional[str] = None¶ Instruction used for domain-specific embeddings. param max_retries: Optional[int] = 3¶ request timeout in seconds param model: str = 'e5-large-v2'¶ The model used for embeddings. param timeout: Optional[int] = 30¶ async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]]
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddings.html
54ef44936e1f-1
Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddings.html
54ef44936e1f-2
self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Get embeddings for a list of texts. Parameters texts (List[str]) – The list of texts to get embeddings for. Returns List of embeddings, one for each text. Return type List[List[float]] embed_query(text: str) → List[float][source]¶ Get embeddings for a single text. Parameters text (str) – The text to get embeddings for. Returns List of embeddings. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddings.html
54ef44936e1f-3
Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddings.html
54ef44936e1f-4
Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using EmbaasEmbeddings¶ Embaas
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddings.html
5e511fd55948-0
langchain_community.embeddings.sparkllm.AssembleHeaderException¶ class langchain_community.embeddings.sparkllm.AssembleHeaderException(msg: str)[source]¶ Exception raised for errors in the header assembly. Parameters msg (str) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.sparkllm.AssembleHeaderException.html
e8dfeba92474-0
langchain_community.embeddings.oracleai.OracleEmbeddings¶ class langchain_community.embeddings.oracleai.OracleEmbeddings[source]¶ Bases: BaseModel, Embeddings Get Embeddings 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 conn: Any = None¶ Embedding Parameters param params: Dict[str, Any] [Required]¶ Proxy param proxy: Optional[str] = None¶ async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oracleai.OracleEmbeddings.html
e8dfeba92474-1
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Compute doc embeddings using an OracleEmbeddings. :param texts: The list of texts to embed. Returns List of embeddings, one for each input text. Parameters texts (List[str]) – Return type List[List[float]] embed_query(text: str) → List[float][source]¶ Compute query embedding using an OracleEmbeddings. :param text: The text to embed.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oracleai.OracleEmbeddings.html
e8dfeba92474-2
Compute query embedding using an OracleEmbeddings. :param text: The text to embed. Returns Embedding for the text. Parameters text (str) – Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode static load_onnx_model(conn: Connection, dir: str, onnx_file: str, model_name: str) → None[source]¶ Load an ONNX model to Oracle Database. :param conn: Oracle Connection, :param dir: Oracle Directory,
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oracleai.OracleEmbeddings.html
e8dfeba92474-3
:param conn: Oracle Connection, :param dir: Oracle Directory, :param onnx_file: ONNX file name, :param model_name: Name of the model. Parameters conn (Connection) – dir (str) – onnx_file (str) – model_name (str) – Return type None classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oracleai.OracleEmbeddings.html
e8dfeba92474-4
dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using OracleEmbeddings¶ Oracle AI Vector Search: Generate Embeddings OracleAI Vector Search
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.oracleai.OracleEmbeddings.html
a0cf7333d9fc-0
langchain_community.embeddings.embaas.EmbaasEmbeddingsPayload¶ class langchain_community.embeddings.embaas.EmbaasEmbeddingsPayload[source]¶ Payload for the Embaas embeddings API. Attributes model texts instruction Methods __init__(*args, **kwargs) clear() copy() fromkeys([value]) Create a new dictionary with keys from iterable and values set to value. get(key[, default]) Return the value for key if key is in the dictionary, else default. items() keys() pop(k[,d]) If the key is not found, return the default if given; otherwise, raise a KeyError. popitem() Remove and return a (key, value) pair as a 2-tuple. setdefault(key[, default]) Insert key with a value of default if key is not in the dictionary. update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] values() __init__(*args, **kwargs)¶ clear() → None.  Remove all items from D.¶ copy() → a shallow copy of D¶ fromkeys(value=None, /)¶ Create a new dictionary with keys from iterable and values set to value. get(key, default=None, /)¶ Return the value for key if key is in the dictionary, else default. items() → a set-like object providing a view on D's items¶
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddingsPayload.html
a0cf7333d9fc-1
items() → a set-like object providing a view on D's items¶ keys() → a set-like object providing a view on D's keys¶ pop(k[, d]) → v, remove specified key and return the corresponding value.¶ If the key is not found, return the default if given; otherwise, raise a KeyError. popitem()¶ Remove and return a (key, value) pair as a 2-tuple. Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty. setdefault(key, default=None, /)¶ Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. update([E, ]**F) → None.  Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k] values() → an object providing a view on D's values¶
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.embaas.EmbaasEmbeddingsPayload.html
1827ad36fb6b-0
langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings¶ class langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings[source]¶ Bases: OpenVINOEmbeddings OpenVNO BGE embedding models. Bge Example:from langchain_community.embeddings import OpenVINOBgeEmbeddings model_name = "BAAI/bge-large-en" model_kwargs = {'device': 'CPU'} encode_kwargs = {'normalize_embeddings': True} ov = OpenVINOBgeEmbeddings( model_name_or_path=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs ) Initialize the sentence_transformer. param embed_instruction: str = ''¶ Instruction to use for embedding document. param encode_kwargs: Dict[str, Any] [Optional]¶ Keyword arguments to pass when calling the encode method of the model. param model_kwargs: Dict[str, Any] [Optional]¶ Keyword arguments to pass to the model. param model_name_or_path: str [Required]¶ HuggingFace model id. param ov_model: Any = None¶ OpenVINO model object. param query_instruction: str = 'Represent this question for searching relevant passages: '¶ Instruction to use for embedding query. param show_progress: bool = False¶ Whether to show a progress bar. param tokenizer: Any = None¶ Tokenizer for embedding model. async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float]
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html
1827ad36fb6b-1
Parameters text (str) – Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html
1827ad36fb6b-2
self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str]) → List[List[float]][source]¶ Compute doc embeddings using a HuggingFace transformer 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 HuggingFace transformer model. Parameters text (str) – The text to embed. Returns Embeddings for the text. Return type List[float] encode(sentences: Any, batch_size: int = 4, show_progress_bar: bool = False, convert_to_numpy: bool = True, convert_to_tensor: bool = False, mean_pooling: bool = False, normalize_embeddings: bool = True) → Any¶ Computes sentence embeddings. Parameters
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html
1827ad36fb6b-3
Computes sentence embeddings. Parameters sentences (Any) – the sentences to embed. batch_size (int) – the batch size used for the computation. show_progress_bar (bool) – Whether to output a progress bar. convert_to_numpy (bool) – Whether the output should be a list of numpy vectors. convert_to_tensor (bool) – Whether the output should be one large tensor. mean_pooling (bool) – Whether to pool returned vectors. normalize_embeddings (bool) – Whether to normalize returned vectors. Returns By default, a 2d numpy array with shape [num_inputs, output_dimension]. Return type Any classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html
1827ad36fb6b-4
exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model save_model(model_path: str) → bool¶ Parameters model_path (str) – Return type bool classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html
1827ad36fb6b-5
dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model Examples using OpenVINOBgeEmbeddings¶ OpenVINO
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.openvino.OpenVINOBgeEmbeddings.html
c8477a6c19b1-0
langchain_community.embeddings.self_hosted_hugging_face.load_embedding_model¶ langchain_community.embeddings.self_hosted_hugging_face.load_embedding_model(model_id: str, instruct: bool = False, device: int = 0) → Any[source]¶ Load the embedding model. Parameters model_id (str) – instruct (bool) – device (int) – Return type Any
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.load_embedding_model.html
4f8884e6a26b-0
langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings¶ class langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings[source]¶ Bases: OpenAIEmbeddings OctoAI Compute Service embedding models. See https://octo.ai/ for information about OctoAI. To use, you should have the openai python package installed and the environment variable OCTOAI_API_TOKEN set with your API token. Alternatively, you can use the octoai_api_token keyword argument. 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 allowed_special: Union[Literal['all'], Set[str]] = {}¶ param chunk_size: int = 1000¶ Maximum number of texts to embed in each batch param default_headers: Union[Mapping[str, str], None] = None¶ param default_query: Union[Mapping[str, object], None] = None¶ param deployment: Optional[str] = 'text-embedding-ada-002'¶ param disallowed_special: Union[Literal['all'], Set[str], Sequence[str]] = 'all'¶ param embedding_ctx_length: int = 8191¶ The maximum number of tokens to embed at once. param endpoint_url: str = 'https://text.octoai.run/v1/'¶ Base URL path for API requests. param headers: Any = None¶ param http_client: Union[Any, None] = None¶ Optional httpx.Client. param max_retries: int = 2¶ Maximum number of retries to make when generating. param model: str = 'thenlper/gte-large'¶ Model name to use. param model_kwargs: Dict[str, Any] [Optional]¶
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
4f8884e6a26b-1
Model name to use. param model_kwargs: Dict[str, Any] [Optional]¶ Holds any model parameters valid for create call not explicitly specified. param octoai_api_token: SecretStr = None¶ OctoAI Endpoints API keys. Constraints type = string writeOnly = True format = password param openai_api_base: Optional[str] = None (alias 'base_url')¶ Base URL path for API requests, leave blank if not using a proxy or service emulator. param openai_api_key: Optional[str] = None (alias 'api_key')¶ Automatically inferred from env var OPENAI_API_KEY if not provided. param openai_api_type: Optional[str] = None¶ param openai_api_version: Optional[str] = None (alias 'api_version')¶ Automatically inferred from env var OPENAI_API_VERSION if not provided. param openai_organization: Optional[str] = None (alias 'organization')¶ Automatically inferred from env var OPENAI_ORG_ID if not provided. param openai_proxy: Optional[str] = None¶ param request_timeout: Optional[Union[float, Tuple[float, float], Any]] = None (alias 'timeout')¶ Timeout for requests to OpenAI completion API. Can be float, httpx.Timeout or None. param retry_max_seconds: int = 20¶ Max number of seconds to wait between retries param retry_min_seconds: int = 4¶ Min number of seconds to wait between retries param show_progress_bar: bool = False¶ Whether to show a progress bar when embedding. param skip_empty: bool = False¶ Whether to skip empty strings when embedding or raise an error. Defaults to not skipping. param tiktoken_enabled: bool = False¶ Set this to False for non-OpenAI implementations of the embeddings API
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
4f8884e6a26b-2
Set this to False for non-OpenAI implementations of the embeddings API param tiktoken_model_name: Optional[str] = None¶ The model name to pass to tiktoken when using this class. Tiktoken is used to count the number of tokens in documents to constrain them to be under a certain limit. By default, when set to None, this will be the same as the embedding model name. However, there are some cases where you may want to use this Embedding class with a model name not supported by tiktoken. This can include when using Azure embeddings or when using one of the many model providers that expose an OpenAI-like API but with different models. In those cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here. async aembed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]]¶ Call out to OpenAI’s embedding endpoint async for embedding search docs. Parameters texts (List[str]) – The list of texts to embed. chunk_size (Optional[int]) – The chunk size of embeddings. If None, will use the chunk size specified by the class. Returns List of embeddings, one for each text. Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Call out to OpenAI’s embedding endpoint async for embedding query text. Parameters text (str) – The text to embed. Returns Embedding for the text. Return type List[float] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
4f8884e6a26b-3
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude and change. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
4f8884e6a26b-4
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny embed_documents(texts: List[str], chunk_size: Optional[int] = 0) → List[List[float]]¶ Call out to OpenAI’s embedding endpoint for embedding search docs. Parameters texts (List[str]) – The list of texts to embed. chunk_size (Optional[int]) – The chunk size of embeddings. If None, will use the chunk size specified by the class. Returns List of embeddings, one for each text. Return type List[List[float]] embed_query(text: str) → List[float]¶ Call out to OpenAI’s embedding endpoint for embedding query text. Parameters text (str) – The text to embed. Returns Embedding for the text. Return type List[float] classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶ Generate a JSON representation of the model, include and exclude arguments as per dict().
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
4f8884e6a26b-5
Generate a JSON representation of the model, include and exclude arguments as per dict(). encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps(). Parameters include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – by_alias (bool) – skip_defaults (Optional[bool]) – exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – encoder (Optional[Callable[[Any], Any]]) – models_as_dict (bool) – dumps_kwargs (Any) – Return type unicode classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters path (Union[str, Path]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod parse_obj(obj: Any) → Model¶ Parameters obj (Any) – Return type Model classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶ Parameters b (Union[str, bytes]) – content_type (unicode) – encoding (unicode) – proto (Protocol) – allow_pickle (bool) – Return type Model classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶ Parameters by_alias (bool) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
4f8884e6a26b-6
Parameters by_alias (bool) – ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model property lc_secrets: Dict[str, str]¶
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.octoai_embeddings.OctoAIEmbeddings.html
6b7f726a0106-0
langchain_community.embeddings.nemo.is_endpoint_live¶ langchain_community.embeddings.nemo.is_endpoint_live(url: str, headers: Optional[dict], payload: Any) → bool[source]¶ Check if an endpoint is live by sending a GET request to the specified URL. Parameters url (str) – The URL of the endpoint to check. headers (Optional[dict]) – payload (Any) – Returns True if the endpoint is live (status code 200), False otherwise. Return type bool Raises Exception – If the endpoint returns a non-successful status code or if there is an error querying the endpoint.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.nemo.is_endpoint_live.html
672993f4c727-0
langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings¶ class langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings[source]¶ Bases: SelfHostedEmbeddings HuggingFace embedding models on self-hosted remote hardware. Supported hardware includes auto-launched instances on AWS, GCP, Azure, and Lambda, as well as servers specified by IP address and SSH credentials (such as on-prem, or another cloud like Paperspace, Coreweave, etc.). To use, you should have the runhouse python package installed. Example from langchain_community.embeddings import SelfHostedHuggingFaceEmbeddings import runhouse as rh model_id = "sentence-transformers/all-mpnet-base-v2" gpu = rh.cluster(name="rh-a10x", instance_type="A100:1") hf = SelfHostedHuggingFaceEmbeddings(model_id=model_id, hardware=gpu) Initialize the remote inference function. param allow_dangerous_deserialization: bool = False¶ Allow deserialization using pickle which can be dangerous if loading compromised data. param cache: Union[BaseCache, bool, None] = None¶ Whether to cache the response. If true, will use the global cache. If false, will not use a cache If None, will use the global cache if it’s set, otherwise no cache. If instance of BaseCache, will use the provided cache. Caching is not currently supported for streaming methods of models. param callback_manager: Optional[BaseCallbackManager] = None¶ [DEPRECATED] param callbacks: Callbacks = None¶ Callbacks to add to the run trace. param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-1
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶ Optional encoder to use for counting tokens. param hardware: Any = None¶ Remote hardware to send the inference function to. param inference_fn: Callable = <function _embed_documents>¶ Inference function to extract the embeddings. param inference_kwargs: Any = None¶ Any kwargs to pass to the model’s inference function. param load_fn_kwargs: Optional[dict] = None¶ Keyword arguments to pass to the model load function. param metadata: Optional[Dict[str, Any]] = None¶ Metadata to add to the run trace. param model_id: str = 'sentence-transformers/all-mpnet-base-v2'¶ Model name to use. param model_load_fn: Callable = <function load_embedding_model>¶ Function to load the model remotely on the server. param model_reqs: List[str] = ['./', 'sentence_transformers', 'torch']¶ Requirements to install on hardware to inference the model. param tags: Optional[List[str]] = None¶ Tags to add to the run trace. param verbose: bool [Optional]¶ Whether to print out response text. __call__(prompt: str, stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) → str¶ [Deprecated] Check Cache and run the LLM on the given prompt and input. Notes Deprecated since version langchain-core==0.1.7: Use invoke instead. Parameters prompt (str) – stop (Optional[List[str]]) – callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) –
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-2
callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – tags (Optional[List[str]]) – metadata (Optional[Dict[str, Any]]) – kwargs (Any) – Return type str async abatch(inputs: List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Any) → List[str]¶ Default implementation runs ainvoke in parallel using asyncio.gather. The default implementation of batch works well for IO bound runnables. Subclasses should override this method if they can batch more efficiently; e.g., if the underlying runnable uses an API which supports a batch mode. Parameters inputs (List[Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]]) – config (Optional[Union[RunnableConfig, List[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Any) – Return type List[str] async abatch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → AsyncIterator[Tuple[int, Union[Output, Exception]]]¶ Run ainvoke in parallel on a list of inputs, yielding results as they complete. Parameters inputs (Sequence[Input]) – config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Optional[Any]) – Return type
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-3
return_exceptions (bool) – kwargs (Optional[Any]) – Return type AsyncIterator[Tuple[int, Union[Output, Exception]]] async aembed_documents(texts: List[str]) → List[List[float]]¶ Asynchronous Embed search docs. Parameters texts (List[str]) – Return type List[List[float]] async aembed_query(text: str) → List[float]¶ Asynchronous Embed query text. Parameters text (str) – Return type List[float] async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[List[str], List[List[str]]]] = None, metadata: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None, run_name: Optional[Union[str, List[str]]] = None, run_id: Optional[Union[UUID, List[Optional[UUID]]]] = None, **kwargs: Any) → LLMResult¶ Asynchronously pass a sequence of prompts to a model and return generations. This method should make use of batched calls for models that expose a batched API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts (List[str]) – List of string prompts. stop (Optional[List[str]]) – Stop words to use when generating. Model output is cut off at the first occurrence of any of these substrings.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-4
first occurrence of any of these substrings. callbacks (Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]]) – Callbacks to pass through. Used for executing additional functionality, such as logging or streaming, throughout generation. **kwargs (Any) – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. tags (Optional[Union[List[str], List[List[str]]]]) – metadata (Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]) – run_name (Optional[Union[str, List[str]]]) – run_id (Optional[Union[UUID, List[Optional[UUID]]]]) – **kwargs – Returns An LLMResult, which contains a list of candidate Generations for each inputprompt and additional model provider-specific output. Return type LLMResult async agenerate_prompt(prompts: List[PromptValue], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, **kwargs: Any) → LLMResult¶ Asynchronously pass a sequence of prompts and return model generations. This method should make use of batched calls for models that expose a batched API. Use this method when you want to: take advantage of batched calls, need more output from the model than just the top generated value, are building chains that are agnostic to the underlying language modeltype (e.g., pure text completion models vs chat models). Parameters prompts (List[PromptValue]) – List of PromptValues. A PromptValue is an object that can be converted to match the format of any language model (string for pure
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-5
converted to match the format of any language model (string for pure text generation models and BaseMessages for chat models). stop (Optional[List[str]]) – Stop words to use when generating. Model output is cut off at the first occurrence of any of these substrings. callbacks (Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]]) – Callbacks to pass through. Used for executing additional functionality, such as logging or streaming, throughout generation. **kwargs (Any) – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns An LLMResult, which contains a list of candidate Generations for each inputprompt and additional model provider-specific output. Return type LLMResult async ainvoke(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → str¶ Default implementation of ainvoke, calls invoke from a thread. The default implementation allows usage of async code even if the runnable did not implement a native async version of invoke. Subclasses should override this method if they can run asynchronously. Parameters input (Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]) – config (Optional[RunnableConfig]) – stop (Optional[List[str]]) – kwargs (Any) – Return type str async apredict(text: str, *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → str¶ [Deprecated] Notes
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-6
[Deprecated] Notes Deprecated since version langchain-core==0.1.7: Use ainvoke instead. Parameters text (str) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type str async apredict_messages(messages: List[BaseMessage], *, stop: Optional[Sequence[str]] = None, **kwargs: Any) → BaseMessage¶ [Deprecated] Notes Deprecated since version langchain-core==0.1.7: Use ainvoke instead. Parameters messages (List[BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type BaseMessage assign(**kwargs: Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) → RunnableSerializable[Any, Any]¶ Assigns new fields to the dict output of this runnable. Returns a new runnable. from langchain_community.llms.fake import FakeStreamingListLLM from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import SystemMessagePromptTemplate from langchain_core.runnables import Runnable from operator import itemgetter prompt = ( SystemMessagePromptTemplate.from_template("You are a nice assistant.") + "{question}" ) llm = FakeStreamingListLLM(responses=["foo-lish"]) chain: Runnable = prompt | llm | {"str": StrOutputParser()} chain_with_assign = chain.assign(hello=itemgetter("str") | llm) print(chain_with_assign.input_schema.schema()) # {'title': 'PromptInput', 'type': 'object', 'properties': {'question': {'title': 'Question', 'type': 'string'}}}
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-7
{'question': {'title': 'Question', 'type': 'string'}}} print(chain_with_assign.output_schema.schema()) # {'title': 'RunnableSequenceOutput', 'type': 'object', 'properties': {'str': {'title': 'Str', 'type': 'string'}, 'hello': {'title': 'Hello', 'type': 'string'}}} Parameters kwargs (Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) – Return type RunnableSerializable[Any, Any] async astream(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIterator[str]¶ Default implementation of astream, which calls ainvoke. Subclasses should override this method if they support streaming output. Parameters input (Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]]) – config (Optional[RunnableConfig]) – stop (Optional[List[str]]) – kwargs (Any) – Return type AsyncIterator[str]
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-8
kwargs (Any) – Return type AsyncIterator[str] astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Optional[Sequence[str]] = None, exclude_types: Optional[Sequence[str]] = None, exclude_tags: Optional[Sequence[str]] = None, **kwargs: Any) → AsyncIterator[StreamEvent]¶ [Beta] Generate a stream of events. Use to create an iterator over StreamEvents that provide real-time information about the progress of the runnable, including StreamEvents from intermediate results. A StreamEvent is a dictionary with the following schema: event: str - Event names are of theformat: on_[runnable_type]_(start|stream|end). name: str - The name of the runnable that generated the event. run_id: str - randomly generated ID associated with the given execution ofthe runnable that emitted the event. A child runnable that gets invoked as part of the execution of a parent runnable is assigned its own unique ID. parent_ids: List[str] - The IDs of the parent runnables thatgenerated the event. The root runnable will have an empty list. The order of the parent IDs is from the root to the immediate parent. Only available for v2 version of the API. The v1 version of the API will return an empty list. tags: Optional[List[str]] - The tags of the runnable that generatedthe event. metadata: Optional[Dict[str, Any]] - The metadata of the runnablethat generated the event. data: Dict[str, Any] Below is a table that illustrates some evens that might be emitted by various
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-9
Below is a table that illustrates some evens that might be emitted by various chains. Metadata fields have been omitted from the table for brevity. Chain definitions have been included after the table. ATTENTION This reference table is for the V2 version of the schema. event name chunk input output on_chat_model_start [model name] {“messages”: [[SystemMessage, HumanMessage]]} on_chat_model_stream [model name] AIMessageChunk(content=”hello”) on_chat_model_end [model name] {“messages”: [[SystemMessage, HumanMessage]]} AIMessageChunk(content=”hello world”) on_llm_start [model name] {‘input’: ‘hello’} on_llm_stream [model name] ‘Hello’ on_llm_end [model name] ‘Hello human!’ on_chain_start format_docs on_chain_stream format_docs “hello world!, goodbye world!” on_chain_end format_docs [Document(…)] “hello world!, goodbye world!” on_tool_start some_tool {“x”: 1, “y”: “2”} on_tool_end some_tool {“x”: 1, “y”: “2”} on_retriever_start [retriever name] {“query”: “hello”} on_retriever_end [retriever name] {“query”: “hello”} [Document(…), ..] on_prompt_start [template_name] {“question”: “hello”} on_prompt_end [template_name] {“question”: “hello”} ChatPromptValue(messages: [SystemMessage, …]) Here are declarations associated with the events shown above: format_docs: def format_docs(docs: List[Document]) -> str:
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-10
format_docs: def format_docs(docs: List[Document]) -> str: '''Format the docs.''' return ", ".join([doc.page_content for doc in docs]) format_docs = RunnableLambda(format_docs) some_tool: @tool def some_tool(x: int, y: str) -> dict: '''Some_tool.''' return {"x": x, "y": y} prompt: template = ChatPromptTemplate.from_messages( [("system", "You are Cat Agent 007"), ("human", "{question}")] ).with_config({"run_name": "my_template", "tags": ["my_template"]}) Example: from langchain_core.runnables import RunnableLambda async def reverse(s: str) -> str: return s[::-1] chain = RunnableLambda(func=reverse) events = [ event async for event in chain.astream_events("hello", version="v2") ] # will produce the following events (run_id, and parent_ids # has been omitted for brevity): [ { "data": {"input": "hello"}, "event": "on_chain_start", "metadata": {}, "name": "reverse", "tags": [], }, { "data": {"chunk": "olleh"}, "event": "on_chain_stream", "metadata": {}, "name": "reverse", "tags": [], }, { "data": {"output": "olleh"}, "event": "on_chain_end", "metadata": {}, "name": "reverse", "tags": [], }, ] Parameters input (Any) – The input to the runnable.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-11
}, ] Parameters input (Any) – The input to the runnable. config (Optional[RunnableConfig]) – The config to use for the runnable. version (Literal['v1', 'v2']) – The version of the schema to use either v2 or v1. Users should use v2. v1 is for backwards compatibility and will be deprecated in 0.4.0. No default will be assigned until the API is stabilized. include_names (Optional[Sequence[str]]) – Only include events from runnables with matching names. include_types (Optional[Sequence[str]]) – Only include events from runnables with matching types. include_tags (Optional[Sequence[str]]) – Only include events from runnables with matching tags. exclude_names (Optional[Sequence[str]]) – Exclude events from runnables with matching names. exclude_types (Optional[Sequence[str]]) – Exclude events from runnables with matching types. exclude_tags (Optional[Sequence[str]]) – Exclude events from runnables with matching tags. kwargs (Any) – Additional keyword arguments to pass to the runnable. These will be passed to astream_log as this implementation of astream_events is built on top of astream_log. Returns An async stream of StreamEvents. Return type AsyncIterator[StreamEvent] Notes
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html
672993f4c727-12
An async stream of StreamEvents. Return type AsyncIterator[StreamEvent] Notes async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Optional[Sequence[str]] = None, exclude_types: Optional[Sequence[str]] = None, exclude_tags: Optional[Sequence[str]] = None, **kwargs: Any) → Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]]¶ Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops can be applied in order to construct state. Parameters input (Any) – The input to the runnable. config (Optional[RunnableConfig]) – The config to use for the runnable. diff (bool) – Whether to yield diffs between each step, or the current state. with_streamed_output_list (bool) – Whether to yield the streamed_output list. include_names (Optional[Sequence[str]]) – Only include logs with these names. include_types (Optional[Sequence[str]]) – Only include logs with these types. include_tags (Optional[Sequence[str]]) – Only include logs with these tags. exclude_names (Optional[Sequence[str]]) – Exclude logs with these names. exclude_types (Optional[Sequence[str]]) – Exclude logs with these types. exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags.
https://api.python.langchain.com/en/latest/embeddings/langchain_community.embeddings.self_hosted_hugging_face.SelfHostedHuggingFaceEmbeddings.html