MCPcopy Create free account

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

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

↓ 2 callersMethodcompute_loss_from_embeddings
Compute the CoSENT loss from embeddings. Args: embeddings: List of embeddings labels: Labels indicating the
sentence_transformers/sentence_transformer/losses/cosent.py:87
↓ 2 callersMethodcompute_loss_from_embeddings
(self, embeddings: torch.Tensor)
sentence_transformers/sparse_encoder/losses/flops.py:47
↓ 2 callersMethodcompute_metrics
(self, model: SentenceTransformer)
sentence_transformers/sentence_transformer/evaluation/binary_classification.py:224
↓ 2 callersFunctioncreate_markov_matrix
(weights_matrix)
examples/sentence_transformer/applications/text-summarization/lex_rank.py:74
↓ 2 callersFunctiondot_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
↓ 2 callersMethodembed_inputs
( self, model: SentenceTransformer, sentences: SingleInput | Sequence[SingleInput] | n
sentence_transformers/sentence_transformer/evaluation/reranking.py:352
↓ 2 callersMethodembed_inputs
( self, model: SentenceTransformer, sentences: str | list[str] | np.ndarray, *
sentence_transformers/sentence_transformer/evaluation/mse.py:135
↓ 2 callersMethodembed_inputs
( self, model: SentenceTransformer, sentences: str | list[str] | np.ndarray, *
sentence_transformers/sentence_transformer/evaluation/mse_from_dataframe.py:123
↓ 2 callersMethodembed_minibatch_iter
Do a forward pass on every mini-batch of the input features and yield the embeddings.
sentence_transformers/base/losses/gradcache.py:370
↓ 2 callersFunctioneuclidean_sim
Computes the euclidean similarity (i.e., negative distance) between two tensors. Handles sparse tensors without converting to dense when poss
sentence_transformers/util/similarity.py:181
↓ 2 callersFunctionevaluate_stsb_test
( model: SparseEncoder, expected_score: float, test_dataset: Dataset, num_test_samples: int = -1 )
tests/sparse_encoder/test_train_stsb.py:20
↓ 2 callersFunctionexport_dynamic_quantized_onnx_model
Export a quantized ONNX model from a SentenceTransformer, SparseEncoder, CrossEncoder, or MultiVectorEncoder model. This function applie
sentence_transformers/backend/quantize.py:24
↓ 2 callersFunctionf
(e,t,o)
docs/_static/js/custom.js:28
↓ 2 callersFunctionformat_log
(value: float | int | str)
sentence_transformers/base/model_card.py:306
↓ 2 callersMethodforward
Route ``features`` through the resolved sub-module pipeline. Resolves the route from ``task`` and ``modality`` (falling back to values stored
sentence_transformers/base/modules/router.py:459
↓ 2 callersMethodfrom_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:244
↓ 2 callersFunctionfrom_pretrained_decorator
(method)
tests/sentence_transformer/test_backends.py:183
↓ 2 callersFunctionfrom_pretrained_decorator
(method)
tests/cross_encoder/test_backends.py:191
↓ 2 callersFunctionfrom_pretrained_decorator
(method)
tests/sparse_encoder/test_backends.py:186
↓ 2 callersMethodget_anchor_negative_triplet_mask
Return a 2D mask where mask[a, n] is True iff a and n have distinct labels. Args: labels: tf.int32 `Tensor` with shape [batch_size
sentence_transformers/sentence_transformer/losses/batch_hard_triplet.py:247
↓ 2 callersMethodget_anchor_positive_triplet_mask
Return a 2D mask where mask[a, p] is True iff a and p are distinct and have same label. Args: labels: tf.int32 `Tensor` with shape
sentence_transformers/sentence_transformer/losses/batch_hard_triplet.py:228
↓ 2 callersMethodget_config_dict
(self)
sentence_transformers/cross_encoder/losses/cached_multiple_negatives_ranking.py:284
↓ 2 callersMethodget_config_dict
Returns a dictionary of the configuration parameters of the module. These parameters are used to save the module's configuration whe
sentence_transformers/base/modules/module.py:113
↓ 2 callersMethodget_embedding_dimension
(self)
sentence_transformers/sentence_transformer/modules/pooling.py:330
↓ 2 callersMethodget_frames_at
(self, indices: list[int])
tests/base/test_model_card.py:1037
↓ 2 callersMethodget_in_batch_negatives
( self, anchors: list[str], candidates: list[list[str]] )
sentence_transformers/cross_encoder/losses/multiple_negatives_ranking.py:128
↓ 2 callersMethodget_labels
()
sentence_transformers/sentence_transformer/readers/nli_data.py:50
↓ 2 callersFunctionget_sample_values
(index: int)
tests/base/samplers/test_no_duplicates_batch_sampler.py:88
↓ 2 callersMethodgradient_checkpointing_enable
Enable gradient checkpointing for the model.
sentence_transformers/base/model.py:1492
↓ 2 callersFunctionh
(e,t,o)
docs/_static/js/custom.js:28
↓ 2 callersMethodinfer_modalities_edge_cases
Return a ``(modality_config, module_output_name)`` for model types that cannot be handled by the general :meth:`infer_modalities` inference pa
sentence_transformers/base/modules/transformer.py:2465
↓ 2 callersMethodinfer_modalities_from_processor
Determine which modalities the processor supports by inspecting its attributes or type.
sentence_transformers/base/modules/transformer.py:2504
↓ 2 callersFunctionis_accelerate_available
Returns True if the Huggingface accelerate library is available.
sentence_transformers/util/environment.py:100
↓ 2 callersMethodis_singular_input
Check if the input is a single example rather than a batch. Redeclared with :class:`~typing_extensions.TypeIs` so type checkers narrow the bra
sentence_transformers/sentence_transformer/model.py:556
↓ 2 callersMethodis_text_pair
Whether a single input is a text pair, i.e. cross-encoder ``(query, document)`` input.
sentence_transformers/base/modality.py:611
↓ 2 callersFunctionkNN
(x, y, k, use_ann_search=False, ann_num_clusters=32768, ann_num_cluster_probe=3)
examples/sentence_transformer/applications/parallel-sentence-mining/bitext_mining_utils.py:31
↓ 2 callersMethodload
Load this module from a model checkpoint. The checkpoint can be either a local directory or a model id on Hugging Face. Args:
sentence_transformers/base/modules/module.py:127
↓ 2 callersFunctionloss_and_grads
(**kwargs)
tests/sentence_transformer/losses/test_mega_batch_margin.py:255
↓ 2 callersFunctionloss_and_grads
(inner: torch.nn.Module)
tests/sentence_transformer/losses/test_cmnrl.py:416
↓ 2 callersFunctionmanhattan_sim
Computes the manhattan similarity (i.e., negative distance) between two tensors. Handles sparse tensors without converting to dense when poss
sentence_transformers/util/similarity.py:135
↓ 2 callersFunctionmean_maxsim
Computes the MeanMaxSim score between two collections of multi-vector embeddings: :func:`maxsim` divided by each query's real token count, wi
sentence_transformers/util/similarity.py:615
↓ 2 callersFunctionmean_maxsim_pairwise
Computes the pairwise MeanMaxSim score for each query-document pair: :func:`maxsim_pairwise` divided by each query's real token count, with i
sentence_transformers/util/similarity.py:647
↓ 2 callersFunctionp
(e)
docs/_static/js/custom.js:28
↓ 2 callersFunctionpairwise_angle_sim
Computes the absolute normalized angle distance. See :class:`~sentence_transformers.sentence_transformer.losses.AnglELoss` or https://hugging
sentence_transformers/util/similarity.py:769
↓ 2 callersMethodpool_one
Pool a single ``(num_tokens, D)`` tensor into a ``(num_out, D)`` tensor.
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:183
↓ 2 callersMethodpredict_minibatch_iter
Do forward pass on all the minibatches of the input features and yield corresponding embeddings.
sentence_transformers/cross_encoder/losses/cached_multiple_negatives_ranking.py:168
↓ 2 callersMethodpreprocess_dataset
Preprocess the dataset by optionally lazily adding a dataset name column, required for multi-dataset training with multiple losses or
sentence_transformers/base/trainer.py:1082
↓ 2 callersMethodprocessor
Property to get the processor that is used by this model
sentence_transformers/base/model.py:1647
↓ 2 callersFunctionraise_unsupported_modality_error
Raise a clear ``ValueError`` explaining why ``modality`` is not supported. Shared by :meth:`BaseModel.preprocess` and :meth:`Transformer.preproce
sentence_transformers/base/modality.py:865
↓ 2 callersMethodrun_usage_snippet
(self)
sentence_transformers/base/model_card.py:1626
↓ 2 callersMethodsave
(self, output_path: str, *args, safe_serialization: bool = True, **kwargs)
sentence_transformers/cross_encoder/modules/logit_score.py:56
↓ 2 callersFunctionsave_with_model_config
Save a model, then update its config_sentence_transformers.json, e.g. to add requirements.
tests/base/test_model.py:1151
↓ 2 callersMethodscale
(self)
sentence_transformers/sentence_transformer/losses/cached_multiple_negatives_ranking.py:217
↓ 2 callersFunctionscore_candidates
(x, y, candidate_inds, fwd_mean, bwd_mean, margin)
examples/sentence_transformer/applications/parallel-sentence-mining/bitext_mining_utils.py:22
↓ 2 callersFunctionsemantic_search_usearch
Performs semantic search using the usearch library. Rescoring will be performed if: 1. `rescore` is True 2. The query embeddings are
sentence_transformers/util/quantization.py:202
↓ 2 callersMethodset_model_id
(self, model_id: str)
sentence_transformers/base/model_card.py:1329
↓ 2 callersFunctionshrink
(tensor: Tensor, dim: int)
sentence_transformers/sentence_transformer/losses/matryoshka.py:18
↓ 2 callersMethodstore_metrics_in_model_card_data
( self, model: SparseEncoder, metrics: dict[str, Any], epoch: int = 0,
sentence_transformers/sparse_encoder/evaluation/sparse_mse.py:157
↓ 2 callersMethodtokenize
(self, text: str, **kwargs)
sentence_transformers/sentence_transformer/modules/tokenizer/word.py:408
↓ 2 callersMethodtokenize
.. deprecated:: `tokenize` is deprecated. Use `preprocess` instead.
sentence_transformers/base/model.py:645
↓ 2 callersMethodtokenize
(self, texts, **kwargs)
tests/base/modules/test_input_module.py:16
↓ 2 callersFunctionu
(e,t,o)
docs/_static/js/custom.js:28
↓ 2 callersFunctionuses_gradient_cache
Whether ``loss`` defers its backward pass to a hook on the loss tensor it returns. Such a loss re-embeds each mini-batch during the *backward* pa
sentence_transformers/base/losses/gradcache.py:194
↓ 2 callersMethodvalidate_datasets
Validate (i.e. check if the dataset IDs exist on the Hub) and process a list of dataset dictionaries. Args: dataset_list
sentence_transformers/base/model_card.py:429
↓ 2 callersFunctionx
(e,t,o)
docs/_static/js/custom.js:28
↓ 1 callersFunctionC
(e)
docs/_static/js/custom.js:28
↓ 1 callersMethodLN
(self, x: torch.Tensor, eps: float = 1e-5)
sentence_transformers/sparse_encoder/modules/sparse_auto_encoder.py:100
↓ 1 callersMethod__init__
(self, fn)
sentence_transformers/sentence_transformer/losses/adaptive_layer.py:69
↓ 1 callersMethod__init__
(self, model: SentenceTransformer)
sentence_transformers/sentence_transformer/losses/contrastive_tension.py:130
↓ 1 callersMethod__init__
( self, dataset_folder, s1_col_idx=0, s2_col_idx=1, score_col_idx=2,
sentence_transformers/sentence_transformer/readers/sts_data.py:26
↓ 1 callersMethod__init__
PListMLE loss for learning to rank with position-aware weighting. This loss function implements the ListMLE ranking algorithm which u
sentence_transformers/cross_encoder/losses/plist_mle.py:46
↓ 1 callersMethod__init__
(self, linear: nn.Linear)
sentence_transformers/sparse_encoder/modules/sparse_auto_encoder.py:16
↓ 1 callersMethod__init__
CSRLoss implements a combined loss function for Contrastive Sparse Representation (CSR) models. This loss combines two components:
sentence_transformers/sparse_encoder/losses/csr.py:130
↓ 1 callersMethod__init__
Initialize a BaseModel instance. Args: model_name_or_path (str, optional): If a filepath on disk, loads the model from t
sentence_transformers/base/model.py:90
↓ 1 callersMethod__init__
(self, result: dict[str, float])
tests/base/test_model.py:538
↓ 1 callersMethod__init__
(self, tensor)
tests/base/modules/test_transformer.py:638
↓ 1 callersMethod__len__
(self)
sentence_transformers/sentence_transformer/datasets/no_duplicates_dataloader.py:59
↓ 1 callersFunction_add_output_column
(resolved: dict[str, Any], name: str, values: list)
sentence_transformers/util/dataset.py:148
↓ 1 callersMethod_apply_legacy_fixups
Patch up modules loaded from save formats that predate :class:`MultiVectorEncoder` (PyLate v3, Stanford-NLP ColBERT). Each step is a no-op for
sentence_transformers/multi_vector_encoder/model.py:1055
↓ 1 callersFunction_batch_singular_input
( embeddings: list | np.ndarray | Tensor, mask: Tensor | None )
sentence_transformers/util/similarity.py:274
↓ 1 callersFunction_build_mako_lut
(n: int = 256)
sentence_transformers/multi_vector_encoder/interpretability.py:37
↓ 1 callersMethod_build_stanford_projection
Build a token-level :class:`~sentence_transformers.base.modules.dense.Dense` from a Stanford-NLP ColBERT checkpoint. Stanford-NLP che
sentence_transformers/multi_vector_encoder/model.py:1328
↓ 1 callersMethod_calculate_avg_flops
Calculate average FLOPS between queries and corpus. FLOPS is the dot product of the average query and corpus count vectors, and can b
sentence_transformers/sparse_encoder/evaluation/sparse_information_retrieval.py:285
↓ 1 callersMethod_calculate_weight_value
Calculate the weight value based on the current step and scheduler type.
sentence_transformers/sparse_encoder/callbacks/splade_callbacks.py:99
↓ 1 callersMethod_call_multimodal_processor
Call a :class:`ProcessorMixin` processor, handling both legacy and v5 calling conventions.
sentence_transformers/base/modules/transformer.py:1801
↓ 1 callersMethod_call_single_modality_processor
Call a single-modality processor (tokenizer, feature extractor, image/video processor).
sentence_transformers/base/modules/transformer.py:1847
↓ 1 callersMethod_chat_template_declares_task
Whether the active chat template (the processor's, else the tokenizer's) uses a ``task`` variable, e.g. to append query augmentation tokens fo
sentence_transformers/base/modules/transformer.py:1182
↓ 1 callersMethod_checkpoint_push_skip_names
(self, checkpoint_folder: str)
sentence_transformers/base/trainer.py:1043
↓ 1 callersFunction_chunked_outputs
Run ``model`` over row chunks of ``features`` and return one output dict per chunk. A single-element result means the batch ran in one forward, i
sentence_transformers/base/losses/merged_forward.py:126
↓ 1 callersFunction_clear_warning_once_cache
()
tests/conftest.py:22
↓ 1 callersMethod_compute_column_stats
Compute the stats entry for a single column using bounded-memory chunking. Iterates at most 100 rows in chunks of 8 so peak memory is
sentence_transformers/base/model_card.py:997
↓ 1 callersMethod_determine_labels_to_use
(dataset: Dataset, valid_label_columns: list[str] | None)
sentence_transformers/base/sampler.py:304
↓ 1 callersFunction_embeddings
(count: int = 3)
tests/sparse_encoder/losses/test_sparse_distill_kl_div.py:10
↓ 1 callersMethod_eval_during_training
Runs evaluation during the training
sentence_transformers/sentence_transformer/fit_mixin.py:689
↓ 1 callersMethod_eval_during_training
Runs evaluation during the training
sentence_transformers/cross_encoder/fit_mixin.py:562
↓ 1 callersMethod_example_asset_html
Generate an inline HTML tag for a saved example asset.
sentence_transformers/base/model_card.py:1795
↓ 1 callersMethod_exclude_prompt_from_mask
Zero out prompt token positions in the attention mask so they are excluded from pooling. Operates on a copy: the gradient-cached losses re-em
sentence_transformers/sentence_transformer/modules/pooling.py:154
↓ 1 callersMethod_flattened
(self, lengths: list[int])
tests/sentence_transformer/losses/test_gradcache.py:255
↓ 1 callersFunction_format_bytes
Human-readable byte formatting.
examples/sentence_transformer/evaluation/evaluation_no_dup_batch_sampler_speed.py:214
↓ 1 callersMethod_forward_flattened
( self, token_embeddings: Tensor, features: dict[str, Tensor], prompt_length:
sentence_transformers/sentence_transformer/modules/pooling.py:245
← previousnext →401–500 of 3,759, ranked by callers