Skip to content

Commit e55a6d1

Browse files
authored
Merge v3.0 pre-release into master, prepare for full v3.0 release (#2685)
Merge v3.0 pre-release into master, prepare for full v3.0 release
2 parents 684b6b5 + 85890d5 commit e55a6d1

File tree

292 files changed

+13732
-7262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+13732
-7262
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
if: steps.restore-cache.outputs.cache-hit != 'true'
4646

4747
- name: Install the checked-out sentence-transformers
48-
run: python -m pip install .
48+
run: python -m pip install .[train]
4949

5050
- name: Run unit tests
5151
shell: bash

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ nr_*/
1919
/docs/make.bat
2020
/examples/training/quora_duplicate_questions/quora-IR-dataset/
2121
build
22-
2322
htmlcov
2423
.coverage
25-
.venv
24+
wandb
25+
checkpoints
26+
tmp
27+
.venv

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include sentence_transformers/model_card_template.md

README.md

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
<!--- BADGES: START --->
2+
[![HF Models](https://img.shields.io/badge/%F0%9F%A4%97-models-yellow)](https://huggingface.co/models?library=sentence-transformers)
23
[![GitHub - License](https://img.shields.io/github/license/UKPLab/sentence-transformers?logo=github&style=flat&color=green)][#github-license]
34
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sentence-transformers?logo=pypi&style=flat&color=blue)][#pypi-package]
45
[![PyPI - Package Version](https://img.shields.io/pypi/v/sentence-transformers?logo=pypi&style=flat&color=orange)][#pypi-package]
5-
[![Conda - Platform](https://img.shields.io/conda/pn/conda-forge/sentence-transformers?logo=anaconda&style=flat)][#conda-forge-package]
6-
[![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/sentence-transformers?logo=anaconda&style=flat&color=orange)][#conda-forge-package]
76
[![Docs - GitHub.io](https://img.shields.io/static/v1?logo=github&style=flat&color=pink&label=docs&message=sentence-transformers)][#docs-package]
8-
<!---
9-
[![PyPI - Downloads](https://img.shields.io/pypi/dm/sentence-transformers?logo=pypi&style=flat&color=green)][#pypi-package]
10-
[![Conda](https://img.shields.io/conda/dn/conda-forge/sentence-transformers?logo=anaconda)][#conda-forge-package]
11-
--->
7+
<!-- [![PyPI - Downloads](https://img.shields.io/pypi/dm/sentence-transformers?logo=pypi&style=flat&color=green)][#pypi-package] -->
128

139
[#github-license]: https://github.com/UKPLab/sentence-transformers/blob/master/LICENSE
1410
[#pypi-package]: https://pypi.org/project/sentence-transformers/
@@ -20,38 +16,24 @@
2016

2117
This framework provides an easy method to compute dense vector representations for **sentences**, **paragraphs**, and **images**. The models are based on transformer networks like BERT / RoBERTa / XLM-RoBERTa etc. and achieve state-of-the-art performance in various tasks. Text is embedded in vector space such that similar text are closer and can efficiently be found using cosine similarity.
2218

23-
We provide an increasing number of **[state-of-the-art pretrained models](https://www.sbert.net/docs/pretrained_models.html)** for more than 100 languages, fine-tuned for various use-cases.
19+
We provide an increasing number of **[state-of-the-art pretrained models](https://www.sbert.net/docs/sentence_transformer/pretrained_models.html)** for more than 100 languages, fine-tuned for various use-cases.
2420

25-
Further, this framework allows an easy **[fine-tuning of custom embeddings models](https://www.sbert.net/docs/training/overview.html)**, to achieve maximal performance on your specific task.
21+
Further, this framework allows an easy **[fine-tuning of custom embeddings models](https://www.sbert.net/docs/sentence_transformer/training_overview.html)**, to achieve maximal performance on your specific task.
2622

2723
For the **full documentation**, see **[www.SBERT.net](https://www.sbert.net)**.
2824

29-
The following publications are integrated in this framework:
30-
31-
- [Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks](https://arxiv.org/abs/1908.10084) (EMNLP 2019)
32-
- [Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillation](https://arxiv.org/abs/2004.09813) (EMNLP 2020)
33-
- [Augmented SBERT: Data Augmentation Method for Improving Bi-Encoders for Pairwise Sentence Scoring Tasks](https://arxiv.org/abs/2010.08240) (NAACL 2021)
34-
- [The Curse of Dense Low-Dimensional Information Retrieval for Large Index Sizes](https://arxiv.org/abs/2012.14210) (arXiv 2020)
35-
- [TSDAE: Using Transformer-based Sequential Denoising Auto-Encoder for Unsupervised Sentence Embedding Learning](https://arxiv.org/abs/2104.06979) (arXiv 2021)
36-
- [BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models](https://arxiv.org/abs/2104.08663) (arXiv 2021)
37-
- [Matryoshka Representation Learning](https://arxiv.org/abs/2205.13147) (arXiv 2022)
38-
3925
## Installation
4026

41-
We recommend **Python 3.8** or higher, **[PyTorch 1.11.0](https://pytorch.org/get-started/locally/)** or higher and **[transformers v4.32.0](https://github.com/huggingface/transformers)** or higher. The code does **not** work with Python 2.7.
27+
We recommend **Python 3.8+**, **[PyTorch 1.11.0+](https://pytorch.org/get-started/locally/)**, and **[transformers v4.34.0+](https://github.com/huggingface/transformers)**.
4228

4329
**Install with pip**
4430

45-
Install the *sentence-transformers* with `pip`:
46-
4731
```
4832
pip install -U sentence-transformers
4933
```
5034

5135
**Install with conda**
5236

53-
You can install the *sentence-transformers* with `conda`:
54-
5537
```
5638
conda install -c conda-forge sentence-transformers
5739
```
@@ -73,8 +55,6 @@ If you want to use a GPU / CUDA, you must install PyTorch with the matching CUDA
7355

7456
See [Quickstart](https://www.sbert.net/docs/quickstart.html) in our documenation.
7557

76-
[This example](https://github.com/UKPLab/sentence-transformers/tree/master/examples/applications/computing-embeddings/computing_embeddings.py) shows you how to use an already trained Sentence Transformer model to embed sentences for another task.
77-
7858
First download a pretrained model.
7959

8060
````python
@@ -87,58 +67,52 @@ Then provide some sentences to the model.
8767

8868
````python
8969
sentences = [
90-
"This framework generates embeddings for each input sentence",
91-
"Sentences are passed as a list of string.",
92-
"The quick brown fox jumps over the lazy dog.",
70+
"The weather is lovely today.",
71+
"It's so sunny outside!",
72+
"He drove to the stadium.",
9373
]
94-
sentence_embeddings = model.encode(sentences)
74+
embeddings = model.encode(sentences)
75+
print(embeddings.shape)
76+
# => (3, 384)
9577
````
9678

97-
And that's it already. We now have a list of numpy arrays with the embeddings.
79+
And that's already it. We now have a numpy arrays with the embeddings, one for each text. We can use these to compute similarities.
9880

9981
````python
100-
for sentence, embedding in zip(sentences, sentence_embeddings):
101-
print("Sentence:", sentence)
102-
print("Embedding:", embedding)
103-
print("")
82+
similarities = model.similarity(embeddings, embeddings)
83+
print(similarities)
84+
# tensor([[1.0000, 0.6660, 0.1046],
85+
# [0.6660, 1.0000, 0.1411],
86+
# [0.1046, 0.1411, 1.0000]])
10487
````
10588

10689
## Pre-Trained Models
10790

108-
We provide a large list of [Pretrained Models](https://www.sbert.net/docs/pretrained_models.html) for more than 100 languages. Some models are general purpose models, while others produce embeddings for specific use cases. Pre-trained models can be loaded by just passing the model name: `SentenceTransformer('model_name')`.
109-
110-
[» Full list of pretrained models](https://www.sbert.net/docs/pretrained_models.html)
91+
We provide a large list of [Pretrained Models](https://www.sbert.net/docs/sentence_transformer/pretrained_models.html) for more than 100 languages. Some models are general purpose models, while others produce embeddings for specific use cases. Pre-trained models can be loaded by just passing the model name: `SentenceTransformer('model_name')`.
11192

11293
## Training
11394

11495
This framework allows you to fine-tune your own sentence embedding methods, so that you get task-specific sentence embeddings. You have various options to choose from in order to get perfect sentence embeddings for your specific task.
11596

116-
See [Training Overview](https://www.sbert.net/docs/training/overview.html) for an introduction how to train your own embedding models. We provide [various examples](https://github.com/UKPLab/sentence-transformers/tree/master/examples/training) how to train models on various datasets.
97+
See [Training Overview](https://www.sbert.net/docs/sentence_transformer/training_overview.html) for an introduction how to train your own embedding models. We provide [various examples](https://github.com/UKPLab/sentence-transformers/tree/master/examples/training) how to train models on various datasets.
11798

11899
Some highlights are:
119100
- Support of various transformer networks including BERT, RoBERTa, XLM-R, DistilBERT, Electra, BART, ...
120101
- Multi-Lingual and multi-task learning
121102
- Evaluation during training to find optimal model
122-
- [20+ loss-functions](https://www.sbert.net/docs/package_reference/losses.html) allowing to tune models specifically for semantic search, paraphrase mining, semantic similarity comparison, clustering, triplet loss, contrastive loss.
123-
124-
## Performance
125-
126-
Our models are evaluated extensively on 15+ datasets including challening domains like Tweets, Reddit, emails. They achieve by far the **best performance** from all available sentence embedding methods. Further, we provide several **smaller models** that are **optimized for speed**.
127-
128-
[» Full list of pretrained models](https://www.sbert.net/docs/pretrained_models.html)
103+
- [20+ loss-functions](https://www.sbert.net/docs/package_reference/sentence_transformer/losses.html) allowing to tune models specifically for semantic search, paraphrase mining, semantic similarity comparison, clustering, triplet loss, contrastive loss, etc.
129104

130105
## Application Examples
131106

132107
You can use this framework for:
133108

134109
- [Computing Sentence Embeddings](https://www.sbert.net/examples/applications/computing-embeddings/README.html)
135110
- [Semantic Textual Similarity](https://www.sbert.net/docs/usage/semantic_textual_similarity.html)
111+
- [Semantic Search](https://www.sbert.net/examples/applications/semantic-search/README.html)
112+
- [Retrieve & Re-Rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html)
136113
- [Clustering](https://www.sbert.net/examples/applications/clustering/README.html)
137114
- [Paraphrase Mining](https://www.sbert.net/examples/applications/paraphrase-mining/README.html)
138-
- [Translated Sentence Mining](https://www.sbert.net/examples/applications/parallel-sentence-mining/README.html)
139-
- [Semantic Search](https://www.sbert.net/examples/applications/semantic-search/README.html)
140-
- [Retrieve & Re-Rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html)
141-
- [Text Summarization](https://www.sbert.net/examples/applications/text-summarization/README.html)
115+
- [Translated Sentence Mining](https://www.sbert.net/examples/applications/parallel-sentence-mining/README.html)
142116
- [Multilingual Image Search, Clustering & Duplicate Detection](https://www.sbert.net/examples/applications/image-search/README.html)
143117

144118
and many more use-cases.
@@ -193,7 +167,7 @@ If you use one of the multilingual models, feel free to cite our publication [Ma
193167

194168
Please have a look at [Publications](https://www.sbert.net/docs/publications.html) for our different publications that are integrated into SentenceTransformers.
195169

196-
Contact person: Tom Aarsen, [[email protected]](mailto:[email protected])
170+
Maintainer: [Tom Aarsen](https://github.com/tomaarsen), 🤗 Hugging Face
197171

198172
https://www.ukp.tu-darmstadt.de/
199173

docs/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11

22
docs:
3-
sphinx-build -c . -a -E .. _build
3+
sphinx-build -c . -a -E .. _build
4+
5+
docs-quick:
6+
sphinx-build -c . .. _build

docs/_static/css/custom.css

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,88 @@ dl.class > dt {
2424

2525
.wy-side-nav-search {
2626
padding-top: 0px;
27-
}
27+
}
28+
29+
.components {
30+
display: flex;
31+
flex-flow: row wrap;
32+
}
33+
34+
.components > .box {
35+
flex: 1;
36+
margin: 0.5rem;
37+
padding: 1rem;
38+
border-style: solid;
39+
border-width: 1px;
40+
border-radius: 0.5rem;
41+
border-color: rgb(55 65 81);
42+
background-color: #e3e3e3;
43+
color: #404040; /* Override the colors imposed by <a href> */
44+
}
45+
46+
.components > .box:nth-child(1) > .header {
47+
background-image: linear-gradient(to bottom right, #60a5fa, #3b82f6);
48+
}
49+
50+
.components > .box:nth-child(2) > .header {
51+
background-image: linear-gradient(to bottom right, #fb923c, #f97316);
52+
}
53+
54+
.components > .box:nth-child(3) > .header {
55+
background-image: linear-gradient(to bottom right, #f472b6, #ec4899);
56+
}
57+
58+
.components > .box:nth-child(4) > .header {
59+
background-image: linear-gradient(to bottom right, #a78bfa, #8b5cf6);
60+
}
61+
62+
.components > .box:nth-child(5) > .header {
63+
background-image: linear-gradient(to bottom right, #34d399, #10b981);
64+
}
65+
66+
.components > .optional {
67+
background: repeating-linear-gradient(
68+
135deg,
69+
#f1f1f1,
70+
#f1f1f1 25px,
71+
#e3e3e3 25px,
72+
#e3e3e3 50px
73+
);
74+
}
75+
76+
.components > .box > .header {
77+
border-style: solid;
78+
border-width: 1px;
79+
border-radius: 0.5rem;
80+
border-color: rgb(55 65 81);
81+
padding: 0.5rem;
82+
text-align: center;
83+
margin-bottom: 0.5rem;
84+
font-weight: bold;
85+
color: white;
86+
}
87+
88+
.sidebar p {
89+
font-size: 100% !important;
90+
}
91+
92+
.training-arguments {
93+
background-color: #f3f6f6;
94+
border: 1px solid #e1e4e5;
95+
}
96+
97+
.training-arguments > .header {
98+
font-weight: 700;
99+
padding: 6px 12px;
100+
background: #e1e4e5;
101+
}
102+
103+
.training-arguments > .table {
104+
display: grid;
105+
grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
106+
}
107+
108+
.training-arguments > .table > a {
109+
padding: 0.5rem;
110+
border: 1px solid #e1e4e5;
111+
}

docs/_themes/sphinx_rtd_theme/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import sphinx
1010

11-
1211
__version__ = "0.5.0"
1312
__version_full__ = __version__
1413

docs/_themes/sphinx_rtd_theme/footer.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
&copy; {% trans %}Copyright{% endtrans %} {{ copyright }}
2525
{%- endif %}
2626
{%- endif %}
27-
28-
&bull; <a href="/docs/contact.html">Contact</a>
29-
3027
{%- if build_id and build_url %}
3128
<span class="build">
3229
{# Translators: Build is a noun, not a verb #}

docs/_themes/sphinx_rtd_theme/layout.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@
121121
</a>
122122

123123
<div style="display: flex; justify-content: center;">
124-
<div id="twitter-button">
124+
<!-- This snippet adds a "Follow SBERT on Twitter" button. I'll remove it as Nils doesn't post about SBERT anmymore -->
125+
<!-- <div id="twitter-button">
125126
<a href="https://twitter.com/Nils_Reimers" target="_blank" title="Follow SBERT on Twitter"><img src="/_static/Twitter_Logo_White.svg" height="20" style="margin: 0px 10px 0px -10px;"> </a>
127+
</div> -->
128+
<div id="hf-button">
129+
<a href="https://huggingface.co/models?library=sentence-transformers" target="_blank" title="See all Sentence Transformer models"><img src="{{ pathto('_static/img/hf-logo.svg', 1) }}" style="margin: 0px 10px 0px -10px; padding: 0px; height: 28px; width: 28px;"></a>
126130
</div>
127131
<div id="github-button"></div>
128132
</div>

docs/_themes/sphinx_rtd_theme/theme.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ canonical_url =
88
analytics_id =
99
collapse_navigation = True
1010
sticky_navigation = True
11-
navigation_depth = 4
11+
navigation_depth =
1212
includehidden = True
1313
titles_only =
1414
logo_only =

0 commit comments

Comments
 (0)