Iker commited on
Commit
26a99dd
·
1 Parent(s): e625e50

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +108 -180
README.md CHANGED
@@ -14,228 +14,156 @@ language:
14
  metrics:
15
  - f1
16
  pipeline_tag: text-generation
 
 
 
 
 
 
 
 
 
17
  ---
18
- # Model Card for Model ID
19
 
20
- GoLLIE **G**uideline-f**o**llowing **L**arge **L**anguage Model for **IE**, is a model able to improve zero-shot results on unseen IE tasks by virtue of being fine-tuned to comply with annotation guidelines.
 
 
 
 
21
 
22
- ## Model Details
23
 
24
- ```Python
25
-
26
- # The following lines describe the task definition
27
- @dataclass
28
- class PersonTemplate(Template):
29
- """Person templates encodes the information about the given query
30
- Person entity."""
31
- query: str # The Person entity query
32
- alternate_names: Optional[List[Name]] = None
33
- """Names used to refer to the query person that are distinct from the
34
- 'official' name. Including: aliases, stage names, abbreviations ..."""
35
- date_of_birth: Optional[Value] = None
36
- """The date on which the query person was born."""
37
- age: Optional[Value] = None
38
- """A reported age of the query person."""
39
- city_of_birth: Optional[Name] = None
40
- """The geopolitical entity at the municipality level (city, town, or
41
- village) in which the query person was born"""
42
- date_of_death: Optional[Value] = None
43
- """The date of the query person's death."""
44
-
45
- # This is the text to analyze
46
- text = "Mongolian Prime Minister M. Enkhbold arrived on Monday. "
47
- # The annotation instances that take place in the text above are listed here
48
- result = [
49
- PersonTemplate(
50
- query="M. Enkhbold",
51
- countries_of_residence=[Name("Mongolian")],
52
- title=[String("Prime Minister")],
53
- ),
54
- ]
55
 
56
- ```
57
 
 
 
58
 
59
- ### Model Description
 
 
 
 
 
60
 
61
- <!-- Provide a longer summary of what this model is. -->
 
 
62
 
63
 
 
64
 
65
- - **Developed by:** Oscar Sainz, Iker García-Ferrero, Rodrigo Agerri, Oier Lopez de Lacalle, German Rigau, Eneko Agirre
66
- - **Institution:** HiTZ Basque Center for Language Technology - Ixa, University of the Basque Country UPV/EHU
67
- - **Model type:** CODE-LLaMA2
68
  - **Language(s) (NLP):** English
69
  - **License:** LLaMA2 License for the base and merged model. Apache 2.0 for pre-trained LoRA Adapters
70
- - **Finetuned from model [optional]:** CODE-LLaMA2
71
-
72
- ### Model Sources [optional]
73
-
74
- - **Repository:** https://github.com/osainz59/CoLLIE
75
- - **Paper [optional]:** **Coming soon**
76
- - **Demo [optional]:** **Coming soon**
77
-
78
- ## Uses
79
-
80
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
81
-
82
- ### Direct Use
83
-
84
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
85
-
86
- [More Information Needed]
87
-
88
- ### Downstream Use [optional]
89
-
90
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
91
 
92
- [More Information Needed]
93
 
94
- ### Out-of-Scope Use
95
 
96
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
97
 
98
- [More Information Needed]
99
-
100
- ## Bias, Risks, and Limitations
101
-
102
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
103
-
104
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- ### Recommendations
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
 
 
 
109
 
110
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
 
 
 
111
 
112
  ## How to Get Started with the Model
113
 
114
- Use the code below to get started with the model.
115
-
116
- [More Information Needed]
117
-
118
- ## Training Details
119
-
120
- ### Training Data
121
 
122
- <!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
123
 
124
- [More Information Needed]
 
 
 
 
 
 
125
 
126
- ### Training Procedure
127
 
128
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
 
129
 
130
- #### Preprocessing [optional]
 
 
131
 
