This repository is organized into six main folders, each representing a key step in the pipeline β from data cleaning to training and evaluation of multimodal models (e.g., CLIP variants).
β οΈ Make sure to modify the paths inside the different scripts where needed !
clean_extract_modalities/ β Data Cleaning & Modality ExtractionThis is the first folder to run. It contains scripts to:
.jsonl datasets (e.g., MedTrinity, Radiopaedia)β‘οΈ Output: clean, modality-specific .jsonl files ready for preprocessing.
prepro_specific_modality/ β Preprocessing by ModalityThis folder handles preprocessing tailored to a specific imaging modality (e.g., MRI, CT).
It includes:
β‘οΈ Output: structured and cleaned datasets, ready for training.
training/ β Contrastive Model Training (e.g., CLIP)This folder contains training scripts for vision-language models on the processed datasets.
Models are trained to align image and text representations using contrastive learning (e.g., CLIP or MedCLIP-style training).
β‘οΈ Output: trained model checkpoints.
evaluation_accuracy/ β Models' Accuracy and Precision EvaluationThis folder includes scripts to evaluate the trained models on downstream tasks such as:
It uses benchmark datasets like GMAI-MMBench and computes metrics such as accuracy and precision.
β‘οΈ Output: metric reports and plots.
pipeline_GPT/ β GPT-Based Qualitative EvaluationThis folder handles qualitative evaluation of model responses using GPT-4 and includes two subfolders:
evaluation/This is where you must place the outputs (cleaned_answers.jsonl) from the models after evaluation.
Each model should have its own subfolder inside evaluation/:
GPT_pipeline/
βββ evaluation/
βββ gemma/
β βββ cleaned_answers.jsonl
βββ qwen/
β βββ cleaned_answers.jsonl
βββ multimeditron/
βββ cleaned_answers.jsonl
gpt_generation/This subfolder contains three distinct pipelines that interface with the OpenAI API:
Answer Extraction
Extract the predicted letter (A, B, C, Dβ¦) from free-form model outputs.
Qualitative Scoring
Use GPT-4 to score model answers on criteria like accuracy, completeness, instruction following, communication, and context awareness.
Model Comparison
Directly compare two model answers to the same question (pairwise judgment with preferred response and per-criterion scores).
This folder contains two different benchmarks to evaluate fine-tuned CLIP models.
similarity_benchmark.py : For each data sample, the benchmark computes the embedding of the image using the encoder under evaluation, as
well as the embedding of its corresponding textual description and those of three random textual distractor descriptions.
We then calculate the cosine similarity between the image embedding and each of the four text embeddings.
The description with the highest similarity score is selected, and we check whether it matches the correct one. This
approach allows us to assess the modelβs retrieval capability, specifically its ability to associate an image with the
most semantically aligned textual description in a contrastive setting.
anatomical_benchmark_us.py : The benchmark consists of a fully connected feed forward neural network with two hidden layers, which takes as
input the image embeddings produced by the encoder under evaluation and classifies it among four different classes:
breast, abdomen, thyroid, or others. The network is trained with the embeddings of the evaluated model and after we
measure the accuracy of the neural classifier. The dataset used is Radiopaedia.
| Folder | Purpose | Run Order |
|---|---|---|
clean_extract_modalities/ | Clean & split data by modality | 1 |
prepro_specific_modality/ | Preprocess data for a target modality | 2 |
training/ | Train CLIP multimodal model. | 3 |
evaluation_accuracy/ | Evaluate models' accuracy and precision on benchmarks | 4 |
pipeline_GPT/ | Run GPT-based evaluation: extraction, scoring, comparison | 5 |
Python
95.5%
PowerShell
3.1%
Shell
1.3%
This repository is organized into six main folders, each representing a key step in the pipeline β from data cleaning to training and evaluation of multimodal models (e.g., CLIP variants).
β οΈ Make sure to modify the paths inside the different scripts where needed !
clean_extract_modalities/ β Data Cleaning & Modality ExtractionThis is the first folder to run. It contains scripts to:
.jsonl datasets (e.g., MedTrinity, Radiopaedia)β‘οΈ Output: clean, modality-specific .jsonl files ready for preprocessing.
prepro_specific_modality/ β Preprocessing by ModalityThis folder handles preprocessing tailored to a specific imaging modality (e.g., MRI, CT).
It includes:
β‘οΈ Output: structured and cleaned datasets, ready for training.
training/ β Contrastive Model Training (e.g., CLIP)This folder contains training scripts for vision-language models on the processed datasets.
Models are trained to align image and text representations using contrastive learning (e.g., CLIP or MedCLIP-style training).
β‘οΈ Output: trained model checkpoints.
evaluation_accuracy/ β Models' Accuracy and Precision EvaluationThis folder includes scripts to evaluate the trained models on downstream tasks such as:
It uses benchmark datasets like GMAI-MMBench and computes metrics such as accuracy and precision.
β‘οΈ Output: metric reports and plots.
pipeline_GPT/ β GPT-Based Qualitative EvaluationThis folder handles qualitative evaluation of model responses using GPT-4 and includes two subfolders:
evaluation/This is where you must place the outputs (cleaned_answers.jsonl) from the models after evaluation.
Each model should have its own subfolder inside evaluation/:
GPT_pipeline/
βββ evaluation/
βββ gemma/
β βββ cleaned_answers.jsonl
βββ qwen/
β βββ cleaned_answers.jsonl
βββ multimeditron/
βββ cleaned_answers.jsonl
gpt_generation/This subfolder contains three distinct pipelines that interface with the OpenAI API:
Answer Extraction
Extract the predicted letter (A, B, C, Dβ¦) from free-form model outputs.
Qualitative Scoring
Use GPT-4 to score model answers on criteria like accuracy, completeness, instruction following, communication, and context awareness.
Model Comparison
Directly compare two model answers to the same question (pairwise judgment with preferred response and per-criterion scores).
This folder contains two different benchmarks to evaluate fine-tuned CLIP models.
similarity_benchmark.py : For each data sample, the benchmark computes the embedding of the image using the encoder under evaluation, as
well as the embedding of its corresponding textual description and those of three random textual distractor descriptions.
We then calculate the cosine similarity between the image embedding and each of the four text embeddings.
The description with the highest similarity score is selected, and we check whether it matches the correct one. This
approach allows us to assess the modelβs retrieval capability, specifically its ability to associate an image with the
most semantically aligned textual description in a contrastive setting.
anatomical_benchmark_us.py : The benchmark consists of a fully connected feed forward neural network with two hidden layers, which takes as
input the image embeddings produced by the encoder under evaluation and classifies it among four different classes:
breast, abdomen, thyroid, or others. The network is trained with the embeddings of the evaluated model and after we
measure the accuracy of the neural classifier. The dataset used is Radiopaedia.
| Folder | Purpose | Run Order |
|---|---|---|
clean_extract_modalities/ | Clean & split data by modality | 1 |
prepro_specific_modality/ | Preprocess data for a target modality | 2 |
training/ | Train CLIP multimodal model. | 3 |
evaluation_accuracy/ | Evaluate models' accuracy and precision on benchmarks | 4 |
pipeline_GPT/ | Run GPT-based evaluation: extraction, scoring, comparison | 5 |
Python
95.5%
PowerShell
3.1%
Shell
1.3%