-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to use multiple retrieval backends
- Loading branch information
Showing
7 changed files
with
104 additions
and
0 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
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Sequence | ||
|
||
from pytest import fixture | ||
|
||
from chatnoir_api import Index, Meta, Results, MinimalResult, \ | ||
Result, ExplainedMinimalResult, ExtendedMeta | ||
from chatnoir_api.v1 import search_page, search | ||
|
||
|
||
@fixture(params=[True, False]) | ||
def minimal(request) -> bool: | ||
return request.param | ||
|
||
|
||
def test_default_retrieval_model(api_key: str) -> None: | ||
results = search("how to find a test dataset", index='msmarco-document-v2.1', retrieval_system='default') | ||
|
||
meta = results.meta | ||
|
||
assert meta is not None | ||
assert isinstance(meta, Meta) | ||
|
||
assert meta.total_results is not None | ||
assert isinstance(meta.total_results, int) | ||
assert meta.total_results == 5517 | ||
assert meta.search_method == 'default' | ||
|
||
def test_bm25_retrieval_model(api_key: str) -> None: | ||
results = search("how to find a test dataset", index='msmarco-document-v2.1', retrieval_system='bm25') | ||
|
||
meta = results.meta | ||
|
||
assert meta is not None | ||
assert isinstance(meta, Meta) | ||
|
||
assert meta.total_results is not None | ||
assert isinstance(meta.total_results, int) | ||
assert meta.total_results == 2800000 | ||
assert meta.search_method == 'bm25' | ||
|
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,38 @@ | ||
from chatnoir_api.cache import term_vectors | ||
|
||
def test_ms_marco_document_1() -> None: | ||
contents = term_vectors( | ||
trec_id='msmarco_doc_16_4126868268', | ||
index='msmarco-document-v2', | ||
) | ||
|
||
assert contents is not None | ||
assert 'term_vectors' in contents | ||
assert 'body_lang_en' in contents['term_vectors'] | ||
assert 'terms' in contents['term_vectors']['body_lang_en'] | ||
terms = contents['term_vectors']['body_lang_en']['terms'] | ||
|
||
assert 'hidden' in terms | ||
assert 25730 == terms['hidden']['doc_freq'] | ||
assert 37614 == terms['hidden']['ttf'] | ||
assert 1 == terms['hidden']['term_freq'] | ||
|
||
def test_ms_marco_document_2() -> None: | ||
contents = term_vectors( | ||
trec_id='msmarco_doc_56_310927995', | ||
index='msmarco-document-v2', | ||
) | ||
|
||
assert contents is not None | ||
assert 'term_vectors' in contents | ||
assert 'body_lang_en' in contents['term_vectors'] | ||
assert 'terms' in contents['term_vectors']['body_lang_en'] | ||
terms = contents['term_vectors']['body_lang_en']['terms'] | ||
|
||
assert 'classifier' in terms | ||
assert 132 == terms['classifier']['doc_freq'] | ||
assert 442 == terms['classifier']['ttf'] | ||
assert 6 == terms['classifier']['term_freq'] | ||
|
||
|
||
|