MCPcopy Create free account

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

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

↓ 9 callersFunction_reset_for_snippet
Reset model_card_data fields to ensure a clean snippet test.
tests/sentence_transformer/test_model_card.py:183
↓ 9 callersFunction_setup_hub_mocks
Set up common mocks for push_to_hub tests. Returns a dict with: - "upload_folder": dict capturing the most recent upload_folder kwargs
tests/base/test_model.py:685
↓ 9 callersFunctionappend_to_last_row
(csv_path, additional_data)
sentence_transformers/util/misc.py:287
↓ 9 callersMethodevaluate
Evaluate the model based on an evaluator Args: evaluator (BaseEvaluator): The evaluator used to evaluate the model.
sentence_transformers/base/model.py:1477
↓ 9 callersMethodget_config_dict
(self)
sentence_transformers/base/modules/dense.py:100
↓ 9 callersMethodsave_torch_weights
Save the PyTorch weights of the module to disk. Args: output_path (str): The path to the directory where the weights sho
sentence_transformers/base/modules/module.py:435
↓ 9 callersFunctionsuggest_extra_on_exception
Re-raise ImportError/AttributeError with an install hint when a multimodal dependency is missing.
sentence_transformers/util/environment.py:33
↓ 9 callersMethodto_message
Convert a typed input dictionary to message format. Produces a single message with the given ``role``. For query/document pairs, use
sentence_transformers/base/modality.py:541
↓ 8 callersMethod_chat_template_suffix_ids
Derive one conversation's trailing chat-template suffix (cached). The conversation is rendered twice with different fillers: the longest comm
sentence_transformers/base/modules/transformer.py:2088
↓ 8 callersMethod_hash_asset
Compute an identity hash for an asset value, or None if the type is not supported.
sentence_transformers/base/model_card.py:791
↓ 8 callersFunction_make_mock_video_decoder
Create a ``_MockVideoDecoder`` with custom metadata overrides.
tests/base/test_model_card.py:1055
↓ 8 callersMethod_prepare_for_inference
Convert a value to a format suitable for model inference. ``VideoDecoder`` objects are converted to a ``VideoDict`` via :meth:`_video_decoder
sentence_transformers/base/model_card.py:1614
↓ 8 callersMethod_process_chat_messages
Process chat messages using the processor's chat template. ``chat_template_kwargs`` is forwarded to ``apply_chat_template``, except the Sente
sentence_transformers/base/modules/transformer.py:1880
↓ 8 callersMethod_restore_chat_template_suffix
Restore the trailing chat-template suffix that truncation may have removed (in place). Chat templates append fixed tokens after the content (
sentence_transformers/base/modules/transformer.py:2020
↓ 8 callersMethodencode_document
(self, sentences, **kwargs)
tests/sentence_transformer/evaluation/test_information_retrieval_evaluator.py:55
↓ 8 callersMethodget_embedding_dimension
The dimensionality of each token vector returned by :meth:`encode`.
sentence_transformers/multi_vector_encoder/model.py:1574
↓ 8 callersFunctionis_audio_url_or_path
Check if a string is an audio URL or file path.
sentence_transformers/base/modality.py:101
↓ 8 callersMethodload
( cls, model_name_or_path: str, subfolder: str = "", token: bool | str | None
sentence_transformers/base/modules/dense.py:113
↓ 8 callersMethodload_config
Load the configuration of the module 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:176
↓ 8 callersMethodlog
(self, logs: dict[str, float], start_time: float | None = None)
sentence_transformers/base/trainer.py:543
↓ 8 callersMethodnormalize_messages
Normalize messages to the target format (``self.message_format``). Extra keys beyond ``"role"`` and ``"content"`` are preserved during conver
sentence_transformers/base/modality.py:640
↓ 8 callersMethodresolve_with_tokenizer
Convert ``skiplist_words`` to token IDs using ``tokenizer``. Called by :class:`MultiVectorEncoder` after the tokenizer is fully initialised.
sentence_transformers/multi_vector_encoder/modules/multi_vector_mask.py:92
↓ 8 callersMethodset_evaluation_metrics
( self, evaluator: BaseEvaluator, metrics: dict[str, Any], epoch: int = 0, step: int = 0 )
sentence_transformers/base/model_card.py:918
↓ 8 callersMethodset_pooling_include_prompt
Sets the ``include_prompt`` attribute in the pooling layer in the model, if there is one. This is useful for models where the prompt
sentence_transformers/sparse_encoder/model.py:841
↓ 8 callersMethodsimilarity
Compute the all-pairs score matrix between two collections of multi-vector embeddings, using this model's :attr:`similarity_fn_name`.
sentence_transformers/multi_vector_encoder/model.py:969
↓ 8 callersMethodsimilarity_pairwise
(self, queries, positives)
tests/util/test_hard_negatives.py:1686
↓ 7 callersFunction_count_media_per_sample
Count images and videos per sample from the message structure. Some VLM processors flatten per-sample visual tokens into single tensors (e.g.
sentence_transformers/base/modules/transformer.py:596
↓ 7 callersFunction_features_and_labels
(model: SentenceTransformer)
tests/sentence_transformer/losses/test_adaptive_layer.py:52
↓ 7 callersMethod_format_snippet_value
Format a value for inclusion in a code snippet. Strings are shown as repr (quoted), and asset paths are converted to Hub URLs when mo
sentence_transformers/base/model_card.py:1836
↓ 7 callersMethod_infer_format
Infer the message format expected by the processor. Checks known model types first, then inspects the processor's chat template for p
sentence_transformers/base/modality.py:307
↓ 7 callersMethod_resolve_prompts
Resolve the prompts for this batch, handling nested (per-dataset) mappings.
sentence_transformers/base/data_collator.py:52
↓ 7 callersFunction_sample_value_str
(value: Any)
sentence_transformers/base/sampler.py:353
↓ 7 callersMethod_video_decoder_to_dict
Convert a ``VideoDecoder`` to a ``VideoDict`` by extracting all frames. Tries multiple strategies to extract frames: 1. ``get_frames_
sentence_transformers/base/model_card.py:1550
↓ 7 callersMethodadd_adapter
Adds a fresh new adapter to the current model for training purposes. If no adapter name is passed, a default name is assigned to the
sentence_transformers/base/peft_mixin.py:65
↓ 7 callersMethodcompute_loss_from_embeddings
(self, embeddings: list[Tensor], labels: Tensor)
sentence_transformers/sentence_transformer/losses/distill_kl_div.py:174
↓ 7 callersFunctioncos_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:59
↓ 7 callersMethodencode_document
( self, inputs: Sequence[SingleInput] | SingleInput, prompt_name: str | None = ...,
sentence_transformers/sentence_transformer/model.py:391
↓ 7 callersFunctionformat_modality
Format a modality for display, e.g. ``("text", "image")`` becomes ``"text+image"``.
sentence_transformers/base/modality.py:858
↓ 7 callersMethodload_config
(cls, *args, **kwargs)
sentence_transformers/sentence_transformer/modules/pooling.py:116
↓ 7 callersFunctionmake_char_chat_template_mock
Chat-template mock: one token per content character plus ``suffix``, honoring truncation/max_length and return_tensors ("pt", "np", or ragged list
tests/base/modules/test_transformer.py:1020
↓ 7 callersFunctionmake_modality_kwargs
Modality kwargs for _process_chat_messages with only the text bucket populated.
tests/base/modules/test_transformer.py:1041
↓ 7 callersFunctionmaxsim_similarity_map
Per-query-token similarity over a 2D image-patch grid. Args: query_embedding: ``(Qt, D)`` per-token query embeddings. image_embed
sentence_transformers/multi_vector_encoder/interpretability.py:136
↓ 7 callersFunctionmodel
()
tests/multi_vector_encoder/test_model.py:24
↓ 7 callersFunctionpairwise_cos_sim
Computes the pairwise cosine similarity cos_sim(a[i], b[i]). Args: a (Union[list, np.ndarray, Tensor]): The first tensor. b
sentence_transformers/util/similarity.py:78
↓ 7 callersMethodrank
Performs ranking with the CrossEncoder on the given query and documents. Returns a sorted list with the document indices and scores.
sentence_transformers/cross_encoder/model.py:752
↓ 7 callersFunctionscore
(x, y, fwd_mean, bwd_mean, margin)
examples/sentence_transformer/applications/parallel-sentence-mining/bitext_mining_utils.py:18
↓ 7 callersMethodset_base_model
(self, model_id: str, revision: str | None = None)
sentence_transformers/base/model_card.py:1332
↓ 7 callersMethodto_dict
(self)
sentence_transformers/base/model_card.py:1915
↓ 6 callersMethod__init__
(self, module: nn.Module)
tests/sentence_transformer/losses/test_adaptive_layer.py:19
↓ 6 callersMethod__init__
(self)
tests/base/modules/test_router.py:32
↓ 6 callersMethod_can_flatten_inputs
Determine whether text-only inputs can be flattened (concatenated without padding) for more efficient inference. When enabled, text-only inpu
sentence_transformers/base/modules/transformer.py:1052
↓ 6 callersFunction_convert_to_float_tensor
Converts like :func:`_convert_to_tensor`, then upcasts sub-float32 floats (fp8, float16, bfloat16) to float32: matmul rounds its output to th
sentence_transformers/util/tensor.py:59
↓ 6 callersFunction_features
(model: SentenceTransformer, texts: list[str])
tests/sentence_transformer/losses/test_embed_distill.py:11
↓ 6 callersMethod_is_typed_media_dict
Check if a dict is an AudioDict or VideoDict (vs a multimodal input dict).
sentence_transformers/base/model_card.py:786
↓ 6 callersFunction_make_loss
(model: SentenceTransformer)
tests/sentence_transformer/losses/test_adaptive_layer.py:47
↓ 6 callersMethod_padded
(self, lengths: list[int])
tests/sentence_transformer/losses/test_gradcache.py:248
↓ 6 callersMethod_prepend_prompt
Prepend a prompt string to each text input.
sentence_transformers/base/modules/input_module.py:76
↓ 6 callersMethodencode_query
( self, inputs: Sequence[SingleInput] | SingleInput, prompt_name: str | None = ...,
sentence_transformers/sentence_transformer/model.py:228
↓ 6 callersFunctionget_rank
The rank of the current process in the distributed group, or ``0`` when not distributed.
sentence_transformers/util/distributed.py:13
↓ 6 callersMethodget_vocab
(self, vocab: Iterable[str])
sentence_transformers/sentence_transformer/modules/tokenizer/word.py:404
↓ 6 callersMethodintersection
Compute the intersection of two sparse embeddings via element-wise multiplication. For each dimension, the result retains the minimu
sentence_transformers/sparse_encoder/model.py:1380
↓ 6 callersFunctionis_ci
Check if the code is running in a Continuous Integration (CI) environment. This is determined by checking for the presence of certain environ
tests/utils.py:32
↓ 6 callersFunctionis_dist_initialized
Returns whether ``torch.distributed`` is available and has been initialized. The availability check must come first: some PyTorch builds (e.
sentence_transformers/util/environment.py:45
↓ 6 callersMethodload
(cls, path)
tests/sentence_transformer/modules/test_word_embeddings.py:27
↓ 6 callersFunctionpairwise_dot_score
Computes the pairwise dot-product dot_prod(a[i], b[i]). Args: a (Union[list, np.ndarray, Tensor]): The first tensor. b (Unio
sentence_transformers/util/similarity.py:118
↓ 6 callersFunctionpairwise_euclidean_sim
Computes the euclidean distance (i.e., negative distance) between pairs of tensors. Args: a (Union[list, np.ndarray, Tensor]): The f
sentence_transformers/util/similarity.py:213
↓ 6 callersFunctionpairwise_manhattan_sim
Computes the manhattan similarity (i.e., negative distance) between pairs of tensors. Args: a (Union[list, np.ndarray, Tensor]): The
sentence_transformers/util/similarity.py:163
↓ 6 callersMethodpreprocess
Resolve the route from ``task`` and ``modality``, then delegate preprocessing to the first module of the matched route. The returned dictionar
sentence_transformers/base/modules/router.py:591
↓ 6 callersMethodsave_projection
Persist the projection layer's weights so they can be reused in a later run. The standard Trainer save path only writes the student model, no
sentence_transformers/sentence_transformer/losses/embed_distill.py:227
↓ 6 callersFunctionselect_max_active_dims
(embeddings: np.ndarray | torch.Tensor, max_active_dims: int)
sentence_transformers/util/tensor.py:181
↓ 6 callersFunctionsemantic_search_faiss
Performs semantic search using the FAISS library. Rescoring will be performed if: 1. `rescore` is True 2. The query embeddings are n
sentence_transformers/util/quantization.py:18
↓ 6 callersMethodsupports
Check if the model supports the given modality. A modality is supported if: 1. It is directly listed in :attr:`modalities` (includin
sentence_transformers/base/model.py:384
↓ 6 callersMethodto_similarity_fn
Converts a similarity function name or enum value to the corresponding similarity function. Args: similarity_function (U
sentence_transformers/util/similarity.py:837
↓ 6 callersMethodto_similarity_pairwise_fn
Converts a similarity function into a pairwise similarity function. The pairwise similarity function returns the diagonal vector fro
sentence_transformers/util/similarity.py:879
↓ 6 callersMethodtokenize
(self, texts, **kwargs)
tests/base/modules/test_router.py:38
↓ 5 callersFunction_build_flattened_features
Convert padded inputs to flattened format using DataCollatorWithFlattening.
tests/sentence_transformer/modules/test_pooling.py:460
↓ 5 callersMethod_can_flatten_inputs
Check if the first module (Transformer or Router containing Transformers) supports flattened text-only inputs. For Router models, this return
sentence_transformers/base/model.py:469
↓ 5 callersFunction_compute_similarity
Compute similarity between a single query and passage using the model. This helper mirrors the internal scoring logic in `mine_hard_negatives` by
tests/util/test_hard_negatives.py:586
↓ 5 callersFunction_features
()
tests/sentence_transformer/losses/test_contrastive.py:20
↓ 5 callersMethod_get_method_output_fields
Extract the output field names from a method's return type annotation. Args: method (Callable): The method to inspect. R
sentence_transformers/base/modules/transformer.py:2553
↓ 5 callersMethod_get_prompt_length
Return the length of the prompt in tokens, excluding any trailing special token. Returns None if the processor does not produce ``input_ids``
sentence_transformers/base/modules/transformer.py:2205
↓ 5 callersMethod_load_init_kwargs
Build the kwargs dict for ``__init__`` by merging config file, hub kwargs, and caller overrides. Priority (highest to lowest): caller kwargs
sentence_transformers/base/modules/transformer.py:2638
↓ 5 callersMethod_load_module_class_from_ref
Load a module class from a class reference string, preferring a class supplied via ``module_classes``. Args: class_ref:
sentence_transformers/base/model.py:1435
↓ 5 callersFunction_make_loss
(model: SparseEncoder, cached: bool, mini_batch_size: int = 2)
tests/sparse_encoder/losses/test_cached_splade.py:18
↓ 5 callersMethod_parse_model_config
Parse model configuration and merge saved prompts/defaults with user-provided values. User-provided prompts and default_prompt_name take prec
sentence_transformers/base/model.py:1328
↓ 5 callersMethod_resolve_route
(self, task: str | None = None, modality: str | tuple[str, ...] | None = None)
sentence_transformers/base/modules/router.py:401
↓ 5 callersMethod_resolve_route_name
Resolve the route key based on task and modality. Args: task: The task type (e.g., "query", "document") moda
sentence_transformers/base/modules/router.py:354
↓ 5 callersFunction_validate_mini_batch_num_tokens
(mini_batch_num_tokens: int | None)
sentence_transformers/base/losses/gradcache.py:251
↓ 5 callersMethodadd_tags
(self, tags: str | list[str])
sentence_transformers/base/model_card.py:1356
↓ 5 callersFunctionbuild_features
()
tests/multi_vector_encoder/losses/test_misc.py:126
↓ 5 callersMethodcalculate_loss
(self, reps, labels=None, *, with_backward=False)
tests/sentence_transformer/losses/test_gradcache.py:227
↓ 5 callersFunctioncolbert_scores
ColBERT (MaxSim) contrastive scoring for in-batch negatives. Takes ``(Q_query, q_tokens, dim)`` query embeddings and ``(Q_doc, N, d_tokens, dim)`
sentence_transformers/multi_vector_encoder/scoring/colbert.py:97
↓ 5 callersMethodcompute_loss_from_embeddings
(self, embeddings, labels=None)
tests/sparse_encoder/losses/test_cached_splade.py:212
↓ 5 callersFunctioncreate_modality_samples
Create test samples for all supported modalities and their combinations. Generates samples for: 1. Each single modality with different input
tests/base/modules/transformer/conftest.py:505
↓ 5 callersMethodfind_spec
(self, fullname, path=None, target=None)
sentence_transformers/util/deprecated_import.py:212
↓ 5 callersMethodfit
Deprecated training method from before Sentence Transformers v4.0, it is recommended to use :class:`~sentence_transformers.cross_enco
sentence_transformers/cross_encoder/fit_mixin.py:180
↓ 5 callersMethodgenerate_usage_snippet
(self)
sentence_transformers/cross_encoder/model_card.py:192
↓ 5 callersMethodget_embedding_dimension
(self)
sentence_transformers/sentence_transformer/modules/cnn.py:63
↓ 5 callersFunctionget_installed_version
Returns the version of an installed package, or None if the package can't be found. The ``__version__`` of an already imported module takes
sentence_transformers/util/environment.py:122
↓ 5 callersMethodget_model_kwargs
Get the keyword arguments specific to this model for inference methods like `encode` or `predict`. Example: >>> from se
sentence_transformers/base/model.py:418
← previousnext →101–200 of 3,759, ranked by callers