"""Science-domain rules for HF Hub models & datasets, used by 08_science.py. Tags are normalised: lower-case, '_' and ' ' -> '-'. Matching is EXACT on the normalised tag (never substring) to avoid 'science-fiction', 'brainstorm', 'model-fusion', 'neuromorphic', 'cosmos' etc. """ import re DOMAINS = { # ---- life sciences ---- "proteins": { # proteins, structural & molecular biology, immunology "tags": {"protein", "proteins", "protein-language-model", "protein-embeddings", "protein-design", "protein-generation", "protein-structure", "protein-structure-prediction", "protein-folding", "protein-recognition", "antibody", "antibodies", "enzyme", "enzymes", "peptide", "peptides", "proteomics", "structural-biology", "molecular-biology", "t-cell", "tcr", "immunology", "protein-function-prediction", "protein-engineering", "plm"}, "libs": {"esm3", "nanoprot"}, }, "genomics": { # DNA/RNA, single-cell & other omics "tags": {"genomics", "dna", "rna", "dnase", "single-cell", "scrna-seq", "scrnaseq", "transcriptomics", "spatial-transcriptomics", "dna-methylation", "epigenomics", "epigenetics", "gene-expression", "metagenomics", "microbiome", "genome", "genomic", "chromatin", "atac-seq", "multi-omics", "omics", "variant-effect-prediction", "genetics", "dna-language-model", "nucleotide", "bioinformatics"}, "libs": {"bpnet", "chrombpnet", "scvi-tools", "multimolecule", "pyaging", "biomed-multi-omic", "cellmap-models"}, }, "biology_other": { # generic 'biology', microscopy, cell imaging "tags": {"biology", "life-sciences", "microscopy", "cell-painting", "cell-biology", "bioimage", "pretrained-microscopy-models", "computational-biology", "systems-biology", "virology"}, "libs": {"cellpose"}, }, "medicine": { # clinical, biomedical NLP, medical imaging (ADJACENT domain) "tags": {"medical", "clinical", "healthcare", "biomedical", "biomedical-nlp", "medical-nlp", "medical-imaging", "radiology", "pathology", "histopathology", "histology", "computational-pathology", "digital-pathology", "dermatology", "ophthalmology", "ehr", "medical-ner", "clinical-nlp", "clinical-reasoning", "medical-qa", "medical-ai", "medical-diagnosis", "mri", "ct", "chest-x-ray", "chest-xray", "x-ray", "ultrasound", "brain-mri", "brain-tumor", "clinical-trials", "medicine", "oncology", "cancer", "medical-embeddings", "clinical-decision-support", "biomed", "medical-vqa", "medical-image-segmentation", "medical-image-analysis", "cardiology", "ecg"}, "libs": {"monai", "atommic", "openmed", "biomed-multi-alignment"}, }, # ---- physical sciences ---- "chemistry": { # chemistry & drug discovery "tags": {"chemistry", "chem", "cheminformatics", "smiles", "molecules", "molecule", "molecular", "molecular-property-prediction", "molecular-generation", "drug-discovery", "drug-design", "admet", "retrosynthesis", "reaction-prediction", "qsar", "toxicity-prediction", "quantum-chemistry", "mass-spectrometry", "spectroscopy", "chemical-entity-recognition", "computational-chemistry", "molecular-modeling", "selfies"}, "libs": {"smallmoleculemultiview", "torch-molecule", "pychemauth"}, }, "materials": { # materials & atomistic simulation "tags": {"materials-science", "materials", "material-science", "interatomic-potential", "mlip", "molecular-dynamics", "dft", "crystal", "crystal-structure", "other-materials", "polymer", "polymers", "catalysis", "battery", "atomistic", "atomistic-simulation", "machine-learning-potential", "fairchem", "inorganic-materials", "density-functional-theory"}, "libs": {"matgl"}, }, "physics": { # physics, PDEs, CFD, fusion, HEP "tags": {"physics", "pde", "pdes", "cfd", "computational-fluid-dynamics", "fluid-dynamics", "neural-operator", "physics-informed", "pinn", "pinns", "high-energy-physics", "particle-physics", "hep", "plasma-physics", "plasma", "fusion-energy", "nuclear-physics", "quantum-physics", "turbulence", "scientific-machine-learning", "sciml", "scientific-computing", "computational-physics", "physics-simulation", "condensed-matter"}, "libs": set(), }, # ---- earth & space ---- "weather_climate": { "tags": {"climate", "weather", "climate-change", "meteorology", "atmospheric-science", "atmosphere", "atmospheric-dynamics", "ocean", "oceanography", "weather-forecasting", "climate-science", "climate-modeling", "era5", "precipitation", "nowcasting", "hydrology", "flood", "flooding", "wildfire", "air-quality", "numerical-weather-prediction", "nwp", "climate-model", "sea-ice"}, "libs": {"anemoi", "earth2studio"}, }, "earth_observation": { "tags": {"remote-sensing", "earth-observation", "satellite", "satellite-imagery", "sentinel-2", "sentinel-1", "landsat", "geospatial", "geology", "sar", "hyperspectral", "earth-science", "aerial-imagery", "land-cover", "bigearthnet-v2.0", "geoscience", "seismology", "geophysics", "multispectral"}, "libs": {"terratorch", "torchgeo", "betaearth"}, "dataset_tags": {"modality:geospatial"}, }, "astronomy": { "tags": {"astronomy", "astrophysics", "cosmology", "heliophysics", "galaxy", "galaxies", "solar-physics", "space-weather", "exoplanets", "exoplanet", "planetary-science", "astroparticle", "radio-astronomy"}, "libs": set(), }, # ---- other ---- "neuroscience": { "tags": {"neuroscience", "eeg", "ieeg", "fmri", "neuroimaging", "brain-computer-interface", "bci", "eegdash", "neural-decoding", "meg", "ecog", "connectomics", "electrophysiology", "brain-decoding", "computational-neuroscience", "brain-encoding"}, "libs": {"braindecode"}, }, "ecology_agri": { "tags": {"ecology", "biodiversity", "wildlife", "species", "species-recognition", "species-classification", "bioacoustics", "camera-traps", "camera-trap", "conservation", "plant-disease", "agriculture", "forestry", "botany", "plants", "entomology", "marine-biology", "ornithology", "animal-behavior", "precision-agriculture", "crop", "crops", "fisheries"}, "libs": set(), }, "math": { # ADJACENT domain - mostly LLM math-reasoning data/finetunes "tags": {"math", "mathematics", "lean4", "lean", "theorem-proving", "mathematical-reasoning", "math-reasoning", "olympiad", "mathlib", "formal-mathematics", "math-word-problems", "formal-verification", "automated-theorem-proving"}, "libs": set(), }, "science_general": { # generic 'science' tags, scientific QA / papers "tags": {"science", "scientific-research", "scientific-reasoning", "science-reasoning", "scienceqa", "scientific-papers", "ai4science", "ai-for-science", "scientific-data", "scientific-discovery", "scientific-qa", "onescience"}, "libs": set(), }, } CORE = [d for d in DOMAINS if d not in ("medicine", "math")] # 'core natural science'; medicine & math = adjacent # High-precision model-family name patterns (repo name, case-insensitive) -> domain. # Only well-known science model families; generic words ('medical', 'math', 'chem') deliberately NOT used. FAMILY_RX = [ (r"(^|[-_/])esm(2|c|3|fold|-?1b|-?1v)|prot[-_]?(bert|t5|gpt|xlnet|electra)|progen2?|(^|[-_])ankh|saprot|prostt5|boltz|chai-1|rfdiffusion|proteinmpnn|ligandmpnn|openfold|antiberty|ablang", "proteins"), (r"dnabert|nucleotide[-_]transformer|hyenadna|caduceus|(^|[-_/])evo[-_]?2|geneformer|scgpt|scfoundation|enformer|borzoi|gena[-_]lm|agro[-_]?nucleotide|segment_nt|tahoe-x1|state[-_]?(se|st)[-_]", "genomics"), (r"medgemma|txgemma|biomedclip|biomedparse|pubmedbert|biomedbert|bioclinical|clinicalbert|biobert|medsam|meditron|biomistral|med42|openbiollm|llava-med|virchow|gigapath|conch|uni2-h|path-foundation|cxr-foundation|derm-foundation|chexagent|radbert", "medicine"), (r"chemberta|molformer|molt5|chemgpt|chemllm|ether0", "chemistry"), (r"mattergen|mattersim|(^|[-_/])mace[-_]|orb-v\d|chgnet|m3gnet|sevennet|omat24|omol25|equiformer|nequip|aimnet", "materials"), (r"aifs|graphcast|gencast|fourcastnet|pangu[-_]?weather|fengwu|fuxi|stormer|climax|prithvi[-_]?wxc|(^|[-_/])ace2([-_]|$)|hiro-ace|samudra", "weather_climate"), (r"prithvi|satlas|olmoearth|terramind|satmae|(^|[-_/])clay[-_]v|copernicus[-_]?fm|skysense|remoteclip|georsclip", "earth_observation"), (r"astropt|astrollama|astrosage|heliofm", "astronomy"), (r"numinamath|deepseek-prover|kimina-prover|goedel-prover|lean[-_]?(dojo|copilot|star)|minif2f", "math"), ] FAMILY_RX = [(re.compile(p, re.I), d) for p, d in FAMILY_RX] # Explicit repo ids for ambiguous names EXPLICIT = {"microsoft/aurora": "weather_climate", "facebook/UMA": "materials", "facebook/OMAT24": "materials", "facebook/OMol25": "chemistry", "facebook/OC25": "materials", "facebook/fairchem": "materials", "microsoft/mattergen": "materials", "microsoft/MatterSim-v1.0.0-5M": "materials"} # Science-native authors: all their repos default to the given domain(s) (catches untagged repos, e.g. # arcinstitute/evo2_40b). Generalist orgs (facebook, google, microsoft, nvidia, allenai, ibm-*) are NOT here. SCIENCE_NATIVE = { # proteins / bio "arcinstitute": "genomics", "InstaDeepAI": "genomics", "tahoebio": "genomics", "kundajelab": "genomics", "scvi-tools": "genomics", "popV": "genomics", "zhangtaolab": "genomics", "pyaging": "genomics", "multimolecule": "genomics", "living-models": "genomics", "AllTheBacteria": "genomics", "tattabio": "genomics", "ZhejiangLab": "genomics", "AIRI-Institute": "genomics", "songlab": "genomics", "marin-dna": "genomics", "HuggingFaceBio": "genomics", "Xaira-Therapeutics": "genomics", "ScientaLab": "genomics", "ctheodoris": "genomics", "theodoris-lab": "genomics", "zhihan1996": "genomics", "LongSafari": "genomics", "genbio-ai": "genomics", "biohub": "proteins", "EvolutionaryScale": "proteins", "Rostlab": "proteins", "chandar-lab": "proteins", "opig": "proteins", "OpenFold": "proteins", "LiteFold": "proteins", "AI4Protein": "proteins", "ginkgo-datapoints": "proteins", "eve-bio": "chemistry", "DSIMB": "proteins", "RosettaCommons": "proteins", "boltzgen": "proteins", "ChatterjeeLab": "proteins", "hugging-science": "science_general", "imageomics": "ecology_agri", "EarthSpeciesProject": "ecology_agri", "lila-bc-community": "ecology_agri", # medicine "MahmoodLab": "medicine", "OpenMed": "medicine", "owkin": "medicine", "Aignostics": "medicine", "paige-ai": "medicine", "bioptimus": "medicine", "prov-gigapath": "medicine", "wanglab": "medicine", "StanfordAIMI": "medicine", "doctolib-lab": "medicine", "miriad": "medicine", "FreedomIntelligence": "medicine", "ratschlab": "medicine", "aitxchallenge": "medicine", "Merck": "chemistry", "recursionpharma": "chemistry", # chemistry / materials "mist-models": "chemistry", "jablonkagroup": "chemistry", "futurehouse": "chemistry", "openadmet": "chemistry", "maomlab": "chemistry", "isayevlab": "materials", "SandboxAQ": "chemistry", "AethronPhantom": "chemistry", "LeMaterial": "materials", "Entalpic": "materials", "foundry-ml": "materials", "mace-foundations": "materials", "Orbital-Materials": "materials", "colabfit": "materials", "mirror-physics": "materials", "atomind": "materials", "AccelerationConsortium": "materials", # physics / engineering "polymathic-ai": "physics", "proxima-fusion": "physics", "luminary-shift": "physics", "PLAID-datasets": "physics", "neashton": "physics", "AstroAutomata": "physics", "camlab-ethz": "physics", "CERN": "physics", # earth & space "ecmwf": "weather_climate", "nasa-impact": "earth_observation", "ibm-nasa-geospatial": "earth_observation", "isp-uv-es": "earth_observation", "Major-TOM": "earth_observation", "torchgeo": "earth_observation", "ESA-philab": "earth_observation", "ONERA": "earth_observation", "nasa-ibm-ai4science": "astronomy", "NASA-AIML": "astronomy", "UniverseTBD": "astronomy", "astro-legacy-archive": "astronomy", "AstroMLab": "astronomy", "parlange": "astronomy", # government / public research (science-only orgs) "ncbi": "medicine", "adsabs": "astronomy", # neuro "EEGDash": "neuroscience", "braindecode": "neuroscience", # math "AI-MO": "math", "SAIRfoundation": "math", } # Quantisers / re-uploaders whose repos inherit domain tags from base models; excluded from 'original' counts. REUPLOADERS = {"mradermacher", "bartowski", "mlx-community", "unsloth", "LoneStriker", "tensorblock", "TheBloke", "QuantFactory", "MaziyarPanahi", "RichardErkhov", "DevQuasar", "lmstudio-community", "second-state", "nightmedia", "Lamapi", "roleplaiapp", "featherless-ai-quants", "NikolayKozloff", "Triangle104", "ArtusDev", "PrunaAI", "legraphista", "matrixportal", "Mungert", "noctrex", "DavidAU"} EXCLUDE_RX = re.compile(r"^ByteDance/LatentSync|^(vikp|datalab-to)/surya", re.I) # metadata errors / name clashes PRIORITY = ["proteins", "genomics", "chemistry", "materials", "physics", "astronomy", "weather_climate", "earth_observation", "neuroscience", "ecology_agri", "medicine", "math", "biology_other", "science_general"] def primary(domains, author): if author in SCIENCE_NATIVE and SCIENCE_NATIVE[author] in domains: return SCIENCE_NATIVE[author] for d in PRIORITY: if d in domains: return d return None import json as _json, os as _os _LF = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)), "data", "lang_codes.json") LANGS = set(_json.load(open(_LF))) if _os.path.exists(_LF) else set() LANG_COLLISIONS = {"bci", "cfd", "dna", "mri", "rna", "sar"} # ISO-639 codes that are also domain tags def norm(t): return t.lower().replace("_", "-").replace(" ", "-") def classify(tags, library, name, author, repo_type): """Return (set_of_domains, set_of_evidence_kinds).""" doms, ev = set(), set() if EXCLUDE_RX.search(name): return doms, ev nt = {norm(t) for t in (tags if tags is not None else [])} if len(nt & LANGS) >= 3: # multilingual repo: bare language codes like 'mri' (Maori), 'bci' (Baoule) nt -= LANG_COLLISIONS lib = norm(library) if isinstance(library, str) else None for d, r in DOMAINS.items(): if nt & r["tags"]: doms.add(d); ev.add("tag") if lib and lib in {norm(x) for x in r["libs"]}: doms.add(d); ev.add("library") if repo_type == "dataset" and nt & r.get("dataset_tags", set()): doms.add(d); ev.add("modality") short = name.split("/", 1)[-1] for rx, d in FAMILY_RX: if rx.search(short): doms.add(d); ev.add("family") if name in EXPLICIT: doms.add(EXPLICIT[name]); ev.add("family") if author in SCIENCE_NATIVE: doms.add(SCIENCE_NATIVE[author]); ev.add("native_org") # 'biology_other' / 'science_general' are fallbacks: drop if a specific domain was found specific = doms - {"biology_other", "science_general"} if specific: doms = specific return doms, ev