โš ๏ธ Pretraining degeneracy (audit 2026-05-18): empirical inspection shows this checkpoint's encoder is largely collapsed: pair-wise within-sequence hidden-state cosines hover at โ‰ˆ 0.999 and the MLM head returns nearly the same top-k tokens regardless of context. The model nominally achieved a low MLM eval_loss but appears to have settled on a degenerate "predict the most frequent token" strategy. Root cause traced to an under-sized BERT pretrain corpus (training_ready_hf_dataset โ‰ˆ 4k rows vs โ‰ˆ 3.3M available in arrow_splits/). Not recommended for downstream use as-is; consider re-training from arrow_splits/ instead. (Note: the matching -large variant exhibits an even more severe collapse and was therefore not uploaded.)

molcrawl-molecule-nat-lang-bert-medium

Model Description

GPT-2 medium (345M parameters) foundation model pre-trained on molecule-related natural language text using a standard GPT-2 BPE tokenizer (vocab_size=50257).

  • Model Type: bert
  • Data Type: Molecule-NL
  • Training Date: 2026-05-13

Usage

from transformers import AutoModelForMaskedLM, AutoTokenizer
import torch

model = AutoModelForMaskedLM.from_pretrained("kojima-lab/molcrawl-molecule-nat-lang-bert-medium")
tokenizer = AutoTokenizer.from_pretrained("kojima-lab/molcrawl-molecule-nat-lang-bert-medium")

# Predict masked token
# Use tokenizer.mask_token instead of hardcoded "[MASK]":
# BERT-style tokenizers vary ("[MASK]", "<mask>", etc.)
if tokenizer.mask_token is None:
    raise ValueError("This tokenizer has no mask_token; masked LM inference is not supported.")
prompt = "your input {MASK} sequence".replace("{MASK}", tokenizer.mask_token)
inputs = tokenizer(prompt, return_tensors="pt")
mask_index = (inputs["input_ids"] == tokenizer.mask_token_id).nonzero(as_tuple=True)[1]

with torch.no_grad():
    outputs = model(**inputs)
logits = outputs.logits

predicted_token_id = logits[0, mask_index].argmax(dim=-1)
predicted_token = tokenizer.decode(predicted_token_id)
result = prompt.replace(tokenizer.mask_token, predicted_token)
print(f"Predicted: {result}")

Source Code

Training pipeline, configuration files, and data preparation scripts are available in the MolCrawl GitHub repository: https://github.com/mmai-framework-lab/MolCrawl

License

This model is released under the APACHE-2.0 license.

Citation

If you use this model, please cite:

@misc{molcrawl_molecule_nat_lang_bert_medium,
  title={molcrawl-molecule-nat-lang-bert-medium},
  author={{RIKEN}},
  year={2026},
  publisher={{Hugging Face}},
  url={{https://huggingface.co/kojima-lab/molcrawl-molecule-nat-lang-bert-medium}}
}

Example Output

Inference test performed on the uploaded checkpoint (CPU):

Note: AutoTokenizer requires codellama/CodeLlama-7b-hf cached locally. When loading from Hub without a local CodeLlama cache, use molcrawl.molecule_nat_lang.utils.tokenizer.MoleculeNatLangTokenizer directly.

import sys
sys.path.insert(0, "/path/to/riken-dataset-fundational-model")  # project root

import torch
from transformers import AutoModelForMaskedLM
from molcrawl.data.molecule_nat_lang.utils.tokenizer import MoleculeNatLangTokenizer

REPO_ID = "kojima-lab/molcrawl-molecule-nat-lang-bert-medium"
model = AutoModelForMaskedLM.from_pretrained(REPO_ID)
model.eval()

tokenizer_wrap = MoleculeNatLangTokenizer()
tokenizer = tokenizer_wrap.tokenizer

MASK = getattr(tokenizer, "mask_token", "[MASK]")
prompt = "The molecule aspirin has the SMILES CC(=O)Oc1ccccc1C(=O)O and it is an {MASK}.".format(MASK=MASK)

inputs = tokenizer(prompt, return_tensors="pt")
mask_index = (inputs["input_ids"] == tokenizer.mask_token_id).nonzero(as_tuple=True)[1]

with torch.no_grad():
    outputs = model(**inputs)
logits = outputs.logits

predicted_token_id = logits[0, mask_index].argmax(dim=-1)
predicted_token = tokenizer.decode(predicted_token_id)
result = prompt.replace(MASK, predicted_token)
print(f"Predicted: {result}")
# => Predicted: The molecule aspirin has the SMILES CC(=O)Oc1ccccc1C(=O)O and it is an  without.
Downloads last month
2
Safetensors
Model size
0.4B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support