You can find the codes from this:
This article will take you to ucover the facial mask of Instruction Tuning, a new paradigm proposed by the Quoc V. team at Google. You can read the article from InstructionNER: A Multi-Task Instruction-Based Generative Framework for Few-shot NER. However, this blog aims to use the Instruction Tuning strategy,
Requirement:
- Python/3.6.8-foss-2019a
- pip install requirements.txt
- mt5-base or mt5-large
1. Transfer Data to Instruction
The issue became to seq2seq. For example, we use the template [Find the entity of {Thing} in article {Ants hurriedly carry the evening, a long road, holding the endless happiness of returning.} ?] as a seq2seq task to replace the entity extraction tasks extracting {Thing: ant, road} from {Ants hurriedly carry the evening, a long road, holding the endless happiness of returning.} You also can transfer CoLA, STS, RTE… tasks to Instruction by constructing a proper seq2seq template.
This class is developed to transfer NER to NERInstruction:
You can set the “label_mappings” as what you want to be: Abstract/Time/Quantifier/Address/Measurement/Thing/Special Name/Organization/Name.
1 | class NERInstruction(Instruction): |
From Entity Extraction:
{
"context": "Ants hurriedly carry the evening, a long road, holding the endless happiness of returning.",
"entity_type": "Thing",
"entities": [
"road",
"ant"
],
"ID": "NER_SANWEN_001"
}
To Instruction:
{
"context": "Ants hurriedly carry the evening, a long road, holding the endless happiness of returning.",
"entity_type": "Thing",
"entities": [
"road",
"ant"
],
"ID": "NER_SANWEN_001",
"target": "road, ant",
"verbalizer": "Abstract/Time/Quantifier/Address/Measurement/Thing/Special Name/Organization/Name",
"instruction": "Find the entity of {Thing} in article {Ants hurriedly carry the evening, a long road, holding the endless happiness of returning.}?",
"data_type": "ner"
}
2. Pretrain on Professional Language Data
Pretraining Language Dataset contains knowledge of Healthcare, Medical, Insurance, Finacial, Law.
1.ClassificationInstruction, 2. NLIInstruction, 3. STSInstruction, 4. PARAInstruction, 5. WeiboEmotionInstruction, 6. C3Instruction, 7. MRCInstruction, 8. WSCInstruction, 9. KEYSInstruction, 10. SUMMInstruction, 11. NERInstruction, 12. MRCInstruction. .1 | dataset2instruction = { |
3. Fine-Tune on Instruction
Few-Shot
Zero-Shot
4. Tips
1. Clean and Process Data: distribution of the Data, remove abnormal symbols, data augmentation (repetition or new relevant data).
2. Redesign the Label: the variation of SpEx-BERT. You can find this method from one entity has one specific demention.
3. Fusion of Language Models: BERT-base without fully connected layer + BERT-base without fully connected layer + … + BERT-large fully connected layer + emmbedding.