matulichpt commited on
Commit
dd3583d
·
verified ·
1 Parent(s): 2ebcc9b

Initial model upload with benchmarks

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: apache-2.0
5
+ library_name: sentence-transformers
6
+ tags:
7
+ - sentence-transformers
8
+ - feature-extraction
9
+ - sentence-similarity
10
+ - radiology
11
+ - medical
12
+ - retrieval
13
+ - embedding
14
+ datasets:
15
+ - custom
16
+ metrics:
17
+ - mrr
18
+ - recall
19
+ pipeline_tag: sentence-similarity
20
+ model-index:
21
+ - name: radlit-biencoder
22
+ results:
23
+ - task:
24
+ type: retrieval
25
+ name: Radiology Document Retrieval
26
+ dataset:
27
+ type: custom
28
+ name: RadLIT-9
29
+ config: radlit9-v1.1-balanced
30
+ metrics:
31
+ - type: mrr
32
+ value: 0.829
33
+ name: MRR
34
+ - type: recall@10
35
+ value: 0.971
36
+ name: Recall@10
37
+ - type: ndcg@10
38
+ value: 0.863
39
+ name: nDCG@10
40
+ ---
41
+
42
+ # RadLIT-BiEncoder: Radiology Late Interaction Transformer
43
+
44
+ A domain-specialized bi-encoder model for radiology document retrieval, trained to understand medical imaging terminology, clinical reasoning patterns, and radiology-specific queries.
45
+
46
+ ## Model Description
47
+
48
+ RadLIT-BiEncoder is the first stage of the RadLITE retrieval pipeline. It generates dense embeddings optimized for radiology content retrieval, significantly outperforming general-purpose embedding models on radiology-specific queries.
49
+
50
+ ### Architecture
51
+
52
+ - **Base Model**: RoBERTa-base architecture
53
+ - **Hidden Size**: 768
54
+ - **Layers**: 12
55
+ - **Attention Heads**: 12
56
+ - **Parameters**: ~125M
57
+ - **Max Sequence Length**: 512 tokens
58
+ - **Embedding Dimension**: 768
59
+
60
+ ### Training
61
+
62
+ The model was trained using contrastive learning with hard negative mining on a large corpus of radiology educational content. Training details:
63
+
64
+ - **Training Objective**: Multiple Negatives Ranking Loss with hard negatives
65
+ - **Batch Size**: 32
66
+ - **Learning Rate**: 2e-5 with warmup
67
+ - **Training Epochs**: 4
68
+ - **Hard Negatives**: Mined from top-k retrieval failures
69
+
70
+ **Note**: Training data consisted of radiology educational materials. Specific sources are not disclosed due to variable licensing, but the model is released under Apache 2.0 for research and commercial use.
71
+
72
+ ## Performance
73
+
74
+ ### RadLIT-9 Benchmark
75
+
76
+ RadLIT-9 is a comprehensive radiology retrieval benchmark covering 9 subspecialties:
77
+
78
+ | Metric | Score |
79
+ |--------|-------|
80
+ | **MRR** | 0.829 |
81
+ | **nDCG@10** | 0.863 |
82
+ | **Recall@10** | 97.1% |
83
+ | **Recall@5** | 93.8% |
84
+ | **Recall@1** | 74.3% |
85
+
86
+ ### Subspecialty Performance
87
+
88
+ | Subspecialty | MRR | Recall@10 |
89
+ |--------------|-----|-----------|
90
+ | Physics/Nuclear | 0.936 | 100% |
91
+ | Pediatric | 0.931 | 100% |
92
+ | Thoracic | 0.913 | 98% |
93
+ | Cardiac | 0.862 | 98% |
94
+ | Neuroradiology | 0.860 | 98% |
95
+ | Gastrointestinal | 0.800 | 96% |
96
+ | Breast | 0.722 | 93% |
97
+ | Musculoskeletal | 0.695 | 89% |
98
+ | Genitourinary | 0.694 | 100% |
99
+
100
+ ### Comparison with Baselines
101
+
102
+ | Model | MRR | vs RadLIT |
103
+ |-------|-----|-----------|
104
+ | **RadLIT-BiEncoder** | **0.829** | -- |
105
+ | ColBERT-v2 | 0.750 | -9.5% |
106
+ | General bi-encoder | 0.703 | -15.2% |
107
+ | BM25 | ~0.55 | -33.6% |
108
+
109
+ ## Usage
110
+
111
+ ### Installation
112
+
113
+ ```bash
114
+ pip install sentence-transformers
115
+ ```
116
+
117
+ ### Basic Usage
118
+
119
+ ```python
120
+ from sentence_transformers import SentenceTransformer
121
+
122
+ # Load model
123
+ model = SentenceTransformer('matulichpt/radlit-biencoder')
124
+
125
+ # Encode queries and documents
126
+ queries = [
127
+ "What are the imaging features of hepatocellular carcinoma on MRI?",
128
+ "How do you differentiate glioblastoma from metastasis?"
129
+ ]
130
+ documents = [
131
+ "HCC typically shows arterial enhancement with washout on portal venous phase...",
132
+ "GBM and metastases can be differentiated by their location and multiplicity..."
133
+ ]
134
+
135
+ query_embeddings = model.encode(queries, convert_to_tensor=True)
136
+ doc_embeddings = model.encode(documents, convert_to_tensor=True)
137
+
138
+ # Compute similarity
139
+ from sentence_transformers.util import cos_sim
140
+ similarities = cos_sim(query_embeddings, doc_embeddings)
141
+ print(similarities)
142
+ ```
143
+
144
+ ### For Retrieval Pipeline
145
+
146
+ ```python
147
+ from sentence_transformers import SentenceTransformer, util
148
+ import torch
149
+
150
+ model = SentenceTransformer('matulichpt/radlit-biencoder')
151
+
152
+ # Pre-encode your document corpus
153
+ corpus = ["document 1...", "document 2...", ...]
154
+ corpus_embeddings = model.encode(corpus, convert_to_tensor=True, show_progress_bar=True)
155
+
156
+ # At query time
157
+ query = "What are the CT findings in pulmonary embolism?"
158
+ query_embedding = model.encode(query, convert_to_tensor=True)
159
+
160
+ # Find top-k similar documents
161
+ cos_scores = util.cos_sim(query_embedding, corpus_embeddings)[0]
162
+ top_results = torch.topk(cos_scores, k=10)
163
+
164
+ for score, idx in zip(top_results[0], top_results[1]):
165
+ print(f"Score: {score:.4f} - {corpus[idx][:100]}...")
166
+ ```
167
+
168
+ ## Recommended: Full RadLITE Pipeline
169
+
170
+ For best results, use RadLIT-BiEncoder as the first stage followed by RadLIT-CrossEncoder for reranking:
171
+
172
+ ```python
173
+ from sentence_transformers import SentenceTransformer, CrossEncoder
174
+
175
+ # Stage 1: Bi-encoder retrieval
176
+ biencoder = SentenceTransformer('grai-rad/radlit-biencoder')
177
+
178
+ # Stage 2: Cross-encoder reranking
179
+ crossencoder = CrossEncoder('matulichpt/radlit-crossencoder')
180
+
181
+ # Retrieve candidates
182
+ query = "What are the MRI findings in anterior cruciate ligament tear?"
183
+ candidates = retrieve_with_biencoder(query, corpus, biencoder, top_k=50)
184
+
185
+ # Rerank with cross-encoder
186
+ pairs = [[query, doc] for doc in candidates]
187
+ scores = crossencoder.predict(pairs)
188
+
189
+ # Apply temperature calibration (recommended: T=1.5)
190
+ calibrated_scores = scores / 1.5
191
+
192
+ # Sort by calibrated scores
193
+ reranked = sorted(zip(candidates, calibrated_scores), key=lambda x: x[1], reverse=True)
194
+ ```
195
+
196
+ ## Intended Use
197
+
198
+ ### Primary Use Cases
199
+
200
+ - Radiology educational content retrieval
201
+ - Medical imaging literature search
202
+ - Clinical decision support (retrieval component)
203
+ - Radiology question-answering systems
204
+
205
+ ### Out-of-Scope Uses
206
+
207
+ - General web search
208
+ - Non-medical document retrieval
209
+ - Clinical diagnosis (this is a retrieval model, not a diagnostic tool)
210
+
211
+ ## Limitations
212
+
213
+ 1. **Domain Specificity**: Optimized for radiology; may underperform on general medical or non-medical content
214
+ 2. **Language**: English only
215
+ 3. **Subspecialty Variance**: Performance varies by subspecialty (0.69-0.94 MRR range)
216
+ 4. **Not a Diagnostic Tool**: This model retrieves relevant documents; it does not provide medical diagnoses
217
+
218
+ ## Ethical Considerations
219
+
220
+ - This model should not be used as a sole source for clinical decision-making
221
+ - Retrieved documents should be reviewed by qualified medical professionals
222
+ - The model may reflect biases present in radiology educational literature
223
+
224
+ ## Citation
225
+
226
+ ```bibtex
227
+ @software{radlit_biencoder_2026,
228
+ title = {RadLIT-BiEncoder: Domain-Specialized Embeddings for Radiology Retrieval},
229
+ author = {Grai Team},
230
+ year = {2026},
231
+ url = {https://huggingface.co/matulichpt/radlit-biencoder},
232
+ note = {MRR 0.829 on RadLIT-9 benchmark}
233
+ }
234
+ ```
235
+
236
+ ## License
237
+
238
+ Apache 2.0 - Free for research and commercial use.
239
+
240
+ ## Contact
241
+
242
+ For questions or collaboration: Open an issue on the model repository
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "RobertaModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "dtype": "float32",
9
+ "eos_token_id": 2,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 514,
18
+ "model_type": "roberta",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 12,
21
+ "pad_token_id": 1,
22
+ "position_embedding_type": "absolute",
23
+ "transformers_version": "4.56.2",
24
+ "type_vocab_size": 1,
25
+ "use_cache": true,
26
+ "vocab_size": 50265
27
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "SentenceTransformer",
3
+ "__version__": {
4
+ "sentence_transformers": "5.1.1",
5
+ "transformers": "4.56.2",
6
+ "pytorch": "2.10.0.dev20251011+cu128"
7
+ },
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1e5e54f4a42b7e4a337b631bf88c517650f8e9cbb569b56f8f9c92b83b43e8a
3
+ size 498604904
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": true,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": true,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": true,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": true,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "max_length": 512,
53
+ "model_max_length": 512,
54
+ "pad_to_multiple_of": null,
55
+ "pad_token": "<pad>",
56
+ "pad_token_type_id": 0,
57
+ "padding_side": "right",
58
+ "sep_token": "</s>",
59
+ "stride": 0,
60
+ "tokenizer_class": "RobertaTokenizer",
61
+ "trim_offsets": true,
62
+ "truncation_side": "right",
63
+ "truncation_strategy": "longest_first",
64
+ "unk_token": "<unk>"
65
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff