Giter VIP home page Giter VIP logo

fewrel_zero_shot's Introduction

Introduction

Code for the paper Exploring the zero-shot limit of FewRel. This repository implements a zero-shot relation extractor.

Dataset

The dataset FewRel 1.0 has been created in the paper FewRel: A Large-Scale Few-Shot Relation Classification Dataset with State-of-the-Art Evaluation and is available here.

Run the Extractor from the notebook

An example relation extraction is in this notebook. The extractor needs a list of candidate relations in English

relations = ['noble title', 'founding date', 'occupation of a person']
extractor = RelationExtractor(model, tokenizer, relations)

Then the model ranks the surface forms by the belief that the relation connects the entities in the text

extractor.rank(text='John Smith received an OBE', head='John Smith', tail='OBE')

[('noble title', 0.9690611883997917),
 ('occupation of a person', 0.0012609362602233887),
 ('founding date', 0.00024014711380004883)]

Training

This repository contains 4 training scripts related to the 4 models in the paper.

train_bert_large_with_squad.py
train_bert_large_without_squad.py
train_distillbert_with_squad.py
train_distillbert_without_squad.py

Validation

There are also 4 scripts for validation

test_bert_large_with_squad.py
test_bert_large_without_squad.py
test_distillbert_with_squad.py
test_distillbert_without_squad.py

The results as in the paper are

Model 0-shot 5-ways 0-shot 10-ways
(1) Distillbert 70.1±0.5 55.9±0.6
(2) Bert Large 80.8±0.4 69.6±0.5
(3) Distillbert + SQUAD 81.3±0.4 70.0±0.2
(4) Bert Large + SQUAD 86.0±0.6 76.2±0.4

Cite as

@inproceedings{cetoli-2020-exploring,
    title = "Exploring the zero-shot limit of {F}ew{R}el",
    author = "Cetoli, Alberto",
    booktitle = "Proceedings of the 28th International Conference on Computational Linguistics",
    month = dec,
    year = "2020",
    address = "Barcelona, Spain (Online)",
    publisher = "International Committee on Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2020.coling-main.124",
    doi = "10.18653/v1/2020.coling-main.124",
    pages = "1447--1451",
    abstract = "This paper proposes a general purpose relation extractor that uses Wikidata descriptions to represent the relation{'}s surface form. The results are tested on the FewRel 1.0 dataset, which provides an excellent framework for training and evaluating the proposed zero-shot learning system in English. This relation extractor architecture exploits the implicit knowledge of a language model through a question-answering approach.",
}

fewrel_zero_shot's People

Contributors

fractalego avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

vhientran

fewrel_zero_shot's Issues

This line may casue some false negative samples

Thanks for your opening source. This is excellent work. I looked carefully and found something that could be improved.

As all_relations is read from the file "all_train_relations.txt", which contains 699 labels for each relation, the candidates still contains the labels for the correct relation after the `remove' operation. Thus, the sampled candidate negative labels have a relatively low probability of belonging to the correct relation. According to my computation, this probability is close to 14.02%.

`all_relations = list(set(all_relations))' could fix this potential risk.

Few-Shot Relation Extraction

Hi! Thank you so much for this work.

I have a question: is it possible to extract relations in a Few-Shot approach?
For example, instead of giving only the surface forms of the desired relations, I would also give 1 or 5 examples for each relation.
If you could give me some examples about how to do it or include this functionality in the code I would really appreciate it.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.