-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add E5 as SBertBiEncoder * fix test * use functools.partialmethod() * fix test case * initial sketch of sbert docs * docs * fix test * add e5 variants --------- Co-authored-by: Sean MacAvaney <[email protected]> Co-authored-by: jinyuan <[email protected]>
- Loading branch information
1 parent
5071f23
commit 9c86daa
Showing
5 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,4 @@ Import ``pyterrier_dr``, load a pre-built index and model, and retrieve: | |
:maxdepth: 1 | ||
|
||
prf | ||
sbert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Using Sentence Transformer models for Dense retrieval in PyTerrier | ||
================================================================== | ||
|
||
With PyTerrier_DR, its easy to support Sentence Transformer (formerly called SentenceBERT) | ||
models, e.g. from HuggingFace, for dense retrieval. | ||
|
||
The base class is ``SBertBiEncoder('huggingface/path')``; | ||
|
||
There are easy to remember classes for a number of standard models: | ||
- ANCE - an early single-representation dense retrieval model: ``Ance.firstp()`` | ||
- GTR - a dense retrieval model based on the T5 pre-trained encoder: ``GTR.base()`` | ||
- `E5 <https://huggingface.co/intfloat/e5-base-v2>`: ``E5.base()`` | ||
- Query2Query - a query similarity model: Query2Query() | ||
|
||
The standard pyterrier_dr pipelines can be used: | ||
|
||
Indexing:: | ||
model = pyterrier_dr.GTR.base() | ||
index = pyterrier_dr.FlexIndex('gtr.flex') | ||
pipe = (model >> index) | ||
pipe.index(pt.get_dataset('irds:msmarco-passage').get_corpus_iter()) | ||
|
||
Retrieval:: | ||
pipe.search("chemical reactions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters