Code Monkey home page Code Monkey logo

pytorch-transformers's Introduction

#Supporting code for paper Ablations over Transformer Models for Biomedical Relationship Extraction

This repo is a fork of HuggingFace/Transformers, with some extensions to demonstrate the code used in the paper Ablations over Transformer Models for Biomedical Relationship Extraction.

run_semeval.py: relationship classification using R-Bert

R-BERT is a relationship classification head for BERT and RoBERTa, described here.

This example code fine-tunes R-BERT on the semeval 2010 Task 8 dataset:

python ./examples/run_semeval.py \
--data_dir $SEMEVAL_DIR \
--output_dir $RESULTS_DIR \
--model_name_or_path bert-base-uncased \
--do_train \
--do_eval \
--overwrite_output_dir \
--num_train_epochs 8.0 \
--per_gpu_train_batch_size 16 \
--per_gpu_eval_batch_size 16 \
--learning_rate 2e-5 \
--max_seq_length 128 \
--task_name semeval2010_task8 \
--train_on_other_labels \
--eval_on_other_labels \
--include_directionality

The $SEMEVAL_DIR should point to the extracted archive.

The --include_directionality flag trains a classifier using all 18 semeval classes. The --train_on_other_labels and --eval_on_other_labels flags also include instances labeled as 'Other' in the training and evaluation respectively. Include all of these to be able to use the official evaluation script.

Note, although an F1 score is calculated in the python code, two additional files are also written out at the checkpoint intervals {global_step}_semeval_results.tsv that may be used with the official Semeval evaluation script (supplied in the semeval data archive). The dataset is available under Creative Commons Atrribution 3.0 Unported Licence (http://creativecommons.org/licenses/by/3.0/) and is available here.

for example, using BERT:

./semeval2010_task8_scorer-v1.2.pl $SEMEVAL_DIR/{global_step}_semeval_results.tsv $SEMEVAL_DIR/TEST_FILE_SEMEVAL_SCRIPT_FORMAT.tsv 

However, the RoBERTa model can also be used with this head:

python ./examples/run_semeval.py \
--data_dir $SEMEVAL_DIR \
--output_dir $RESULTS_DIR \
--model_name_or_path roberta-large \
--model_type roberta \
--do_train \
--do_eval \
--overwrite_output_dir \
--num_train_epochs 8.0 \
--per_gpu_train_batch_size 16 \
--per_gpu_eval_batch_size 16 \
--learning_rate 2e-5 \
--max_seq_length 128 \
--task_name semeval2010_task8 \
--train_on_other_labels \
--eval_on_other_labels \
--include_directionality

pytorch-transformers's People

Contributors

8enmann avatar ananyahjha93 avatar catalinvoss avatar crafterkolyan avatar davidefiocco avatar dhanajitb avatar feiwang96 avatar guillemgsubies avatar guotong1988 avatar joelgrus avatar julien-c avatar liangtaiwan avatar lukovnikov avatar lysandrejik avatar morizeyao avatar mottox avatar pingnie1 avatar richjackson avatar rocketknight1 avatar rodgzilla avatar samuelbroscheit avatar shijie-wu avatar stefan-it avatar tholor avatar thomwolf avatar trault14 avatar victorsanh avatar yongbowin avatar yzy5630 avatar ziliwang avatar

Watchers

 avatar

Forkers

synergetic-ai

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.