Sting.Sparse (Sting v0.1.0)

Copy Markdown View Source

Loading and model construction for SentenceTransformers sparse encoders.

The supported pipeline is an MLM transformer followed by SpladePooling, or a SparseStaticEmbedding lookup table. SPLADE applies log1p(relu(logits)) token-wise and then pools each vocabulary dimension with :max or :sum. Sparse vectors remain unnormalized vocabulary-space tensors; use dot-product similarity for retrieval.

Summary

Functions

Encodes one text or a list of texts with a sparse embedding serving. Returns one %{embedding: rank_1_tensor} map or a list of maps.

Loads an MLMTransformer or SparseStaticEmbedding sparse pipeline. These are the supported sparse base modules; other saved module types return an error.

Loads the tokenizer used by the first sparse pipeline module.

Returns the highest dot-product matches for each sparse query vector.

Computes sparse-vector dot-product similarities.

Builds a serving that returns unnormalized sparse vocabulary vectors in %{embedding: tensor} result maps.

Types

repository()

@type repository() :: Bumblebee.repository()

Functions

encode(model_info, tokenizer, input, opts \\ [])

Encodes one text or a list of texts with a sparse embedding serving. Returns one %{embedding: rank_1_tensor} map or a list of maps.

load_model(repository, opts \\ [])

@spec load_model(repository(), keyword()) :: {:ok, map()} | {:error, String.t()}

Loads an MLMTransformer or SparseStaticEmbedding sparse pipeline. These are the supported sparse base modules; other saved module types return an error.

load_tokenizer(repository, opts \\ [])

@spec load_tokenizer(repository(), keyword()) :: {:ok, term()} | {:error, String.t()}

Loads the tokenizer used by the first sparse pipeline module.

semantic_search(queries, corpus, opts \\ [])

Returns the highest dot-product matches for each sparse query vector.

similarity(left, right)

Computes sparse-vector dot-product similarities.

text_embedding(model_info, tokenizer, opts \\ [])

Builds a serving that returns unnormalized sparse vocabulary vectors in %{embedding: tensor} result maps.