Gene→disease relation classifier
Classifies the relation asserted between a given gene and a given disease in a single sentence, over 18 predicates. Multi-label: a pair can carry several predicates at once (e.g. somatically mutated and a therapeutic target).
Fine-tuned from michiyasunaga/BioLinkBERT-large with a linear head on the [CLS] representation.
Input format
One sentence per example, with the gene and disease already identified and wrapped in marker tokens:
[GENE]BRCA1[/GENE] mutations confer an elevated lifetime risk of [DISEASE]breast cancer[/DISEASE].
- The model does not find entities — run NER first, then mark one gene and one disease per input. A sentence with several pairs becomes several inputs.
- The four markers
[GENE] [/GENE] [DISEASE] [/DISEASE]are special tokens in the bundled tokenizer. Use that tokenizer: a stock BioLinkBERT tokenizer will split them into sub-words and predictions degrade silently. - Sentence-level only. Inputs are truncated at 256 tokens.
Output
18 independent probabilities, one per predicate (sigmoid, not softmax). A
predicate is predicted when its probability is ≥ 0.5. If nothing clears the
threshold, the pair is deemed to have no relation — there is no explicit no_relation class.
Usage
This is a custom architecture, so it cannot be loaded with AutoModel,
AutoModelForSequenceClassification, or pipeline(). Load it with the
re_model.py file that ships in this repository.
Command line
pip install torch transformers huggingface_hub
huggingface-cli download ktiwari-el0303/re-gene-disease --local-dir re-model
python re-model/example_usage.py --model re-model --text "[GENE]BRCA1[/GENE] mutations cause [DISEASE]breast cancer[/DISEASE]."
example_usage.py also takes a TSV with a marked_text column (--tsv) and
writes predictions plus all 18 probabilities with --out.
Python
import sys
from huggingface_hub import snapshot_download
path = snapshot_download("ktiwari-el0303/re-gene-disease")
sys.path.insert(0, path)
from re_model import load, predict
model, tok = load(path) # also checks the markers are intact
predict(model, tok, [
"[GENE]BRCA1[/GENE] mutations cause [DISEASE]breast cancer[/DISEASE].",
])
# [{"predicates": [...], "probabilities": {...all 18...}}]
predict returns the predicted predicates (empty list = no relation) and every
probability, so a different threshold can be applied afterwards.
Common mistakes
| don't | why | instead |
|---|---|---|
AutoModel.from_pretrained(repo) / pipeline(...) |
architecture not registered with transformers | re_model.load(path) |
| a stock BioLinkBERT tokenizer | splits the markers into sub-words; accuracy drops with no error | the tokenizer in this repo (load checks it) |
softmax over the logits |
the labels are independent, not mutually exclusive | sigmoid, as predict does |
expecting a no_relation label |
there isn't one | an empty predicates list means no relation |
| several pairs marked in one input | the model reads one gene–disease pair | one input per pair |
Labels
biomarker_for_diseasecauses_diseaseconfers_disease_riskconfers_drug_resistance_in_diseasecopy_number_altered_in_diseasediagnostic_biomarker_fordrives_disease_progressionepigenetically_altered_in_diseaseexpression_altered_in_diseasegene_associated_with_diseasemodifies_diseasepost_translationally_modified_in_diseasepredictive_biomarker_forprognostic_biomarker_forsomatically_mutated_in_diseasestructurally_rearranged_in_diseasesynthetic_lethal_target_in_diseasetherapeutic_target_for_disease
Training data
Sentence-level gene–disease pairs from PubMed abstracts, labelled by a three-run LLM consensus (a predicate is kept only when all runs agree; no-relation rows require unanimous agreement). The corpus was enriched with targeted retrieval for sparse predicates (synthetic lethality, PTM, predictive biomarkers, disease modifiers, drug resistance, biomarkers, copy number). Splits are grouped by PMID so no abstract spans two splits: train 10,451, validation 1,347, test 1,347.
Training
- Base:
michiyasunaga/BioLinkBERT-large,clspooling, entity markers in the input text - Multi-label binary cross-entropy, threshold 0.5
- LR 2e-05, batch 32, up to 15 epochs, early stopping on validation macro-F1 (patience 2), bf16
- LR selected per backbone on validation; released checkpoint is seed 2
Results
Test set. Released model is the checkpoint in this repository (seed 2). 10-seed mean is the same training recipe repeated over seeds (1, 2, 3, 4, 5, 6, 7, 8, 9, 42), showing how much results vary with the seed.
The release seed was chosen on the validation set (highest validation no-relation accuracy), not on test, so the released model's test scores are an unbiased estimate of its performance.
| metric | released model | 10-seed mean ± sd |
|---|---|---|
| macro F1 | 0.850 | 0.840 ± 0.008 |
| micro F1 | 0.861 | 0.853 ± 0.006 |
| no-relation accuracy | 0.818 | 0.728 ± 0.069 |
No-relation accuracy is the fraction of true no-relation pairs for which the model predicts nothing; macro/micro F1 are computed over the 18 predicates and do not measure it. It also appears to be the most seed-dependent metric, ranging widely across seeds, which is why the release seed was selected on it.
Per-predicate F1
| predicate | released model | 10-seed mean ± sd |
|---|---|---|
synthetic_lethal_target_in_disease |
0.958 | 0.954 ± 0.007 |
causes_disease |
0.939 | 0.925 ± 0.030 |
diagnostic_biomarker_for |
0.938 | 0.915 ± 0.019 |
prognostic_biomarker_for |
0.929 | 0.899 ± 0.016 |
expression_altered_in_disease |
0.895 | 0.896 ± 0.011 |
copy_number_altered_in_disease |
0.892 | 0.883 ± 0.026 |
confers_disease_risk |
0.888 | 0.885 ± 0.022 |
post_translationally_modified_in_disease |
0.879 | 0.853 ± 0.026 |
drives_disease_progression |
0.877 | 0.877 ± 0.009 |
confers_drug_resistance_in_disease |
0.855 | 0.829 ± 0.018 |
somatically_mutated_in_disease |
0.829 | 0.799 ± 0.047 |
predictive_biomarker_for |
0.826 | 0.836 ± 0.043 |
epigenetically_altered_in_disease |
0.825 | 0.759 ± 0.037 |
gene_associated_with_disease |
0.821 | 0.819 ± 0.013 |
structurally_rearranged_in_disease |
0.800 | 0.807 ± 0.058 |
biomarker_for_disease |
0.757 | 0.714 ± 0.040 |
therapeutic_target_for_disease |
0.750 | 0.754 ± 0.015 |
modifies_disease |
0.642 | 0.723 ± 0.041 |
Limitations
- Labels are LLM-generated. A manual audit found per-predicate label precision of roughly 70–90% for most predicates. The model inherits those tendencies
- Direction and negation are not encoded. A gene reported as protective, or a relation reported as absent, can still receive a positive predicate. These will be handled by a separate qualifier stage.
- Trained on abstracts; behaviour on full text is untested.