Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[model cards] Replace 'sentence_transformers_model_id' from reused model if possible #2714

Conversation

tomaarsen
Copy link
Collaborator

Hello!

Pull Request overview

  • Replace 'sentence_transformers_model_id' from reused model if possible

Details

A common occurrence is saving a model locally with model.save_pretrained("my_model"), then later loading the model again with SentenceTransformer("my_model") and uploading that model with model.push_to_hub("my_user/my_model"). Sentence Transformers reuses the model card if no training is carried out, so you still get all of your training logs, hyperparameters, etc., but the original save likely resulted in a usage snippet of:

from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
    'Then he ran.',
    'The people are running.',
    'The man is on his bike.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

This'll get fully reused, even if with the push_to_hub the code should know the final model ID. This PR fixes that, i.e. the sentence_transformers_model_id will get updated.

  • Tom Aarsen

@tomaarsen tomaarsen merged commit a3e1b86 into UKPLab:master Jun 4, 2024
9 checks passed
@tomaarsen tomaarsen deleted the model_card/update_sentence_transformers_model_id branch June 4, 2024 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant