MCPcopy Create free account

hub / github.com/huggingface/sentence-transformers / functions

Functions3,759 in github.com/huggingface/sentence-transformers

↓ 3 callersFunctionembed_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 callersMethodencode
( self, inputs: SingleInput, prompt_name: str | None = ..., prompt: str | None
sentence_transformers/multi_vector_encoder/model.py:581
↓ 3 callersFunctionencode_and_compare
(model: MultiVectorEncoder, torch_embeddings, atol: float = 1e-5)
tests/multi_vector_encoder/test_backends.py:52
↓ 3 callersFunctionevaluate_stsb_test
( model: CrossEncoder, expected_score: float, test_dataset: Dataset, num_test_samples: int = -1 )
tests/cross_encoder/test_train_stsb.py:23
↓ 3 callersMethodfind_best_acc_and_threshold
(scores, labels, high_score_more_similar: bool)
sentence_transformers/sentence_transformer/evaluation/binary_classification.py:317
↓ 3 callersMethodfind_best_f1_and_threshold
(scores, labels, high_score_more_similar: bool)
sentence_transformers/sentence_transformer/evaluation/binary_classification.py:344
↓ 3 callersMethodforward
(self, features: dict[str, Tensor], task: str | None = None)
sentence_transformers/multi_vector_encoder/modules/multi_vector_mask.py:124
↓ 3 callersMethodfrom_text_file
( cls, embeddings_file_path: str, update_embeddings: bool = False, item_separa
sentence_transformers/sentence_transformer/modules/word_embeddings.py:146
↓ 3 callersMethodget_batch_sampler
Returns the appropriate batch sampler based on the ``batch_sampler`` argument in ``self.args``. This batch sampler class supports ``_
sentence_transformers/base/trainer.py:716
↓ 3 callersMethodget_config_dict
(self)
sentence_transformers/multi_vector_encoder/losses/multiple_negatives_ranking.py:131
↓ 3 callersMethodget_config_dict
(self)
sentence_transformers/multi_vector_encoder/losses/distill_kl_div.py:130
↓ 3 callersMethodget_config_dict
Get the configuration dictionary. Returns: Dictionary containing the configuration parameters
sentence_transformers/sparse_encoder/losses/csr.py:207
↓ 3 callersMethodget_multi_dataset_batch_sampler
Returns the appropriate multi-dataset batch sampler based on the ``multi_dataset_batch_sampler`` argument in ``self.args``. This batc
sentence_transformers/base/trainer.py:781
↓ 3 callersMethodhas_pair_roles
Whether any conversation in a batch carries both of the ``query``/``document`` pair roles. Anchored on produced messages so both routes into
sentence_transformers/base/modality.py:505
↓ 3 callersFunctionhas_static_embedding_input
Whether the model embeds its inputs with a StaticEmbedding, directly or behind a Router. StaticEmbedding features are an EmbeddingBag (``input_id
sentence_transformers/base/losses/gradcache.py:256
↓ 3 callersMethodload_file_path
A utility function to load a file from a model checkpoint. The checkpoint can be either a local directory or a model id on Hugging Face.
sentence_transformers/base/modules/module.py:233
↓ 3 callersFunctionloss_and_grads
(loss_fn: torch.nn.Module)
tests/sentence_transformer/losses/test_cached_gist_embed.py:235
↓ 3 callersFunctionmock_encode
We simply one-hot encode the sentences. If a sentence contains a keyword, the corresponding one-hot encoding is added to the sentence
tests/sentence_transformer/evaluation/test_information_retrieval_evaluator.py:15
↓ 3 callersFunctionmodify_processor_for_pairs
(model: Transformer)
tests/base/modules/transformer/conftest.py:756
↓ 3 callersFunctionparaphrase_mining
Given a list of sentences / texts, this function performs paraphrase mining. It compares all sentences against all other sentences and return
sentence_transformers/util/retrieval.py:23
↓ 3 callersMethodpossible_values
Returns a list of possible values for the SimilarityFunction enum. Returns: list: A list of possible values for the Simi
sentence_transformers/util/similarity.py:924
↓ 3 callersMethodsave
(self, output_path: str, *args, safe_serialization: bool = True, **kwargs)
sentence_transformers/base/modules/dense.py:108
↓ 3 callersMethodsave
Save the model, processor, and module config to ``output_path``.
sentence_transformers/base/modules/transformer.py:2593
↓ 3 callersFunctionsave_or_push_to_hub_model
( export_function: Callable, export_function_name: str, config, model_name_or_path: str, p
sentence_transformers/backend/utils.py:155
↓ 3 callersMethodsave_to_hub
DEPRECATED, use `push_to_hub` instead. Uploads all elements of this model to a new HuggingFace Hub repository. Args:
sentence_transformers/base/model.py:854
↓ 3 callersFunctionset_temporary_class_attrs
(cls, **overrides)
sentence_transformers/base/modules/transformer.py:487
↓ 3 callersMethodsimilarity
(self, a, b)
tests/sentence_transformer/evaluation/test_information_retrieval_evaluator.py:46
↓ 3 callersMethodsimilarity
(self, queries, corpus)
tests/util/test_hard_negatives.py:1683
↓ 3 callersFunctionstack_padded_token_embeddings
Stack a list of ``(B, T_i, D)`` token embeddings and their ``(B, T_i)`` masks along ``dim=1``, padding each column up to the batch-wide max token
sentence_transformers/util/tensor.py:265
↓ 3 callersMethodstart
(self)
examples/sentence_transformer/evaluation/evaluation_no_dup_batch_sampler_speed.py:268
↓ 3 callersMethodtrack_loss_components
(self, loss: dict[str, torch.Tensor])
sentence_transformers/base/trainer.py:519
↓ 3 callersMethodtruncate_embeddings
In this context, :meth:`SentenceTransformer.encode` outputs embeddings truncated at dimension ``truncate_dim``. This may be
sentence_transformers/sentence_transformer/model.py:1271
↓ 3 callersMethodtry_to_set_ir_model_from_evaluators
(self)
sentence_transformers/base/model_card.py:1315
↓ 3 callersFunctionxtr_kd_scores
XTR scoring for knowledge distillation. Same global top-k scoring as :func:`xtr_scores`, but returns each query's own N-way document scores `
sentence_transformers/multi_vector_encoder/scoring/xtr.py:130
↓ 2 callersFunctionF
(e,t)
docs/_static/js/custom.js:28
↓ 2 callersMethod__init__
(self, callback: Callable[[float, int, int], None], evaluator: BaseEvaluator)
sentence_transformers/sentence_transformer/fit_mixin.py:138
↓ 2 callersMethod__init__
(self, *, tasks: str | list[str] | None = None)
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:85
↓ 2 callersMethod__init__
The LambdaLoss Framework for Ranking Metric Optimization. This loss function implements the LambdaLoss framework for ranking metric optimizat
sentence_transformers/cross_encoder/losses/lambda_loss.py:104
↓ 2 callersMethod_append_csv_headers
(self, similarity_fn_names: list[str])
sentence_transformers/sentence_transformer/evaluation/binary_classification.py:123
↓ 2 callersMethod_append_csv_headers
(self, score_function_names)
sentence_transformers/sentence_transformer/evaluation/information_retrieval.py:200
↓ 2 callersMethod_append_csv_headers
(self, similarity_fn_names: list[str])
sentence_transformers/sentence_transformer/evaluation/embedding_similarity.py:134
↓ 2 callersMethod_append_csv_headers
(self, score_function_names)
sentence_transformers/sentence_transformer/evaluation/nano_beir.py:288
↓ 2 callersFunction_build_loss
(model: SparseEncoder)
tests/sparse_encoder/losses/test_merged_forward.py:43
↓ 2 callersMethod_call_processor
Call the appropriate processor with the correct arguments. Dispatches based on the processor type and modality: 1. **Message modalit
sentence_transformers/base/modules/transformer.py:1755
↓ 2 callersFunction_canonicalize_side
Shared input front door for one side of a scoring call: masks become a single tensor (a list of per-item masks is padded to the batch), and a bare
sentence_transformers/util/similarity.py:290
↓ 2 callersFunction_compute_scheduled_efficiency
Helper: return fraction of samples that appear in properly balanced batches (not the remainder).
tests/base/samplers/test_group_by_label_batch_sampler.py:166
↓ 2 callersMethod_create_model_card
Create an automatic model card and store it in the specified path. Args: path (str): The path where the model card will
sentence_transformers/base/model.py:812
↓ 2 callersFunction_create_video_dataset
Create a small Dataset with a Video feature column from synthetic video files.
tests/base/test_model_card.py:1343
↓ 2 callersFunction_embedding_dim
The trailing embedding dimension, read without materializing a padded batch.
sentence_transformers/util/similarity.py:359
↓ 2 callersFunction_embeddings_device
The device multi-vector embeddings live on, or None for numpy and empty inputs.
sentence_transformers/util/similarity.py:319
↓ 2 callersMethod_flattened
(self, lengths: list[int])
tests/sentence_transformer/losses/test_gradcache.py:518
↓ 2 callersMethod_get_default_modality_config
Get the default modality configuration for the current transformer task. Returns: tuple[ModalityConfig, str]: A tuple of (modalit
sentence_transformers/base/modules/transformer.py:2792
↓ 2 callersMethod_get_processor_attributes
Get the attributes of the processor if available. Will be removed in the future as transformers v5 becomes the minimum requirement. R
sentence_transformers/base/modules/transformer.py:2539
↓ 2 callersMethod_get_task_for_column
Resolve the task a column is preprocessed with. Subclasses may add positional defaults.
sentence_transformers/base/data_collator.py:82
↓ 2 callersFunction_hierarchical_pool_one
Ward hierarchical clustering on cosine distance for a single 2D embedding.
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:190
↓ 2 callersMethod_is_flash_attention_requested
Whether the loaded model was configured for FlashAttention-2 (via ``attn_implementation``).
sentence_transformers/base/modules/transformer.py:1217
↓ 2 callersFunction_is_video_frames
(value: Any)
sentence_transformers/base/modality.py:174
↓ 2 callersMethod_load_default_modules
Args: model_name_or_path (str): The name or path of the pre-trained model. token (Optional[Union[bool, str]]): The t
sentence_transformers/base/model.py:1087
↓ 2 callersMethod_load_from_checkpoint
(self, checkpoint_path: str)
sentence_transformers/base/trainer.py:1070
↓ 2 callersMethod_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:287
↓ 2 callersFunction_looks_like_url
Check if a string looks like a valid URL (starts with http(s) and has no spaces).
sentence_transformers/base/modality.py:59
↓ 2 callersFunction_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
↓ 2 callersMethod_make_image_dataset
(self, n: int = 5)
tests/base/test_model_card.py:559
↓ 2 callersFunction_make_ragged_feature
Like ``_make_feature``, but each sample has its own real token count. ``mini_batch_num_tokens`` packs by real tokens, so it only produces uneven m
tests/multi_vector_encoder/losses/test_misc.py:150
↓ 2 callersFunction_make_samples
()
tests/sparse_encoder/test_reciprocal_rank_fusion.py:8
↓ 2 callersFunction_make_similarity_evaluator
()
tests/base/test_model_card.py:1470
↓ 2 callersMethod_maybe_load_stanford_metadata
Read Stanford-NLP ColBERT settings from ``artifact.metadata`` and stash them on ``self._legacy`` for the Transformer constructor + prefix-toke
sentence_transformers/multi_vector_encoder/model.py:1361
↓ 2 callersMethod_message_skeleton
Replace each non-system message content with ``filler``, keeping everything else verbatim. Keeping system messages whole lets the derivation
sentence_transformers/base/modules/transformer.py:2157
↓ 2 callersFunction_pad_chunk
Pad one chunk of a side onto the scoring device, with its mask narrowed to the chunk's local width. Padding the whole batch upfront instead would
sentence_transformers/util/similarity.py:339
↓ 2 callersFunction_pad_multi_vector_inputs
Pad a list of variable-length multi-vector tensors into a single 3D tensor with a mask. Returns the padded tensor and either the user-provided ma
sentence_transformers/util/similarity.py:740
↓ 2 callersFunction_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:56
↓ 2 callersFunction_patch_hfapi
(method: str, **kwargs)
tests/base/test_trainer.py:31
↓ 2 callersMethod_push_from_checkpoint
(self, checkpoint_folder: str)
sentence_transformers/base/trainer.py:1019
↓ 2 callersFunction_query_token_counts
Per-item count of real query tokens for MeanMaxSim scoring: the mask sum when a mask is given, the item lengths for ragged lists, and the non-zero
sentence_transformers/util/similarity.py:366
↓ 2 callersMethod_register_prefix_tokens
Mark a prompt-prefix token as special so the tokenizer emits it as a single piece. Call only with the prefixes of an existing token-prepended
sentence_transformers/multi_vector_encoder/model.py:1077
↓ 2 callersMethod_render_examples_table
Render the examples table for a dataset, saving non-text values as assets when possible. Returns: A tuple of ``(rendered_table, n
sentence_transformers/base/model_card.py:1744
↓ 2 callersMethod_resolve_activation_fn
Instantiate an activation function from a dotted path string, respecting trust_remote_code.
sentence_transformers/cross_encoder/model.py:395
↓ 2 callersFunction_resolve_retrieval_model_class
Resolve the concrete ``*ForRetrieval`` class (ColPali, ColQwen2, ...) for ``transformer_task="retrieval"``. transformers (as of v5.13) has no ``A
sentence_transformers/base/modules/transformer.py:158
↓ 2 callersMethod_save_asset
Save a non-text value to the assets directory, deduplicating by content hash. Args: prefix: Prepended to filenames, e.g. ``"examp
sentence_transformers/base/model_card.py:810
↓ 2 callersFunction_save_pretrained_wrapper
Wraps the save_pretrained method of a model to save to a subfolder. Args: _save_pretrained_fn: The original save_pretrained function
sentence_transformers/backend/utils.py:21
↓ 2 callersFunction_student_kd_scores
Mirror the evaluator's student MaxSim scoring so teacher scores can be built from it.
tests/multi_vector_encoder/test_evaluators.py:301
↓ 2 callersFunction_to_device
Move one side's padded embeddings and mask onto the scoring device. The mask is checked separately, since a caller can hand in a cpu mask alongsid
sentence_transformers/util/similarity.py:328
↓ 2 callersMethod_validate_input
(sentence_features: list[dict[str, Tensor]])
sentence_transformers/sentence_transformer/losses/mega_batch_margin.py:138
↓ 2 callersMethod_warn_on_unsupported_attention_config
Warn if the config requests bidirectional attention settings not supported by the installed transformers version.
sentence_transformers/base/modules/transformer.py:2273
↓ 2 callersFunction_wav_bytes
(frequency: int)
tests/base/samplers/test_no_duplicates_batch_sampler.py:31
↓ 2 callersMethodactive_adapters
If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT official documentation: htt
sentence_transformers/base/peft_mixin.py:114
↓ 2 callersFunctionall_gather
Gathers a tensor from each distributed rank into a list. Always retains gradients for the local rank's tensor, and optionally retains gradien
sentence_transformers/util/distributed.py:27
↓ 2 callersFunctionall_gather_padded
All-gather a ``(B, T, D)`` token-embedding tensor and its ``(B, T)`` mask across ranks, padding the token axis to the cross-rank max ``T`` first.
sentence_transformers/util/distributed.py:80
↓ 2 callersMethodapply_chat_template
(self, messages, tokenize=False, chat_template=None, **kwargs)
tests/base/test_modality.py:1576
↓ 2 callersFunctionb
(e)
docs/_static/js/custom.js:28
↓ 2 callersFunctionbackend_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
↓ 2 callersFunctionbackend_warn_to_save
Warns the user to save the model if they just exported it. Args: model_name_or_path: The model name or path is_local: Whethe
sentence_transformers/backend/utils.py:138
↓ 2 callersMethodcalculate_loss
Generalized function to calculate the cross-entropy loss without caching gradients.
sentence_transformers/sentence_transformer/losses/cached_gist_embed.py:253
↓ 2 callersMethodcalculate_loss
Calculate the all-pairs InfoNCE loss, chunked over ``mini_batch_size`` rows of the score matrix. The labels are unused: the positive pair is t
sentence_transformers/sentence_transformer/losses/cached_multiple_negatives_ranking.py:244
↓ 2 callersMethodcalculate_loss
( self, reps: list[list[Tensor]], masks_chunks: list[list[Tensor]], *,
sentence_transformers/multi_vector_encoder/losses/cached_multiple_negatives_ranking.py:218
↓ 2 callersFunctioncat_padded_token_embeddings
Concatenate ``(B_i, T_i, D)`` token-embedding chunks and ``(B_i, T_i)`` mask chunks along ``dim=0``, padding each chunk up to the chunk-wide max t
sentence_transformers/util/tensor.py:285
↓ 2 callersFunctioncheck_package_availability
Checks if a package is available from the correct owner.
sentence_transformers/util/environment.py:88
↓ 2 callersFunctioncheck_teacher_targets
Inspect a distillation loss's teacher target once, on its first forward. Takes the target the loss itself computed rather than recomputing a soft
sentence_transformers/util/misc.py:76
↓ 2 callersFunctioncolbert_scores_pairwise
Pairwise ColBERT (MaxSim) scoring for matched ``(query_i, document_i)`` pairs. Takes ``(batch_size, q_tokens, dim)`` query embeddings and ``(batc
sentence_transformers/multi_vector_encoder/scoring/colbert.py:65
↓ 2 callersMethodcompute_loss_from_embeddings
Compute the Triplet loss from embeddings. Args: embeddings: List of embeddings Returns: Loss value
sentence_transformers/sentence_transformer/losses/triplet.py:88
← previousnext →301–400 of 3,759, ranked by callers