File size: 11,527 Bytes
c620e11 1aa7fb4 c620e11 1aa7fb4 c620e11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
---
license: apache-2.0
language:
- en
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- radiology
- medical
- retrieval
- embeddings
- healthcare
- clinical
base_model: zzxslp/RadBERT-RoBERTa-4m
pipeline_tag: sentence-similarity
library_name: sentence-transformers
datasets:
- radiology-education-corpus
metrics:
- mrr
- ndcg
model-index:
- name: RadLITE-Encoder
results:
- task:
type: retrieval
name: Information Retrieval
dataset:
name: RadLIT-9 (Radiology Retrieval Benchmark)
type: radiology-retrieval
metrics:
- type: mrr
value: 0.829
name: MRR (with full pipeline)
- type: ndcg@10
value: 0.863
name: nDCG@10
- type: recall@10
value: 0.90
name: Recall@10
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: Radiology Similarity Evaluation
type: radiology-similarity
metrics:
- type: spearman_cosine
value: 0.8454
name: Spearman Correlation
- type: pearson_cosine
value: 0.8504
name: Pearson Correlation
---
# RadLITE-Encoder
**Radiology Late Interaction Transformer Enhanced - Bi-Encoder Component**
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.
> **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.
## Model Description
| Property | Value |
|----------|-------|
| **Model Type** | Sentence Transformer (Bi-Encoder) |
| **Base Model** | [RadBERT-RoBERTa-4m](https://huggingface.co/zzxslp/RadBERT-RoBERTa-4m) |
| **Domain** | Radiology / Medical Imaging |
| **Vector Dimensions** | 768 |
| **Max Sequence Length** | 512 tokens |
| **Similarity Function** | Cosine Similarity |
| **License** | Apache 2.0 |
### Why RadLITE-Encoder?
Standard embedding models (BGE, E5, OpenAI) are trained on general web text and struggle with radiology-specific terminology:
- **Anatomical terms**: "hepatic flexure", "foramen magnum", "costophrenic angle"
- **Imaging sequences**: "T2 FLAIR", "DWI/ADC mismatch", "post-gadolinium"
- **Pathology descriptions**: "ground-glass opacity", "cortical ribbon sign", "double duct sign"
- **Abbreviations**: "HCC", "RCC", "NSCLC", "BI-RADS"
RadLITE-Encoder is fine-tuned on millions of radiology documents to understand this specialized vocabulary.
## Performance
### RadLIT-9 Benchmark (Radiology Retrieval)
| Model | MRR | nDCG@10 | Notes |
|-------|-----|---------|-------|
| **RadLITE-Encoder** | **0.829** | **0.863** | Full pipeline with reranker |
| RadLITE-Encoder (standalone) | 0.78 | 0.81 | Bi-encoder only |
| BGE-large-en-v1.5 | 0.72 | 0.76 | General-purpose |
| RadBERT (baseline) | 0.45 | 0.52 | No retrieval training |
### Subspecialty Performance
| Subspecialty | MRR | Notes |
|--------------|-----|-------|
| Physics/Nuclear Medicine | 0.936 | Excellent |
| Pediatric Radiology | 0.931 | Excellent |
| Thoracic Imaging | 0.913 | Excellent |
| Cardiac Imaging | 0.862 | Good |
| Neuroradiology | 0.860 | Good |
| Gastrointestinal | 0.800 | Good |
| Breast Imaging | 0.722 | Moderate |
| Musculoskeletal | 0.695 | Moderate |
| Genitourinary | 0.694 | Moderate |
## Quick Start
### Installation
```bash
pip install sentence-transformers>=2.2.0
```
### Basic Usage
```python
from sentence_transformers import SentenceTransformer
# Load the model
model = SentenceTransformer("matulichpt/RadLITE-Encoder")
# Encode radiology text
documents = [
"Hepatocellular carcinoma typically shows arterial enhancement with washout on portal venous phase.",
"Ground-glass opacities in the bilateral lower lobes, concerning for viral pneumonia.",
"No acute intracranial abnormality. Age-appropriate cerebral volume loss.",
]
queries = [
"HCC imaging characteristics on CT",
"COVID-19 chest CT findings",
]
# Generate embeddings
doc_embeddings = model.encode(documents, normalize_embeddings=True)
query_embeddings = model.encode(queries, normalize_embeddings=True)
# Compute similarities
similarities = query_embeddings @ doc_embeddings.T
print(similarities)
# Query 1 (HCC) will score highest with Document 1
# Query 2 (COVID) will score highest with Document 2
```
### Semantic Search over Your Corpus
```python
from sentence_transformers import SentenceTransformer, util
import torch
# Load model
model = SentenceTransformer("matulichpt/RadLITE-Encoder")
# Your radiology corpus (articles, reports, educational content)
corpus = [
{"id": "doc1", "text": "Pancoast tumor: apical lung mass with rib destruction..."},
{"id": "doc2", "text": "Hepatic hemangioma shows peripheral nodular enhancement..."},
{"id": "doc3", "text": "Acoustic neuroma appears as enhancing CP angle mass..."},
# ... your documents
]
# Pre-compute corpus embeddings (do this once, save for reuse)
corpus_texts = [doc["text"] for doc in corpus]
corpus_embeddings = model.encode(corpus_texts, normalize_embeddings=True, show_progress_bar=True)
# Save embeddings for later
torch.save(corpus_embeddings, "corpus_embeddings.pt")
# Search function
def search(query: str, top_k: int = 10):
query_embedding = model.encode(query, normalize_embeddings=True)
scores = util.cos_sim(query_embedding, corpus_embeddings)[0]
top_results = torch.topk(scores, k=min(top_k, len(corpus)))
results = []
for score, idx in zip(top_results.values, top_results.indices):
results.append({
"document": corpus[idx],
"score": float(score)
})
return results
# Example search
results = search("superior sulcus tumor with Horner syndrome")
for r in results[:3]:
print(f"Score: {r['score']:.3f} - {r['document']['text'][:100]}...")
```
### Integration with FAISS (Large-Scale)
```python
import faiss
import numpy as np
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("matulichpt/RadLITE-Encoder")
# Encode your corpus
corpus_embeddings = model.encode(corpus_texts, normalize_embeddings=True)
corpus_embeddings = np.array(corpus_embeddings).astype('float32')
# Build FAISS index
dimension = 768
index = faiss.IndexFlatIP(dimension) # Inner product = cosine for normalized vectors
index.add(corpus_embeddings)
# Save index
faiss.write_index(index, "radiology_index.faiss")
# Search
def faiss_search(query: str, top_k: int = 10):
query_embedding = model.encode(query, normalize_embeddings=True)
query_embedding = np.array([query_embedding]).astype('float32')
scores, indices = index.search(query_embedding, top_k)
return [(int(idx), float(score)) for idx, score in zip(indices[0], scores[0])]
```
## Best Practices
### 1. Normalize Embeddings
Always use `normalize_embeddings=True` for retrieval tasks. This enables efficient cosine similarity via dot product.
### 2. Chunk Long Documents
The model has a 512 token limit. For long articles:
```python
def chunk_text(text: str, max_length: int = 400, overlap: int = 50):
"""Chunk text with overlap for better retrieval."""
words = text.split()
chunks = []
for i in range(0, len(words), max_length - overlap):
chunk = " ".join(words[i:i + max_length])
chunks.append(chunk)
return chunks
```
### 3. Batch Processing
For large corpora, use batching:
```python
embeddings = model.encode(
texts,
batch_size=32,
normalize_embeddings=True,
show_progress_bar=True
)
```
### 4. GPU Acceleration
```python
model = SentenceTransformer("matulichpt/RadLITE-Encoder", device="cuda")
```
## Two-Stage Retrieval (Recommended)
For best results, combine RadLITE-Encoder with the [RadLITE-Reranker](https://huggingface.co/matulichpt/RadLITE-Reranker):
```python
from sentence_transformers import SentenceTransformer, CrossEncoder
# Stage 1: Fast bi-encoder retrieval
encoder = SentenceTransformer("matulichpt/RadLITE-Encoder")
# Stage 2: Precise cross-encoder reranking
reranker = CrossEncoder("matulichpt/RadLITE-Reranker", max_length=512)
def two_stage_search(query: str, corpus: list, top_k: int = 10):
# Stage 1: Get top candidates (fast)
query_emb = encoder.encode(query, normalize_embeddings=True)
corpus_embs = encoder.encode(corpus, normalize_embeddings=True)
scores = query_emb @ corpus_embs.T
top_indices = scores.argsort()[-50:][::-1] # Top 50 candidates
# Stage 2: Rerank with cross-encoder (precise)
candidates = [corpus[i] for i in top_indices]
pairs = [[query, doc] for doc in candidates]
rerank_scores = reranker.predict(pairs)
# Apply temperature calibration (recommended: 1.5)
rerank_scores = rerank_scores / 1.5
# Sort by reranked scores
reranked = sorted(zip(top_indices, rerank_scores), key=lambda x: x[1], reverse=True)
return reranked[:top_k]
```
## Architecture
```
Input Text
|
v
[RadBERT Tokenizer] --> tokens (max 512)
|
v
[RoBERTa Encoder] --> 12 layers, 768 hidden
|
v
[Mean Pooling] --> aggregate token embeddings
|
v
768-dim embedding vector
```
## Training Details
- **Base Model**: RadBERT-RoBERTa-4m (pre-trained on 4.42M VA radiology reports)
- **Fine-tuning**: Contrastive learning on radiology education corpus
- **Training Samples**: 6.7M query-document pairs
- **Loss Function**: Multiple Negatives Ranking Loss
- **Epochs**: 2 (8,400 steps)
- **Final Spearman**: 0.8454
## Limitations
- **English only**: Trained on English radiology text
- **Domain-specific**: May underperform on non-radiology medical content
- **Subspecialty variance**: GU/MSK content has lower performance than Physics/Neuro
- **512 token limit**: Long documents require chunking
## Citation
If you use RadLITE in your work, please cite both RadLITE and the underlying RadBERT model:
```bibtex
@software{radlite_2026,
title = {RadLITE: Calibrated Multi-Stage Retrieval for Radiology Education},
author = {Grai Team},
year = {2026},
month = {January},
url = {https://huggingface.co/matulichpt/RadLITE-Encoder},
note = {MRR 0.829 on RadLIT-9 benchmark}
}
@article{yan2022radbert,
title = {RadBERT: Adapting Transformer-based Language Models to Radiology},
author = {Yan, An and McAuley, Julian and Lu, Xing and Du, Jiang and Chang, Eric Y and Gentili, Amilcare and Hsu, Chun-Nan},
journal = {Radiology: Artificial Intelligence},
volume = {4},
number = {4},
pages = {e210258},
year = {2022},
publisher = {Radiological Society of North America},
doi = {10.1148/ryai.210258}
}
```
## Related Models
- [RadLITE-Reranker](https://huggingface.co/matulichpt/RadLITE-Reranker) - Cross-encoder for reranking
- [RadBERT-RoBERTa-4m](https://huggingface.co/zzxslp/RadBERT-RoBERTa-4m) - Base model
## License
Apache 2.0 - Free for commercial and research use.
|