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

Implement the MUNI/33/0769/2022 R&D project #8

Merged
merged 67 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e8df577
evaluation metrics module (#7)
MarekToma Feb 27, 2023
22c0220
ensembles module (#6)
MarekToma Feb 27, 2023
8c327ab
Datasets module (#1)
MarekToma Feb 27, 2023
62a77ce
Preprocessing (#5)
VojtechKalivoda Feb 27, 2023
e5d5d7d
fixed setupfile and changed default eval depth
MarekToma Feb 27, 2023
6726f07
use DocPreprocessingBase
VojtechKalivoda Mar 4, 2023
9119521
removed forking for num_processes=1
MarekToma Mar 5, 2023
2c3a04d
adressed some requested changes
MarekToma Mar 5, 2023
071841b
added preprocessing module to setup
MarekToma Mar 5, 2023
092e4da
added cqadupstack class into datasets module, defined query ordering …
MarekToma Mar 6, 2023
5cd3aa4
updated tests for new ids and fixed judgments loading
MarekToma Mar 6, 2023
f05953d
fixed style checks
MarekToma Mar 6, 2023
fec508f
fixed line breaks in test.beir.test_loader
MarekToma Mar 6, 2023
7ab2ae8
updated beir_cqadupstack notebook, added some docstring to beir.loade…
MarekToma Mar 9, 2023
d467235
fixed some typechecks
MarekToma Mar 9, 2023
d9c2dcd
fixed eval call in beir notebook
MarekToma Mar 9, 2023
f52936c
added cache_location atribute to arqmathdataset
MarekToma Mar 9, 2023
2ff7188
set default cach download location in datasets module
MarekToma Mar 9, 2023
e931ac9
Fix NumPy docstring style
Witiko Mar 10, 2023
c3cf5ff
changed data loading to use datasets module in arqmath notebook
MarekToma Mar 13, 2023
eaa41f9
updated beir notebook and eval with new min MAP and added beir notebo…
MarekToma Mar 16, 2023
9af8d8e
add requirements file with pinned versions of libs
VojtechKalivoda Mar 16, 2023
d12473c
rename core of BM25Plus
VojtechKalivoda Mar 16, 2023
a3bceaf
use lib for BM25
VojtechKalivoda Mar 17, 2023
6dfc34a
update requirements
VojtechKalivoda Mar 17, 2023
94b76be
clean BM25 and readme
VojtechKalivoda Mar 17, 2023
5442bfb
use systems in notebooks
VojtechKalivoda Mar 17, 2023
721f09e
use datasets module in cranfield and trec notebooks
VojtechKalivoda Mar 18, 2023
be70ece
updated description of IR system in cqadupstack notebook
MarekToma Mar 19, 2023
9468d37
changed the multiprocessing implementation ov map in evaluation metri…
MarekToma Mar 19, 2023
237ae96
updated multiprocessing implementation of other metrics and set a chu…
MarekToma Mar 19, 2023
fe92126
changed imap to map
MarekToma Mar 19, 2023
dd50dc9
reverted some changes
MarekToma Mar 19, 2023
8c8c0f8
temporarely reverted some changes for sanity check
MarekToma Mar 19, 2023
8845b2f
put back in changes I made earlier
MarekToma Mar 19, 2023
7ad873b
put back in changes I made earlier
MarekToma Mar 19, 2023
fd28b63
fixed some type errors
MarekToma Mar 19, 2023
1cf35ea
made map eval faster using technique from original implementation
MarekToma Mar 19, 2023
e18360d
fixed some style errors
MarekToma Mar 19, 2023
da8e45d
use datasets module in trec
VojtechKalivoda Mar 20, 2023
ac246de
update notebooks and their scores in README
VojtechKalivoda Mar 20, 2023
33bd92c
update beir notebook
VojtechKalivoda Mar 20, 2023
901a358
In `notebooks/cranfield.ipynb`, replace tfidf with bow and clear outputs
Witiko Mar 20, 2023
028cb5e
Add more details to system section in `notebooks/cranfield.ipynb`
Witiko Mar 20, 2023
0395582
update arqmath and beir notebook
VojtechKalivoda Mar 20, 2023
4bc5b58
In `notebooks/arqmath.ipynb`, improve text and clear outputs
Witiko Mar 20, 2023
923dce3
In `notebooks/trec.ipynb`, improve text and clear outputs
Witiko Mar 20, 2023
43dbc49
In `notebooks/beir*.ipynb`, clear outputs and use `NoneDocPreprocessing`
Witiko Mar 20, 2023
1fd757b
Fix wrong MAP score for `notebooks/beir*.ipynb` in `README.md`
Witiko Mar 20, 2023
26509e3
fixed error in typing
MarekToma Mar 20, 2023
ac2c340
updated min map for arqmath
MarekToma Mar 20, 2023
dc22c72
Update minimum MAP score for `notebooks/beir.ipynb`
Witiko Mar 20, 2023
9cb5f84
Remove duplicate paragraph in `notebooks/arqmath.ipynb`
Witiko Mar 20, 2023
7019e4e
add tutorial notebook
VojtechKalivoda Mar 20, 2023
8042bf8
Use `find_packages` and `parse_requirements` in `setup.py`
Witiko Mar 20, 2023
a4cefb7
Add newline to code block in `notebooks/arqmath.ipynb`
Witiko Mar 20, 2023
bd09ae1
Merge branch 'developer' of github.com:MIR-MU/pv211-utils into developer
Witiko Mar 20, 2023
ebe564c
Fix the use of `parse_requirements` in `setup.py`
Witiko Mar 20, 2023
82f3f17
Pull `preprocessing.*.*` members to `preprocessing`
Witiko Mar 20, 2023
fd5bee7
Loosen `requirements.txt`
Witiko Mar 20, 2023
0761fa7
Loosen `requirements.txt`
Witiko Mar 20, 2023
5df3176
Loosen `requirements.txt`
Witiko Mar 20, 2023
a8a7efa
Add `rank-bm25` to `requirements.txt`
Witiko Mar 20, 2023
1a57376
Minimize parameters passed to `*Evaluation` in `notebooks/*.ipynb`
Witiko Mar 20, 2023
acfb437
Revert "Fix wrong MAP score for `notebooks/beir*.ipynb` in `README.md`"
Witiko Mar 20, 2023
a6aff58
Revert "In `notebooks/beir*.ipynb`, clear outputs and use `NoneDocPre…
Witiko Mar 20, 2023
1a8c40b
Pin `notebooks/cranfield.ipynb` and `trec.ipynb`
Witiko Mar 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
546 changes: 546 additions & 0 deletions notebooks/beir_cqadupstack.ipynb

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pv211_utils/arqmath/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ArqmathEvaluation(EvaluationBase):
The information retrieval system.
judgements : set of ArqmathJudgementBase
Pairs of queries and relevant documents.
k : int, optional
Parameter defining evaluation depth. Default is 10.
leaderboard : ArqmathLeaderboard or None, optional
A leaderboard to which we may later submit evaluation results.
If None, then evaluation results will not be submitted. Default is None.
Expand All @@ -24,12 +26,11 @@ class ArqmathEvaluation(EvaluationBase):
num_workers : int or None, optional
The number of processes used to compute the mean average precision.
If None, all available CPUs will be used. Default is 1.

"""
def __init__(self, system: ArqmathIRSystemBase, judgements: Set[ArqmathJudgementBase],
leaderboard: Optional[ArqmathLeaderboard] = None,
k: Optional[int] = 10, leaderboard: Optional[ArqmathLeaderboard] = None,
Witiko marked this conversation as resolved.
Show resolved Hide resolved
author_name: Optional[str] = None, num_workers: Optional[int] = 1):
super().__init__(system, judgements, leaderboard, author_name, num_workers)
super().__init__(system, judgements, k, leaderboard, author_name, num_workers)

def _get_minimum_mean_average_precision(self) -> float:
return 0.012
Empty file added pv211_utils/beir/__init__.py
Empty file.
86 changes: 86 additions & 0 deletions pv211_utils/beir/entities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from typing import Any, Tuple, Optional, List, Set

from pv211_utils.entities import DocumentBase, QueryBase


class BeirDocumentBase(DocumentBase):
"""A Generic document with just an id and a body.

Parameters
----------
document_id : str
A unique identifier of the document.
body : Any
The text of the document.

"""
def __init__(self, document_id: str, body: Any):
super().__init__(document_id, body)


class BeirQueryBase(QueryBase):
"""A Generic query with just an id and a body

Parameters
----------
query_id : int
A unique identifier of the query.
body : Any
The text of the query.

"""
def __init__(self, query_id: int, body: Any):
super().__init__(query_id, body)


class RawBeirDataset:
"""A generic BIER dataset with options
Witiko marked this conversation as resolved.
Show resolved Hide resolved

Parameters
----------
name : str
A unique identifier of the dataset, select one name from the list of available datasets.
train : bool
A bool value that dictates if a train subset should be prepared.
dev : bool
A bool value that dictates if a dev subset should be prepared.
test : bool
A bool value that dictates if a test subset should be prepared.
train_alternative : str
An alternative in case the given dataset does not come with an available training subset.
dev_alternative : str
An alternative in case the given dataset does not come with an available dev subset.
test_alternative : str
An alternative in case the given dataset does not come with an available test subset.

"""
def __init__(self, name: str,
train: bool = False, dev: bool = False, test: bool = False,
Witiko marked this conversation as resolved.
Show resolved Hide resolved
train_alternative: Optional[str] = None, dev_alternative: Optional[str] = None,
test_alternative: Optional[str] = None):
self.name = name
self.train = train
self.dev = dev
self.test = test
self.train_alternative = train_alternative
self.dev_alternative = dev_alternative
self.test_alternative = test_alternative


class RawBeirDatasets:
"""A list of RawBeirDataset that will be loaded, prepared and merged into one for use in IR systems.

Parameters
----------
download_location : str
A address where all the datasets will be downloaded. Access availability is required.
datasets : List[RawBeirDataset]
A list of RawBeirDataset values.
"""
def __init__(self, datasets: List[RawBeirDataset], download_location: str):
self.download_location = download_location
self.datasets = datasets


BeirJudgementBase = Tuple[BeirQueryBase, BeirDocumentBase]
BeirJudgementsBase = Set[BeirJudgementBase]
34 changes: 34 additions & 0 deletions pv211_utils/beir/eval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import Set, Optional

from pv211_utils.eval import EvaluationBase
from .entities import BeirJudgementBase
from .irsystem import BeirIRSystemBase


class BeirEvaluation(EvaluationBase):
"""A Generic information retrieval system evaluation.

Parameters
----------
system : BeirIRSystemBase
The information retrieval system.
judgements : set of BeirJudgementBase
Pairs of queries and relevant documents.
k : int, optional
Parameter defining evaluation depth. Default is 10.
leaderboard : BeirLeaderboard or None, optional
A leaderboard to which we may later submit evaluation results.
If None, then evaluation results will not be submitted. Default is None.
author_name : str or None, optional
The name of the author submitted to the leaderboard.
If None, then the result will not be submitted. Default is None.
num_workers : int or None, optional
The number of processes used to compute the mean average precision.
If None, all available CPUs will be used. Default is 1.
"""
def __init__(self, system: BeirIRSystemBase, judgements: Set[BeirJudgementBase], k: Optional[int] = 10,
Witiko marked this conversation as resolved.
Show resolved Hide resolved
leaderboard=None, author_name: Optional[str] = None, num_workers: Optional[int] = 1):
super().__init__(system, judgements, k, leaderboard, author_name, num_workers)

def _get_minimum_mean_average_precision(self) -> float:
return 0.1
MarekToma marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions pv211_utils/beir/irsystem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import abc
from typing import Iterable

from ..irsystem import IRSystemBase
from .entities import BeirQueryBase, BeirDocumentBase


class BeirIRSystemBase(IRSystemBase):
@abc.abstractmethod
def search(self, query: BeirQueryBase) -> Iterable[BeirDocumentBase]:
pass
27 changes: 27 additions & 0 deletions pv211_utils/beir/leaderboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import datetime
import pkg_resources
from typing import Optional

from ..leaderboard import GoogleSpreadsheetLeaderboardBase


class BeirLeaderboard(GoogleSpreadsheetLeaderboardBase):
def get_competition_start(self) -> datetime.date:
return datetime.date(2022, 8, 18)

def get_competition_end(self) -> datetime.date:
return datetime.date(2022, 12, 30)
Witiko marked this conversation as resolved.
Show resolved Hide resolved

def _get_key_path(self) -> str:
key_path = pkg_resources.resource_filename('pv211_utils', 'data/pv211-leaderboard-b8e892e3e8bb.json')
return key_path

def _get_spreadsheet_key(self) -> str:
spreadsheet_key = '1LVCY6H2iaS05DDwON4YyZ2aWYnFCBYbnZqtpMdn7e6M'
return spreadsheet_key

def get_public_url(self) -> Optional[str]:
return (
'https://docs.google.com/spreadsheets/d/e/2PACX'
'-1vSnyvgqXDq3XPzGz3eLz_8JPwceou10HiEShI0wJ2A8vlosRZc1QhKZ10aOmmQFitv2yPAyBERD2wwx/pubhtml '
)
Loading