• Stars
    star
    333
  • Rank 121,895 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pytorch implementation of R-BERT: "Enriching Pre-trained Language Model with Entity Information for Relation Classification"

R-BERT

PWC

(Unofficial) Pytorch implementation of R-BERT: Enriching Pre-trained Language Model with Entity Information for Relation Classification

Model Architecture

Method

  1. Get three vectors from BERT.
    • [CLS] token vector
    • averaged entity_1 vector
    • averaged entity_2 vector
  2. Pass each vector to the fully-connected layers.
    • dropout -> tanh -> fc-layer
  3. Concatenate three vectors.
  4. Pass the concatenated vector to fully-connect layer.
    • dropout -> fc-layer
  • Exactly the SAME conditions as written in paper.
    • Averaging on entity_1 and entity_2 hidden state vectors, respectively. (including $, # tokens)
    • Dropout and Tanh before Fully-connected layer.
    • No [SEP] token at the end of sequence. (If you want add [SEP] token, give --add_sep_token option)

Dependencies

  • perl (For evaluating official f1 score)
  • python>=3.6
  • torch==1.6.0
  • transformers==3.3.1

How to run

$ python3 main.py --do_train --do_eval
  • Prediction will be written on proposed_answers.txt in eval directory.

Official Evaluation

$ python3 official_eval.py
# macro-averaged F1 = 88.29%
  • Evaluate based on the official evaluation perl script.
    • MACRO-averaged f1 score (except Other relation)
  • You can see the detailed result on result.txt in eval directory.

Prediction

$ python3 predict.py --input_file {INPUT_FILE_PATH} --output_file {OUTPUT_FILE_PATH} --model_dir {SAVED_CKPT_PATH}

References

More Repositories

1

JointBERT

Pytorch implementation of JointBERT: "BERT for Joint Intent Classification and Slot Filling"
Python
600
star
2

KoELECTRA

Pretrained ELECTRA Model for Korean
Python
584
star
3

KoBigBird

πŸ¦… Pretrained BigBird Model for Korean (up to 4096 tokens)
Python
201
star
4

KoBERT-Transformers

KoBERT on πŸ€— Huggingface Transformers πŸ€— (with Bug Fixed)
Python
190
star
5

DistilKoBERT

Distillation of KoBERT from SKTBrain (Lightweight KoBERT)
Python
180
star
6

GoEmotions-pytorch

Pytorch Implementation of GoEmotions 😍😒😱
Python
142
star
7

KoBERT-NER

NER Task with KoBERT (with Naver NLP Challenge dataset)
Python
90
star
8

HanBert-Transformers

HanBert on πŸ€— Huggingface Transformers πŸ€—
Python
85
star
9

KoBERT-nsmc

Naver movie review sentiment classification with KoBERT
Python
76
star
10

transformers-android-demo

πŸ“² Transformers android examples (Tensorflow Lite & Pytorch Mobile)
Java
76
star
11

KoBERT-KorQuAD

Korean MRC (KorQuAD) with KoBERT
Python
66
star
12

nlp-arxiv-daily

Automatically Update NLP Papers Daily using Github Actions (ref: https://github.com/Vincentqyw/cv-arxiv-daily)
Python
63
star
13

EncT5

Pytorch Implementation of EncT5: Fine-tuning T5 Encoder for Non-autoregressive Tasks
Python
58
star
14

NER-Multimodal-pytorch

Pytorch Implementation of "Adaptive Co-attention Network for Named Entity Recognition in Tweets" (AAAI 2018)
Python
56
star
15

KoCharELECTRA

Character-level Korean ELECTRA Model (음절 λ‹¨μœ„ ν•œκ΅­μ–΄ ELECTRA)
Python
53
star
16

GoEmotions-Korean

Korean version of GoEmotions Dataset 😍😒😱
Python
50
star
17

hashtag-prediction-pytorch

Multimodal Hashtag Prediction with instagram data & pytorch (2nd Place on OpenResource Hackathon 2019)
Python
47
star
18

KoELECTRA-Pipeline

Transformers Pipeline with KoELECTRA
Python
40
star
19

ko_lm_dataformat

A utility for storing and reading files for Korean LM training πŸ’Ύ
Python
36
star
20

korean-ner-pytorch

NER Task with CNN + BiLSTM + CRF (with Naver NLP Challenge dataset) with Pytorch
Python
27
star
21

korean-hate-speech-koelectra

Bias, Hate classification with KoELECTRA πŸ‘Ώ
Python
26
star
22

python-template

Python template code
Makefile
21
star
23

naver-nlp-challenge-2018

NER task for Naver NLP Challenge 2018 (3rd Place)
Python
19
star
24

BIO-R-BERT

R-BERT on DDI Bio dataset with BioBERT
Python
17
star
25

HanBert-NER

NER Task with HanBert (with Naver NLP Challenge dataset)
Python
16
star
26

kakaotrans

[Unofficial] Kakaotrans: Kakao translate API for python
Python
15
star
27

py-backtrans

Python library for backtranslation (with Google Translate)
Python
12
star
28

dotfiles

Simple setup for personal dotfiles
Shell
10
star
29

monologg

Profile repository
9
star
30

kobert2transformers

KoBERT to transformers library format
Python
7
star
31

ner-sample

NER Sample Code
Python
7
star
32

HanBert-nsmc

Naver movie review sentiment classification with HanBert
Python
4
star
33

torchserve-practice

Python
4
star
34

monologg.github.io

Personal Blog https://monologg.github.io
CSS
3
star