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
Function
test_convert_dense_st_with_dense_head_redirects_to_token_level
Converting a dense SentenceTransformer WITH a Dense head (LaBSE-shape) redirects the head to token level: the conversion drops the Pooling, so sen
tests/multi_vector_encoder/test_model.py:846
Method
test_convert_kwargs_dropped_for_rank
rank no longer declares them, so they are dropped as no-ops and the warning names rank.
tests/util/test_decorators.py:398
Method
test_convert_kwargs_kept_for_predict
predict still declares both, so they must pass through untouched and unwarned.
tests/util/test_decorators.py:388
Function
test_convert_to_tensor_is_rejected_by_name
Variable-length embeddings cannot stack, so unlike every other model type there is no `convert_to_tensor` here. Copied-over calls are common enoug
tests/multi_vector_encoder/test_model.py:782
Function
test_convert_to_tensor_negative_stride_still_rejected
Negative strides were never convertible and still are not. `torch.from_numpy` rejects them with the same error `torch.tensor` raised before the vi
tests/util/test_tensor.py:202
Function
test_convert_to_tensor_read_only_array_does_not_warn
Read-only buffers (memmaps, broadcast views) take the copying path instead of torch's non-writable-tensor warning.
tests/util/test_tensor.py:210
Function
test_convert_to_tensor_stacks_a_list_of_arrays_without_reading_elementwise
A list of arrays (what encoding with `convert_to_numpy=True` returns) went through `torch.tensor`, which reads it one element at a time. Stacking
tests/util/test_tensor.py:190
Function
test_convert_to_tensor_stacks_dense_tensors_preserving_gradients
()
tests/util/test_tensor.py:237
Function
test_convert_to_tensor_views_numpy_without_copying
A numpy corpus is viewed, not copied: the copy costs as much as the scoring it feeds.
tests/util/test_tensor.py:183
Method
test_copy_pickle_and_compile
(self)
tests/cross_encoder/test_model.py:1419
Function
test_corpus_input_types
(corpus_type: str, monkeypatch: pytest.MonkeyPatch)
tests/util/test_hard_negatives.py:2153
Function
test_corpus_overrides
(corpus_override: str, device: str)
tests/sparse_encoder/evaluation/test_information_retrieval_evaluator.py:19
Function
test_cos_sim_sparse
Test cosine similarity between sparse and dense representations.
tests/util/test_similarity.py:174
Function
test_cosent_does_not_save_a_pairwise_score_matrix
(dummy_model)
tests/sentence_transformer/losses/test_cosent.py:126
Function
test_cosent_large_scale_has_finite_loss_and_gradients
(dummy_model)
tests/sentence_transformer/losses/test_cosent.py:164
Function
test_cosent_low_precision_scores_use_float32_reduction
(dummy_model, dtype)
tests/sentence_transformer/losses/test_cosent.py:145
Function
test_cosent_matches_explicit_pair_loss_and_gradients
(dummy_model, loss_class, dtype, label_case, device)
tests/sentence_transformer/losses/test_cosent.py:92
Function
test_cosent_penalises_the_lower_labelled_pair
The exponent is s(k,l) - s(i,j): the score of the pair with the *lower* expected similarity minus the score of the pair with the higher one, so ra
tests/sentence_transformer/losses/test_cosent.py:31
Function
test_cosent_rejects_mismatched_label_counts
(dummy_model, loss_class, label_shape)
tests/sentence_transformer/losses/test_cosent.py:66
Function
test_cosine_distance_precision_and_diagonal
(dtype, autocast)
tests/sentence_transformer/losses/test_triplet_distance_precision.py:49
Method
test_covers_non_text_pairs
Non-text pairs reach pair_to_messages by a different route, but take the same roles.
tests/base/test_modality.py:1718
Function
test_cpu_dtype_warning_from_checkpoint
(dtype, model_kwargs, override_dtype, tmp_path: Path, caplog)
tests/base/test_model.py:2119
Function
test_cpu_dtype_warning_once
(model_class, dtype, tmp_path: Path, caplog)
tests/base/test_model.py:2137
Function
test_cpu_dtype_warning_respects_config_dtype
(dtype_key, model_kwargs, tmp_path: Path, caplog)
tests/base/test_model.py:2168
Function
test_cpu_dtype_warning_skips_other_backends
(backend, tmp_path: Path, caplog)
tests/base/test_model.py:2146
Function
test_cpu_dtype_warning_skips_parameterless_model
(caplog)
tests/base/test_model.py:2206
Function
test_cpu_dtype_warning_skips_prebuilt_modules
(tmp_path: Path, caplog)
tests/base/test_model.py:2181
Function
test_cpu_dtype_warning_skips_static_checkpoint
(tmp_path: Path, caplog, clear_warning_once_cache)
tests/base/test_model.py:2189
Function
test_cpu_dtype_warning_uses_execution_device
(execution_device, tmp_path: Path, caplog)
tests/base/test_model.py:2155
Function
test_create_minibatch_keeps_left_padding
Leading padding is left in place: trimming it would shift the positions a model derives from the sequence length.
tests/sentence_transformer/losses/test_gradcache.py:482
Function
test_create_minibatch_keeps_query_expansion_positions
ColBERT expansion positions carry attention_mask 0 but are still scored, so the trailing trim must not drop them: doing so silently shrinks a 32-t
tests/sentence_transformer/losses/test_gradcache.py:493
Function
test_create_minibatch_trims_trailing_padding
A padded mini-batch of short sequences must be embedded at its own width, not the whole batch's padded width, or mini_batch_num_tokens would not b
tests/sentence_transformer/losses/test_gradcache.py:462
Function
test_cross_encoder
(reranker_bert_tiny_model: CrossEncoder)
tests/base/test_model.py:344
Function
test_cross_encoder
Test using a cross-encoder for rescoring.
tests/util/test_hard_negatives.py:216
Method
test_cross_encoder_checkpoint
(self, tmp_path, adapter_order, offload)
tests/cross_encoder/test_model.py:1545
Method
test_cross_encoder_custom_examples
(self)
tests/cross_encoder/test_model_card.py:204
Method
test_cross_encoder_default_examples
(self)
tests/cross_encoder/test_model_card.py:194
Function
test_cross_encoder_detailed
Test using a cross-encoder with different parameters.
tests/util/test_hard_negatives.py:236
Method
test_cross_encoder_multi_label
Multi-label: shape includes num_labels, no rank section.
tests/cross_encoder/test_model_card.py:215
Method
test_cross_encoder_multimodal_pairs
Multimodal pairs use _format_snippet_value for non-text elements and skip rank section.
tests/cross_encoder/test_model_card.py:245
Method
test_cross_encoder_multimodal_run_usage_snippet
run_usage_snippet with multimodal pairs gracefully falls back when predict fails.
tests/cross_encoder/test_model_card.py:268
Function
test_cross_encoder_rescores_with_only_min_score
min_score is a score filter too, so it must filter on the CrossEncoder scores rather than the bi-encoder ones.
tests/util/test_hard_negatives.py:285
Function
test_cross_encoder_rescores_without_score_filters
A supplied reranker controls candidate ordering and scores even without score filters.
tests/util/test_hard_negatives.py:2119
Method
test_cross_encoder_single_label_has_rank
Single-label: shape is (n,), rank section present.
tests/cross_encoder/test_model_card.py:230
Function
test_cross_encoder_with_multiple_positives_non_faiss
( multiple_positive_dataset: Dataset, static_retrieval_mrl_en_v1_model: SentenceTransformer, reran
tests/util/test_hard_negatives.py:262
Function
test_cross_entropy_preserves_class_and_probability_targets
(batch_size, target_type)
tests/cross_encoder/losses/test_misc.py:344
Function
test_csr_4k_latents_contain_the_k_latents
()
tests/sparse_encoder/modules/test_csr.py:196
Function
test_csr_auxiliary_reconstruction_bias
(normalize: bool)
tests/sparse_encoder/modules/test_csr.py:156
Function
test_csr_auxk_mask_uses_the_current_dead_threshold
()
tests/sparse_encoder/modules/test_csr.py:240
Function
test_csr_copy_masks_with_its_own_dead_feature_stats
()
tests/sparse_encoder/modules/test_csr.py:230
Function
test_csr_encode_does_not_update_dead_feature_stats
(csr_bert_tiny_model: SparseEncoder)
tests/sparse_encoder/modules/test_csr.py:185
Function
test_csr_inference_does_not_update_dead_feature_stats
(mode: str)
tests/sparse_encoder/modules/test_csr.py:82
Function
test_csr_max_active_dims_override_saved_limit
(csr_bert_tiny_model: SparseEncoder, tmp_path)
tests/sparse_encoder/test_model.py:373
Function
test_csr_max_active_dims_passed_to_forward
(csr_bert_tiny_model: SparseEncoder, monkeypatch: pytest.MonkeyPatch)
tests/sparse_encoder/test_model.py:306
Function
test_csr_normalized_perfect_reconstruction_has_zero_loss
(k_aux: int)
tests/sparse_encoder/modules/test_csr.py:132
Function
test_csr_outputs
(csr_bert_tiny_model: SparseEncoder, is_inference: bool, expected_keys: set)
tests/sparse_encoder/modules/test_csr.py:62
Function
test_csr_pickle_roundtrip
()
tests/sparse_encoder/modules/test_csr.py:214
Function
test_csr_training_updates_dead_feature_stats
()
tests/sparse_encoder/modules/test_csr.py:100
Function
test_csr_training_without_auxiliary_latents
()
tests/sparse_encoder/modules/test_csr.py:109
Function
test_csv_output_has_one_line_per_row
( make_evaluator, reranker_bert_tiny_model: CrossEncoder, tmp_path: Path )
tests/cross_encoder/evaluation/test_misc.py:29
Function
test_csv_output_has_one_line_per_row
(tmp_path)
tests/sparse_encoder/test_reciprocal_rank_fusion.py:150
Function
test_custom_dataset_transform
(dataset: Dataset, static_retrieval_mrl_en_v1_model: SentenceTransformer)
tests/util/test_hard_negatives.py:1068
Method
test_custom_keep_columns
(self, queries: Dataset, documents: Dataset)
tests/util/test_dataset.py:198
Function
test_custom_loss_keeps_flattened_scalar_labels
( model: SentenceTransformer, features: list[dict[str, torch.Tensor]], num_labels: int )
tests/sentence_transformer/losses/test_softmax.py:76
Method
test_custom_model_id
(self)
tests/multi_vector_encoder/test_model_card.py:57
Function
test_custom_pooling_configuration
()
tests/multi_vector_encoder/evaluation/test_utils.py:34
Method
test_custom_role
(self)
tests/base/test_modality.py:510
Function
test_custom_ward_supports_inputs_beyond_default_provider_limit
(loader)
tests/test_kernels.py:426
Function
test_data
()
tests/sentence_transformer/evaluation/test_information_retrieval_evaluator.py:62
Function
test_data_collator
( stsb_bert_tiny_model: SentenceTransformer, stsb_dataset_dict: DatasetDict, has_bos_token: bool,
tests/sentence_transformer/test_trainer.py:804
Method
test_data_uri
(self)
tests/base/test_modality.py:36
Method
test_data_uri_not_affected_by_space_check
data: URIs bypass the URL space check and should still be detected as images.
tests/base/test_modality.py:337
Method
test_dataset_dict_rejected
(self, queries: Dataset)
tests/util/test_dataset.py:261
Function
test_dataset_metrics_respect_router_mapping
(word_embeddings_model, tmp_path, dataset_type, mapping_type)
tests/base/test_model_card.py:781
Function
test_decode_batch_with_empty_sample
(splade_bert_tiny_model: SparseEncoder)
tests/sparse_encoder/test_model.py:183
Function
test_decode_empty_tensor
(splade_bert_tiny_model: SparseEncoder)
tests/sparse_encoder/test_model.py:149
Function
test_decode_handles_sparse_dense_inputs
( splade_bert_tiny_model: SparseEncoder, texts: list[str] | str, format_type: str )
tests/sparse_encoder/test_model.py:114
Function
test_decode_invalid_input_type
(splade_bert_tiny_model: SparseEncoder)
tests/sparse_encoder/test_model.py:170
Function
test_decode_invalid_ndim
(splade_bert_tiny_model: SparseEncoder)
tests/sparse_encoder/test_model.py:176
Function
test_decode_invalid_top_k
(splade_bert_tiny_model: SparseEncoder, top_k: int)
tests/sparse_encoder/test_model.py:163
Function
test_decode_returns_sorted_weights
( splade_bert_tiny_model: SparseEncoder, texts: list[str] | str, top_k: int | None )
tests/sparse_encoder/test_model.py:207
Function
test_decode_shapes
( splade_bert_tiny_model: SparseEncoder, texts: list[str] | str, top_k: int, expected_shape: int )
tests/sparse_encoder/test_model.py:50
Function
test_decode_token_types
(splade_bert_tiny_model: SparseEncoder, text: str, expected_token_types: type)
tests/sparse_encoder/test_model.py:79
Function
test_decode_top_k_respects_limit
(splade_bert_tiny_model: SparseEncoder, text: str, top_k: int)
tests/sparse_encoder/test_model.py:98
Method
test_decoder_cache_config
(self, decoder_cache_model)
tests/base/modules/test_transformer.py:323
Method
test_decoder_cache_forward
(self, decoder_cache_model)
tests/base/modules/test_transformer.py:333
Function
test_decoder_only_weights_are_not_tied
Cross-attention is decoder-only, so it has no encoder counterpart and must be skipped.
tests/sentence_transformer/losses/test_denoising_auto_encoder.py:42
Method
test_dedup_keeps_last_occurrence
(self)
tests/util/test_dataset.py:435
Function
test_default_activation_fn
(reranker_bert_tiny_model: CrossEncoder)
tests/cross_encoder/test_model.py:892
Function
test_default_activation_fn_without_transformer
``get_default_activation_fn`` must pick Sigmoid/Identity based on ``num_labels`` even when there's no Transformer (and thus no ``config``) to insp
tests/cross_encoder/test_model.py:519
Method
test_default_and_explicit_tasks
Dict lookup should work for all tasks, and missing key should default to feature-extraction.
tests/base/modules/test_transformer.py:2028
Function
test_default_colbert_attributes
()
tests/multi_vector_encoder/test_model.py:41
Function
test_default_column_selection_allows_extra_columns
()
tests/util/test_hard_negatives.py:2038
Method
test_default_examples_shape_comment
(self)
tests/multi_vector_encoder/test_model_card.py:83
Method
test_default_examples_when_none
(self)
tests/multi_vector_encoder/test_model_card.py:73
Function
test_default_loss_is_mnr
(mve_bert_tiny_model: MultiVectorEncoder, triplet_dataset: Dataset)
tests/multi_vector_encoder/test_trainer.py:78
Method
test_default_model_name
(self)
tests/multi_vector_encoder/test_model_card.py:162
Function
test_default_pooling_mode
CausalLM models should default to last-token pooling, while encoder models default to mean pooling.
tests/sentence_transformer/test_model.py:1413
Function
test_default_pooling_mode_causal_lm_with_is_causal_false
A CausalLM model with is_causal=False should default to mean pooling.
tests/sentence_transformer/test_model.py:1422
Method
test_default_tags_include_colbert_family
(self)
tests/multi_vector_encoder/test_model_card.py:157
← previous
next →
2,501–2,600 of 4,575, ranked by callers