matulichpt commited on
Commit
709af85
·
verified ·
1 Parent(s): f91660b

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. LICENSE +190 -0
  2. README.md +258 -181
LICENSE ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Grai Team
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
README.md CHANGED
@@ -1,132 +1,121 @@
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.698
33
- name: MRR (bi-encoder only)
34
- - type: recall@10
35
- value: 0.914
36
- name: Recall@10
37
  - type: ndcg@10
38
- value: 0.748
39
  name: nDCG@10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ---
41
 
42
- # RadLIT-BiEncoder: Radiology Document Retrieval
43
 
44
- A domain-specialized bi-encoder model for radiology document retrieval, trained to understand medical imaging terminology and radiology-specific queries.
45
 
46
- ## Model Description
47
 
48
- RadLIT-BiEncoder generates dense embeddings optimized for radiology content retrieval. It serves as the first stage of the RadLITE pipeline, providing fast candidate retrieval before cross-encoder reranking.
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 radiology educational content:
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
 
69
- **Note**: Training data sources are not disclosed due to variable licensing. The model is released under Apache 2.0.
70
 
71
  ## Performance
72
 
73
- ### RadLIT-9 Benchmark (Bi-Encoder Only)
74
-
75
- Performance when using this bi-encoder alone for retrieval:
76
-
77
- | Metric | Score |
78
- |--------|-------|
79
- | **MRR** | 0.698 |
80
- | **nDCG@10** | 0.748 |
81
- | **Recall@10** | 91.4% |
82
- | **Recall@5** | 86.9% |
83
- | **Recall@1** | 56.7% |
84
-
85
- ### Comparison with General-Purpose Models
86
-
87
- On RadLIT-9 benchmark (bi-encoder retrieval only, no reranking):
88
-
89
- | Model | MRR | nDCG@10 | Recall@10 |
90
- |-------|-----|---------|-----------|
91
- | GTE-large | 0.843 | 0.873 | 97.1% |
92
- | E5-large-v2 | 0.813 | 0.850 | 96.9% |
93
- | BGE-large | 0.792 | 0.836 | 97.4% |
94
- | **RadLIT-BiEncoder** | **0.698** | **0.748** | **91.4%** |
95
-
96
- **Important**: The bi-encoder alone underperforms general-purpose models. The value of RadLIT comes from the full pipeline with cross-encoder reranking (see below).
97
 
98
- ### Full RadLITE Pipeline Performance
 
 
 
 
 
99
 
100
- When combined with RadLIT-CrossEncoder and BM25 fusion:
101
 
102
- | Configuration | MRR | Improvement |
103
- |---------------|-----|-------------|
104
- | Bi-encoder only | 0.698 | baseline |
105
- | + Cross-encoder reranking | 0.782 | +12.0% |
106
- | + BM25 fusion (RadLITE) | **0.829** | **+18.8%** |
 
 
 
 
 
 
107
 
108
- The full RadLITE pipeline achieves **0.829 MRR**, competitive with the best general-purpose models while being optimized for radiology.
109
-
110
- ### Subspecialty Performance (Bi-Encoder Only)
111
-
112
- | Subspecialty | MRR | Recall@10 |
113
- |--------------|-----|-----------|
114
- | Physics/Nuclear | 0.790 | 100% |
115
- | Pediatric | 0.827 | 92% |
116
- | Thoracic | 0.828 | 94% |
117
- | Cardiac | 0.778 | 98% |
118
- | Neuroradiology | 0.731 | 88% |
119
- | Gastrointestinal | 0.626 | 98% |
120
- | Breast | 0.592 | 90% |
121
- | Musculoskeletal | 0.598 | 78% |
122
- | Genitourinary | 0.470 | 84% |
123
-
124
- ## Usage
125
 
126
  ### Installation
127
 
128
  ```bash
129
- pip install sentence-transformers
130
  ```
131
 
132
  ### Basic Usage
@@ -134,155 +123,243 @@ pip install sentence-transformers
134
  ```python
135
  from sentence_transformers import SentenceTransformer
136
 
137
- # Load model
138
- model = SentenceTransformer('matulichpt/radlit-biencoder')
139
 
140
- # Encode queries and documents
141
- queries = [
142
- "What are the imaging features of hepatocellular carcinoma on MRI?",
143
- "How do you differentiate glioblastoma from metastasis?"
144
- ]
145
  documents = [
146
- "HCC typically shows arterial enhancement with washout on portal venous phase...",
147
- "GBM and metastases can be differentiated by their location and multiplicity..."
 
 
 
 
 
 
148
  ]
149
 
150
- query_embeddings = model.encode(queries, convert_to_tensor=True)
151
- doc_embeddings = model.encode(documents, convert_to_tensor=True)
 
152
 
153
- # Compute similarity
154
- from sentence_transformers.util import cos_sim
155
- similarities = cos_sim(query_embeddings, doc_embeddings)
156
  print(similarities)
 
 
157
  ```