132
- [More Information Needed]
133
 
134
 
135
- #### Training Hyperparameters
136
 
137
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
138
 
139
- #### Speeds, Sizes, Times [optional]
 
140
 
141
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
142
 
143
- [More Information Needed]
144
 
145
  ## Evaluation
146
 
147
- <!-- This section describes the evaluation protocols and provides the results. -->
148
-
149
- ### Testing Data, Factors & Metrics
 
 
150
 
151
- #### Testing Data
152
-
153
- <!-- This should link to a Data Card if possible. -->
154
-
155
- [More Information Needed]
156
-
157
- #### Factors
158
-
159
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
160
-
161
- [More Information Needed]
162
-
163
- #### Metrics
164
-
165
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
166
-
167
- [More Information Needed]
168
-
169
- ### Results
170
-
171
- [More Information Needed]
172
-
173
- #### Summary
174
-
175
-
176
-
177
- ## Model Examination [optional]
178
-
179
- <!-- Relevant interpretability work for the model goes here -->
180
-
181
- [More Information Needed]
182
 
183
  ## Environmental Impact
184
 
185
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
186
-
187
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
188
-
189
- - **Hardware Type:** [More Information Needed]
190
- - **Hours used:** [More Information Needed]
191
- - **Cloud Provider:** [More Information Needed]
192
- - **Compute Region:** [More Information Needed]
193
- - **Carbon Emitted:** [More Information Needed]
194
-
195
- ## Technical Specifications [optional]
196
-
197
- ### Model Architecture and Objective
198
-
199
- [More Information Needed]
200
-
201
- ### Compute Infrastructure
202
-
203
- [More Information Needed]
204
-
205
- #### Hardware
206
-
207
- [More Information Needed]
208
-
209
- #### Software
210
-
211
- [More Information Needed]
212
-
213
- ## Citation [optional]
214
-
215
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
216
-
217
- **BibTeX:**
218
-
219
- [More Information Needed]
220
-
221
- **APA:**
222
-
223
- [More Information Needed]
224
-
225
- ## Glossary [optional]
226
-
227
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
228
-
229
- [More Information Needed]
230
-
231
- ## More Information [optional]
232
-
233
- [More Information Needed]
234
-
235
- ## Model Card Authors [optional]
236
 
237
- [More Information Needed]
238
 
239
- ## Model Card Contact
240
 
241
- [More Information Needed]
 
14
  metrics:
15
  - f1
16
  pipeline_tag: text-generation
17
+ tags:
18
+ - code
19
+ - text-generation-inference
20
+ - Information Extraction
21
+ - IE
22
+ - Named Entity Recogniton
23
+ - Event Extraction
24
+ - Relation Extraction
25
+ - LLaMA
26
  ---
 
27
 
28
+ <p align="center">
29
+ <br>
30
+ <img src="assets/GoLLIE.png" style="height: 250px;">
31
+ <br>
32
+ <h2 align="center"><b>G</b>uideline f<b>o</b>llowing <b>L</b>arge <b>L</b>anguage Model for <b>I</b>nformation <b>E</b>xtraction</h2>
33
 
 
34
 
35
+ # Model Card for GoLLIE 7B
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
 
37
 
38
+ <p align="justify">
39
+ We present <img src="assets/GoLLIE.png" width="20"> GoLLIE, a Large Language Model trained to follow annotation guidelines. GoLLIE outperforms previous approaches on zero-shot Information Extraction and allows the user to perform inferences with annotation schemas defined on the fly. Different from previous approaches, GoLLIE is able to follow detailed definitions and does not only rely on the knowledge already encoded in the LLM. Code and models are publicly available.
40
 
