Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/huggingface/sentence-transformers
/ functions
Functions
4,575 in github.com/huggingface/sentence-transformers
⨍
Functions
4,575
◇
Types & classes
516
↳
Endpoints
81
↓ 4 callers
Function
dot_score
Computes the dot-product dot_prod(a[i], b[j]) for all i and j. Args: a (Union[list, np.ndarray, Tensor]): The first tensor.
sentence_transformers/util/similarity.py:101
↓ 4 callers
Function
encode
(seed: int)
tests/base/test_model_card.py:1383
↓ 4 callers
Method
encode
( self, inputs: SingleInput, prompt_name: str | None = ..., prompt: str | None
sentence_transformers/multi_vector_encoder/model.py:664
↓ 4 callers
Function
evaluate_stsb_test
(model: SentenceTransformer, expected_score: float, test_dataset: Dataset)
tests/sentence_transformer/test_train_stsb.py:36
↓ 4 callers
Method
find_best_acc_and_threshold
(scores, labels, high_score_more_similar: bool)
sentence_transformers/sentence_transformer/evaluation/binary_classification.py:317
↓ 4 callers
Method
find_best_f1_and_threshold
(scores, labels, high_score_more_similar: bool)
sentence_transformers/sentence_transformer/evaluation/binary_classification.py:358
↓ 4 callers
Method
forward
(self, features: dict[str, Tensor], task: str | None = None)
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:424
↓ 4 callers
Method
from_text_file
( cls, embeddings_file_path: str, update_embeddings: bool = False, item_separa
sentence_transformers/sentence_transformer/modules/word_embeddings.py:146
↓ 4 callers
Method
get_embedding_dimension
(self)
sentence_transformers/sentence_transformer/modules/cnn.py:64
↓ 4 callers
Method
get_embedding_dimension
Returns the number of dimensions in the output of :meth:`SparseEncoder.encode`. Unlike :class:`~sentence_transformers.sentence_trans
sentence_transformers/sparse_encoder/model.py:976
↓ 4 callers
Function
import_from_string
Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import failed.
sentence_transformers/util/misc.py:132
↓ 4 callers
Method
lookup
Return the row positions for ``ids``, raising ``KeyError(missing_id)`` on a miss.
sentence_transformers/util/dataset.py:104
↓ 4 callers
Method
make_recording_collator
(self, **kwargs)
tests/base/test_data_collator.py:187
↓ 4 callers
Method
prepare
(self, x: torch.Tensor)
sentence_transformers/sparse_encoder/modules/sparse_auto_encoder.py:113
↓ 4 callers
Method
prepend_prompt_to_texts
Prepend a prompt to text format inputs. For single texts, prepends the prompt directly. For text pairs (cross-encoder inputs), prepen
sentence_transformers/base/modality.py:699
↓ 4 callers
Method
preprocess
(self, inputs: list[str], prompt: str | None = None, **kwargs)
sentence_transformers/sentence_transformer/modules/bow.py:64
↓ 4 callers
Function
pytorch_cos_sim
Computes the cosine similarity between two tensors. Args: a (Union[list, np.ndarray, Tensor]): The first tensor. b (Union[li
sentence_transformers/util/similarity.py:45
↓ 4 callers
Function
r
(n)
docs/_static/js/custom.js:28
↓ 4 callers
Function
real_query_token_slice
Return the slice into ``encode_query``'s output that selects the real content tokens. Chat-template prefixes (e.g. ``<bos>``), ColBERT query mark
sentence_transformers/multi_vector_encoder/interpretability.py:48
↓ 4 callers
Function
render_similarity_map_on_image
Overlay a 2D similarity map onto an image with the mako colormap. Args: image: PIL image, URL, or local file path (loaded via :func:`tran
sentence_transformers/multi_vector_encoder/interpretability.py:178
↓ 4 callers
Method
reset
(self)
tests/sparse_encoder/modules/test_csr.py:30
↓ 4 callers
Function
s
(e,t,o)
docs/_static/js/custom.js:28
↓ 4 callers
Method
save
Save the model, processor, and module config to ``output_path``.
sentence_transformers/base/modules/transformer.py:2645
↓ 4 callers
Function
semantic_search_seismic
Performs semantic search using sparse embeddings with Seismic. Args: query_embeddings_decoded: List of query embeddings in format [[
sentence_transformers/sparse_encoder/search_engines.py:304
↓ 4 callers
Method
set_epoch
(self, epoch: int)
sentence_transformers/base/sampler.py:196
↓ 4 callers
Function
shrink
(tensor: Tensor, dim: int)
sentence_transformers/sentence_transformer/losses/matryoshka.py:18
↓ 4 callers
Method
start
(self)
examples/sentence_transformer/evaluation/evaluation_no_dup_batch_sampler_speed.py:268
↓ 4 callers
Method
track_loss_components
(self, loss: dict[str, torch.Tensor])
sentence_transformers/base/trainer.py:524
↓ 4 callers
Function
uses_gradient_cache
Whether the loss reports that it uses gradient caching.
sentence_transformers/base/losses/gradcache.py:219
↓ 3 callers
Method
__init__
(self, distance_threshold: float | None = None)
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:214
↓ 3 callers
Method
__init__
(self, model: CrossEncoder, loss_fct: nn.Module, activation_fn: nn.Module = nn.Identity())
sentence_transformers/cross_encoder/fit_mixin.py:146
↓ 3 callers
Method
__init__
(self)
tests/sentence_transformer/losses/test_cached_gist_embed.py:77
↓ 3 callers
Method
_apply_chat_template
Call ``apply_chat_template`` with the kwarg routing the processor type expects: nested kwargs for a ProcessorMixin, flat with the size kwargs
sentence_transformers/base/modules/transformer.py:1956
↓ 3 callers
Function
_as_sequence
(value: Any)
sentence_transformers/base/modality.py:171
↓ 3 callers
Method
_assert_outputs_match
(out1: dict, out2: dict)
tests/base/modules/test_transformer.py:2116
↓ 3 callers
Method
_asset_path_to_url
Convert a relative asset path to a Hub URL if model_id is available, otherwise keep relative.
sentence_transformers/base/model_card.py:1888
↓ 3 callers
Function
_base_params
Return ``(encoder_params, decoder_base_params)`` keyed by name, for the shared base models.
tests/sentence_transformer/losses/test_denoising_auto_encoder.py:11
↓ 3 callers
Method
_build_dataloader
Shared logic for building train/eval/test DataLoaders. Args: dataset: The dataset to build a DataLoader for. batch_si
sentence_transformers/base/trainer.py:840
↓ 3 callers
Function
_build_features
(batch: int = 4)
tests/multi_vector_encoder/losses/test_matryoshka.py:30
↓ 3 callers
Method
_build_hashes
(self)
sentence_transformers/base/sampler.py:491
↓ 3 callers
Function
_columns
( model: SparseEncoder, columns: Sequence[Sequence[str]], tasks: Sequence[str | None] | None = None )
tests/sparse_encoder/losses/test_merged_forward.py:26
↓ 3 callers
Method
_crash
(self)
tests/utils.py:55
↓ 3 callers
Function
_embeddings
(num_columns: int, batch_size: int = BATCH_SIZE)
tests/sentence_transformer/losses/test_misc.py:45
↓ 3 callers
Function
_explicit_cosent_loss
(loss_fn, embeddings, labels)
tests/sentence_transformer/losses/test_cosent.py:53
↓ 3 callers
Function
_features
(per: int, dim: int = 16, seed: int = 7)
tests/sentence_transformer/losses/test_gist_embed.py:53
↓ 3 callers
Function
_fill_empty_document_scores
Overwrite the scores of documents flagged in ``empty`` (no unmasked token), whose every token sat at the masked-fill dtype minimum and whose sum t
sentence_transformers/util/similarity.py:532
↓ 3 callers
Function
_fit_mask_width
Match a mask's token span to the padded embeddings. The chunk loops pass ``truncate=True``, since a batch-wide mask legitimately spans more than o
sentence_transformers/util/similarity.py:312
↓ 3 callers
Method
_fold_model2vec_weights
Fold a model2vec token mapping and per-token weights into one row per token id, so that ``embedding[token_id] == embeddings[token_mapping[toke
sentence_transformers/sentence_transformer/modules/static_embedding.py:173
↓ 3 callers
Method
_generate_non_text_snippet
Generate a usage snippet for non-text inputs (multimodal dicts or single-modality items).
sentence_transformers/base/model_card.py:1738
↓ 3 callers
Method
_get_inputs
(transformer: Transformer, is_audio: bool)
tests/base/modules/test_transformer.py:2110
↓ 3 callers
Method
_get_model_config
(self)
sentence_transformers/base/model.py:837
↓ 3 callers
Function
_get_quantization_ranges
( embeddings: np.ndarray, precision: Literal["int8", "uint8"], calibration_embeddings: np.ndarray
sentence_transformers/util/quantization.py:431
↓ 3 callers
Method
_get_routes_string
(self)
sentence_transformers/base/modules/router.py:339
↓ 3 callers
Method
_get_similarity_functions
(self)
sentence_transformers/sentence_transformer/evaluation/triplet.py:263
↓ 3 callers
Method
_infer_method_output_name
Validate that ``method_output_name`` is present in the method's return type annotation. Returns the name if found, or ``None`` if the method'
sentence_transformers/base/modules/transformer.py:2633
↓ 3 callers
Method
_inference
Run local inference on normalized inputs with resolved arguments.
sentence_transformers/base/model.py:2005
↓ 3 callers
Function
_int_column
(t_tokens: int, seed: int, batch: int = 2, left_pad: int = 0)
tests/multi_vector_encoder/losses/test_misc.py:622
↓ 3 callers
Method
_interleave_sorted_indices
Interleave a largest-to-smallest sorted index array so that each consecutive batch contains a mix of long and short inputs. When text
sentence_transformers/base/model.py:561
↓ 3 callers
Function
_is_media_url_or_path
Check if a string is a URL or local file path with one of the given extensions.
sentence_transformers/base/modality.py:65
↓ 3 callers
Function
_leaves
(features: list[dict[str, Tensor]])
tests/multi_vector_encoder/losses/test_matryoshka.py:42
↓ 3 callers
Method
_load_config_modules
Loads a full model using the modules.json file. Args: model_name_or_path (str): The name or path of the pre-trained mode
sentence_transformers/base/model.py:1288
↓ 3 callers
Method
_load_converted_modules
(self, *args, **kwargs)
tests/base/test_model_type_subclass.py:49
↓ 3 callers
Method
_load_from_checkpoint
(self, checkpoint_path: str)
sentence_transformers/base/trainer.py:1087
↓ 3 callers
Method
_load_transformer
(model_name: str, extra_kwargs: dict)
tests/base/modules/test_transformer.py:2101
↓ 3 callers
Method
_load_with_module_classes
Load a saved model, resolving the ``modules.json`` types listed in ``module_classes`` to those classes rather than importing them. Ty
sentence_transformers/base/model.py:360
↓ 3 callers
Function
_local_reps
(per: int, dim: int = 16, seed: int = 7)
tests/sentence_transformer/losses/test_cached_gist_embed.py:154
↓ 3 callers
Function
_loss_and_grads
( model: SentenceTransformer, loss_fn: torch.nn.Module, columns: tuple[list[str], list[str]], labels: Tens
tests/sentence_transformer/losses/test_gradcache.py:30
↓ 3 callers
Function
_make_ir_evaluator
()
tests/base/test_model_card.py:1524
↓ 3 callers
Function
_make_loss
Build a GISTEmbedLoss without loading real models. ``forward`` encodes via ``self.model`` / ``self.guide``. We replace both with a fake that
tests/sentence_transformer/losses/test_gist_embed.py:12
↓ 3 callers
Function
_make_loss
Build a CachedGISTEmbedLoss without loading real models. ``calculate_loss`` only needs the configuration attributes and operates on precomput
tests/sentence_transformer/losses/test_cached_gist_embed.py:13
↓ 3 callers
Function
_make_pil_image
Create a small dummy PIL image.
tests/sentence_transformer/test_model_card.py:263
↓ 3 callers
Function
_make_samples
()
tests/sparse_encoder/test_reciprocal_rank_fusion.py:12
↓ 3 callers
Function
_maxsim_score_pairs
Score one chunk of aligned query-document pairs, returned as ``(batch,)`` float32. Pulled out of :func:`maxsim_pairwise` so the chunk loop stays r
sentence_transformers/util/similarity.py:718
↓ 3 callers
Function
_move_tensors_to_device
Move nested tensors to a device, preserving lists, tuples, dictionaries, and non-tensor values.
sentence_transformers/util/tensor.py:336
↓ 3 callers
Function
_normalize_token_embeddings
(embedding: Tensor)
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:263
↓ 3 callers
Function
_off_device
(*values: float)
tests/base/test_multi_process.py:59
↓ 3 callers
Function
_pad_to_3d
Pad a list of ``(t_i, D)`` tensors back into a ``(B, max_t, D)`` tensor. Callers guarantee a non-empty list.
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:55
↓ 3 callers
Method
_parse_model_config
(self, model_config: dict[str, Any])
sentence_transformers/multi_vector_encoder/model.py:1228
↓ 3 callers
Method
_place_modules
Align auxiliary modules without changing backbones or dispatched submodules.
sentence_transformers/base/model.py:1703
↓ 3 callers
Function
_pool_reference
(features: list[dict[str, Tensor]], pooling: BaseTokenPooling | None)
tests/multi_vector_encoder/losses/test_token_pooling.py:63
↓ 3 callers
Function
_reference_no_duplicates_batches
Reference implementation of the historical dict-based iteration logic.
tests/base/samplers/test_no_duplicates_batch_sampler.py:74
↓ 3 callers
Method
_scatter
(self, messages: list | None = None)
sentence_transformers/util/distributed.py:163
↓ 3 callers
Function
_scipy_pool_reference
(embedding, pool_factor, num_protected_tokens, normalize_embeddings)
tests/multi_vector_encoder/modules/test_token_pooling.py:24
↓ 3 callers
Method
_set_kernel_settings
(self, use_kernels: bool, kernel_config: KernelConfig | None)
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:390
↓ 3 callers
Method
_total_rss
(self)
examples/sentence_transformer/evaluation/evaluation_no_dup_batch_sampler_speed.py:245
↓ 3 callers
Method
_total_uss
(self)
examples/sentence_transformer/evaluation/evaluation_no_dup_batch_sampler_speed.py:306
↓ 3 callers
Function
_write_stanford_checkpoint
A Stanford-NLP ColBERT-shaped checkpoint: ``architectures: ["HF_ColBERT"]``, the projection stored at the repo root as ``linear.weight`` rather th
tests/multi_vector_encoder/test_model.py:636
↓ 3 callers
Function
_zero_row_mask
Derive a ``(B, T)`` mask from a pre-padded ``(B, T, D)`` token-embedding tensor by treating all-zero rows as padding. Real token embeddings n
sentence_transformers/util/similarity.py:742
↓ 3 callers
Function
backend_should_export
Determines whether the model should be exported to the backend, or if it can be loaded directly. Also update the `file_name` and `subfolder`
sentence_transformers/backend/utils.py:40
↓ 3 callers
Method
batch_decode
(self, sequences, skip_special_tokens)
tests/sentence_transformer/losses/test_cached_gist_embed.py:95
↓ 3 callers
Function
colbert_kd_scores
Compute MaxSim scores for knowledge distillation. The query embeddings have shape ``(batch_size, q_tokens, dim)``. The document embeddings have t
sentence_transformers/multi_vector_encoder/scoring/colbert.py:26
↓ 3 callers
Method
compute_loss_from_embeddings
Compute the embedding-distillation loss from already-computed embedding lists. Exposed so subclasses (or callers composing this with another
sentence_transformers/sentence_transformer/losses/embed_distill.py:197
↓ 3 callers
Function
create_modality_pair_samples
Create test pair samples for all supported modality combinations. Generates pairs for: 1. Text pairs: (text, text) - handled natively by the
tests/base/modules/transformer/conftest.py:440
↓ 3 callers
Function
distributed_evaluation
Share DDP inference and yield whether this rank should run the evaluator. When disabled, every rank runs the evaluator. Nonzero ranks suppress lo
sentence_transformers/util/distributed.py:196
↓ 3 callers
Function
embed_columns_padded
The multi-vector counterpart of :func:`embed_columns`. Returns per-column ``(batch_size, tokens, dim)`` embeddings and their boolean scoring mask
sentence_transformers/base/losses/merged_forward.py:203
↓ 3 callers
Function
encode_and_compare
(model: MultiVectorEncoder, torch_embeddings, atol: float = 1e-5)
tests/multi_vector_encoder/test_backends.py:52
↓ 3 callers
Function
evaluate_stsb_test
( model: CrossEncoder, expected_score: float, test_dataset: Dataset, num_test_samples: int = -1 )
tests/cross_encoder/test_train_stsb.py:23
↓ 3 callers
Method
forward
(self, features: dict[str, Tensor], task: str | None = None)
sentence_transformers/multi_vector_encoder/modules/multi_vector_mask.py:124
↓ 3 callers
Method
forward
(self, features: dict[str, Tensor], task: str | None = None)
tests/multi_vector_encoder/losses/test_matryoshka.py:57
↓ 3 callers
Method
from_model2vec
Create a StaticEmbedding instance from a model2vec model. This method loads a pre-trained model2vec model and extracts the embedding
sentence_transformers/sentence_transformer/modules/static_embedding.py:269
← previous
next →
301–400 of 4,575, ranked by callers