PereLluis13 commited on
Commit
614f4b7
β€’
1 Parent(s): 8b11d07

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +181 -0
README.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ This model card is for a more lightweight index for the sapienzanlp/relik-retriever-e5-base-v2-aida-blink-encoder retriever. It contains the most popular 2M entities by their frequency across Wikipedia pages.
27
+
28
+ A blazing fast and lightweight Information Extraction model for **Entity Linking** and **Relation Extraction**.
29
+
30
+ **This repository contains the weights and the index for the Entity Linking ReLiK pipeline.**
31
+
32
+ ## πŸ› οΈ Installation
33
+
34
+ Installation from PyPI
35
+
36
+ ```bash
37
+ pip install relik
38
+ ```
39
+
40
+ <details>
41
+ <summary>Other installation options</summary>
42
+
43
+ #### Install with optional dependencies
44
+
45
+ Install with all the optional dependencies.
46
+
47
+ ```bash
48
+ pip install relik[all]
49
+ ```
50
+
51
+ Install with optional dependencies for training and evaluation.
52
+
53
+ ```bash
54
+ pip install relik[train]
55
+ ```
56
+
57
+ Install with optional dependencies for [FAISS](https://github.com/facebookresearch/faiss)
58
+
59
+ FAISS PyPI package is only available for CPU. For GPU, install it from source or use the conda package.
60
+
61
+ For CPU:
62
+
63
+ ```bash
64
+ pip install relik[faiss]
65
+ ```
66
+
67
+ For GPU:
68
+
69
+ ```bash
70
+ conda create -n relik python=3.10
71
+ conda activate relik
72
+
73
+ # install pytorch
74
+ conda install -y pytorch=2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia
75
+
76
+ # GPU
77
+ conda install -y -c pytorch -c nvidia faiss-gpu=1.8.0
78
+ # or GPU with NVIDIA RAFT
79
+ conda install -y -c pytorch -c nvidia -c rapidsai -c conda-forge faiss-gpu-raft=1.8.0
80
+
81
+ pip install relik
82
+ ```
83
+
84
+ Install with optional dependencies for serving the models with
85
+ [FastAPI](https://fastapi.tiangolo.com/) and [Ray](https://docs.ray.io/en/latest/serve/quickstart.html).
86
+
87
+ ```bash
88
+ pip install relik[serve]
89
+ ```
90
+
91
+ #### Installation from source
92
+
93
+ ```bash
94
+ git clone https://github.com/SapienzaNLP/relik.git
95
+ cd relik
96
+ pip install -e .[all]
97
+ ```
98
+
99
+ </details>
100
+
101
+ ## πŸš€ Quick Start
102
+
103
+ [//]: # (Write a short description of the model and how to use it with the `from_pretrained` method.)
104
+
105
+ ReLiK is a lightweight and fast model for **Entity Linking** and **Relation Extraction**.
106
+ It is composed of two main components: a retriever and a reader.
107
+ The retriever is responsible for retrieving relevant documents from a large collection,
108
+ while the reader is responsible for extracting entities and relations from the retrieved documents.
109
+ ReLiK can be used with the `from_pretrained` method to load a pre-trained pipeline.
110
+
111
+ Here is an example of how to use ReLiK for **Entity Linking**:
112
+
113
+ ```python
114
+ from relik import Relik
115
+ from relik.inference.data.objects import RelikOutput
116
+
117
+ relik = Relik.from_pretrained("sapienzanlp/relik-entity-linking-large")
118
+ relik_out: RelikOutput = relik("Michael Jordan was one of the best players in the NBA.")
119
+ ```
120
+
121
+ RelikOutput(
122
+ text="Michael Jordan was one of the best players in the NBA.",
123
+ tokens=['Michael', 'Jordan', 'was', 'one', 'of', 'the', 'best', 'players', 'in', 'the', 'NBA', '.'],
124
+ id=0,
125
+ spans=[
126
+ Span(start=0, end=14, label="Michael Jordan", text="Michael Jordan"),
127
+ Span(start=50, end=53, label="National Basketball Association", text="NBA"),
128
+ ],
129
+ triples=[],
130
+ candidates=Candidates(
131
+ span=[
132
+ [
133
+ [
134
+ {"text": "Michael Jordan", "id": 4484083},
135
+ {"text": "National Basketball Association", "id": 5209815},
136
+ {"text": "Walter Jordan", "id": 2340190},
137
+ {"text": "Jordan", "id": 3486773},
138
+ {"text": "50 Greatest Players in NBA History", "id": 1742909},
139
+ ...
140
+ ]
141
+ ]
142
+ ]
143
+ ),
144
+ )
145
+
146
+ ## πŸ“Š Performance
147
+
148
+ 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:
149
+
150
+ | Model | AIDA | MSNBC | Der | K50 | R128 | R500 | O15 | O16 | Tot | OOD | AIT (m:s) |
151
+ |------------------------------------------|------|-------|------|------|------|------|------|------|------|------|------------|
152
+ | GENRE | 83.7 | 73.7 | 54.1 | 60.7 | 46.7 | 40.3 | 56.1 | 50.0 | 58.2 | 54.5 | 38:00 |
153
+ | EntQA | 85.8 | 72.1 | 52.9 | 64.5 | **54.1** | 41.9 | 61.1 | 51.3 | 60.5 | 56.4 | 20:00 |
154
+ | [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 |
155
+ | ➑️ [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 |
156
+
157
+ 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),
158
+ N3-RSS-500 (R500), OKE-15 (O15), and OKE-16 (O16) test sets. **Bold** indicates the best model.
159
+ GENRE uses mention dictionaries.
160
+ 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,
161
+ except for EntQA which does not fit in 24GB of RAM and for which an A100 is used.
162
+
163
+ ## πŸ€– Models
164
+
165
+ Models can be found on [πŸ€— Hugging Face](https://huggingface.co/collections/sapienzanlp/relik-retrieve-read-and-link-665d9e4a5c3ecba98c1bef19).
166
+
167
+ ## πŸ’½ Cite this work
168
+
169
+ If you use any part of this work, please consider citing the paper as follows:
170
+
171
+ ```bibtex
172
+ @inproceedings{orlando-etal-2024-relik,
173
+ title = "Retrieve, Read and LinK: Fast and Accurate Entity Linking and Relation Extraction on an Academic Budget",
174
+ author = "Orlando, Riccardo and Huguet Cabot, Pere-Llu{\'\i}s and Barba, Edoardo and Navigli, Roberto",
175
+ booktitle = "Findings of the Association for Computational Linguistics: ACL 2024",
176
+ month = aug,
177
+ year = "2024",
178
+ address = "Bangkok, Thailand",
179
+ publisher = "Association for Computational Linguistics",
180
+ }
181
+ ```