Update README.md
Browse files
README.md
CHANGED
|
@@ -30,14 +30,164 @@ model = AutoAdapterModel.from_pretrained("allenai/specter_plus_plus")
|
|
| 30 |
adapter_name = model.load_adapter("allenai/spp_classification", source="hf", set_active=True)
|
| 31 |
```
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
## Citation
|
| 42 |
|
| 43 |
-
<!-- Add some description here -->
|
|
|
|
| 30 |
adapter_name = model.load_adapter("allenai/spp_classification", source="hf", set_active=True)
|
| 31 |
```
|
| 32 |
|
| 33 |
+
---
|
| 34 |
+
license: apache-2.0
|
| 35 |
+
datasets:
|
| 36 |
+
- allenai/scirepeval
|
| 37 |
+
language:
|
| 38 |
+
- en
|
| 39 |
+
---
|
| 40 |
+
# SPECTER 2.0
|
| 41 |
+
|
| 42 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 43 |
+
|
| 44 |
+
SPECTER 2.0 is the successor to [SPECTER](allenai/specter) and is capable of generating task specific embeddings for scientific tasks when paired with [adapters](https://huggingface.co/models?search=allenai/spp).
|
| 45 |
+
Given the combination of title and abstract of a scientific paper or a short texual query, the model can be used to generate effective embeddings to be used in downstream applications.
|
| 46 |
+
|
| 47 |
+
# Model Details
|
| 48 |
+
|
| 49 |
+
## Model Description
|
| 50 |
+
|
| 51 |
+
SPECTER 2.0 has been trained on over 6M triplets of scientific paper citations, which are available [here](https://huggingface.co/datasets/allenai/scirepeval/viewer/cite_prediction_new/evaluation).
|
| 52 |
+
Post that it is trained on all the [SciRepEval](https://huggingface.co/datasets/allenai/scirepeval) training tasks, with task format specific adapters.
|
| 53 |
+
|
| 54 |
+
Task Formats trained on:
|
| 55 |
+
- Classification
|
| 56 |
+
- Regression
|
| 57 |
+
- Proximity
|
| 58 |
+
- Adhoc Search
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
It builds on the work done in [SciRepEval: A Multi-Format Benchmark for Scientific Document Representations](https://api.semanticscholar.org/CorpusID:254018137) and we evaluate the trained model on this benchmark as well.
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
- **Developed by:** Amanpreet Singh, Mike D'Arcy, Arman Cohan, Doug Downey, Sergey Feldman
|
| 66 |
+
- **Shared by :** Allen AI
|
| 67 |
+
- **Model type:** bert-base-uncased + adapters
|
| 68 |
+
- **License:** Apache 2.0
|
| 69 |
+
- **Finetuned from model [optional]:** [allenai/scibert](https://huggingface.co/allenai/scibert_scivocab_uncased).
|
| 70 |
+
|
| 71 |
+
## Model Sources [optional]
|
| 72 |
+
|
| 73 |
+
<!-- Provide the basic links for the model. -->
|
| 74 |
+
|
| 75 |
+
- **Repository:** [https://github.com/allenai/SPECTER2_0] (https://github.com/allenai/SPECTER2_0)
|
| 76 |
+
- **Paper [optional]:** [https://api.semanticscholar.org/CorpusID:254018137](https://api.semanticscholar.org/CorpusID:254018137)
|
| 77 |
+
- **Demo [optional]:** [Usage] (https://github.com/allenai/SPECTER2_0/blob/main/README.md)
|
| 78 |
+
|
| 79 |
+
# Uses
|
| 80 |
+
|
| 81 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 82 |
+
|
| 83 |
+
## Direct Use
|
| 84 |
+
|
| 85 |
+
|Model|Type|Name and HF link|
|
| 86 |
+
|--|--|--|
|
| 87 |
+
|Base|Transformer|[allenai/specter_plus_plus](https://huggingface.co/allenai/specter_plus_plus)|
|
| 88 |
+
|Classification|Adapter|[allenai/spp_classification](https://huggingface.co/allenai/spp_classification)|
|
| 89 |
+
|Regression|Adapter|[allenai/spp_regression](https://huggingface.co/allenai/spp_regression)|
|
| 90 |
+
|Retrieval|Adapter|[allenai/spp_proximity](https://huggingface.co/allenai/spp_proximity)|
|
| 91 |
+
|Adhoc Query|Adapter|[allenai/spp_adhoc_query](https://huggingface.co/allenai/spp_adhoc_query)|
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
from transformers import AutoTokenizer, AutoModel
|
| 95 |
+
|
| 96 |
+
# load model and tokenizer
|
| 97 |
+
tokenizer = AutoTokenizer.from_pretrained('allenai/specter_plus_plus')
|
| 98 |
+
|
| 99 |
+
#load base model
|
| 100 |
+
model = AutoModel.from_pretrained('allenai/specter_plus_plus')
|
| 101 |
+
|
| 102 |
+
#load the adapter(s) as per the required task, provide an identifier for the adapter in load_as argument and activate it
|
| 103 |
+
model.load_adapter("allenai/spp_classification", source="hf", load_as="spp_classification", set_active=True)
|
| 104 |
|
| 105 |
+
papers = [{'title': 'BERT', 'abstract': 'We introduce a new language representation model called BERT'},
|
| 106 |
+
{'title': 'Attention is all you need', 'abstract': ' The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'}]
|
| 107 |
|
| 108 |
+
# concatenate title and abstract
|
| 109 |
+
text_batch = [d['title'] + tokenizer.sep_token + (d.get('abstract') or '') for d in papers]
|
| 110 |
+
# preprocess the input
|
| 111 |
+
inputs = self.tokenizer(text_batch, padding=True, truncation=True,
|
| 112 |
+
return_tensors="pt", return_token_type_ids=False, max_length=512)
|
| 113 |
+
output = model(**inputs)
|
| 114 |
+
# take the first token in the batch as the embedding
|
| 115 |
+
embeddings = output.last_hidden_state[:, 0, :]
|
| 116 |
+
```
|
| 117 |
+
|
| 118 |
+
## Downstream Use [optional]
|
| 119 |
+
|
| 120 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 121 |
+
|
| 122 |
+
For evaluation and downstream usage, please refer to [https://github.com/allenai/scirepeval/blob/main/evaluation/INFERENCE.md](https://github.com/allenai/scirepeval/blob/main/evaluation/INFERENCE.md).
|
| 123 |
+
|
| 124 |
+
# Training Details
|
| 125 |
+
|
| 126 |
+
## Training Data
|
| 127 |
+
|
| 128 |
+
<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 129 |
+
|
| 130 |
+
The base model is trained on citation links between papers and the adapters are trained on 8 large scale tasks across the four formats.
|
| 131 |
+
All the data is a part of SciRepEval benchmark and is available [here](https://huggingface.co/datasets/allenai/scirepeval).
|
| 132 |
+
|
| 133 |
+
The citation link are triplets in the form
|
| 134 |
+
|
| 135 |
+
```json
|
| 136 |
+
{"query": {"title": ..., "abstract": ...}, "pos": {"title": ..., "abstract": ...}, "neg": {"title": ..., "abstract": ...}}
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
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.
|
| 140 |
+
|
| 141 |
+
## Training Procedure
|
| 142 |
|
| 143 |
+
Please refer to the [SPECTER paper](https://api.semanticscholar.org/CorpusID:215768677).
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
### Training Hyperparameters
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
The model is trained in two stages using [SciRepEval](https://github.com/allenai/scirepeval/blob/main/training/TRAINING.md):
|
| 150 |
+
- Base Model: First a base model is trained on the above citation triplets.
|
| 151 |
+
``` batch size = 1024, max input length = 512, learning rate = 2e-5, epochs = 2 warmup steps = 10% fp16```
|
| 152 |
+
- Adapters: Thereafter, task format specific adapters are trained on the SciRepEval training tasks, where 600K triplets are sampled from above and added to the training data as well.
|
| 153 |
+
``` batch size = 256, max input length = 512, learning rate = 1e-4, epochs = 6 warmup = 1000 steps fp16```
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
# Evaluation
|
| 157 |
+
|
| 158 |
+
We evaluate the model on [SciRepEval](https://github.com/allenai/scirepeval), a large scale eval benchmark for scientific embedding tasks which which has [SciDocs] as a subset.
|
| 159 |
+
We also evaluate and establish a new SoTA on [MDCR](https://github.com/zoranmedic/mdcr), a large scale citation recommendation benchmark.
|
| 160 |
+
|
| 161 |
+
|Model|SciRepEval In-Train|SciRepEval Out-of-Train|SciRepEval Avg|MDCR(MAP, Recall@5)|
|
| 162 |
+
|--|--|--|--|--|
|
| 163 |
+
|[BM-25](https://api.semanticscholar.org/CorpusID:252199740)|n/a|n/a|n/a|(33.7, 28.5)|
|
| 164 |
+
|[SPECTER](https://huggingface.co/allenai/specter)|54.7|57.4|68.0|(30.6, 25.5)|
|
| 165 |
+
|[SciNCL](https://huggingface.co/malteos/scincl)|55.6|57.8|69.0|(32.6, 27.3)|
|
| 166 |
+
|[SciRepEval-Adapters](https://huggingface.co/models?search=scirepeval)|61.9|59.0|70.9|(35.3, 29.6)|
|
| 167 |
+
|[SPECTER 2.0-base](https://huggingface.co/allenai/specter_plus_plus)|56.3|58.0|69.2|(38.0, 32.4)|
|
| 168 |
+
|[SPECTER 2.0-Adapters](https://huggingface.co/models?search=allen/spp)|**62.3**|**59.2**|**71.2**|**(38.4, 33.0)**|
|
| 169 |
+
|
| 170 |
+
Please cite the following works if you end up using SPECTER 2.0:
|
| 171 |
+
|
| 172 |
+
[SPECTER paper](https://api.semanticscholar.org/CorpusID:215768677):
|
| 173 |
+
|
| 174 |
+
```bibtex
|
| 175 |
+
@inproceedings{specter2020cohan,
|
| 176 |
+
title={{SPECTER: Document-level Representation Learning using Citation-informed Transformers}},
|
| 177 |
+
author={Arman Cohan and Sergey Feldman and Iz Beltagy and Doug Downey and Daniel S. Weld},
|
| 178 |
+
booktitle={ACL},
|
| 179 |
+
year={2020}
|
| 180 |
+
}
|
| 181 |
+
```
|
| 182 |
+
[SciRepEval paper](https://api.semanticscholar.org/CorpusID:254018137)
|
| 183 |
+
```bibtex
|
| 184 |
+
@article{Singh2022SciRepEvalAM,
|
| 185 |
+
title={SciRepEval: A Multi-Format Benchmark for Scientific Document Representations},
|
| 186 |
+
author={Amanpreet Singh and Mike D'Arcy and Arman Cohan and Doug Downey and Sergey Feldman},
|
| 187 |
+
journal={ArXiv},
|
| 188 |
+
year={2022},
|
| 189 |
+
volume={abs/2211.13308}
|
| 190 |
+
}
|
| 191 |
+
```
|
| 192 |
|
|
|
|
| 193 |
|
|
|