Views
No views yet
pamessina/T5FactExtractorpamessina/CXRFE)| Architecture | CXR-BERT (CXRBertModel) with a projection head |
| Initialized from | microsoft/BiomedVLP-CXR-BERT-specialized |
| Hidden size | 768 |
| Projected embedding size | 128 (projection_size) |
| Intended inputs | Short radiology facts / sentences (typically after fact extraction) |
| License | Apache 2.0 |
Note: This public checkpoint is trained with slightly more NLI data than the single best CXRFE variant reported in the paper. Additional paper-matched variants may be released later.
trust_remote_code=True (custom CXR-BERT code from the BioViL / CXR-BERT family).get_projected_text_embeddings):1import torch
2from transformers import AutoModel, AutoTokenizer
3
4device = "cuda" if torch.cuda.is_available() else "cpu"
5model_id = "pamessina/CXRFE"
6
7tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
8model = AutoModel.from_pretrained(model_id, trust_remote_code=True).to(device)
9model.eval()
10
11texts = [
12 "small right pleural effusion",
13 "normal heart size",
14]
15
16inputs = tokenizer(
17 texts,
18 add_special_tokens=True,
19 padding="longest",
20 return_tensors="pt",
21)
22input_ids = inputs["input_ids"].to(device)
23attention_mask = inputs["attention_mask"].to(device)
24
25with torch.no_grad():
26 embeddings = model.get_projected_text_embeddings(
27 input_ids=input_ids,
28 attention_mask=attention_mask,
29 )
30
31print(embeddings.shape) # (batch_size, 128)1pip install cxrfescore
2# optional heatmaps:
3pip install "cxrfescore[viz]"1from cxrfescore import CXRFEScore
2
3metric = CXRFEScore(device="cuda") # default encoder: pamessina/CXRFE
4result = metric(
5 ["There is a small right pleural effusion. The heart size is normal."],
6 ["Small right pleural effusion. Normal heart size."],
7)
8print(result["mean_similarity"])1@inproceedings{messina-etal-2024-extracting,
2 title = "Extracting and Encoding: Leveraging Large Language Models and Medical Knowledge to Enhance Radiological Text Representation",
3 author = "Messina, Pablo and
4 Vidal, Rene and
5 Parra, Denis and
6 Soto, Alvaro and
7 Araujo, Vladimir",
8 booktitle = "Findings of the Association for Computational Linguistics: ACL 2024",
9 month = aug,
10 year = "2024",
11 address = "Bangkok, Thailand",
12 publisher = "Association for Computational Linguistics",
13 url = "https://aclanthology.org/2024.findings-acl.236/",
14 doi = "10.18653/v1/2024.findings-acl.236",
15 pages = "3955--3986"
16}