Views
No views yet
allenai/scibert_scivocab_cased, maintained for teaching a course on transformer-based topic modeling in R.pytorch_model.bin (PyTorch pickle format) and vocab.txt. Both are fine for Python users, but they create friction for R users working through the torch (libtorch) and safetensors R packages:transformers Python library or the R-torch pickle reader, which has known limitations (cannot remap CUDA-saved tensors to CPU, executes arbitrary code on load, slower to read than safetensors).tokenizer.json is missing, which forces R code to either depend on a separate WordPiece-tokenization package or to install the Python tokenizers library through reticulate.model.safetensors — the same weights in safetensors format, which is device-agnostic, safe (cannot execute code on load), and faster to read than pickle.config.json, vocab.txt, the model architecture — is identical to the upstream original. The original pytorch_model.bin is preserved alongside the safetensors copy so the repo remains a strict superset of the upstream.protein, algorithm, mitochondria, and gradient are single tokens rather than fragments, which gives the model a meaningful advantage on scientific text compared to general-purpose BERT.| Property | Value |
|---|---|
| Architecture | BERT-base |
| Parameters | ~110M |
| Hidden size | 768 |
| Layers | 12 |
| Attention heads | 12 |
| Vocabulary size | 31,116 (cased, scientific) |
| Max sequence length | 512 tokens |
| Training data | 1.14M scientific papers (Semantic Scholar) |
| Case sensitivity | Cased (preserves capitalization — important for gene names, chemical formulas, acronyms) |
pritamdeka/S-Scibert-snli-multinli-stsb perform substantially better.torch (libtorch) R package, with no Python at runtime:1source("bert_r.R")
2enc <- load_hf_bert("NetworkIsLife/SciBert_Cased_DAFS")
3
4emb <- embed_texts(enc$model, enc$tokenizer,
5 c("CRISPR-Cas9 enables targeted gene editing.",
6 "Glioblastoma exhibits invasive growth patterns."))
7dim(emb) # 2 x 768model.safetensors first (this file) and falls back to pytorch_model.bin if it isn't found. Since the safetensors file is present, that's the fast path taken.1enc <- load_hf_bert(
2 "NetworkIsLife/SciBert_Cased_DAFS",
3 weights_path = hfhub::hub_download(
4 "NetworkIsLife/SciBert_Cased_DAFS",
5 "model.safetensors",
6 revision = "MAIN_COMMIT_HASH_HERE"
7 )
8)MAIN_COMMIT_HASH_HERE with the commit hash visible in this repo's commit history.1from transformers import AutoTokenizer, AutoModel
2tok = AutoTokenizer.from_pretrained("NetworkIsLife/SciBert_Cased_DAFS")
3mod = AutoModel.from_pretrained("NetworkIsLife/SciBert_Cased_DAFS")| File | Source | Purpose |
|---|---|---|
model.safetensors | converted from upstream pytorch_model.bin | model weights, modern format |
pytorch_model.bin | copied from upstream | model weights, legacy format (kept for compatibility) |
config.json | copied from upstream | architecture parameters |
vocab.txt | copied from upstream | WordPiece vocabulary |
README.md | this file | provenance and usage |
model.safetensors file in this repo was produced by HuggingFace's official SFconvertbot (the same automated conversion used across thousands of HuggingFace repos). The conversion is purely a re-serialization — every tensor in the safetensors file is bit-identical to the corresponding tensor in pytorch_model.bin. No re-training, no quantization, no precision loss.1import torch
2from safetensors.torch import load_file
3
4a = torch.load("pytorch_model.bin", map_location="cpu", weights_only=True)
5b = load_file("model.safetensors")
6assert set(a.keys()) == set(b.keys())
7for k in a:
8 assert torch.equal(a[k], b[k]), f"Mismatch in {k}"
9print("Bit-identical.")1@inproceedings{beltagy-etal-2019-scibert,
2 title = "{SciBERT}: A Pretrained Language Model for Scientific Text",
3 author = "Beltagy, Iz and Lo, Kyle and Cohan, Arman",
4 booktitle = "Proceedings of EMNLP-IJCNLP",
5 year = "2019",
6 url = "https://www.aclweb.org/anthology/D19-1371"
7}allenai/scibert_scivocab_cased by the Allen Institute for AI.