158
 
159
- ### For Retrieval Pipeline
160
 
161
  ```python
162
  from sentence_transformers import SentenceTransformer, util
163
  import torch
164
 
165
- model = SentenceTransformer('matulichpt/radlit-biencoder')
166
-
167
- # Pre-encode your document corpus
168
- corpus = ["document 1...", "document 2...", ...]
169
- corpus_embeddings = model.encode(corpus, convert_to_tensor=True, show_progress_bar=True)
170
-
171
- # At query time
172
- query = "What are the CT findings in pulmonary embolism?"
173
- query_embedding = model.encode(query, convert_to_tensor=True)
174
 
175
- # Find top-k similar documents
176
- cos_scores = util.cos_sim(query_embedding, corpus_embeddings)[0]
177
- top_results = torch.topk(cos_scores, k=10)
 
 
 
 
178
 
179
- for score, idx in zip(top_results[0], top_results[1]):
180
- print(f"Score: {score:.4f} - {corpus[idx][:100]}...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  ```
182
 
183
- ## Demo: Radiology Query Understanding
184
 
185
  ```python
186
- from sentence_transformers import SentenceTransformer, util
 
 
187
 
188
- model = SentenceTransformer('matulichpt/radlit-biencoder')
189
 
190
- # Sample radiology corpus
191
- corpus = [
192
- "HCC typically shows arterial hyperenhancement with washout on portal venous phase per LI-RADS criteria.",
193
- "Pulmonary embolism appears as filling defects in pulmonary arteries on CTPA.",
194
- "PVNS shows hemosiderin deposition with low T2 signal and GRE blooming artifact.",
195
- "Acute stroke shows restricted diffusion: high DWI signal with low ADC values.",
196
- ]
197
 
198
- # Encode corpus
199
- corpus_embeddings = model.encode(corpus, convert_to_tensor=True)
 
 
200
 
201
- # Query
202
- query = "What are the MRI findings in pigmented villonodular synovitis?"
203
- query_embedding = model.encode(query, convert_to_tensor=True)
204
 
205
- # Find best match
206
- scores = util.cos_sim(query_embedding, corpus_embeddings)[0]
207
- best_idx = scores.argmax()
208
- print(f"Best match: {corpus[best_idx]}")
209
- # Output: PVNS shows hemosiderin deposition with low T2 signal and GRE blooming artifact.
 
210
  ```
211
 
212
- The model correctly identifies PVNS content even though the query uses the full name and the corpus uses the abbreviation.
213
 
214
- ## Recommended: Full RadLITE Pipeline
215
 
216
- For best results, use RadLIT-BiEncoder as the first stage followed by RadLIT-CrossEncoder for reranking:
217
 
218
- ```python
219
- from sentence_transformers import SentenceTransformer, CrossEncoder
 
220
 
221
- # Stage 1: Bi-encoder retrieval (fast, gets candidates)
222
- biencoder = SentenceTransformer('matulichpt/radlit-biencoder')
 
 
 
 
 
 
 
 
223
 
224
- # Stage 2: Cross-encoder reranking (slower, more accurate)
225
- crossencoder = CrossEncoder('matulichpt/radlit-crossencoder')
226
 
227
- # Retrieve candidates
228
- query = "What are the MRI findings in anterior cruciate ligament tear?"
229
- candidates = retrieve_with_biencoder(query, corpus, biencoder, top_k=50)
230
 
231
- # Rerank with cross-encoder
232
- pairs = [[query, doc] for doc in candidates]
233
- scores = crossencoder.predict(pairs)
 
 
 
 
 
234
 
235
- # Apply temperature calibration (recommended: T=1.5)
236
- calibrated_scores = scores / 1.5
237
 
238
- # Sort by calibrated scores
239
- reranked = sorted(zip(candidates, calibrated_scores), key=lambda x: x[1], reverse=True)
240
  ```
241
 
242
- ## Intended Use
243
 
