Ë
    l^(hà  ã                  ó<   — d Z ddlmZ ddlZddlmZ  G d„ d«      Zy)zÕ
This file contains the templating for model cards prior to the v3.0 release. It still exists to be used alongside
SentenceTransformer.old_fit for backwards compatibility, but will be removed in a future release.
é    )ÚannotationsNé   )Úfullnamec                  óR   — e Zd Zg d¢ZdddddddœZdZd	Zd
Zed„ «       Z	ed„ «       Z
y)ÚModelCardTemplate)zsentence-transformerszfeature-extractionúsentence-similarityr   z"<!--- Describe your model here -->Ú z/<!--- Describe how your model was evaluated -->z9<!--- Describe where people can find more information -->)z{PIPELINE_TAG}z{MODEL_DESCRIPTION}z{TRAINING_SECTION}z{USAGE_TRANSFORMERS_SECTION}z{EVALUATION}z{CITING}as  
---
library_name: sentence-transformers
pipeline_tag: {PIPELINE_TAG}
tags:
{TAGS}
{DATASETS}
---

# {MODEL_NAME}

This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a {NUM_DIMENSIONS} dimensional dense vector space and can be used for tasks like clustering or semantic search.

{MODEL_DESCRIPTION}

## Usage (Sentence-Transformers)

Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:

```
pip install -U sentence-transformers
```

Then you can use the model like this:

```python
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]

model = SentenceTransformer('{MODEL_NAME}')
embeddings = model.encode(sentences)
print(embeddings)
```

{USAGE_TRANSFORMERS_SECTION}

## Evaluation Results

{EVALUATION}

For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})

{TRAINING_SECTION}

## Full Model Architecture
```
{FULL_MODEL_STR}
```

## Citing & Authors

{CITING}

z„
## Training
The model was trained with the parameters:

{LOSS_FUNCTIONS}

Parameters of the fit()-Method:
```
{FIT_PARAMETERS}
```
a  

## Usage (HuggingFace Transformers)
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.

```python
from transformers import AutoTokenizer, AutoModel
import torch

{POOLING_FUNCTION}

# Sentences we want sentence embeddings for
sentences = ['This is an example sentence', 'Each sentence is converted']

# Load model from HuggingFace Hub
tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
model = AutoModel.from_pretrained('{MODEL_NAME}')

# Tokenize sentences
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')

# Compute token embeddings
with torch.no_grad():
    model_output = model(**encoded_input)

# Perform pooling. In this case, {POOLING_MODE} pooling.
sentence_embeddings = {POOLING_FUNCTION_NAME}(model_output, encoded_input['attention_mask'])

print("Sentence embeddings:")
print(sentence_embeddings)
```

c                ó(   — | dk(  ry| dk(  ry| dk(  ryy )NÚmax)Úmax_poolingaÙ  
# Max Pooling - Take the max value over time for every dimension.
def max_pooling(model_output, attention_mask):
    token_embeddings = model_output[0] #First element of model_output contains all token embeddings
    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).to(token_embeddings.dtype)
    token_embeddings[input_mask_expanded == 0] = -1e9  # Set padding tokens to large negative value
    return torch.max(token_embeddings, 1)[0]
Úmean)Úmean_poolingaÂ  
#Mean Pooling - Take attention mask into account for correct averaging
def mean_pooling(model_output, attention_mask):
    token_embeddings = model_output[0] #First element of model_output contains all token embeddings
    input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).to(token_embeddings.dtype)
    return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
Úcls)Úcls_poolingzP
def cls_pooling(model_output, attention_mask):
    return model_output[0][:,0]
© )Úpooling_modes    úh/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sentence_transformers/model_card_templates.pyÚmodel_card_get_pooling_functionz1ModelCardTemplate.model_card_get_pooling_function|   s2   € à˜5Ò ð
ð ˜VÒ#ð	ð ˜UÒ"ðð #ó    c                ó4  — 	 t        | d«      r| j                  «       }ngi }t        | d«      r| j                  nd|d<   t        | d«      rt        | j                  «      |d<   t        | d«      rt        | j
                  «      |d<   dt        | «      › dt        | «      › d|› d	�}d
j                  t        |«      t        |d«      rd|j                  «       › d�nd«      }||gS # t        $ r+}t        j                  dt        |«      › �«       Y d }~yd }~ww xY w)NÚget_config_dictÚ
batch_sizeÚunknownÚsamplerÚbatch_samplerz**DataLoader**:

`z` of length z with parameters:
```
z
```z**Loss**:

`{}` {}zwith parameters:
  ```
  z
  ```r	   z2Exception when creating get_train_objective_info: )Úhasattrr   r   r   r   r   ÚlenÚformatÚ	ExceptionÚloggingÚWARNÚstr)Ú
dataloaderÚlossÚloader_paramsÚdataloader_strÚloss_strÚes         r   Úget_train_objective_infoz*ModelCardTemplate.get_train_objective_infoŸ   s4  € ð	Ü�zÐ#4Ô5Ø *× :Ñ :Ó <‘à "�ÜGNÈzÐ[gÔGh¨j×.CÒ.CÐnw�˜lÑ+Ü˜: yÔ1Ü/7¸
×8JÑ8JÓ/K�M )Ñ,Ü˜: Ô7Ü5=¸j×>VÑ>VÓ5W�M /Ñ2à!5´h¸zÓ6JÐ5KÈ<ÔX[Ð\fÓXgÐWhð ià€ð ðˆNð
 .×4Ñ4Ü˜“ô
 ˜4Ð!2Ô3ð	à×ÑÓÐð ñ	ð
 óˆHð # HÐ-Ð-øäò 	Ü�L‰LÐMÌcÐRSËfÈXÐVÔWÜûð	ús   ‚C C# Ã#	DÃ,!DÄDN)Ú__name__Ú
__module__Ú__qualname__Ú__TAGS__Ú__DEFAULT_VARS__Ú__MODEL_CARD__Ú__TRAINING_SECTION__Ú__USAGE_TRANSFORMERS__Ústaticmethodr   r)   r   r   r   r   r      sc   „ ÚU€Hà/ØCØ Ø(*ØIØOñÐð5€Nðn
ÐðÐðB ñ ó ð ðD ñó ñr   r   )Ú__doc__Ú
__future__r   r    Úutilr   r   r   r   r   ú<module>r6      s!   ðñõ
 #ã å ÷rò rr   