Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognizing textual entailment #2123

Merged
merged 9 commits into from
Mar 2, 2021
Merged

Conversation

marcelmmm
Copy link
Collaborator

Datasets and Corpus for Data involving Pairs of sentences/paragraphs (DataPairDataset and DataPairCorpus) and a Classifier that can dead with this kind of Data (BiCrossClassifier).

@alanakbik
Copy link
Collaborator

alanakbik commented Mar 2, 2021

Example script to train RTE task of GLUE benchmark:

import torch

from flair.data import Corpus
from flair.datasets import GLUE_RTE
from flair.embeddings import TransformerDocumentEmbeddings

# 1. get the entailment corpus
corpus: Corpus = GLUE_RTE()

# 2. make the tag dictionary from the corpus
label_dictionary = corpus.make_label_dictionary()

# 3. initialize text pair tagger
from flair.models import TextPairClassifier

tagger = TextPairClassifier(
    document_embeddings=TransformerDocumentEmbeddings(),
    label_dictionary=label_dictionary,
)

# 4. train trainer with AdamW
from flair.trainers import ModelTrainer

trainer = ModelTrainer(tagger, corpus, optimizer=torch.optim.AdamW)

# 5. run training
trainer.train('resources/taggers/glue-rte-english',
              learning_rate=2e-5,
              mini_batch_chunk_size=2, # this can be removed if you hae a big GPU
              train_with_dev=True,
              max_epochs=3)

@alanakbik alanakbik merged commit 9b46ccd into master Mar 2, 2021
@alanakbik alanakbik deleted the recognizing_textual_entailment branch March 2, 2021 12:00
@alanakbik
Copy link
Collaborator

@marcelmmm thanks a lot for adding this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants