MCPcopy Create free account

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

Functions4,575 in github.com/huggingface/sentence-transformers

Functiontest_basic_functionality
Test the basic functionality with default parameters.
tests/util/test_hard_negatives.py:115
Functiontest_batch_all_does_not_save_a_cube_for_paired_labels
()
tests/sentence_transformer/losses/test_batch_all_triplet.py:59
Functiontest_batch_all_matches_explicit_triplets
(distance_metric, case)
tests/sentence_transformer/losses/test_batch_all_triplet.py:34
Functiontest_batch_all_retains_gradient_at_zero_hinge
()
tests/sentence_transformer/losses/test_batch_all_triplet.py:78
Methodtest_batch_decode_succeeds
get_frames_at with all frame indices succeeds on first try.
tests/base/test_model_card.py:1164
Functiontest_batch_guarantees
Every batch must satisfy three invariants: 1. Contains >= 2 distinct labels. 2. Every label in the batch appears >= 2 times. 3. Non-last
tests/base/samplers/test_group_by_label_batch_sampler.py:194
Functiontest_batch_hard_soft_margin_finite_loss_and_gradients
(dummy_model, separation)
tests/sentence_transformer/losses/test_triplet.py:127
Methodtest_batch_n_minus_1_fallback
get_frames_at(n) fails but get_frames_at(n-1) succeeds.
tests/base/test_model_card.py:1174
Functiontest_batch_options
(model, batch_options, expected_batch_sizes, monkeypatch)
tests/test_merging.py:218
Functiontest_batch_size
Test batch_size parameter.
tests/util/test_hard_negatives.py:890
Functiontest_batch_triplet_losses_keep_finite_loss_and_gradients
(loss_class, dtype, autocast)
tests/sentence_transformer/losses/test_triplet_distance_precision.py:75
Methodtest_batches
(self, messages_batch, expected)
tests/base/test_modality.py:1715
Functiontest_batches_spanning_shuffled_rounds_have_negative_labels
(label_sizes: list[int], seed: int)
tests/base/samplers/test_group_by_label_batch_sampler.py:238
Functiontest_bert_base_slow
(stsb_dataset_dict: DatasetDict)
tests/sentence_transformer/test_pretrained_stsb.py:47
Functiontest_bert_large_slow
(stsb_dataset_dict: DatasetDict)
tests/sentence_transformer/test_pretrained_stsb.py:56
Functiontest_bfloat16
()
tests/cross_encoder/test_model.py:414
Functiontest_binary_classification_evaluator_csv_columns_are_aligned
( splade_bert_tiny_model: SparseEncoder, tmp_path: Path, similarity_fn_names: list[str] | None )
tests/sparse_encoder/evaluation/test_binary_classification_evaluator.py:13
Functiontest_binary_quantize_keeps_leading_dims
A single 1-D embedding (e.g. from ``model.encode("text")``) or a 3-D batch packs along the last axis only.
tests/util/test_quantization.py:88
Functiontest_binary_quantize_multiple_of_8_shape
For dims divisible by 8, the packed shape must equal (n, dim // 8).
tests/util/test_quantization.py:52
Functiontest_binary_quantize_non_multiple_of_8_does_not_raise
quantize_embeddings must not crash for embedding dimensions not divisible by 8.
tests/util/test_quantization.py:26
Functiontest_binary_quantize_row_independence
Each row is packed independently. An all-positive row must not bleed into an all-negative one.
tests/util/test_quantization.py:67
Methodtest_bool_column_stats
(self, stsb_bert_tiny_model: SentenceTransformer)
tests/base/test_model_card.py:883
Methodtest_both_provided_new_wins
(self, caplog)
tests/util/test_decorators.py:48
Methodtest_both_provided_new_wins
(self, caplog, old_name, new_name)
tests/util/test_decorators.py:137
Methodtest_both_provided_new_wins
(self, caplog, old_name, new_name)
tests/util/test_decorators.py:265
Methodtest_both_provided_repo_id_wins
(self, caplog)
tests/util/test_decorators.py:442
Methodtest_both_sibling_metadata_keys_hint_both_forms
(self)
tests/base/test_modality.py:275
Methodtest_budget_boundary_is_inclusive
(self)
tests/multi_vector_encoder/modules/test_token_pooling.py:398
Methodtest_budget_larger_than_the_batch
(self)
tests/sentence_transformer/losses/test_gradcache.py:297
Functiontest_cache
Test cache_folder parameter.
tests/util/test_hard_negatives.py:980
Methodtest_cache_dir_accepts_none_kwargs
(self, name)
tests/util/test_decorators.py:180
Methodtest_cache_dir_distributed
(self, caplog)
tests/util/test_decorators.py:148
Methodtest_cache_dir_does_not_mutate_kwargs
(self, name, target)
tests/util/test_decorators.py:204
Methodtest_cache_dir_does_not_override_existing
(self, caplog, name, existing_cache_dir)
tests/util/test_decorators.py:165
Methodtest_cache_dir_none_no_warning
(self, caplog)
tests/util/test_decorators.py:217
Functiontest_cache_folder_from_env
When cache_folder is None, it should fall back to SENTENCE_TRANSFORMERS_HOME env var.
tests/base/test_model.py:437
Functiontest_cache_respects_prompt
The cache key must incorporate the prompt arguments, so a different `query_prompt` produces its own cache file rather than silently reusing embedd
tests/util/test_hard_negatives.py:1001
Functiontest_cached_ce_mnrl_matches_mnrl
``mini_batch_size`` only bounds memory: the cached loss must reproduce MultipleNegativesRankingLoss's loss and gradient, whether or not it divides
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:32
Functiontest_cached_ce_mnrl_prompt_reaches_the_backward_pass
The prompt (and task) must be carried into the backward hook's re-prediction: they change the tokenization, so if the hook's bundle dropped them,
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:190
Functiontest_cached_ce_mnrl_replays_dropout_on_cuda
The backward pass must re-predict exactly the logits of the forward pass, dropout included. ``RandContext`` can only capture the RNG state of dev
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:52
Functiontest_cached_ce_mnrl_scales_with_the_outer_backward
Scaling the returned loss (gradient accumulation, fp16 loss scaling) must scale the whole gradient.
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:124
Functiontest_cached_ce_mnrl_two_forwards_before_one_backward
Each forward pass must hand its own cached gradients to its own backward hook. The cache used to live on the loss module, where a second forward p
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:95
Functiontest_cached_ce_mnrl_under_no_grad
The loss must be computable under ``torch.no_grad``, as the trainer does for the eval loss.
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:146
Functiontest_cached_ce_mnrl_with_hard_negatives
Explicit hard negatives (a third input column) triple the pair count. The cached loss must still reproduce the non-cached loss and gradient.
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:165
Functiontest_cached_gemma3_mixed_images_matches_non_cached
(tmp_path, mini_batch_size)
tests/sentence_transformer/losses/test_cmnrl.py:383
Functiontest_cached_gist_matches_gist
``mini_batch_size`` only bounds memory: for the 2- and 3-column shapes the non-cached loss supports, the cached loss must reproduce GISTEmbedLoss'
tests/sentence_transformer/losses/test_cached_gist_embed.py:320
Functiontest_cached_gist_rejects_static_embedding_behind_a_router
A Router keeps its input modules one level down, so a guard that only inspects ``model[0]`` waves a StaticEmbedding straight through, and mini-bat
tests/sentence_transformer/losses/test_cached_gist_embed.py:389
Functiontest_cached_gist_replays_dropout_in_the_backward_pass
The backward pass must re-embed exactly what the forward pass embedded, dropout included, also with this loss's bespoke ``embed_minibatch``, which
tests/sentence_transformer/losses/test_cached_gist_embed.py:354
Functiontest_cached_gist_token_budget_matches_gist
The token budget must flow through this loss's bespoke ``embed_minibatch_iter`` (which also runs the guide model) without changing the loss or gra
tests/sentence_transformer/losses/test_cached_gist_embed.py:448
Functiontest_cached_gist_two_forwards_before_one_backward
Each forward pass must hand its own cached gradients to its own backward hook. The cache used to live on the loss module, so a second forward pas
tests/sentence_transformer/losses/test_cached_gist_embed.py:283
Functiontest_cached_loss_behind_wrappers_matches_non_cached
(stsb_bert_tiny_model: SentenceTransformer)
tests/sentence_transformer/losses/test_matryoshka.py:268
Functiontest_cached_mnr_gather_across_devices_single_process
Single-process gather guard for the GradCache loss: the gather block must run (all_gather no-ops without a process group) and produce a finite, di
tests/multi_vector_encoder/losses/test_misc.py:478
Functiontest_cached_mnr_gradients_match_non_cached
GradCache's contract is gradient equivalence with the non-cached loss. Regression pin for the per-chunk backward normalization: it must run on the
tests/multi_vector_encoder/losses/test_misc.py:153
Functiontest_cached_mnr_handles_varlen_document_columns
Cross-column varlen through the GradCache path. Exercises the same surface as the non-cached MNRL test but with chunked embedding forward + cached
tests/multi_vector_encoder/losses/test_misc.py:101
Functiontest_cached_mnr_handles_varlen_mini_batches_within_a_column
The GradCache cat path pads each mini-batch chunk to a common ``T`` before concatenating, so native-resolution VLMs that emit different ``T`` per
tests/multi_vector_encoder/losses/test_misc.py:270
Functiontest_cached_mnr_rejects_non_positive_token_budget
The constructor runs the shared validation, so a non-positive budget fails at build time rather than producing a degenerate mini-batch split later
tests/multi_vector_encoder/losses/test_misc.py:237
Functiontest_cached_mnr_slices_flattened_vlm_inputs_grid_aware
Native-resolution VLM columns (Qwen2-VL family) flatten per-sample visual tokens into one ``pixel_values`` tensor with an ``image_grid_thw`` row p
tests/multi_vector_encoder/losses/test_misc.py:130
Functiontest_cached_mnr_stamped_task_reaches_backward_hook
The GradCache second pass re-embeds from the same feature dicts: the stamped task must govern both the no-grad forward and the with-grad re-run.
tests/multi_vector_encoder/losses/test_misc.py:364
Functiontest_cached_mnr_token_budget_matches_non_cached
``mini_batch_num_tokens`` packs mini-batches by real token count rather than by sequence count, which must not change the loss or the gradients. P
tests/multi_vector_encoder/losses/test_misc.py:196
Functiontest_cached_mnrl_matches_mnrl
Gradient caching must produce the loss and gradient of the non-cached loss, for any configuration and whether or not ``mini_batch_size`` divides (
tests/sentence_transformer/losses/test_gradcache.py:50
Functiontest_cached_splade_components_sum_to_the_total
The trainer back-propagates the sum of the returned dict, so the components must sum exactly to the gradient-carrying total even though only one e
tests/sparse_encoder/losses/test_cached_splade.py:65
Functiontest_cached_splade_inference_free_frozen_query_route
An inference-free SPLADE model routes queries through a (frozen) SparseStaticEmbedding, whose embeddings then don't require grad. The backward hoo
tests/sparse_encoder/losses/test_cached_splade.py:122
Functiontest_cached_splade_keeps_dict_base_loss_components
A dict-valued base loss must keep its own component keys in the returned dict, exactly as SpladeLoss spreads them. The separate keys are the point
tests/sparse_encoder/losses/test_cached_splade.py:201
Functiontest_cached_splade_matches_splade
``mini_batch_size`` only bounds memory: the cached loss must reproduce SpladeLoss's total loss, per-component values, and gradients, whether or no
tests/sparse_encoder/losses/test_cached_splade.py:42
Functiontest_cached_splade_replays_dropout_in_the_backward_pass
The backward pass must re-embed exactly what the forward pass embedded, dropout included, making this loss self-guarding instead of relying only o
tests/sparse_encoder/losses/test_cached_splade.py:247
Functiontest_cached_splade_token_budget_matches_splade
The token budget must reproduce SpladeLoss's per-component losses and gradients.
tests/sparse_encoder/losses/test_cached_splade.py:167
Functiontest_cached_splade_two_forwards_before_one_backward
Each forward pass must hand its own cached gradients to its own backward hook.
tests/sparse_encoder/losses/test_cached_splade.py:80
Functiontest_cached_splade_under_no_grad
The eval loss must be computable under ``torch.no_grad`` and match the training-path total.
tests/sparse_encoder/losses/test_cached_splade.py:106
Functiontest_cached_symmetric_matches_symmetric
The deprecated symmetric shim only wires ``directions`` and ``partition_mode`` into the composed loss, and that wiring has no test of its own. The
tests/sentence_transformer/losses/test_cached_mnsrl.py:19
Methodtest_cached_video_not_saved_again
Second call for same VideoDecoder returns cached path without incrementing counter.
tests/base/test_model_card.py:1340
Methodtest_calibration_handles_empty_and_short_documents
(self)
tests/multi_vector_encoder/modules/test_token_pooling.py:466
Methodtest_calibration_matches_budget_with_protected_tokens
(self, tmp_path)
tests/multi_vector_encoder/modules/test_token_pooling.py:436
Methodtest_calibration_ties_can_compress_below_target
(self)
tests/multi_vector_encoder/modules/test_token_pooling.py:477
Functiontest_can_flatten_inputs_static_model
A StaticEmbedding model (non-Transformer first module) should not support flattened inputs.
tests/base/test_model.py:1782
Functiontest_can_flatten_inputs_transformer_model
_can_flatten_inputs should delegate to the Transformer module's can_flatten_inputs attribute.
tests/base/test_model.py:1767
Methodtest_case_insensitive_extension
(self)
tests/base/test_modality.py:56
Methodtest_causal_invalid_logits_processing_kwargs
(self, logits_to_keep)
tests/base/modules/test_transformer.py:697
Methodtest_causal_logits_processing_kwargs
(self, tmp_path, logits_to_keep)
tests/base/modules/test_transformer.py:668
Methodtest_causal_padding_check_ignores_unpadded_batches
A batch with nothing to pad has no last-token problem, whatever padding_side says.
tests/base/modules/test_transformer.py:741
Methodtest_causal_right_padding_via_attribute_raises
padding_side is set to "left" on load, so reaching this means it was mutated afterwards.
tests/base/modules/test_transformer.py:702
Methodtest_causal_right_padding_via_multimodal_tokenizer_raises
A multimodal processor pads via its tokenizer and has no padding_side of its own, so the tokenizer attribute is the only one that can be wrong
tests/base/modules/test_transformer.py:754
Methodtest_causal_right_padding_via_processing_kwargs_raises
processing_kwargs overrides the attribute at call time, so the attribute alone can't be trusted: it still reads "left" here while the processo
tests/base/modules/test_transformer.py:712
Methodtest_causal_right_padding_via_processing_kwargs_raises_without_message_modality
TINY_LLAMA has a chat template, so text normally routes through apply_chat_template, which only forwards the "text" bucket. Without a "message
tests/base/modules/test_transformer.py:724
Methodtest_causal_task_left_pads_by_default
The module sets padding_side to "left" on load, so a ragged batch ends in real tokens.
tests/base/modules/test_transformer.py:656
Functiontest_cde_small_v2
()
tests/sentence_transformer/test_custom_models.py:15
Functiontest_changing_similarity_keeps_kernel_provider_and_cache
(loader, embeddings)
tests/test_kernels.py:215
Methodtest_chat_template_non_string
(self)
tests/base/test_modality.py:461
Functiontest_chat_template_receives_task_kwarg
Chat-template backbones own their query augmentation in the template (the colpali-engine suffix pattern): preprocess forwards ``task`` into ``appl
tests/multi_vector_encoder/test_model.py:74
Methodtest_chat_template_suffix_cache_is_bounded
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1601
Methodtest_chat_template_suffix_ids_captures_prompt_rendered_in_tail
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1612
Methodtest_chat_template_suffix_ids_keys_on_non_content_fields
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1633
Methodtest_chat_template_suffix_ids_mirrors_common_kwargs
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1651
Methodtest_chat_template_suffix_ids_returns_empty_without_variable_content
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1594
Methodtest_chat_template_suffix_ids_skips_uninspectable_messages
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1584
Methodtest_chat_template_suffix_ids_tolerates_unhashable_kwargs
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1576
Methodtest_chat_truncation_restore_can_be_disabled
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1393
Methodtest_chat_truncation_restore_handles_implicit_truncation
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1460
Methodtest_chat_truncation_restore_leaves_non_torch_tensors_untouched
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1420
Methodtest_chat_truncation_restore_reads_chat_template_bucket_kwargs
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1435
Methodtest_chat_truncation_restores_chat_template_suffix
(self, bert_tiny_transformer, monkeypatch)
tests/base/modules/test_transformer.py:1348
← previousnext →2,301–2,400 of 4,575, ranked by callers