KomeijiForce commited on
Commit
2a0a46c
1 Parent(s): b1a5cab

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -3
README.md CHANGED
@@ -1,3 +1,77 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: roberta-large
4
+ language:
5
+ - en
6
+ metrics:
7
+ - f1
8
+ pipeline_tag: token-classification
9
+ ---
10
+
11
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
12
+ should probably proofread and complete it, then remove this comment. -->
13
+
14
+ # MetaIE (Academia)
15
+
16
+ This is a meta-model distilled from ChatGPT-4o for information extraction **in the academic domain**. This is an intermediate checkpoint that can be well-transferred to all kinds of downstream information extraction tasks. This model can also be tested by different label-to-span matching as shown in the following example:
17
+
18
+ ```python
19
+ from transformers import AutoModelForTokenClassification, AutoTokenizer
20
+ from nltk import word_tokenize
21
+ import torch
22
+
23
+ device = torch.device("cuda:1")
24
+ path = f"KomeijiForce/roberta-large-metaie-super-academia-gpt4o"
25
+ tokenizer = AutoTokenizer.from_pretrained(path)
26
+ tagger = AutoModelForTokenClassification.from_pretrained(path).to(device)
27
+
28
+ def find_sequences(lst):
29
+ sequences = []
30
+ i = 0
31
+ while i < len(lst):
32
+ if lst[i] == 0:
33
+ start = i
34
+ end = i
35
+ i += 1
36
+ while i < len(lst) and lst[i] == 1:
37
+ end = i
38
+ i += 1
39
+ sequences.append((start, end+1))
40
+ else:
41
+ i += 1
42
+ return sequences
43
+
44
+ passage = '''MetaIE: Distilling a Meta Model from LLM for All Kinds of Information Extraction Tasks
45
+
46
+ Information extraction (IE) is a fundamental area in natural language processing where prompting large language models (LLMs), even with in-context examples, cannot defeat small LMs tuned on very small IE datasets. We observe that IE tasks, such as named entity recognition and relation extraction, all focus on extracting important information, which can be formalized as a label-to-span matching. In this paper, we propose a novel framework MetaIE to build a small LM as meta-model by learning to extract "important information", i.e., the meta-understanding of IE, so that this meta-model can be adapted to all kind of IE tasks effectively and efficiently. Specifically, MetaIE obtains the small LM via a symbolic distillation from an LLM following the label-to-span scheme. We construct the distillation dataset via sampling sentences from language model pre-training datasets (e.g., OpenWebText in our implementation) and prompting an LLM to identify the typed spans of "important information". We evaluate the meta-model under the few-shot adaptation setting. Extensive results on 13 datasets from 6 IE tasks confirm that MetaIE can offer a better starting point for few-shot tuning on IE datasets and outperform other meta-models from (1) vanilla language model pre-training, (2) multi-IE-task pre-training with human annotations, and (3) single-IE-task symbolic distillation from LLM. Moreover, we provide comprehensive analyses of MetaIE, such as the size of the distillation dataset, the meta-model architecture, and the size of the meta-model.'''
47
+
48
+
49
+ labels = [
50
+ "Research Domain",
51
+ "Tasks for MetaIE",
52
+ "Way to Build MetaIE",
53
+ "Method",
54
+ "Model Performance",
55
+ ]
56
+
57
+ for label in labels:
58
+
59
+ text = f"{label}: " + passage
60
+
61
+ inputs = tokenizer(text, return_tensors="pt").to(device)
62
+ tag_predictions = tagger(**inputs).logits[0].argmax(-1)
63
+
64
+ predictions = [tokenizer.decode(inputs.input_ids[0, seq[0]:seq[1]]).strip() for seq in find_sequences(tag_predictions)]
65
+
66
+ print(label, predictions)
67
+ ```
68
+
69
+ The output will be
70
+
71
+ ```python
72
+ Research Domain ['natural language processing']
73
+ Tasks for MetaIE ['named entity recognition', 'relation extraction']
74
+ Way to Build MetaIE ['learning to extract "important information', 'symbolic distillation from an LLM following the label']
75
+ Method ['symbolic distillation from an LLM following the label']
76
+ Model Performance ['outperform other meta-models']
77
+ ```