MCPcopy Create free account

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

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

↓ 6 callersMethod_prepend_prompt
Prepend a prompt string to each text input.
sentence_transformers/base/modules/input_module.py:76
↓ 6 callersFunction_save_cpu_dtype_checkpoint
(path: Path, dtype: torch.dtype = torch.float16)
tests/base/test_model.py:2091
↓ 6 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:159
↓ 6 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:491
↓ 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:1325
↓ 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 callersFunctionis_xxhash_available
()
tests/base/samplers/test_no_duplicates_batch_sampler.py:70
↓ 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_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 callersFunctionpooling_config
Describe the pooling class and its complete declared configuration.
sentence_transformers/multi_vector_encoder/evaluation/utils.py:10
↓ 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:596
↓ 6 callersMethodput
(self, item)
tests/base/test_multi_process.py:40
↓ 6 callersMethodsave
(self, output_path: str, *args, safe_serialization: bool = True, **kwargs)
sentence_transformers/sentence_transformer/modules/cnn.py:67
↓ 6 callersMethodsave
Saves a model and its configuration files to a directory, so that it can be loaded again. Args: path (str): Path on disk
sentence_transformers/base/model.py:757
↓ 6 callersMethodsave
(self, output_path: str, *args, safe_serialization: bool = True, **kwargs)
sentence_transformers/base/modules/dense.py:110
↓ 6 callersMethodsave
(self, output_path, **kwargs)
tests/multi_vector_encoder/test_model.py:303
↓ 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:228
↓ 6 callersFunctionselect_max_active_dims
(embeddings: np.ndarray | torch.Tensor, max_active_dims: int)
sentence_transformers/util/tensor.py:197
↓ 6 callersFunctionsemantic_search_qdrant
Performs semantic search using sparse embeddings with Qdrant. Args: query_embeddings: PyTorch COO sparse tensor containing query emb
sentence_transformers/sparse_encoder/search_engines.py:35
↓ 6 callersMethodset_keep_in_fp32_modules
Run selected linear layers in fp32, even when autocast is enabled. Selected layers return fp32 outputs during inference and training, while t
sentence_transformers/cross_encoder/model.py:235
↓ 6 callersMethodsimilarity
Compute the similarity between two collections of embeddings. The output is a matrix with the similarity scores between all embedding
sentence_transformers/sentence_transformer/model.py:1067
↓ 6 callersMethodsimilarity_pairwise
Compute the pairwise score vector between matched query / document pairs, using this model's :attr:`similarity_fn_name`. Args:
sentence_transformers/multi_vector_encoder/model.py:1121
↓ 6 callersMethodstep
(self, *args, **kwargs)
tests/sentence_transformer/test_trainer.py:1392
↓ 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:457
↓ 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:877
↓ 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:919
↓ 6 callersMethodtokenize
(self, texts, **kwargs)
tests/base/modules/test_router.py:38
↓ 5 callersFunction_build_features
(batch: int = 4)
tests/multi_vector_encoder/losses/test_token_pooling.py:37
↓ 5 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:1097
↓ 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:669
↓ 5 callersFunction_convert_to_batch_tensor
Converts the input data to a tensor with a batch dimension, stacking lists as :func:`_convert_to_tensor` does. Args: a (Union[li
sentence_transformers/util/tensor.py:95
↓ 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:2605
↓ 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:2235
↓ 5 callersFunction_leaves
(features: list[dict[str, Tensor]])
tests/multi_vector_encoder/losses/test_token_pooling.py:49
↓ 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:2690
↓ 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:1610
↓ 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:1503
↓ 5 callersMethod_resolve_route
(self, task: str | None = None, modality: str | tuple[str, ...] | None = None)
sentence_transformers/base/modules/router.py:402
↓ 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:355
↓ 5 callersFunction_tensor_to_numpy
Convert a tensor to NumPy, upcasting bfloat16 to the supported float32 dtype.
sentence_transformers/util/tensor.py:113
↓ 5 callersFunction_validate_mini_batch_num_tokens
(mini_batch_num_tokens: int | None)
sentence_transformers/base/losses/gradcache.py:273
↓ 5 callersMethodadd_tags
(self, tags: str | list[str])
sentence_transformers/base/model_card.py:1391
↓ 5 callersFunctionbuild_features
()
tests/multi_vector_encoder/losses/test_misc.py:159
↓ 5 callersMethodcalculate_loss
(self, reps, labels=None, *, with_backward=False)
tests/sentence_transformer/losses/test_gradcache.py:245
↓ 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:512
↓ 5 callersMethodfind_spec
(self, fullname, path=None, target=None)
sentence_transformers/util/deprecated_import.py:212
↓ 5 callersMethodforward_cached
Run the three-step GradCache forward pass. See the module docstring.
sentence_transformers/base/losses/gradcache.py:485
↓ 5 callersMethodfrom_json
Create an SparseStaticEmbedding module from a JSON file containing token to IDF weight mappings. Args: json_path (str):
sentence_transformers/sparse_encoder/modules/sparse_static_embedding.py:105
↓ 5 callersMethodgenerate_usage_snippet
(self)
sentence_transformers/cross_encoder/model_card.py:192
↓ 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:126
↓ 5 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:70
↓ 5 callersFunctionis_message_dict
Check if a value is a single chat message: a dict with ``"role"`` and ``"content"`` keys.
sentence_transformers/base/modality.py:107
↓ 5 callersMethodload_projection
Load projection weights previously written with `save_projection`. If the loss was constructed without a `projection_dim`, the projection lay
sentence_transformers/sentence_transformer/losses/embed_distill.py:250
↓ 5 callersFunctionload_transformer
Load a Transformer model for the given architecture and task. Args: arch: Architecture name from TINY_MODEL_MAPPING transformer_t
tests/base/modules/transformer/conftest.py:706
↓ 5 callersFunctionmaxsim_heatmap
One-shot MaxSim heatmap for a (query, image-document) pair. Args: image: PIL image, URL, or local file path. query_embedding: ``(
sentence_transformers/multi_vector_encoder/interpretability.py:220
↓ 5 callersFunctionnormalized_mean_squared_error
Normalize MSE by batch variance, falling back to ordinary MSE for zero-variance batches. Args: reconstruction: output of Autoencoder
sentence_transformers/sparse_encoder/losses/csr.py:15
↓ 5 callersMethodoverride_model_in_loss
(self, loss: torch.nn.Module, model: BaseModel)
sentence_transformers/base/trainer.py:440
↓ 5 callersFunctionpairwise_angle_sim
Computes the absolute AnglE similarity: ``|cos_sim(x, y) + sin_sim(x, y)|`` after L2 normalization. Dimensions ``i`` and ``i + D/2`` are pair
sentence_transformers/util/similarity.py:814
↓ 5 callersFunctionpooling_name_suffix
Short pooling label for metrics. Use evaluator names to distinguish finer configuration differences.
sentence_transformers/multi_vector_encoder/evaluation/utils.py:18
↓ 5 callersMethodprepend_prompt_to_messages
Prepend a system prompt to message format inputs. Args: messages: List of message lists (each message list represents one input).
sentence_transformers/base/modality.py:680
↓ 5 callersMethodpreprocess
(self, inputs, prompt=None, **kwargs)
tests/base/modules/test_input_module.py:29
↓ 5 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:202
↓ 5 callersFunctionscore_function
(query_embeddings: torch.Tensor, corpus_embeddings: torch.Tensor)
tests/util/test_retrieval.py:129
↓ 5 callersFunctionsparse_allclose
Check if two sparse embeddings are close to each other. This function works with sparse embeddings in either: 1. Tensor format (assuming
tests/sparse_encoder/utils.py:6
↓ 5 callersMethodstore_metrics_in_model_card_data
( self, model: BaseModel, metrics: dict[str, Any], epoch: int = 0, step: int = 0 )
sentence_transformers/base/evaluation/evaluator.py:66
↓ 4 callersMethod__init__
(self, *args, **kwargs)
sentence_transformers/base/sampler.py:192
↓ 4 callersFunction_chunk_ranges
Greedily pack items into ``(start, end)`` chunks whose padded cost of ``(per_item_token * chunk_width + per_item_fixed) * chunk_size`` elements st
sentence_transformers/util/similarity.py:242
↓ 4 callersMethod_configure_use_cache
Override Transformers cache settings with False unless explicitly set in ST's config_kwargs. Applies recursively to sub-configs, with more sp
sentence_transformers/base/modules/transformer.py:2308
↓ 4 callersFunction_convert_legacy_pooling_kwargs
Convert legacy ``pooling_mode_*`` bool keys to a single ``pooling_mode`` key in-place. Old keys are removed from *kwargs*. If ``pooling_mode`` is
sentence_transformers/sentence_transformer/modules/pooling.py:26
↓ 4 callersMethod_format_and_save_example
Format a dataset example value for the model card table, saving non-text values as assets. Delegates the actual file I/O to :meth:`_save_asse
sentence_transformers/base/model_card.py:1800
↓ 4 callersFunction_get_batch_size
Get the number of samples in sentence features, handling both padded and flattened inputs. With padded inputs, the batch size is the first dimens
sentence_transformers/base/losses/gradcache.py:67
↓ 4 callersMethod_get_model_type
Retrieves the model_type from the config_sentence_transformers.json file. This is used to determine whether the model being loaded m
sentence_transformers/base/model.py:1552
↓ 4 callersMethod_get_prompt_for_column
Get the prompt string for a specific column.
sentence_transformers/base/data_collator.py:74
↓ 4 callersMethod_get_scheduler
Returns the correct learning rate scheduler. Available scheduler: - constantlr, - warmupconstant, - warmuplinear,
sentence_transformers/sentence_transformer/fit_mixin.py:411
↓ 4 callersMethod_get_snippet_output_dimensionality
(self)
sentence_transformers/base/model_card.py:1894
↓ 4 callersFunction_gradients
(model: CrossEncoder)
tests/cross_encoder/losses/test_cached_multiple_negatives_ranking.py:14
↓ 4 callersMethod_infer_flatten_position_offset
(self)
sentence_transformers/base/modules/transformer.py:1170
↓ 4 callersMethod_input_length
Estimate the "size" of an input sample for length-based batch sorting. The exact value doesn't matter, it's only used to group similarly size
sentence_transformers/base/model.py:578
↓ 4 callersFunction_int_features
()
tests/multi_vector_encoder/losses/test_misc.py:631
↓ 4 callersMethod_make_text_image_dataset
(self, n: int = 5)
tests/base/test_model_card.py:579
↓ 4 callersFunction_match_layouts
Converts the dense tensor to sparse COO if exactly one of the two inputs is sparse, so that mixed inputs can reuse the all-sparse computation
sentence_transformers/util/similarity.py:24
↓ 4 callersFunction_maxsim_score_documents
Score one chunk of documents against every query, returned as ``(a_batch, b_batch)`` float32. Pulled out of :func:`maxsim` so the chunk loop stays
sentence_transformers/util/similarity.py:495
↓ 4 callersFunction_move_tensors_to_cpu
Move every tensor inside ``value`` to CPU, keeping the surrounding structure. Results leaving a multi-process worker have to make this trip. A te
sentence_transformers/util/tensor.py:352
↓ 4 callersMethod_resolve_prompt
Resolve a prompt from a prompt name or the default prompt name. Args: prompt: An explicit prompt string, or None. pro
sentence_transformers/base/model.py:417
↓ 4 callersMethod_resolve_router_mapping
Resolve the router mapping for this batch, handling nested (per-dataset) mappings.
sentence_transformers/base/data_collator.py:39
↓ 4 callersMethod_save
(self, output_dir: str | None = None, state_dict=None)
sentence_transformers/base/trainer.py:1016
↓ 4 callersFunction_text_column
(width: int, seed: int, batch: int = 2)
tests/sentence_transformer/losses/test_merged_forward.py:54
↓ 4 callersFunction_train
(model: MultiVectorEncoder, dataset: Dataset, loss: torch.nn.Module)
tests/multi_vector_encoder/test_trainer.py:59
↓ 4 callersFunction_validate_relative_path
Reject rooted paths and parent traversal in both POSIX and Windows syntax.
sentence_transformers/util/file_io.py:152
↓ 4 callersFunctionall_gather_with_grad
Gathers a tensor from each distributed rank into a list, retaining gradients for the local rank's tensor. Args: tensor (torch.Tensor
sentence_transformers/util/distributed.py:77
↓ 4 callersMethodapplies_to
Whether this pooling applies to inputs encoded for ``task`` (``None`` counts as ``"document"``).
sentence_transformers/multi_vector_encoder/modules/token_pooling.py:90
↓ 4 callersMethodauxk_mask_fn
Args: x: autoencoder latents before activation (shape: [batch, hidden_dim]) Returns: the latents with all bu
sentence_transformers/sparse_encoder/modules/sparse_auto_encoder.py:82
↓ 4 callersMethodclear_placement_cache
Clear the cached Accelerate hook and repeat auxiliary alignment on the next inference. Call this after attaching, replacing, or removing Acce
sentence_transformers/base/model.py:1811
↓ 4 callersMethodcompute_gor
Compute the Global Orthogonal Regularization terms for a batch of embeddings. The GOR loss encourages embeddings to be well-distribu
sentence_transformers/sentence_transformer/losses/global_orthogonal_regularization.py:167
↓ 4 callersMethodcompute_loss_from_embeddings
(self, embeddings: list[Tensor], labels: Tensor)
sentence_transformers/sentence_transformer/losses/batch_semi_hard_triplet.py:107
↓ 4 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
↓ 4 callersMethodcompute_loss_from_embeddings
(self, embeddings: list[Tensor], labels: Tensor)
sentence_transformers/sentence_transformer/losses/batch_all_triplet.py:97
↓ 4 callersFunctioncross_encoder_predict_rank_args_decorator
Decorator for :class:`CrossEncoder.predict` / :class:`CrossEncoder.rank` that handles deprecated keyword arguments. Handles the following legacy
sentence_transformers/util/decorators.py:179
← previousnext →201–300 of 4,575, ranked by callers