TogetherEmbeddings#

class langchain_together.embeddings.TogetherEmbeddings[source]#

Bases: BaseModel, Embeddings

TogetherEmbeddings embedding model.

To use, set the environment variable TOGETHER_API_KEY with your API key or pass it as a named parameter to the constructor.

Example

from langchain_together import TogetherEmbeddings

model = TogetherEmbeddings()

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: Literal['all'] | Set[str] = {}#

Not yet supported.

param chunk_size: int = 1000#

Maximum number of texts to embed in each batch.

Not yet supported.

param default_headers: Mapping[str, str] | None = None#
param default_query: Mapping[str, object] | None = None#
param dimensions: int | None = None#

The number of dimensions the resulting output embeddings should have.

Not yet supported.

param disallowed_special: Literal['all'] | Set[str] | Sequence[str] = 'all'#

Not yet supported.

param embedding_ctx_length: int = 4096#

The maximum number of tokens to embed at once.

Not yet supported.

param http_async_client: Any | None = None#

Optional httpx.AsyncClient. Only used for async invocations. Must specify http_client as well if you’d like a custom client for sync invocations.

param http_client: Any | None = None#

Optional httpx.Client. Only used for sync invocations. Must specify http_async_client as well if you’d like a custom client for async invocations.

param max_retries: int = 2#

Maximum number of retries to make when generating.

param model: str = 'togethercomputer/m2-bert-80M-8k-retrieval'#

Embeddings model name to use. Instead, use ‘togethercomputer/m2-bert-80M-8k-retrieval’ for example.

param model_kwargs: Dict[str, Any] [Optional]#

Holds any model parameters valid for create call not explicitly specified.

param request_timeout: float | Tuple[float, float] | Any | None = None (alias 'timeout')#

Timeout for requests to Together embedding API. Can be float, httpx.Timeout or None.

param show_progress_bar: bool = False#

Whether to show a progress bar when embedding.

Not yet supported.

param skip_empty: bool = False#

Whether to skip empty strings when embedding or raise an error. Defaults to not skipping.

Not yet supported.

param together_api_base: str = 'https://api.together.ai/v1/' (alias 'base_url')#

Endpoint URL to use.

param together_api_key: SecretStr | None = None (alias 'api_key')#

API Key for Solar API.

Constraints:
  • type = string

  • writeOnly = True

  • format = password

async aembed_documents(texts: List[str]) List[List[float]][source]#

Embed a list of document texts using passage model asynchronously.

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]#

Asynchronous Embed query text using query model.

Parameters:

text (str) – The text to embed.

Returns:

Embedding for the text.

Return type:

List[float]

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

Embed a list of document texts using passage model.

Parameters:

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

Returns:

List of embeddings, one for each text.

Return type:

List[List[float]]

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

Embed query text using query model.

Parameters:

text (str) – The text to embed.

Returns:

Embedding for the text.

Return type:

List[float]

Examples using TogetherEmbeddings#