matulichpt commited on
Commit
c620e11
·
verified ·
1 Parent(s): 39aba7c

Upload folder using huggingface_hub

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
+ }
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 ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/RadLITE-Reranker) 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
122
+
123
+ ```python
124
+ from sentence_transformers import SentenceTransformer
125
+
126
+ # Load the model
127
+ model = SentenceTransformer("matulichpt/RadLITE-Encoder")
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/RadLITE-Encoder")
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/RadLITE-Encoder")
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/RadLITE-Encoder", 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/RadLITE-Reranker):
268
+
269
+ ```python
270
+ from sentence_transformers import SentenceTransformer, CrossEncoder
271
+
272
+ # Stage 1: Fast bi-encoder retrieval
273
+ encoder = SentenceTransformer("matulichpt/RadLITE-Encoder")
274
+ # Stage 2: Precise cross-encoder reranking
275
+ reranker = CrossEncoder("matulichpt/RadLITE-Reranker", 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
+ ```bibtex
334
+ @software{radlite_2026,
335
+ title = {RadLITE: Calibrated Multi-Stage Retrieval for Radiology Education},
336
+ author = {Grai Team},
337
+ year = {2026},
338
+ month = {January},
339
+ url = {https://huggingface.co/matulichpt/RadLITE-Encoder},
340
+ note = {MRR 0.829 on RadLIT-9 benchmark}
341
+ }
342
+ ```
343
+
344
+ ## Related Models
345
+
346
+ - [RadLITE-Reranker](https://huggingface.co/matulichpt/RadLITE-Reranker) - Cross-encoder for reranking
347
+ - [RadBERT-RoBERTa-4m](https://huggingface.co/zzxslp/RadBERT-RoBERTa-4m) - Base model
348
+
349
+ ## License
350
+
351
+ Apache 2.0 - Free for commercial and research use.
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