Downloads · 30 days
0
adamlabadorf/specter2-proximity-onnx
specter2-proximity-onnx is a feature extraction model from adamlabadorf. Use it when you need embeddings to search or compare text. It is set up for onnxruntime. The card lists the license as apache-2.0.
This is an ONNX export of allenai/specter2base with the proximity adapter fused in. It produces 768-dimensional embeddings optimized for scientific document similarity and citation prediction.
Downloads · 30 days
0
Access
Public
Updated Feb 15, 2026
Repo size
442 MB
Likes
0
Public
Click a slice to open those files.
.data441 MB · 100%
From the Hugging Face model README
This is an ONNX export of allenai/specter2_base with the proximity adapter fused in. It produces 768-dimensional embeddings optimized for scientific document similarity and citation prediction.
The adapter weights are baked into the model graph — no separate adapter loading needed.
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
from tokenizers import Tokenizer
# Download model and tokenizer
model_path = hf_hub_download("adamlabadorf/specter2-proximity-onnx", "specter2_proximity.onnx")
data_path = hf_hub_download("adamlabadorf/specter2-proximity-onnx", "specter2_proximity.onnx.data")
tokenizer_path = hf_hub_download("adamlabadorf/specter2-proximity-onnx", "tokenizer/tokenizer.json")
# Load
session = ort.InferenceSession(model_path, providers=["CPUExecutionProvider"])
tokenizer = Tokenizer.from_file(tokenizer_path)
tokenizer.enable_truncation(max_length=512)
tokenizer.enable_padding(pad_id=0, pad_token="[PAD]")
# Encode
texts = ["Effect of gut microbiota on neuroinflammation"]
encodings = tokenizer.encode_batch(texts)
input_ids = np.array([e.ids for e in encodings], dtype=np.int64)
attention_mask = np.array([e.attention_mask for e in encodings], dtype=np.int64)
embeddings = session.run(None, {"input_ids": input_ids, "attention_mask": attention_mask})[0]
# Normalize
embeddings = embeddings / np.linalg.norm(embeddings, axis=1, keepdims=True)
specter2_proximity.onnx — ONNX graph structurespecter2_proximity.onnx.data — Model weights (external data)tokenizer/ — SciBERT tokenizer filesThis export allows running SPECTER2 embeddings without PyTorch or transformers as runtime dependencies — only onnxruntime and tokenizers are needed. Useful for lightweight deployments and applications that already use ONNX Runtime.
If you use this model, please cite the original SPECTER2 paper:
@inproceedings{singh2023scirepeval,
title={SciRepEval: A Multi-Format Benchmark for Scientific Document Representations},
author={Singh, Amanpreet and D'Arcy, Mike and Cohan, Arman and Downey, Doug and Feldman, Sergey},
booktitle={EMNLP},
year={2023}
}
Apache 2.0, consistent with the original allenai/specter2 model.