Views
No views yet


pip install relikpip install relik[all]pip install relik[train]pip install relik[faiss]1conda create -n relik python=3.10
2conda activate relik
3
4# install pytorch
5conda install -y pytorch=2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia
6
7# GPU
8conda install -y -c pytorch -c nvidia faiss-gpu=1.8.0
9# or GPU with NVIDIA RAFT
10conda install -y -c pytorch -c nvidia -c rapidsai -c conda-forge faiss-gpu-raft=1.8.0
11
12pip install relikpip install relik[serve]1git clone https://github.com/SapienzaNLP/relik.git
2cd relik
3pip install -e .[all]from_pretrained method to load a pre-trained pipeline.1from relik import Relik
2from relik.inference.data.objects import RelikOutput
3
4relik = Relik.from_pretrained("sapienzanlp/relik-relation-extraction-nyt-large")
5relik_out: RelikOutput = relik("Michael Jordan was one of the best players in the NBA.")RelikOutput(
text='Michael Jordan was one of the best players in the NBA.',
tokens=Michael Jordan was one of the best players in the NBA.,
id=0,
spans=[
Span(start=0, end=14, label='--NME--', text='Michael Jordan'),
Span(start=50, end=53, label='--NME--', text='NBA')
],
triplets=[
Triplets(
subject=Span(start=0, end=14, label='--NME--', text='Michael Jordan'),
label='company',
object=Span(start=50, end=53, label='--NME--', text='NBA'),
confidence=1.0
)
],
candidates=Candidates(
span=[],
triplet=[
[
[
{"text": "company", "id": 4, "metadata": {"definition": "company of this person"}},
{"text": "nationality", "id": 10, "metadata": {"definition": "nationality of this person or entity"}},
{"text": "child", "id": 17, "metadata": {"definition": "child of this person"}},
{"text": "founded by", "id": 0, "metadata": {"definition": "founder or co-founder of this organization, religion or place"}},
{"text": "residence", "id": 18, "metadata": {"definition": "place where this person has lived"}},
...
]
]
]
),
)| Model | NYT | NYT (Pretr) | AIT (m:s) |
|---|---|---|---|
| REBEL | 93.1 | 93.4 | 01:45 |
| UiE | 93.5 | -- | -- |
| USM | 94.0 | 94.1 | -- |
| ➡️ ReLiKLarge | 95.0 | 94.9 | 00:30 |
1@inproceedings{orlando-etal-2024-relik,
2 title = "Retrieve, Read and LinK: Fast and Accurate Entity Linking and Relation Extraction on an Academic Budget",
3 author = "Orlando, Riccardo and Huguet Cabot, Pere-Llu{\'\i}s and Barba, Edoardo and Navigli, Roberto",
4 booktitle = "Findings of the Association for Computational Linguistics: ACL 2024",
5 month = aug,
6 year = "2024",
7 address = "Bangkok, Thailand",
8 publisher = "Association for Computational Linguistics",
9}