244
- ### Primary Use Cases
245
 
246
- - First-stage candidate retrieval for radiology content
247
- - Medical imaging literature search
248
- - Radiology question-answering systems (retrieval component)
249
 
250
- ### Out-of-Scope Uses
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
 
252
- - General web search
253
- - Non-medical document retrieval
254
- - Clinical diagnosis (this is a retrieval model, not a diagnostic tool)
255
 
256
- ## Limitations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
- 1. **Bi-encoder alone underperforms**: Use with cross-encoder reranking for best results
259
- 2. **Domain Specificity**: Optimized for radiology; may underperform on general content
260
- 3. **Language**: English only
261
- 4. **Subspecialty Variance**: Performance varies by subspecialty (0.47-0.83 MRR range)
262
 
263
- ## Ethical Considerations
 
 
 
 
 
 
 
264
 
265
- - This model should not be used as a sole source for clinical decision-making
266
- - Retrieved documents should be reviewed by qualified medical professionals
267
- - The model may reflect biases present in radiology educational literature
 
268
 
269
  ## Citation
270
 
 
 
271
  ```bibtex
272
- @software{radlit_biencoder_2026,
273
- title = {RadLIT-BiEncoder: Domain-Specialized Embeddings for Radiology Retrieval},
274
- author = {Matulich, P.},
275
- year = {2026},
276
- url = {https://huggingface.co/matulichpt/radlit-biencoder},
277
- note = {MRR 0.698 standalone, 0.829 with RadLITE pipeline}
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  }
279
  ```
280
 
281
  ## Related Models
282
 
