SPECTER2 has been trained on over 6M triplets of scientific paper citations, which are available here. Post that it is trained with additionally attached task format specific adapter modules on all the SciRepEval training tasks.
Task Formats trained on:
It builds on the work done in SciRepEval: A Multi-Format Benchmark for Scientific Document Representations and we evaluate the trained model on this benchmark as well.
| Model | Name and HF link | Description |
|---|---|---|
| Proximity* | allenai/specter2 | Encode papers as queries and candidates eg. Link Prediction, Nearest Neighbor Search |
| Adhoc Query | allenai/specter2_adhoc_query | Encode short raw text queries for search tasks. (Candidate papers can be encoded with the proximity adapter) |
| Classification | allenai/specter2_classification | Encode papers to feed into linear classifiers as features |
| Regression | allenai/specter2_regression | Encode papers to feed into linear regressors as features |
*Proximity model should suffice for downstream task types not mentioned above
from transformers import AutoTokenizer
from adapters import AutoAdapterModel
# load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained('allenai/specter2_base')
#load base model
model = AutoAdapterModel.from_pretrained('allenai/specter2_base')
#load the adapter(s) as per the required task, provide an identifier for the adapter in load_as argument and activate it
model.load_adapter("allenai/specter2", source="hf", load_as="proximity", set_active=True)
#other possibilities: allenai/specter2_<classification|regression|adhoc_query>
papers = [{'title': 'BERT', 'abstract': 'We introduce a new language representation model called BERT'},
{'title': 'Attention is all you need', 'abstract': ' The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'}]
# concatenate title and abstract
text_batch = [d['title'] + tokenizer.sep_token + (d.get('abstract') or '') for d in papers]
# preprocess the input
inputs = self.tokenizer(text_batch, padding=True, truncation=True,
return_tensors="pt", return_token_type_ids=False, max_length=512)
output = model(**inputs)
# take the first token in the batch as the embedding
embeddings = output.last_hidden_state[:, 0, :]
For evaluation and downstream usage, please refer to https://github.com/allenai/scirepeval/blob/main/evaluation/INFERENCE.md.
The base model is trained on citation links between papers and the adapters are trained on 8 large scale tasks across the four formats. All the data is a part of SciRepEval benchmark and is available here.
The citation link are triplets in the form
{"query": {"title": ..., "abstract": ...}, "pos": {"title": ..., "abstract": ...}, "neg": {"title": ..., "abstract": ...}}
consisting of a query paper, a positive citation and a negative which can be from the same/different field of study as the query or citation of a citation.
Please refer to the SPECTER paper.
The model is trained in two stages using SciRepEval:
batch size = 1024, max input length = 512, learning rate = 2e-5, epochs = 2 warmup steps = 10% fp16 batch size = 256, max input length = 512, learning rate = 1e-4, epochs = 6 warmup = 1000 steps fp16We evaluate the model on SciRepEval, a large scale eval benchmark for scientific embedding tasks which which has [SciDocs] as a subset. We also evaluate and establish a new SoTA on MDCR, a large scale citation recommendation benchmark.
| Model | SciRepEval In-Train | SciRepEval Out-of-Train | SciRepEval Avg | MDCR(MAP, Recall@5) |
|---|---|---|---|---|
| BM-25 | n/a | n/a | n/a | (33.7, 28.5) |
| SPECTER | 54.7 | 72.0 | 67.5 | (30.6, 25.5) |
| SciNCL | 55.6 | 73.4 | 68.8 | (32.6, 27.3) |
| SciRepEval-Adapters | 61.9 | 73.8 | 70.7 | (35.3, 29.6) |
| SPECTER2 Base | 56.3 | 73.6 | 69.1 | (38.0, 32.4) |
| SPECTER2-Adapters | 62.3 | 74.1 | 71.1 | (38.4, 33.0) |
Please cite the following works if you end up using SPECTER2:
[SciRepEval paper](https://api.semanticscholar.org/CorpusID:254018137)
```bibtex
@inproceedings{Singh2022SciRepEvalAM,
title={SciRepEval: A Multi-Format Benchmark for Scientific Document Representations},
author={Amanpreet Singh and Mike D'Arcy and Arman Cohan and Doug Downey and Sergey Feldman},
booktitle={Conference on Empirical Methods in Natural Language Processing},
year={2022},
url={https://api.semanticscholar.org/CorpusID:254018137}
}