riccorl commited on
Commit
ff163d2
β€’
1 Parent(s): ac5148e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +180 -0
README.md ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ ---
5
+
6
+ <div align="center">
7
+ <img src="https://github.com/SapienzaNLP/relik/blob/main/relik.png?raw=true" height="150">
8
+ <img src="https://github.com/SapienzaNLP/relik/blob/main/Sapienza_Babelscape.png?raw=true" height="50">
9
+ </div>
10
+
11
+ <div align="center">
12
+ <h1>Retrieve, Read and LinK: Fast and Accurate Entity Linking and Relation Extraction on an Academic Budget</h1>
13
+ </div>
14
+
15
+ <div style="display:flex; justify-content: center; align-items: center; flex-direction: row;">
16
+ <a href="https://2024.aclweb.org/"><img src="http://img.shields.io/badge/ACL-2024-4b44ce.svg"></a> &nbsp; &nbsp;
17
+ <a href="https://aclanthology.org/"><img src="http://img.shields.io/badge/paper-ACL--anthology-B31B1B.svg"></a> &nbsp; &nbsp;
18
+ <a href="https://arxiv.org/abs/placeholder"><img src="https://img.shields.io/badge/arXiv-placeholder-b31b1b.svg"></a>
19
+ </div>
20
+ <div style="display:flex; justify-content: center; align-items: center; flex-direction: row;">
21
+ <a href="https://huggingface.co/collections/sapienzanlp/relik-retrieve-read-and-link-665d9e4a5c3ecba98c1bef19"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Collection-FCD21D"></a> &nbsp; &nbsp;
22
+ <a href="https://github.com/SapienzaNLP/relik"><img src="https://img.shields.io/badge/GitHub-Repo-121013?logo=github&logoColor=white"></a> &nbsp; &nbsp;
23
+ <a href="https://github.com/SapienzaNLP/relik/releases"><img src="https://img.shields.io/github/v/release/SapienzaNLP/relik"></a>
24
+ </div>
25
+
26
+
27
+ A blazing fast and lightweight Information Extraction model for **Entity Linking** and **Relation Extraction**.
28
+
29
+ **This repository contains the weights and the index for the Entity Linking ReLiK pipeline.**
30
+
31
+ ## πŸ› οΈ Installation
32
+
33
+ Installation from PyPI
34
+
35
+ ```bash
36
+ pip install relik
37
+ ```
38
+
39
+ <details>
40
+ <summary>Other installation options</summary>
41
+
42
+ #### Install with optional dependencies
43
+
44
+ Install with all the optional dependencies.
45
+
46
+ ```bash
47
+ pip install relik[all]
48
+ ```
49
+
50
+ Install with optional dependencies for training and evaluation.
51
+
52
+ ```bash
53
+ pip install relik[train]
54
+ ```
55
+
56
+ Install with optional dependencies for [FAISS](https://github.com/facebookresearch/faiss)
57
+
58
+ FAISS PyPI package is only available for CPU. For GPU, install it from source or use the conda package.
59
+
60
+ For CPU:
61
+
62
+ ```bash
63
+ pip install relik[faiss]
64
+ ```
65
+
66
+ For GPU:
67
+
68
+ ```bash
69
+ conda create -n relik python=3.10
70
+ conda activate relik
71
+
72
+ # install pytorch
73
+ conda install -y pytorch=2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia
74
+
75
+ # GPU
76
+ conda install -y -c pytorch -c nvidia faiss-gpu=1.8.0
77
+ # or GPU with NVIDIA RAFT
78
+ conda install -y -c pytorch -c nvidia -c rapidsai -c conda-forge faiss-gpu-raft=1.8.0
79
+
80
+ pip install relik
81
+ ```
82
+
83
+ Install with optional dependencies for serving the models with
84
+ [FastAPI](https://fastapi.tiangolo.com/) and [Ray](https://docs.ray.io/en/latest/serve/quickstart.html).
85
+
86
+ ```bash
87
+ pip install relik[serve]
88
+ ```
89
+
90
+ #### Installation from source
91
+
92
+ ```bash
93
+ git clone https://github.com/SapienzaNLP/relik.git
94
+ cd relik
95
+ pip install -e .[all]
96
+ ```
97
+
98
+ </details>
99
+
100
+ ## πŸš€ Quick Start
101
+
102
+ [//]: # (Write a short description of the model and how to use it with the `from_pretrained` method.)
103
+
104
+ ReLiK is a lightweight and fast model for **Entity Linking** and **Relation Extraction**.
105
+ It is composed of two main components: a retriever and a reader.
106
+ The retriever is responsible for retrieving relevant documents from a large collection,
107
+ while the reader is responsible for extracting entities and relations from the retrieved documents.
108
+ ReLiK can be used with the `from_pretrained` method to load a pre-trained pipeline.
109
+
110
+ Here is an example of how to use ReLiK for **Entity Linking**:
111
+
112
+ ```python
113
+ from relik import Relik
114
+ from relik.inference.data.objects import RelikOutput
115
+
116
+ relik = Relik.from_pretrained("sapienzanlp/relik-entity-linking-large")
117
+ relik_out: RelikOutput = relik("Michael Jordan was one of the best players in the NBA.")
118
+ ```
119
+
120
+ RelikOutput(
121
+ text="Michael Jordan was one of the best players in the NBA.",
122
+ tokens=['Michael', 'Jordan', 'was', 'one', 'of', 'the', 'best', 'players', 'in', 'the', 'NBA', '.'],
123
+ id=0,
124
+ spans=[
125
+ Span(start=0, end=14, label="Michael Jordan", text="Michael Jordan"),
126
+ Span(start=50, end=53, label="National Basketball Association", text="NBA"),
127
+ ],
128
+ triples=[],
129
+ candidates=Candidates(
130
+ span=[
131
+ [
132
+ [
133
+ {"text": "Michael Jordan", "id": 4484083},
134
+ {"text": "National Basketball Association", "id": 5209815},
135
+ {"text": "Walter Jordan", "id": 2340190},
136
+ {"text": "Jordan", "id": 3486773},
137
+ {"text": "50 Greatest Players in NBA History", "id": 1742909},
138
+ ...
139
+ ]
140
+ ]
141
+ ]
142
+ ),
143
+ )
144
+
145
+ ## πŸ“Š Performance
146
+
147
+ We evaluate the performance of ReLiK on Entity Linking using [GERBIL](http://gerbil-qa.aksw.org/gerbil/). The following table shows the results (InKB Micro F1) of ReLiK Large and Base:
148
+
149
+ | Model | AIDA | MSNBC | Der | K50 | R128 | R500 | O15 | O16 | Tot | OOD | AIT (m:s) |
150
+ |------------------------------------------|------|-------|------|------|------|------|------|------|------|------|------------|
151
+ | GENRE | 83.7 | 73.7 | 54.1 | 60.7 | 46.7 | 40.3 | 56.1 | 50.0 | 58.2 | 54.5 | 38:00 |
152
+ | EntQA | 85.8 | 72.1 | 52.9 | 64.5 | **54.1** | 41.9 | 61.1 | 51.3 | 60.5 | 56.4 | 20:00 |
153
+ | [ReLiK<sub>Base<sub>](https://huggingface.co/sapienzanlp/relik-entity-linking-base) | 85.3 | 72.3 | 55.6 | 68.0 | 48.1 | 41.6 | 62.5 | 52.3 | 60.7 | 57.2 | 00:29 |
154
+ | ➑️ [ReLiK<sub>Large<sub>](https://huggingface.co/sapienzanlp/relik-entity-linking-large) | **86.4** | **75.0** | **56.3** | **72.8** | 51.7 | **43.0** | **65.1** | **57.2** | **63.4** | **60.2** | 01:46 |
155
+
156
+ Comparison systems' evaluation (InKB Micro F1) on the *in-domain* AIDA test set and *out-of-domain* MSNBC (MSN), Derczynski (Der), KORE50 (K50), N3-Reuters-128 (R128),
157
+ N3-RSS-500 (R500), OKE-15 (O15), and OKE-16 (O16) test sets. **Bold** indicates the best model.
158
+ GENRE uses mention dictionaries.
159
+ The AIT column shows the time in minutes and seconds (m:s) that the systems need to process the whole AIDA test set using an NVIDIA RTX 4090,
160
+ except for EntQA which does not fit in 24GB of RAM and for which an A100 is used.
161
+
162
+ ## πŸ€– Models
163
+
164
+ Models can be found on [πŸ€— Hugging Face](https://huggingface.co/collections/sapienzanlp/relik-retrieve-read-and-link-665d9e4a5c3ecba98c1bef19).
165
+
166
+ ## πŸ’½ Cite this work
167
+
168
+ If you use any part of this work, please consider citing the paper as follows:
169
+
170
+ ```bibtex
171
+ @inproceedings{orlando-etal-2024-relik,
172
+ title = "Retrieve, Read and LinK: Fast and Accurate Entity Linking and Relation Extraction on an Academic Budget",
173
+ author = "Orlando, Riccardo and Huguet Cabot, Pere-Llu{\'\i}s and Barba, Edoardo and Navigli, Roberto",
174
+ booktitle = "Findings of the Association for Computational Linguistics: ACL 2024",
175
+ month = aug,
176
+ year = "2024",
177
+ address = "Bangkok, Thailand",
178
+ publisher = "Association for Computational Linguistics",
179
+ }
180
+ ```