View Source TxtaiEx.Embeddings (txtai_ex v0.1.1)

Handles interactions with a remote txtai embeddings service, offering functionalities such as searching for similar documents, adding documents for indexing, and more, via REST API calls.

Summary

Functions

Adds a batch of documents for indexing in the embeddings model.

Performs a batch search for queries, finding documents similar to each query.

Computes similarity between a list of queries and a list of texts in batch.

Transforms a list of texts into embeddings representations in batch.

Counts the total number of documents in the embeddings index.

Deletes specified documents from the embeddings index.

Triggers indexing of previously added documents.

Recreates the embeddings index with new configuration settings.

Searches for documents similar to the input query within the embeddings model.

Computes similarity between a query and a list of texts.

Transforms text into embeddings representation.

Updates or inserts documents into the embeddings index, depending on whether they exist.

Functions

Adds a batch of documents for indexing in the embeddings model.

Parameters

  • api: Struct containing API configuration (URL and token).
  • documents: List of documents, where each is a map with id and text keys.

Returns

  • on successful indexing.
  • on failure.
Link to this function

batchsearch(api, queries, limit \\ 10, weights \\ nil, index \\ nil)

View Source

Performs a batch search for queries, finding documents similar to each query.

Parameters

  • api: Struct containing API configuration (URL and token).
  • queries: List of text queries to search for similar documents.
  • limit: Maximum number of results per query (default: 10).
  • weights: (Optional) Hybrid score weights.
  • index: (Optional) Specific index name to search within.

Returns

  • on success, with results being a list of results per query.
  • on failure.
Link to this function

batchsimilarity(api, queries, texts)

View Source

Computes similarity between a list of queries and a list of texts in batch.

Parameters

  • api: Struct containing API configuration (URL and token).
  • queries: A list of query texts.
  • texts: A list of texts to compare against each query.

Returns

  • on success, with scores being a list of results for each query.
  • on failure.
Link to this function

batchtransform(api, texts)

View Source

Transforms a list of texts into embeddings representations in batch.

Parameters

  • api: Struct containing API configuration (URL and token).
  • texts: A list of texts to transform.

Returns

  • on success, where embeddings is a list of embeddings representations for each text.
  • on failure.

Counts the total number of documents in the embeddings index.

Parameters

  • api: Struct containing API configuration (URL and token).

Returns

  • with count being the total number of documents in the index.
  • on failure.

Deletes specified documents from the embeddings index.

Parameters

  • api: Struct containing API configuration (URL and token).
  • ids: List of document ids to delete.

Returns

  • upon successful deletion.
  • on failure.

Triggers indexing of previously added documents.

Parameters

  • api: Struct containing API configuration (URL and token).

Returns

  • upon successful triggering of the indexing process.
  • on failure.
Link to this function

reindex(api, config, func \\ nil)

View Source

Recreates the embeddings index with new configuration settings.

Parameters

  • api: Struct containing API configuration (URL and token).
  • config: New configuration settings for the index.
  • func: (Optional) A function to prepare content for indexing.

Returns

  • upon successful reindexing.
  • on failure.
Link to this function

search(api, query, limit \\ 10, weights \\ nil, index \\ nil)

View Source

Searches for documents similar to the input query within the embeddings model.

Parameters

  • api: Struct containing API configuration (URL and token).
  • query: Text query to search for similar documents.
  • limit: Maximum number of results to return (default: 10).
  • weights: (Optional) Hybrid score weights for adjusting importance in scoring.
  • index: (Optional) Specific index name to search within.

Returns

  • on success, with results being a list of documents sorted by similarity score.
  • on failure.
Link to this function

similarity(api, query, texts)

View Source

Computes similarity between a query and a list of texts.

Parameters

  • api: Struct containing API configuration (URL and token).
  • query: The query text.
  • texts: A list of texts to compare against the query.

Returns

  • on success, where scores is a list of similarity scores.
  • on failure.

Transforms text into embeddings representation.

Parameters

  • api: Struct containing API configuration (URL and token).
  • text: The text to transform.

Returns

  • on success, where embeddings is the embeddings representation of the text.
  • on failure.

Updates or inserts documents into the embeddings index, depending on whether they exist.

Parameters

  • api: Struct containing API configuration (URL and token).

Returns

  • upon successful upsert operation.
  • on failure.