michiyasunaga/LinkBERT-large

Model

LinkBERT-large

14

1 commits

2 linked in READMEs

updated Mar 31, 2022

See the code

README

LinkBERT-large

LinkBERT-large model pretrained on English Wikipedia articles along with hyperlink information. It is introduced in the paper LinkBERT: Pretraining Language Models with Document Links (ACL 2022). The code and data are available in this repository.

Model description

LinkBERT is a transformer encoder (BERT-like) model pretrained on a large corpus of documents. It is an improvement of BERT that newly captures document links such as hyperlinks and citation links to include knowledge that spans across multiple documents. Specifically, it was pretrained by feeding linked documents into the same language model context, besides a single document.

LinkBERT can be used as a drop-in replacement for BERT. It achieves better performance for general language understanding tasks (e.g. text classification), and is also particularly effective for knowledge-intensive tasks (e.g. question answering) and cross-document tasks (e.g. reading comprehension, document retrieval).

Intended uses & limitations

The model can be used by fine-tuning on a downstream task, such as question answering, sequence classification, and token classification. You can also use the raw model for feature extraction (i.e. obtaining embeddings for input text).

How to use

To use the model to get the features of a given text in PyTorch:

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained('michiyasunaga/LinkBERT-large')
model = AutoModel.from_pretrained('michiyasunaga/LinkBERT-large')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state

For fine-tuning, you can use this repository or follow any other BERT fine-tuning codebases.

Evaluation results

When fine-tuned on downstream tasks, LinkBERT achieves the following results.

General benchmarks (MRQA and GLUE):

HotpotQATriviaQASearchQANaturalQNewsQASQuADGLUE
F1F1F1F1F1F1Avg score
BERT-base76.070.374.276.565.788.779.2
LinkBERT-base78.273.976.878.369.390.179.6
BERT-large78.173.778.379.070.991.180.7
LinkBERT-large80.878.280.581.072.692.781.1

Citation

If you find LinkBERT useful in your project, please cite the following:

@InProceedings{yasunaga2022linkbert,
  author =  {Michihiro Yasunaga and Jure Leskovec and Percy Liang},
  title =   {LinkBERT: Pretraining Language Models with Document Links},
  year =    {2022},  
  booktitle = {Association for Computational Linguistics (ACL)},  
}
bert
endpoints_compatible
exbert
feature-extraction
fill-mask
linkbert
pytorch
question-answering
text-classification
text-embeddings-inference
token-classification
transformers

Contributors

michiyasunaga

1 commits

michiyasunaga/LinkBERT-large

Model

LinkBERT-large

14

1 commits

2 linked in READMEs

updated Mar 31, 2022

See the code

README

LinkBERT-large

LinkBERT-large model pretrained on English Wikipedia articles along with hyperlink information. It is introduced in the paper LinkBERT: Pretraining Language Models with Document Links (ACL 2022). The code and data are available in this repository.

Model description

LinkBERT is a transformer encoder (BERT-like) model pretrained on a large corpus of documents. It is an improvement of BERT that newly captures document links such as hyperlinks and citation links to include knowledge that spans across multiple documents. Specifically, it was pretrained by feeding linked documents into the same language model context, besides a single document.

LinkBERT can be used as a drop-in replacement for BERT. It achieves better performance for general language understanding tasks (e.g. text classification), and is also particularly effective for knowledge-intensive tasks (e.g. question answering) and cross-document tasks (e.g. reading comprehension, document retrieval).

Intended uses & limitations

The model can be used by fine-tuning on a downstream task, such as question answering, sequence classification, and token classification. You can also use the raw model for feature extraction (i.e. obtaining embeddings for input text).

How to use

To use the model to get the features of a given text in PyTorch:

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained('michiyasunaga/LinkBERT-large')
model = AutoModel.from_pretrained('michiyasunaga/LinkBERT-large')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state

For fine-tuning, you can use this repository or follow any other BERT fine-tuning codebases.

Evaluation results

When fine-tuned on downstream tasks, LinkBERT achieves the following results.

General benchmarks (MRQA and GLUE):

HotpotQATriviaQASearchQANaturalQNewsQASQuADGLUE
F1F1F1F1F1F1Avg score
BERT-base76.070.374.276.565.788.779.2
LinkBERT-base78.273.976.878.369.390.179.6
BERT-large78.173.778.379.070.991.180.7
LinkBERT-large80.878.280.581.072.692.781.1

Citation

If you find LinkBERT useful in your project, please cite the following:

@InProceedings{yasunaga2022linkbert,
  author =  {Michihiro Yasunaga and Jure Leskovec and Percy Liang},
  title =   {LinkBERT: Pretraining Language Models with Document Links},
  year =    {2022},  
  booktitle = {Association for Computational Linguistics (ACL)},  
}
bert
endpoints_compatible
exbert
feature-extraction
fill-mask
linkbert
pytorch
question-answering
text-classification
text-embeddings-inference
token-classification
transformers

Contributors

michiyasunaga

1 commits