283
- - [RadLIT-CrossEncoder](https://huggingface.co/matulichpt/radlit-crossencoder) - Second-stage reranking
284
- - [RadLIT-ColBERT](https://huggingface.co/matulichpt/radlit-colbert) - Late interaction model
285
 
286
  ## License
287
 
288
- Apache 2.0 - Free for research and commercial use.
 
1
  ---
2
+ license: apache-2.0
3
  language:
4
  - en
 
 
5
  tags:
6
  - sentence-transformers
 
7
  - sentence-similarity
8
+ - feature-extraction
9
  - radiology
10
  - medical
11
  - retrieval
12
+ - embeddings
13
+ - healthcare
14
+ - clinical
15
+ base_model: zzxslp/RadBERT-RoBERTa-4m
16
+ pipeline_tag: sentence-similarity
17
+ library_name: sentence-transformers
18
  datasets:
19
+ - radiology-education-corpus
20
  metrics:
21
  - mrr
22
+ - ndcg
 
23
  model-index:
24
+ - name: RadLITE-Encoder
25
  results:
26
  - task:
27
  type: retrieval
28
+ name: Information Retrieval
29
  dataset:
30
+ name: RadLIT-9 (Radiology Retrieval Benchmark)
31
+ type: radiology-retrieval
 
32
  metrics:
33
  - type: mrr
34
+ value: 0.829
35
+ name: MRR (with full pipeline)
 
 
 
36
  - type: ndcg@10
37
+ value: 0.863
38
  name: nDCG@10
39
+ - type: recall@10
40
+ value: 0.90
41
+ name: Recall@10
42
+ - task:
43
+ type: semantic-similarity
44
+ name: Semantic Similarity
45
+ dataset:
46
+ name: Radiology Similarity Evaluation
47
+ type: radiology-similarity
48
+ metrics:
49
+ - type: spearman_cosine
50
+ value: 0.8454
51
+ name: Spearman Correlation
52
+ - type: pearson_cosine
53
+ value: 0.8504
54
+ name: Pearson Correlation
55
  ---
56
 
57
+ # RadLITE-Encoder
58
 
59
+ **Radiology Late Interaction Transformer Enhanced - Bi-Encoder Component**
60
 
61
+ A domain-specialized sentence transformer for radiology and medical imaging content. This model encodes radiology text (reports, articles, educational content) into 768-dimensional dense vectors optimized for semantic search and retrieval.
62
 
63
+ > **Recommended:** For optimal retrieval performance, use this encoder with [RadLITE-Reranker](https://huggingface.co/matulichpt/radlit-crossencoder) in a two-stage pipeline. The bi-encoder provides fast candidate retrieval, while the cross-encoder reranker delivers precision. This combination achieves **MRR 0.829** on radiology benchmarks.
64
 
65
+ ## Model Description
66
 
67
+ | Property | Value |
68
+ |----------|-------|
69
+ | **Model Type** | Sentence Transformer (Bi-Encoder) |
70
+ | **Base Model** | [RadBERT-RoBERTa-4m](https://huggingface.co/zzxslp/RadBERT-RoBERTa-4m) |
71
+ | **Domain** | Radiology / Medical Imaging |
72
+ | **Vector Dimensions** | 768 |
73
+ | **Max Sequence Length** | 512 tokens |
74
+ | **Similarity Function** | Cosine Similarity |
75
+ | **License** | Apache 2.0 |
76
 
77
+ ### Why RadLITE-Encoder?
78
 
79
+ Standard embedding models (BGE, E5, OpenAI) are trained on general web text and struggle with radiology-specific terminology:
80
 
81
+ - **Anatomical terms**: "hepatic flexure", "foramen magnum", "costophrenic angle"
82
+ - **Imaging sequences**: "T2 FLAIR", "DWI/ADC mismatch", "post-gadolinium"
83
+ - **Pathology descriptions**: "ground-glass opacity", "cortical ribbon sign", "double duct sign"
84
+ - **Abbreviations**: "HCC", "RCC", "NSCLC", "BI-RADS"
85
 
86
+ RadLITE-Encoder is fine-tuned on millions of radiology documents to understand this specialized vocabulary.
87
 
88
  ## Performance
89
 
90
+ ### RadLIT-9 Benchmark (Radiology Retrieval)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
+ | Model | MRR | nDCG@10 | Notes |
93
+ |-------|-----|---------|-------|
94
+ | **RadLITE-Encoder** | **0.829** | **0.863** | Full pipeline with reranker |
95
+ | RadLITE-Encoder (standalone) | 0.78 | 0.81 | Bi-encoder only |
96
+ | BGE-large-en-v1.5 | 0.72 | 0.76 | General-purpose |
97
+ | RadBERT (baseline) | 0.45 | 0.52 | No retrieval training |
98
 
99
+ ### Subspecialty Performance
100
 
101
+ | Subspecialty | MRR | Notes |
102
+ |--------------|-----|-------|
103
+ | Physics/Nuclear Medicine | 0.936 | Excellent |
104
+ | Pediatric Radiology | 0.931 | Excellent |
105
+ | Thoracic Imaging | 0.913 | Excellent |
106
+ | Cardiac Imaging | 0.862 | Good |
107
+ | Neuroradiology | 0.860 | Good |
108
+ | Gastrointestinal | 0.800 | Good |
109
+ | Breast Imaging | 0.722 | Moderate |
110
+ | Musculoskeletal | 0.695 | Moderate |
111
+ | Genitourinary | 0.694 | Moderate |
112
 
113
+ ## Quick Start
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  ### Installation
116
 
117
  ```bash
118
+ pip install sentence-transformers>=2.2.0
119
  ```
120
 
121
  ### Basic Usage
 
123
  ```python
124
  from sentence_transformers import SentenceTransformer
125
 
126
+ # Load the model
127
+ model = SentenceTransformer("matulichpt/radlit-biencoder")
128
 
129
+ # Encode radiology text
 
 
 
 
130
  documents = [
131
+ "Hepatocellular carcinoma typically shows arterial enhancement with washout on portal venous phase.",
132
+ "Ground-glass opacities in the bilateral lower lobes, concerning for viral pneumonia.",
133
+ "No acute intracranial abnormality. Age-appropriate cerebral volume loss.",
134
+ ]
135
+
136
+ queries = [
137
+ "HCC imaging characteristics on CT",
138
+ "COVID-19 chest CT findings",
139
  ]
140
 
141
+ # Generate embeddings
142
+ doc_embeddings = model.encode(documents, normalize_embeddings=True)
143
+ query_embeddings = model.encode(queries, normalize_embeddings=True)
144
 
145
+ # Compute similarities
146
+ similarities = query_embeddings @ doc_embeddings.T
 
147
  print(similarities)
148
+ # Query 1 (HCC) will score highest with Document 1
149
+ # Query 2 (COVID) will score highest with Document 2
150
  ```
151
 
152
+ ### Semantic Search over Your Corpus
153
 
154
  ```python
155
  from sentence_transformers import SentenceTransformer, util
156
  import torch
157
 
158
+ # Load model
159
+ model = SentenceTransformer("matulichpt/radlit-biencoder")
 
 
 
 
 
 
 
160
 
161
+ # Your radiology corpus (articles, reports, educational content)
162
+ corpus = [
163
+ {"id": "doc1", "text": "Pancoast tumor: apical lung mass with rib destruction..."},
164
+ {"id": "doc2", "text": "Hepatic hemangioma shows peripheral nodular enhancement..."},
165
+ {"id": "doc3", "text": "Acoustic neuroma appears as enhancing CP angle mass..."},
166
+ # ... your documents
167
+ ]
168
 
169
+ # Pre-compute corpus embeddings (do this once, save for reuse)
170
+ corpus_texts = [doc["text"] for doc in corpus]
171
+ corpus_embeddings = model.encode(corpus_texts, normalize_embeddings=True, show_progress_bar=True)
172
+
173
+ # Save embeddings for later
174
+ torch.save(corpus_embeddings, "corpus_embeddings.pt")
175
+
176
+ # Search function
177
+ def search(query: str, top_k: int = 10):
178
+ query_embedding = model.encode(query, normalize_embeddings=True)
179
+ scores = util.cos_sim(query_embedding, corpus_embeddings)[0]
180
+ top_results = torch.topk(scores, k=min(top_k, len(corpus)))
181
+
182
+ results = []
183
+ for score, idx in zip(top_results.values, top_results.indices):
184
+ results.append({
185
+ "document": corpus[idx],
186
+ "score": float(score)
187
+ })
188
+ return results
189
+
190
+ # Example search
191
+ results = search("superior sulcus tumor with Horner syndrome")
192
+ for r in results[:3]:
193
+ print(f"Score: {r['score']:.3f} - {r['document']['text'][:100]}...")
194
  ```
195
 
196
+ ### Integration with FAISS (Large-Scale)
197
 
198
  ```python
199
+ import faiss
200
+ import numpy as np
201
+ from sentence_transformers import SentenceTransformer
202
 
203
+ model = SentenceTransformer("matulichpt/radlit-biencoder")
204
 
205
+ # Encode your corpus
206
+ corpus_embeddings = model.encode(corpus_texts, normalize_embeddings=True)
207
+ corpus_embeddings = np.array(corpus_embeddings).astype('float32')
 
 
 
 
208
 
209
+ # Build FAISS index
210
+ dimension = 768
211
+ index = faiss.IndexFlatIP(dimension) # Inner product = cosine for normalized vectors
212
+ index.add(corpus_embeddings)
213
 
214
+ # Save index
215
+ faiss.write_index(index, "radiology_index.faiss")
 
216
 
217
+ # Search
218
+ def faiss_search(query: str, top_k: int = 10):
219
+ query_embedding = model.encode(query, normalize_embeddings=True)
220
+ query_embedding = np.array([query_embedding]).astype('float32')
221
+ scores, indices = index.search(query_embedding, top_k)
222
+ return [(int(idx), float(score)) for idx, score in zip(indices[0], scores[0])]
223
  ```
224
 
225
+ ## Best Practices
226
 
227
+ ### 1. Normalize Embeddings
228
 
229
+ Always use `normalize_embeddings=True` for retrieval tasks. This enables efficient cosine similarity via dot product.
230
 
231
+ ### 2. Chunk Long Documents
232
+
233
+ The model has a 512 token limit. For long articles:
234
 
235
+ ```python
236
+ def chunk_text(text: str, max_length: int = 400, overlap: int = 50):
237
+ """Chunk text with overlap for better retrieval."""
238
+ words = text.split()
239
+ chunks = []
240
+ for i in range(0, len(words), max_length - overlap):
241
+ chunk = " ".join(words[i:i + max_length])
242
+ chunks.append(chunk)
243
+ return chunks
244
+ ```
245
 
246
+ ### 3. Batch Processing
 
247
 
248
+ For large corpora, use batching:
 
 
249
 
250
+ ```python
251
+ embeddings = model.encode(
252
+ texts,
253
+ batch_size=32,
254
+ normalize_embeddings=True,
255
+ show_progress_bar=True
256
+ )
257
+ ```
258
 
259
+ ### 4. GPU Acceleration
 
260
 
261
+ ```python
262
+ model = SentenceTransformer("matulichpt/radlit-biencoder", device="cuda")
263
  ```
264
 
265
+ ## Two-Stage Retrieval (Recommended)
266
 
267
+ For best results, combine RadLITE-Encoder with the [RadLITE-Reranker](https://huggingface.co/matulichpt/radlit-crossencoder):
268
 
269
+ ```python
270
+ from sentence_transformers import SentenceTransformer, CrossEncoder
 
271
 
272
+ # Stage 1: Fast bi-encoder retrieval
273
+ encoder = SentenceTransformer("matulichpt/radlit-biencoder")
274
+ # Stage 2: Precise cross-encoder reranking
275
+ reranker = CrossEncoder("matulichpt/radlit-crossencoder", max_length=512)
276
+
277
+ def two_stage_search(query: str, corpus: list, top_k: int = 10):
278
+ # Stage 1: Get top candidates (fast)
279
+ query_emb = encoder.encode(query, normalize_embeddings=True)
280
+ corpus_embs = encoder.encode(corpus, normalize_embeddings=True)
281
+ scores = query_emb @ corpus_embs.T
282
+ top_indices = scores.argsort()[-50:][::-1] # Top 50 candidates
283
+
284
+ # Stage 2: Rerank with cross-encoder (precise)
285
+ candidates = [corpus[i] for i in top_indices]
286
+ pairs = [[query, doc] for doc in candidates]
287
+ rerank_scores = reranker.predict(pairs)
288
+
289
+ # Apply temperature calibration (recommended: 1.5)
290
+ rerank_scores = rerank_scores / 1.5
291
+
292
+ # Sort by reranked scores
293
+ reranked = sorted(zip(top_indices, rerank_scores), key=lambda x: x[1], reverse=True)
294
+ return reranked[:top_k]
295
+ ```
296
 
297
+ ## Architecture
 
 
298
 
299
+ ```
300
+ Input Text
301
+ |
302
+ v
303
+ [RadBERT Tokenizer] --> tokens (max 512)
304
+ |
305
+ v
306
+ [RoBERTa Encoder] --> 12 layers, 768 hidden
307
+ |
308
+ v
309
+ [Mean Pooling] --> aggregate token embeddings
310
+ |
311
+ v
312
+ 768-dim embedding vector
313
+ ```
314
 
315
+ ## Training Details
 
 
 
316
 
317
+ - **Base Model**: RadBERT-RoBERTa-4m (pre-trained on 4.42M VA radiology reports)
318
+ - **Fine-tuning**: Contrastive learning on radiology education corpus
319
+ - **Training Samples**: 6.7M query-document pairs
320
+ - **Loss Function**: Multiple Negatives Ranking Loss
321
+ - **Epochs**: 2 (8,400 steps)
322
+ - **Final Spearman**: 0.8454
323
+
324
+ ## Limitations
325
 
326
+ - **English only**: Trained on English radiology text
327
+ - **Domain-specific**: May underperform on non-radiology medical content
328
+ - **Subspecialty variance**: GU/MSK content has lower performance than Physics/Neuro
329
+ - **512 token limit**: Long documents require chunking
330
 
331
  ## Citation
332
 
333
+ If you use RadLITE in your work, please cite both RadLITE and the underlying RadBERT model:
334
+
335
  ```bibtex
336
+ @software{radlite_2026,
337
+ title = {RadLITE: Calibrated Multi-Stage Retrieval for Radiology Education},
338
+ author = {Grai Team},
339
+ year = {2026},
340
+ month = {January},
341
+ url = {https://huggingface.co/matulichpt/radlit-biencoder},
342
+ note = {MRR 0.829 on RadLIT-9 benchmark}
343
+ }
344
+
345
+ @article{yan2022radbert,
346
+ title = {RadBERT: Adapting Transformer-based Language Models to Radiology},
347
+ author = {Yan, An and McAuley, Julian and Lu, Xing and Du, Jiang and Chang, Eric Y and Gentili, Amilcare and Hsu, Chun-Nan},
348
+ journal = {Radiology: Artificial Intelligence},
349
+ volume = {4},
350
+ number = {4},
351
+ pages = {e210258},
352
+ year = {2022},
353
+ publisher = {Radiological Society of North America},
354
+ doi = {10.1148/ryai.210258}
355
  }
356
  ```
357
 
358
  ## Related Models
359
 
360
+ - [RadLITE-Reranker](https://huggingface.co/matulichpt/radlit-crossencoder) - Cross-encoder for reranking
361
+ - [RadBERT-RoBERTa-4m](https://huggingface.co/zzxslp/RadBERT-RoBERTa-4m) - Base model
362
 
363
  ## License
364
 
365
+ Apache 2.0 - Free for commercial and research use.