Update README.md
Browse files
README.md
CHANGED
@@ -1,8 +1,90 @@
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: meta-llama/Meta-Llama-3-8B-Instruct
|
|
|
|
|
|
|
4 |
---
|
5 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
### Framework versions
|
8 |
|
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: meta-llama/Meta-Llama-3-8B-Instruct
|
4 |
+
license: apache-2.0
|
5 |
+
language:
|
6 |
+
- en
|
7 |
---
|
8 |
+
## Overview
|
9 |
+
|
10 |
+
The model is a LoRa Adaptor based on LLaMA-3-8B-Instruct. The model has been trained on a [re-annotated version](https://github.com/Teddy-Li/MulVOIEL/tree/master/CaRB/data) of the [CaRB dataset](https://github.com/dair-iitd/CaRB).
|
11 |
+
|
12 |
+
The model produces multi-valent Open IE tuples, i.e. relations with various numbers of arguments (1, 2, or more). We provide an example below:
|
13 |
+
|
14 |
+
Consider the following sentence (taken from the CaRB dev set):
|
15 |
+
|
16 |
+
`Earlier this year , President Bush made a final `` take - it - or - leave it '' offer on the minimum wage`
|
17 |
+
|
18 |
+
Our model would extract the following relation from the sentence:
|
19 |
+
|
20 |
+
<<span style="color:#2471A3">President Bush</span>, <span style="color:#A93226">made</span>, <span style="color:#138D75">a final "take-it-or-leave-it" offer</span>, <span style="color:#B7950B ">on the minimum wage</span>, <span style="color:#B9770E">earlier this year</span>>
|
21 |
+
|
22 |
+
where we include <span style="color:#2471A3">President Bush</span> as the <span style="color:#2471A3">subject</span>, <span style="color:#A93226">made</span> as the <span style="color:#A93226">object</span>, <span style="color:#138D75">a final "take-it-or-leave-it" offer</span> as the<span style="color:#138D75">direct object</span>, and <span style="color:#B7950B ">on the minimum wage</span> and <span style="color:#B9770E">earlier this year</span>> as salient <span style="color:#B7950B">_compl_</span><span style="color:#B9770E">_ements_</span>.
|
23 |
+
|
24 |
+
We briefly describe how to use our model in the below, and provide further details in our [MulVOIEL repository on Github](https://github.com/Teddy-Li/MulVOIEL/)
|
25 |
+
|
26 |
+
|
27 |
+
## Getting Started
|
28 |
+
|
29 |
+
### Model Output Format
|
30 |
+
|
31 |
+
Given a sentence, the model produces textual predictions in the following format:
|
32 |
+
|
33 |
+
`<subj> ,, (<auxi> ###) <predicate> ,, (<prep1> ###) <obj1>, (<prep2> ###) <obj2>, ...`
|
34 |
+
|
35 |
+
### How to Use
|
36 |
+
|
37 |
+
1. Install the relevant libraries (using the LLaMA3-8b-instruct model as an example):
|
38 |
+
```bash
|
39 |
+
pip install transformers datasets peft torch
|
40 |
+
```
|
41 |
+
|
42 |
+
2. Load the model and perform inference (example):
|
43 |
+
```python
|
44 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
45 |
+
from peft import PeftModel
|
46 |
+
import torch
|
47 |
+
from llamaOIE import parse_outstr_to_triples
|
48 |
+
from llamaOIE_dataset import prepare_input
|
49 |
+
|
50 |
+
base_model_name = "meta-llama/Meta-Llama-3-8B-Instruct"
|
51 |
+
peft_adapter_name = "Teddy487/LLaMA3-8b-for-OpenIE"
|
52 |
+
|
53 |
+
model = AutoModelForCausalLM.from_pretrained(base_model_name)
|
54 |
+
model = PeftModel.from_pretrained(model, peft_adapter_name)
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
|
56 |
+
|
57 |
+
input_text = "Earlier this year , President Bush made a final `` take - it - or - leave it '' offer on the minimum wage"
|
58 |
+
input_text, _ = prepare_input({'s': input_text}, tokenizer, has_labels=False)
|
59 |
+
|
60 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
61 |
+
|
62 |
+
outputs = model.generate(input_ids)
|
63 |
+
outstr = tokenizer.decode(outputs[0][len(input_ids):], skip_special_tokens=True)
|
64 |
+
triples = parse_outstr_to_triples(outstr)
|
65 |
+
|
66 |
+
for tpl in triples:
|
67 |
+
print(tpl)
|
68 |
+
```
|
69 |
+
|
70 |
+
🍺
|
71 |
+
|
72 |
+
## Model Performance
|
73 |
+
|
74 |
+
The primary benefit of our model is the ability to extract finer-grained information for predicates. On the other hand, we also report performance on a roughly comparable basis with prior SOTA open IE models, where our method is comparable and even superior to prior models, while producing finer-grained and more complex outputs. We report evaluation results in (macro) F-1 metric, as well as in the average [Levenshtein Distance](https://pypi.org/project/python-Levenshtein/) between gold and predicted relations:
|
75 |
+
|
76 |
+
| Model | Levenshtein Distance | Macro F-1 |
|
77 |
+
| --- | --- | --- | --- |
|
78 |
+
| [LoRA LLaMA2-7b](https://huggingface.co/Teddy487/LLaMA2-7b-for-OpenIE) | 5.85 | 50.21% |
|
79 |
+
| [LoRA LLaMA3-8b](https://huggingface.co/Teddy487/LLaMA3-8b-for-OpenIE) | 5.04 | 55.32% |
|
80 |
+
| RNN OIE * | - | 49.0 |
|
81 |
+
| IMOJIE * | - | 53.5 |
|
82 |
+
| Open IE 6 * | - | 54.0/52.7 |
|
83 |
+
|
84 |
+
Note that the precision and recall values are not directly comparable, because we evaluate the model prediction at a finer granularity, and we use different train/dev/test arrangements as the original CaRB dataset, hence the asterisk.
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
|
89 |
### Framework versions
|
90 |
|