Upload folder using huggingface_hub
Browse files- README.md +115 -3
- config.json +34 -0
- model.safetensors +3 -0
- optimizer.pt +3 -0
- rng_state.pth +3 -0
- scaler.pt +3 -0
- scheduler.pt +3 -0
- special_tokens_map.json +7 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
- trainer_state.json +0 -0
- training_args.bin +3 -0
- vocab.txt +0 -0
README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
| 1 |
-
-
|
| 2 |
-
|
| 3 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# BOND-reranker
|
| 2 |
+
|
| 3 |
+
A cross-encoder reranker model fine-tuned for biomedical ontology entity normalization, designed to work with the BOND (Biomedical Ontology Neural Disambiguation) system.
|
| 4 |
+
|
| 5 |
+
## Model Description
|
| 6 |
+
|
| 7 |
+
This model is a cross-encoder reranker trained to improve the accuracy of entity normalization by re-ranking candidate ontology terms retrieved by BOND's initial retrieval stage. It takes a query-candidate pair and outputs a relevance score.
|
| 8 |
+
|
| 9 |
+
**Training Framework:** Sentence Transformers with cross-encoder architecture
|
| 10 |
+
|
| 11 |
+
## Model Architecture
|
| 12 |
+
|
| 13 |
+
- **Type:** Cross-Encoder
|
| 14 |
+
- **Framework:** Sentence Transformers
|
| 15 |
+
- **Max Sequence Length:** 512 tokens
|
| 16 |
+
- **Output:** Single relevance score per query-candidate pair
|
| 17 |
+
- **Parameters:** ~110M (based on BiomedBERT-base)
|
| 18 |
+
|
| 19 |
+
## Training Data
|
| 20 |
+
|
| 21 |
+
The model was trained on biomedical entity normalization data covering multiple ontologies including:
|
| 22 |
+
|
| 23 |
+
- MONDO (diseases)
|
| 24 |
+
- HPO (phenotypes)
|
| 25 |
+
- UBERON (anatomy)
|
| 26 |
+
- Cell Ontology (CL)
|
| 27 |
+
- Gene Ontology (GO)
|
| 28 |
+
- And other biomedical ontologies
|
| 29 |
+
|
| 30 |
+
Training data consists of query-candidate pairs with relevance labels, where queries are biomedical entity mentions and candidates are ontology terms.
|
| 31 |
+
|
| 32 |
+
## Usage
|
| 33 |
+
|
| 34 |
+
### With BOND Pipeline
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
from bond.config import BondSettings
|
| 38 |
+
from bond.pipeline import BondMatcher
|
| 39 |
+
|
| 40 |
+
# Configure BOND to use this reranker
|
| 41 |
+
settings = BondSettings(
|
| 42 |
+
reranker_path="AronowLab/BOND-reranker",
|
| 43 |
+
enable_reranker=True
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
matcher = BondMatcher(settings=settings)
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### Direct Usage
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
import torch
|
| 53 |
+
from sentence_transformers import CrossEncoder
|
| 54 |
+
|
| 55 |
+
# Load model from local path
|
| 56 |
+
model = CrossEncoder(
|
| 57 |
+
"model_path", # Replace with your model path
|
| 58 |
+
device='cuda' if torch.cuda.is_available() else 'cpu'
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
# Example: Rank candidates for a query
|
| 62 |
+
query = "cell_type: C_BEST4; tissue: descending colon; organism: Homo sapiens"
|
| 63 |
+
candidates = [
|
| 64 |
+
"label: smooth muscle fiber of descending colon; synonyms: non-striated muscle fiber of descending colon",
|
| 65 |
+
"label: smooth muscle cell of colon; synonyms: non-striated muscle fiber of colon",
|
| 66 |
+
"label: epithelial cell of colon; synonyms: colon epithelial cell"
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
# Get ranked results with probabilities
|
| 70 |
+
ranked_results = model.rank(query, candidates, return_documents=True, top_k=3)
|
| 71 |
+
|
| 72 |
+
print("Top 3 ranked results")
|
| 73 |
+
|
| 74 |
+
for result in ranked_results:
|
| 75 |
+
prob = torch.sigmoid(torch.tensor(result['score'])).item()
|
| 76 |
+
print(f"{prob:.8f} - {result['text']}")
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Performance
|
| 80 |
+
|
| 81 |
+
This reranker is designed to work as the final stage in the BOND pipeline:
|
| 82 |
+
|
| 83 |
+
1. **Retrieval:** Exact + BM25 + Dense retrieval with LLM expansion
|
| 84 |
+
2. **Reranking:** This cross-encoder model scores and re-ranks top candidates
|
| 85 |
+
3. **Output:** Final ranked list of ontology terms
|
| 86 |
+
|
| 87 |
+
The reranker significantly improves precision by re-scoring the top-k candidates (typically k=100) retrieved by the initial retrieval stage.
|
| 88 |
+
|
| 89 |
+
### Evaluation Metrics
|
| 90 |
+
|
| 91 |
+
Evaluated on biomedical entity normalization development set:
|
| 92 |
+
|
| 93 |
+
| Metric | Score |
|
| 94 |
+
| --------------------------- | ------ |
|
| 95 |
+
| **Accuracy** | 97.50% |
|
| 96 |
+
| **F1 Score** | 82.37% |
|
| 97 |
+
| **Precision** | 79.58% |
|
| 98 |
+
| **Recall** | 85.36% |
|
| 99 |
+
| **Average Precision** | 88.67% |
|
| 100 |
+
| **Eval Loss** | 0.230 |
|
| 101 |
+
|
| 102 |
+
**Best Model:** Checkpoint at step 69,500 (epoch 2.28) with best metric score of 0.9734
|
| 103 |
+
|
| 104 |
+
## Model Files
|
| 105 |
+
|
| 106 |
+
- `config.json` - Model configuration
|
| 107 |
+
- `model.safetensors` - Model weights in SafeTensors format
|
| 108 |
+
- `tokenizer.json` - Fast tokenizer
|
| 109 |
+
- `vocab.txt` - Vocabulary file
|
| 110 |
+
- `special_tokens_map.json` - Special tokens mapping
|
| 111 |
+
- `tokenizer_config.json` - Tokenizer configuration
|
| 112 |
+
|
| 113 |
+
## License
|
| 114 |
+
|
| 115 |
+
Apache 2.0
|
config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"BertForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"classifier_dropout": null,
|
| 7 |
+
"hidden_act": "gelu",
|
| 8 |
+
"hidden_dropout_prob": 0.1,
|
| 9 |
+
"hidden_size": 384,
|
| 10 |
+
"id2label": {
|
| 11 |
+
"0": "LABEL_0"
|
| 12 |
+
},
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 1536,
|
| 15 |
+
"label2id": {
|
| 16 |
+
"LABEL_0": 0
|
| 17 |
+
},
|
| 18 |
+
"layer_norm_eps": 1e-12,
|
| 19 |
+
"max_position_embeddings": 1024,
|
| 20 |
+
"model_type": "bert",
|
| 21 |
+
"num_attention_heads": 6,
|
| 22 |
+
"num_hidden_layers": 16,
|
| 23 |
+
"pad_token_id": 0,
|
| 24 |
+
"position_embedding_type": "absolute",
|
| 25 |
+
"sentence_transformers": {
|
| 26 |
+
"activation_fn": "torch.nn.modules.activation.Sigmoid",
|
| 27 |
+
"version": "4.1.0"
|
| 28 |
+
},
|
| 29 |
+
"torch_dtype": "float32",
|
| 30 |
+
"transformers_version": "4.53.3",
|
| 31 |
+
"type_vocab_size": 2,
|
| 32 |
+
"use_cache": true,
|
| 33 |
+
"vocab_size": 32768
|
| 34 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:14766d1baf6f825437915baf643f17d827ef9dcd2b083b9f29987a5e6f6691a8
|
| 3 |
+
size 166100172
|
optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4bb4f3417135e321c3b25f5a61f28fe5ef51a14b59915c022803181329d1057
|
| 3 |
+
size 332363770
|
rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ec55b4daad85ce349cc9dcc48542de3969d24bc9676d6ceda96257d516bc1184
|
| 3 |
+
size 14244
|
scaler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ee0fcf7a93ec5c15dc5bc24f4dcfdbdd297f774458ffc4a9e28b6338778e87c7
|
| 3 |
+
size 988
|
scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a4e0dda4ac01f5ed15d66380b515965c66a53aea573d5a1b42728550281990d
|
| 3 |
+
size 1064
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": true,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_basic_tokenize": true,
|
| 47 |
+
"do_lower_case": false,
|
| 48 |
+
"extra_special_tokens": {},
|
| 49 |
+
"mask_token": "[MASK]",
|
| 50 |
+
"model_max_length": 512,
|
| 51 |
+
"never_split": null,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"sep_token": "[SEP]",
|
| 54 |
+
"strip_accents": null,
|
| 55 |
+
"tokenize_chinese_chars": true,
|
| 56 |
+
"tokenizer_class": "BertTokenizer",
|
| 57 |
+
"unk_token": "[UNK]"
|
| 58 |
+
}
|
trainer_state.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:edc5a6d42126b280f3644ab439422a54e2040172376f4f27aed625e2725dbfa4
|
| 3 |
+
size 5496
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|