41
+ - 💻 Code: [https://github.com/osainz59/CoLLIE/](https://github.com/osainz59/CoLLIE/)
42
+ - 📒 Blog Post: [GoLLIE: Guideline-following Large Language Model for Information Extraction](docs/index.md)
43
+ - 📖 Paper: [GoLLIE: Annotation Guidelines improve Zero-Shot Information-Extraction]()
44
+ - <img src="assets/GoLLIE.png" width="20">GoLLIE in the 🤗HuggingFace Hub: [HiTZ/gollie](https://huggingface.co/collections/HiTZ/gollie-651bf19ee315e8a224aacc4f)
45
+ - 🚀 Example Jupyter Notebooks: [GoLLIE Notebooks](notebooks/)
46
+ </p>
47
 
48
+ <p align="center">
49
+ <img src="assets/zero_shot_results.png">
50
+ </p>
51
 
52
 
53
+ ### Model Description
54
 
55
+ - **Developed by:** [Oscar Sainz](https://osainz59.github.io/), [Iker García-Ferrero](https://ikergarcia1996.github.io/Iker-Garcia-Ferrero/), [Rodrigo Agerri](https://ragerri.github.io/), [Oier Lopez de Lacalle](https://oierldl.github.io/), [German Rigau](https://adimen.si.ehu.es/~rigau/) and [Eneko Agirre](https://eagirre.github.io/)
56
+ - **Institution:** [HiTZ Basque Center for Language Technology](http://www.hitz.eus/) - [Ixa](https://www.ixa.eus/node/2?language=en), [University of the Basque Country UPV/EHU](https://www.ehu.eus/en/en-home)
57
+ - **Model type:** Text Generation
58
  - **Language(s) (NLP):** English
59
  - **License:** LLaMA2 License for the base and merged model. Apache 2.0 for pre-trained LoRA Adapters
60
+ - **Finetuned from model:** CODE-LLaMA2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
 
62
 
 
63
 
64
+ ## Schema definition and inference example
65
 
66
+ The labels are represented as Python classes, and the guidelines or instructions are introduced as docstrings. The model start generating after the `result = [` line.
67
+ ```Python
68
+ # Entity definitions
69
+ @dataclass
70
+ class Launcher(Template):
71
+ """Refers to a vehicle designed primarily to transport payloads from the Earth's
72
+ surface to space. Launchers can carry various payloads, including satellites,
73
+ crewed spacecraft, and cargo, into various orbits or even beyond Earth's orbit.
74
+ They are usually multi-stage vehicles that use rocket engines for propulsion."""
75
+
76
+ mention: str
77
+ """
78
+ The name of the launcher vehicle.
79
+ Such as: "Sturn V", "Atlas V", "Soyuz", "Ariane 5"
80
+ """
81
+ space_company: str # The company that operates the launcher. Such as: "Blue origin", "ESA", "Boeing", "ISRO", "Northrop Grumman", "Arianespace"
82
+ crew: List[str] # Names of the crew members boarding the Launcher. Such as: "Neil Armstrong", "Michael Collins", "Buzz Aldrin"
83
+
84
 
85
+ @dataclass
86
+ class Mission(Template):
87
+ """Any planned or accomplished journey beyond Earth's atmosphere with specific objectives,
88
+ either crewed or uncrewed. It includes missions to satellites, the International
89
+ Space Station (ISS), other celestial bodies, and deep space."""
90
+
91
+ mention: str
92
+ """
93
+ The name of the mission.
94
+ Such as: "Apollo 11", "Artemis", "Mercury"
95
+ """
96
+ date: str # The start date of the mission
97
+ departure: str # The place from which the vehicle will be launched. Such as: "Florida", "Houston", "French Guiana"
98
+ destination: str # The place or planet to which the launcher will be sent. Such as "Moon", "low-orbit", "Saturn"
99
 
100
+ # This is the text to analyze
101
+ text = (
102
+ "The Ares 3 mission to Mars is scheduled for 2032. The Starship rocket build by SpaceX will take off from Boca Chica,"
103
+ "carrying the astronauts Max Rutherford, Elena Soto, and Jake Martinez."
104
+ )
105
 
106
+ # The annotation instances that take place in the text above are listed here
107
+ result = [
108
+ Mission(mention='Ares 3', date='2032', departure='Boca Chica', destination='Mars'),
109
+ Launcher(mention='Starship', space_company='SpaceX', crew=['Max Rutherford', 'Elena Soto', 'Jake Martinez'])
110
+ ]
111
+ ```
112
 
113
  ## How to Get Started with the Model
114
 
115
+ Please read our [🚀 Example Jupyter Notebooks](notebooks/) to get started with GoLLIE.
 
 
 
 
 
 
116
 
117
+ The best way to load the model is using our custom `load_model` fuction. However, you can also load them using the AutoModelForCausalLM class.
118
 
119
+ **Important**: Our flash attention implementation has small numerical differences compared to the attention implementation in Huggingface.
120
+ You must use the flag `trust_remote_code=True` or you will get inferior results. Flash attention requires an available CUDA GPU. Running GOLLIE
121
+ pre-trained models on a CPU is not supported. We plan to address this in future releases. First, install flash attention 2:
122
+ ```bash
123
+ pip install flash-attn --no-build-isolation
124
+ pip install git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/rotary
125
+ ```
126
 
127
+ Then you can load the model using
128
 
129
+ ```python
130
+ from transformers import AutoTokenizer, AutoModelForCausalLM
131
 
132
+ tokenizer = AutoTokenizer.from_pretrained("HiTZ/GoLLIE-7B")
133
+ model = AutoModelForCausalLM.from_pretrained("HiTZ/GoLLIE-7B", trust_remote_code=True)
134
+ ```
135
 
136
+ Read our [🚀 Example Jupyter Notebooks](notebooks/) to learn how to easily define guidelines, generate model inputs and parse the output!
137
 
138
 
 
139
 
140
+ ### Training Data
141
 
142
+ This is the list of task used for training and evaluating GoLLIE. However, as demonstrated in the 🚀 [Create Custom Task notebook](notebooks/Create%20Custom%20Task.ipynb) GoLLIE can perform a wide range of unseen tasks.
143
+ For more info, read our [📖Paper]().
144
 
145
+ <p align="center">
146
+ <img src="assets/datasets.png">
147
+ </p>
148
 
 
149
 
150
  ## Evaluation
151
 
152
+ | Model | Supervised average F1 | Zero-shot average F1 | 🤗HuggingFace Hub |
153
+ |---|:---------------------:|:--------------------:|:---------------------------------------------------------:|
154
+ | GoLLIE-7B | 73.0 | 55.3 | [HiTZ/GoLLIE-7B](https://huggingface.co/HiTZ/GoLLIE-7B) |
155
+ | GoLLIE-13B | 73.9 | 56.0 | [HiTZ/GoLLIE-13B](https://huggingface.co/HiTZ/GoLLIE-13B) |
156
+ | GoLLIE-34B | **75.0** | **57.2** | [HiTZ/GoLLIE-34B](https://huggingface.co/HiTZ/GoLLIE-34B) |
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
  ## Environmental Impact
160
 
161
+ | Model | Hardware | FLOPs | Time (h) | CO<sup>2</sup>eq (kg) |
162
+ |----------------|-------------------|---------------------------|-------------------|-------------------------------------|
163
+ | <img src="assets/GoLLIE.png" width="20">GoLLIE 7B | 1xA100 | 11.9e<sup>18</sup> | 44.5 | 1.57 |
164
+ | <img src="assets/GoLLIE.png" width="20">GoLLIE 13B | 1xA100 | 22.7e<sup>18</sup> | 79.5 | 2.80 |
165
+ | <img src="assets/GoLLIE.png" width="20">GoLLIE 34B | 2xA100 | 55.8e<sup>18</sup> | 94.6 | 6.67 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
 
167
 
 
168
 
169
+ ## Citation