SAVRN
Search Contact SAVRN

Open-weight model · Feature extraction

specter2_base

by Ai2 allenai/specter2_base

SPECTER2 is the successor to SPECTER and is capable of generating task specific embeddings for scientific tasks when paired with adapters. This is the base model to be used along with the adapters.

Parameters
Context512
Weights439.7 MB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads1.1M

Model Card

By Ai2, published under apache-2.0, revision 3447645e1def.

SPECTER2 is the successor to SPECTER and is capable of generating task specific embeddings for scientific tasks when paired with adapters. This is the base model to be used along with the adapters. 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. Note:For general embedding purposes, please use allenai/specter2. To get the best performance on a downstream task type please load the associated adapter with the base model as in the example below. Model usage updated to be compatible with latest versions of transformers and adapters (newly released update to…

Read Ai2's full model card

SPECTER2

SPECTER2 is the successor to SPECTER and is capable of generating task specific embeddings for scientific tasks when paired with adapters. This is the base model to be used along with the adapters. 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.

Note:For general embedding purposes, please use allenai/specter2.

To get the best performance on a downstream task type please load the associated adapter with the base model as in the example below.

Dec 2023 Update:

Model usage updated to be compatible with latest versions of transformers and adapters (newly released update to adapter-transformers) libraries.

Aug 2023 Update: 1. The SPECTER2 Base and proximity adapter models have been renamed in Hugging Face based upon usage patterns as follows:

Old Name New Name
allenai/specter2 allenai/specter2_base
allenai/specter2_proximity allenai/specter2
  1. We have a parallel version (termed aug2023refresh) where the base transformer encoder version is pre-trained on a collection of newer papers (published after 2018). However, for benchmarking purposes, please continue using the current version.

An adapter for the allenai/specter2_base model that was trained on the allenai/scirepeval dataset.

This adapter was created for usage with the adapters library.

Model Details

Model Description

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: - Classification - Regression - Proximity (Retrieval) - Adhoc Search

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.

  • Developed by: Amanpreet Singh, Mike D'Arcy, Arman Cohan, Doug Downey, Sergey Feldman
  • Shared by : Allen AI
  • Model type: bert-base-uncased + adapters
  • License: Apache 2.0
  • Finetuned from model: allenai/scibert.

Model Sources

Uses

Direct Use

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, :]

Downstream Use

For evaluation and downstream usage, please refer to https://github.com/allenai/scirepeval/blob/main/evaluation/INFERENCE.md.

Training Details

Training Data

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.

Training Procedure

Please refer to the SPECTER paper.

Training Hyperparameters

The model is trained in two stages using SciRepEval: - Base Model: First a base model is trained on the above citation triplets. batch size = 1024, max input length = 512, learning rate = 2e-5, epochs = 2 warmup steps = 10% fp16 - 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. batch size = 256, max input length = 512, learning rate = 1e-4, epochs = 6 warmup = 1000 steps fp16

Evaluation

We 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}
}

Configuration

Architecture
BertModel
Context length (tokens)
512
Layers
12
Hidden size
768
Feed-forward size
3,072
Attention heads
12
Vocabulary size
31,090
Stored precision
float32
Model type
bert

Identity and Version

Repository
allenai/specter2_base
Publisher
Ai2
Task
Feature extraction
Modality
Text
Library
transformers
Parameters
Not stated by the source
Languages
en
Revision
3447645e1def9117997203454fa4495937bfbd83
First published
2023-02-16
Last updated
2024-12-04

Files and Weights

8 files, 440.7 MB in total. The weights are 1 file totalling 439.7 MB in bin.

Weights1 file · 439.7 MB
Configuration2 files · 879 B
Tokenizer3 files · 945.1 KB
Documentation1 file · 9.2 KB
Repository1 file · 1.5 KB
Every file
FileTypeSizeSHA-256
pytorch_model.binWeights439.7 MB 801eda968fad
config.jsonConfiguration754 B
special_tokens_map.jsonConfiguration125 B
README.mdDocumentation9.2 KB
.gitattributesRepository1.5 KB
tokenizer.jsonTokenizer716.8 KB
tokenizer_config.jsonTokenizer453 B
vocab.txtTokenizer227.8 KB

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
439.7 MB
Download from Ai2

Released by Ai2 through its official repository on Hugging Face. Read the license.

Built From

  • Trained on (disclosed) allenai/scirepeval

Memory Requirements

PrecisionWeights in memory
As published439.7 MB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About specter2_base

Can I use specter2_base commercially?

Yes. specter2_base is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

What is specter2_base's context length?

512 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Feature extraction

all-MiniLM-L6-v2

Joshua

https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2 with ONNX weights to be compatible with Transformers.js. If you haven't already, you can install the Transformers.js JavaScript library from NPM using: You can then use the model to compute embeddings like this: You can convert this Tensor to a nested JavaScript array using.tolist(): Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).

Open weights apache-2.0 512 tokens transformers.js

Model · Feature extraction

bge-base-en-v1.5

Joshua

https://huggingface.co/BAAI/bge-base-en-v1.5 with ONNX weights to be compatible with Transformers.js. If you haven't already, you can install the Transformers.js JavaScript library from NPM using: You can then use the model to compute embeddings, as follows: You can also use the model for retrieval. For example: Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).

Open weights mit 512 tokens transformers.js

Model · Feature extraction

clap-htsat-unfused

LAION eV

The abstract of the paper states that: You can use this model for zero shot audio classification or extracting audio and/or textual features. You can also get the audio and text embeddings using ClapModel If you are using this model for your work, please consider citing the original paper

Open weights apache-2.0 514 tokens transformers

Model · Feature extraction

wavlm-large

Microsoft

The large model pretrained on 16kHz sampled speech audio. When using the model, make sure that your speech input is also sampled at 16kHz. Note: This model does not have a tokenizer as it was pretrained on audio alone. In order to use this model speech recognition, a tokenizer should be created and the model should be fine-tuned on labeled text data. Check out this blog for more in-detail explanation of how to fine-tune the model. - 60,000 hours of Libri-Light - 10,000 hours of GigaSpeech - 24,000 hours of VoxPopuli Authors: Sanyuan Chen, Chengyi Wang, Zhengyang Chen, Yu Wu, Shujie Liu, Zhuo Chen, Jinyu Li, Naoyuki Kanda, Takuya Yoshioka, Xiong Xiao, Jian Wu, Long Zhou, Shuo Ren, Yanmin…

Open weights transformers

For more details please refer to our Github: FlagEmbedding. If you are looking for a model that supports more languages, longer texts, and other retrieval methods, you can try using bge-m3. FlagEmbedding focuses on retrieval-augmented LLMs, consisting of the following projects currently: - 1/30/2024: Release BGE-M3, a new member to BGE model series! M3 stands for Multi-linguality (100+ languages), Multi-granularities (input length up to 8192), Multi-Functionality (unification of dense, lexical, multi-vec/colbert retrieval). It is the first embedding model which supports all three retrieval methods, achieving new SOTA on multi-lingual (MIRACL) and cross-lingual (MKQA) benchmarks. Technical…

Open weights mit 512 tokens sentence-transformers