--- license: mit language: - en library_name: transformers pipeline_tag: text-generation tags: - mixture-of-experts - science - chemistry - biology - proteins - dna - galactica - base-model datasets: - common-pile/arxiv_papers - common-pile/pubmed - common-pile/stackv2_edu_filtered - HuggingFaceTB/finemath - jablonkagroup/chempile-paper - jablonkagroup/chempile-education - jablonkagroup/chempile-reasoning - jablonkagroup/chempile-instruction - jablonkagroup/chempile-lift - jablonkagroup/chempile-code - codeparrot/github-jupyter-parsed - tumorailab/protein2text-swissprot-split - DanielHesslow/SwissProt-Pfam - ConvergeBio/uniref50 - arcinstitute/opengenome2 - MegaScience/MegaScience - SWE-bench/SWE-smith-trajectories - Agent-Ark/Toucan-1.5M - open-thoughts/OpenThoughts3-1.2M - nvidia/OpenCodeReasoning - HuggingFaceFW/fineweb-edu - HuggingFaceFW/finepdfs-edu - wikimedia/wikipedia - karpathy/climbmix-400b-shuffle - TinyGSM/TinyGSM - open-thoughts/OpenThoughts-Agent-SFT-100K - nvidia/Nemotron-Terminal-Corpus - open-thoughts/AgentTrove - HuggingFaceTB/smoltalk - HuggingFaceTB/smol-smoltalk - glaiveai/glaive-function-calling-v2 --- # FemtoScience (base) **This revision (`main`) is the final base model**: Stage 3 cooldown, 250B tokens, 16K context. FemtoScience is a small open scientific language model trained from scratch in the spirit of Galactica: a **994M-total / 229M-active** Mixture-of-Experts transformer with a **modality-aware 65k tokenizer**, pretrained on **250B tokens** in three stages (4K → 16K context). This is a **base (pretrained) model**: it is not instruction-tuned, chat-tuned or safety-tuned. Code, data recipe and training scripts: https://github.com/MJ10/FemtoScience ## Revisions | Revision | Stage | Tokens seen | Context | Val BPB (8-domain) | |---|---|---:|---:|---:| | `main` | Stage 3 cooldown (final base) | 250B | 16,384 | **0.6494** | | `stage2b-230B` | Stage 2b midtrain | 230B | 16,384 | 0.7166 | | `stage2a-215B` | Stage 2a midtrain | 215B | 4,096 | 0.7321 | | `stage1-185B` | Stage 1 pretrain (constant LR, not annealed) | 185B | 4,096 | 0.7354 | ```python from transformers import AutoModelForCausalLM, AutoTokenizer repo = "mokshjain/FemtoScience" tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True) # revision="stage1-185B", ... model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True, dtype="bfloat16") ids = tok("Aspirin, [START_SMILES]CC(=O)Oc1ccccc1C(=O)O[END_SMILES], is", return_tensors="pt") out = model.generate(**ids, max_new_tokens=64, do_sample=False) print(tok.decode(out[0])) ``` The remote code uses transformers' standard `DynamicCache` and `GenerationMixin`, so `model.generate()` works as for any causal LM, including sampling and left-padded batches. For lossless MTP-1 speculative decoding from `mtp.safetensors`, use the native `femtoscience` package (`femtoscience.hub.load_pretrained` + `femtoscience.infer.generate_mtp_speculative`). Prompts should **not** start with a BOS token; pretraining packed documents as `doc doc …`. Tested with transformers 4.57 and 5.24. ## Files | File | Contents | |---|---| | `model.safetensors` | trunk weights, bf16 (MoE routing biases `e_bias` kept fp32) | | `mtp.safetensors` | depth-1 multi-token-prediction head, bf16 (optional; not used by the transformers code) | | `config.json`, `configuration_femtoscience.py`, `modeling_femtoscience.py` | architecture config and standalone remote code | | `tokenizer.json`, `tokenizer_config.json`, `tokenization_femtoscience.py`, `femtoscience_meta.json` | modality-aware tokenizer | | `training_metadata.json` | stage, step, tokens seen and the training hyperparameters of this checkpoint | | `checksums.sha256` | SHA-256 of every file | Optimizer state is not included. ## Architecture - 16 layers, `d_model=1024`; GQA with 16 query / 4 KV heads (`head_dim=64`), QK-Norm, element-wise sigmoid attention output gate, RoPE `theta=1e6`. - Layer 0: dense SwiGLU (`d_ff=2560`). Layers 1–15: 1 shared expert (`d_ff=512`) + 64 routed experts (`d_ff=256`), top-6 sigmoid routing with auxiliary-loss-free bias balancing. - 65,536-token vocabulary, untied embeddings; MTP-1 auxiliary head (weight 0.3) during pretraining. - 994.04M parameters in total (980.41M without the MTP head); 229.10M active per token. ### Tokenizer Byte-level BPE with single-digit splitting, plus atomic tokens inside `[START_AMINO]…[END_AMINO]` (one token per residue), `[START_DNA]…[END_DNA]` (one per base), `[START_SMILES]…[END_SMILES]` (regex atoms/bonds) and `[START_SELFIES]…[END_SELFIES]`, and `[START_REF]…[END_REF]` citation spans. Chat/agent markers (`<|im_start|>`, `<|think|>`, `<|tool_call|>`, `<|code_exec|>`, …) are reserved but were seen only inside agentic pretraining traces. Most chemistry in the corpus is plain-text SMILES inside prose. ## Training data 116.38B unique tokens from public sources in 8 domains, 250B tokens seen in total (~2.15 epochs on average): | Domain | Unique (B) | Stage 1 | Stage 2 | Stage 3 | Seen (B) | |---|---:|---:|---:|---:|---:| | papers (arXiv, PubMed, bio/med/chemRxiv, EuroPMC) | 28.91 | 34% | 24% | 15% | 76.7 | | STEM education web text and encyclopedias | 25.11 | 25% | 12% | 8% | 53.2 | | math | 18.39 | 14% | 18% | 20% | 38.0 | | code (scientific Python, shell, notebooks, chemistry code) | 14.74 | 12% | 16% | 15% | 32.4 | | chemistry (textbooks, Q&A, property/structure text) | 8.17 | 7% | 8% | 12% | 18.9 | | proteins (UniRef50, SwissProt) | 7.96 | 4% | 4% | 4% | 10.0 | | DNA (OpenGenome2 slice) | 5.00 | 2% | 2% | 1% | 4.8 | | agentic / reasoning traces | 8.11 | 2% | 16% | 25% | 15.9 | Some web-text, math, code and agent-trace sources were read from pre-downloaded Parquet mirrors of FineWeb-Edu, FinePDFs-Edu, Wikipedia, ClimbMix, FineMath, TinyGSM, Stack-v2-edu, terminal-agent corpora (OpenThoughts-Agent, Nemotron-Terminal, AgentTrove), function-calling sets (smoltalk APIGen, Glaive) and smol-smoltalk; `docs/DATA_SOURCES.md` in the code repository lists the exact files, filters and licenses. Licenses of the training sources differ; see their dataset cards. ClimbMix is licensed CC-BY-NC-4.0 (non-commercial). ## Training procedure 8× H200, bf16, 1,048,576 tokens per step, Muon (2-D and stacked 3-D expert matrices) + AdamW (embeddings, head, router, norms), `lr=6e-4`, `muon_lr=1.2e-3`, weight decay 0.1. | Stage | Tokens | Context | Steps | Schedule | |---|---:|---:|---:|---| | 1 Pretrain | 185B | 4,096 | 176,429 | 2,000-step warmup, constant | | 2a Midtrain (more math/code/agentic) | 30B | 4,096 | 28,610 | constant | | 2b Midtrain | 15B | 16,384, document-masked | 14,305 | 200-step re-warmup, constant | | 3 Cooldown (high-quality / reasoning mix) | 20B | 16,384, document-masked | 19,073 | `1 − sqrt` decay to 0, MoE bias frozen | ## Evaluation (Stage 3 unless noted) **Held-out bits per byte** (16K windows, document-masked): overall **0.6494** — papers 0.6384, STEM edu 0.7482, math 0.4490, code 0.4594, chemistry 0.5153, proteins 1.3556, DNA 1.8110, agentic 0.1984. **Long context** (BPB at token positions 12K–16K, Stage 1 → Stage 3): papers 0.6433 → 0.5415, code 0.6431 → 0.4640, STEM edu 0.8251 → 0.7411. With document masking, DNA 1.7760 → 1.7542 (without it, DNA windows span unrelated genome slices and are not meaningful). **CORE** (22 tasks, centered): **0.2510** (GPT-2 XL 1.5B: 0.2565). **Scientific probes** (vs Galactica): | Model | Active | Protein bits ↑ | ProteinGym DMS ρ ↑ | DNA MCC ↑ | SMILES valid, tagged ↑ | SMILES valid, plain ↑ | ChemBench ↑ | LAB-Bench ↑ | PubMedQA ↑ | SciQ ↑ | |---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:| | Galactica-125M | 125M | 0.0597 | -0.0029 | 0.4395 | 41.25% | 8.75% | 0.2643 | 0.1850 | 0.5350 | 0.5900 | | Galactica-1.3B | 1,315M | 0.0762 | 0.0202 | 0.4621 | 35.0% | 7.5% | 0.3240 | 0.2479 | 0.5550 | 0.7450 | | FemtoScience Stage 1 | 229M | 0.2015 | 0.0814 | 0.4543 | 6.25% | 33.75% | 0.2812 | 0.2258 | 0.5600 | 0.7000 | | FemtoScience Stage 3 | 229M | 0.2260 | 0.1031 | 0.4751 | 1.25% | 22.5% | 0.3094 | 0.2334 | 0.4050 | 0.7000 | SMILES columns are RDKit validity of greedy completions of half-molecules from ChEBI-20, either inside `[START_SMILES]` tags or as plain text after "SMILES:". Galactica was trained with tagged SMILES and wins there; FemtoScience saw almost all of its chemistry as plain-text SMILES in prose and wins on plain prompts. An earlier version of this table reported bracket/ring balance instead (Galactica 0.79/0.84, FemtoScience 0.20/0.23). ## Intended use Research on small scientific language models: continued pretraining, fine-tuning, probing of protein/DNA/chemistry representations, MoE and long-context studies, and as a base for post-training. ## Limitations and risks - Base model: generations can be fluent but wrong, including invalid molecules, implausible sequences and fabricated citations. Do not use outputs as scientific or medical facts without verification. - Small capacity (229M active): weak multi-step arithmetic and exact symbolic manipulation; generated SMILES are rarely valid (RDKit validity 1.25% for span-tagged SMILES at Stage 3). - DNA modelling is close to the per-base entropy floor; protein modelling is limited. - English-centric; web text and model-generated reasoning traces carry their own biases and errors. - Not intended for clinical or safety-critical decisions, or for designing harmful biological or chemical agents. ## Credits The model architecture, tokenizer, data recipe, training schedule and pretraining code were designed and written by **Gemini 4 Neon**, an AI coding agent, working with Moksh Jain, who directed the project. **Claude** (Anthropic) prepared the release: checkpoint conversion, the transformers remote-code fixes, tests and this model card. ## Citation ```bibtex @misc{femtoscience2026, title = {FemtoScience: a small open scientific Mixture-of-Experts language model}, author = {Jain, Moksh}, year = {2026}, url = {https://github.com/MJ10/FemtoScience} } ```