Canonical metric implementations + baseline wrappers for SAPER-CLIP. Protein-function description RAG benchmarks.
Python
0
2 commits
updated Apr 24, 2026
Shared benchmarking toolkit for SAPER, ProteinCLIP, SAPER-CLIP, and related protein-function-description methods. Provides canonical metric implementations, a GPT-4o LLM-as-Judge harness, and inference wrappers for the baselines reported in our ICML 2026 workshop submission (under review).
In this repo:
METRICS_ALIGNMENT.md.results/.docs/.Not in this repo:
HANDOFF_NOTES.md).SAPER_DATA_ROOT at your local copy.Two typical flows:
(1) Score an existing predictions file against Entity-BLEU / Entity-F1:
import os, sys
sys.path.insert(0, "/path/to/this/clone")
from metrics import entity
res = entity.compute_metrics(
predictions_path="my_model_catalytic_activity_OOD_predictions.json",
dataset_path=f"{os.environ['SAPER_DATA_ROOT']}/catalytic_activity_OOD.json",
)
print(res) # entity_bleu2, entity_bleu4, entity_precision, entity_recall, entity_f1
(2) Run a baseline end-to-end:
export SAPER_DATA_ROOT=/path/to/saper/dataset
python run_qwen3_benchmark.py \
--model_dir /path/to/Qwen3-8B \
--results_dir ./results/Qwen3-8B-3shot \
--datasets catalytic_activity_OOD
See HANDOFF_NOTES.md for the full onboarding walk-through.
This toolkit supports inference and/or evaluation for the following methods:
/data/rbg/users/linrui/SAPER/SAPER/. Run SAPER from that directory;
pipe its predictions into this toolkit's evaluation for scoring./data/rbg/users/linrui/SAPER/proteinclip_experiments/phase_a_comparison/./data/rbg/users/linrui/SAPER/proteinclip_experiments/saper_clip_hybrid/.benchmarks/
├── README.md # this file
├── METRICS_ALIGNMENT.md # canonical metric definitions + discrepancies
├── HANDOFF_NOTES.md # collaborator onboarding
├── metrics/ # thin re-export module: benchmarks.metrics.{entity,rapm,judge}
├── fix_entity_bleu.py # canonical Entity-BLEU / Entity-P/R/F1
├── rapm_rescore.py # RAPM-official Meta-BLEU / METEOR / ROUGE
├── llm_judge_score.py # GPT-4o LLM-as-Judge (4-axis rubric)
├── aggregate_judge_scores.py # per-model / per-match-type aggregation
├── fix_llama_predictions.py # post-hoc cleanup of Llama outputs
├── download_model.py # HuggingFace snapshot helper
├── run_qwen3_benchmark.py # Qwen-3 8B 3-shot wrapper
├── run_llama_benchmark.py # Llama-3.1 8B 3-shot wrapper
├── run_prot2text_benchmark.py
├── run_esm2text_benchmark.py
├── run_mmseqs2_baseline.py
├── run_*_benchmark.sh # launch scripts for the above
├── Prot2Text-V2/ # upstream clone — not tracked (see note below)
├── RAPM_official/ # upstream clone — not tracked (see note below)
├── results/ # cached predictions + metrics per model
│ ├── Qwen3-8B-3shot/
│ ├── Llama-3.1-8B-3shot/
│ ├── Prot2Text-V2/
│ ├── MMseqs2-retrieval/
│ ├── BioReason-Pro-RL/ # reference baseline (wrapper removed)
│ └── BioT5plus/ # reference baseline (wrapper removed)
└── docs/ # design docs + historical audits
├── METRICS_DOCUMENTATION.md
├── METRIC_AUDIT.md
├── METRIC_FIXES_BEFORE_AFTER.md
├── JUDGE_COMPARISON.md
├── JUDGE_PROMPT.md
├── ALL_BASELINE_METRICS.csv
└── ALL_BASELINE_METRICS.md
model_cache/, venv/, venv2/, .hf_cache/, and .pip_cache/ are
excluded from the repository (see .gitignore).
All metrics are computed on the 0–100 scale. Canonical parameters are
documented in METRICS_ALIGNMENT.md; this section is a quick summary.
corpus_bleu and SmoothingFunction.method1. Matches the
SAPER paper's Table 3 reporting convention.sentence_bleu + method1 smoothing, then averaged. Suitable for
paired t-tests between methods.meteor_score on tokenized predictions and references
(meta-filtered tokens, matching SAPER).rouge_score.RougeScorer F1 values.fix_entity_bleu.py for the matcher construction.evaluate() helpers).{0,3,5,7,10} scale. See
docs/JUDGE_PROMPT.md for the full rubric.import sys
sys.path.insert(0, "/path/to/benchmarks")
from metrics import entity
res = entity.compute_metrics(
predictions_path="results/Qwen3-8B-3shot/catalytic_activity_OOD_predictions.json",
dataset_path="/data/rbg/users/linrui/SAPER/dataset/catalytic_activity_OOD.json",
)
For the full SAPER-CLIP paper evaluation pipeline (BLEU + Meta-BLEU +
METEOR + ROUGE + Entity-F1 + paired t-tests) see
proteinclip_experiments/phase_a_comparison/rag_pilot/scripts/v2_phase4_eval.py.
export OPENAI_API_KEY=...
python llm_judge_score.py \
--predictions_dir results/Qwen3-8B-3shot \
--judge_model gpt-4o \
--dataset_dir /data/rbg/users/linrui/SAPER/dataset
Each run_*_benchmark.py script is self-contained; see its header
docstring for CLI flags. All scripts consume the four OOD datasets at
/data/rbg/users/linrui/SAPER/dataset/.
For interoperability with v2_phase4_eval.py and friends, predictions
should be written as one JSON object per line with these fields:
test_array_index (int) — index into the source dataset JSONparsed_description (str) — the model's predicted descriptionerror (str or null) — non-empty means the sample was skippedPaths default to the author's CSAIL workspace. Override via environment variables:
| Variable | Purpose | Default |
|---|---|---|
SAPER_DATA_ROOT | Directory containing the four OOD dataset JSONs | /data/rbg/users/linrui/SAPER/dataset |
LLAMA_TOKENIZER_PATH | Llama-3.1-8B-Instruct snapshot used for BLEU tokenization | /data/rbg/users/linrui/benchmarks/model_cache/Llama-3.1-8B-Instruct |
QWEN3_MODEL_DIR | Qwen-3 8B snapshot | /data/rbg/users/linrui/benchmarks/model_cache/Qwen3-8B |
OPENAI_API_KEY | Required for the LLM-as-Judge | (unset) |
{LLAMA,QWEN3,MMSEQS2,PROT2TEXT,ESM2TEXT}_RESULTS_DIR | Per-baseline output directory | ./results/<Model> (relative) |
BENCHMARKS_RESULTS_ROOT | Root for aggregate_judge_scores.py | /data/rbg/users/linrui/SAPER/benchmarks/results |
All argparse defaults can also be overridden at invocation time with the
usual --flag value CLI syntax.
transformers, torchnltk (with punkt and wordnet downloaded)rouge_scorescipy, numpypyahocorasick (for the entity matcher)openai (for the LLM-as-Judge)tqdmmmseqs2 binary on PATH for run_mmseqs2_baseline.pySee setup_env.sh for the reference environment bootstrap.
Citation placeholder — add the ICML 2026 workshop entry once accepted.
Prot2Text-V2/ and RAPM_official/ are local clones of their respective
upstream repositories. They are gitignored here (each carries its own
.git/ directory) — collaborators should clone them into this directory:
git clone https://github.com/pierre-pessi/prot2text-v2 Prot2Text-V2
git clone https://github.com/ZhuoluHou/RAPM RAPM_official # adjust to actual URL
Builds on SAPER (Liu et al. 2024), ProteinCLIP, Prot2Text-V2, and the RAPM benchmark protocol.
Canonical metric implementations + baseline wrappers for SAPER-CLIP. Protein-function description RAG benchmarks.
Python
0
2 commits
updated Apr 24, 2026
Shared benchmarking toolkit for SAPER, ProteinCLIP, SAPER-CLIP, and related protein-function-description methods. Provides canonical metric implementations, a GPT-4o LLM-as-Judge harness, and inference wrappers for the baselines reported in our ICML 2026 workshop submission (under review).
In this repo:
METRICS_ALIGNMENT.md.results/.docs/.Not in this repo:
HANDOFF_NOTES.md).SAPER_DATA_ROOT at your local copy.Two typical flows:
(1) Score an existing predictions file against Entity-BLEU / Entity-F1:
import os, sys
sys.path.insert(0, "/path/to/this/clone")
from metrics import entity
res = entity.compute_metrics(
predictions_path="my_model_catalytic_activity_OOD_predictions.json",
dataset_path=f"{os.environ['SAPER_DATA_ROOT']}/catalytic_activity_OOD.json",
)
print(res) # entity_bleu2, entity_bleu4, entity_precision, entity_recall, entity_f1
(2) Run a baseline end-to-end:
export SAPER_DATA_ROOT=/path/to/saper/dataset
python run_qwen3_benchmark.py \
--model_dir /path/to/Qwen3-8B \
--results_dir ./results/Qwen3-8B-3shot \
--datasets catalytic_activity_OOD
See HANDOFF_NOTES.md for the full onboarding walk-through.
This toolkit supports inference and/or evaluation for the following methods:
/data/rbg/users/linrui/SAPER/SAPER/. Run SAPER from that directory;
pipe its predictions into this toolkit's evaluation for scoring./data/rbg/users/linrui/SAPER/proteinclip_experiments/phase_a_comparison/./data/rbg/users/linrui/SAPER/proteinclip_experiments/saper_clip_hybrid/.benchmarks/
├── README.md # this file
├── METRICS_ALIGNMENT.md # canonical metric definitions + discrepancies
├── HANDOFF_NOTES.md # collaborator onboarding
├── metrics/ # thin re-export module: benchmarks.metrics.{entity,rapm,judge}
├── fix_entity_bleu.py # canonical Entity-BLEU / Entity-P/R/F1
├── rapm_rescore.py # RAPM-official Meta-BLEU / METEOR / ROUGE
├── llm_judge_score.py # GPT-4o LLM-as-Judge (4-axis rubric)
├── aggregate_judge_scores.py # per-model / per-match-type aggregation
├── fix_llama_predictions.py # post-hoc cleanup of Llama outputs
├── download_model.py # HuggingFace snapshot helper
├── run_qwen3_benchmark.py # Qwen-3 8B 3-shot wrapper
├── run_llama_benchmark.py # Llama-3.1 8B 3-shot wrapper
├── run_prot2text_benchmark.py
├── run_esm2text_benchmark.py
├── run_mmseqs2_baseline.py
├── run_*_benchmark.sh # launch scripts for the above
├── Prot2Text-V2/ # upstream clone — not tracked (see note below)
├── RAPM_official/ # upstream clone — not tracked (see note below)
├── results/ # cached predictions + metrics per model
│ ├── Qwen3-8B-3shot/
│ ├── Llama-3.1-8B-3shot/
│ ├── Prot2Text-V2/
│ ├── MMseqs2-retrieval/
│ ├── BioReason-Pro-RL/ # reference baseline (wrapper removed)
│ └── BioT5plus/ # reference baseline (wrapper removed)
└── docs/ # design docs + historical audits
├── METRICS_DOCUMENTATION.md
├── METRIC_AUDIT.md
├── METRIC_FIXES_BEFORE_AFTER.md
├── JUDGE_COMPARISON.md
├── JUDGE_PROMPT.md
├── ALL_BASELINE_METRICS.csv
└── ALL_BASELINE_METRICS.md
model_cache/, venv/, venv2/, .hf_cache/, and .pip_cache/ are
excluded from the repository (see .gitignore).
All metrics are computed on the 0–100 scale. Canonical parameters are
documented in METRICS_ALIGNMENT.md; this section is a quick summary.
corpus_bleu and SmoothingFunction.method1. Matches the
SAPER paper's Table 3 reporting convention.sentence_bleu + method1 smoothing, then averaged. Suitable for
paired t-tests between methods.meteor_score on tokenized predictions and references
(meta-filtered tokens, matching SAPER).rouge_score.RougeScorer F1 values.fix_entity_bleu.py for the matcher construction.evaluate() helpers).{0,3,5,7,10} scale. See
docs/JUDGE_PROMPT.md for the full rubric.import sys
sys.path.insert(0, "/path/to/benchmarks")
from metrics import entity
res = entity.compute_metrics(
predictions_path="results/Qwen3-8B-3shot/catalytic_activity_OOD_predictions.json",
dataset_path="/data/rbg/users/linrui/SAPER/dataset/catalytic_activity_OOD.json",
)
For the full SAPER-CLIP paper evaluation pipeline (BLEU + Meta-BLEU +
METEOR + ROUGE + Entity-F1 + paired t-tests) see
proteinclip_experiments/phase_a_comparison/rag_pilot/scripts/v2_phase4_eval.py.
export OPENAI_API_KEY=...
python llm_judge_score.py \
--predictions_dir results/Qwen3-8B-3shot \
--judge_model gpt-4o \
--dataset_dir /data/rbg/users/linrui/SAPER/dataset
Each run_*_benchmark.py script is self-contained; see its header
docstring for CLI flags. All scripts consume the four OOD datasets at
/data/rbg/users/linrui/SAPER/dataset/.
For interoperability with v2_phase4_eval.py and friends, predictions
should be written as one JSON object per line with these fields:
test_array_index (int) — index into the source dataset JSONparsed_description (str) — the model's predicted descriptionerror (str or null) — non-empty means the sample was skippedPaths default to the author's CSAIL workspace. Override via environment variables:
| Variable | Purpose | Default |
|---|---|---|
SAPER_DATA_ROOT | Directory containing the four OOD dataset JSONs | /data/rbg/users/linrui/SAPER/dataset |
LLAMA_TOKENIZER_PATH | Llama-3.1-8B-Instruct snapshot used for BLEU tokenization | /data/rbg/users/linrui/benchmarks/model_cache/Llama-3.1-8B-Instruct |
QWEN3_MODEL_DIR | Qwen-3 8B snapshot | /data/rbg/users/linrui/benchmarks/model_cache/Qwen3-8B |
OPENAI_API_KEY | Required for the LLM-as-Judge | (unset) |
{LLAMA,QWEN3,MMSEQS2,PROT2TEXT,ESM2TEXT}_RESULTS_DIR | Per-baseline output directory | ./results/<Model> (relative) |
BENCHMARKS_RESULTS_ROOT | Root for aggregate_judge_scores.py | /data/rbg/users/linrui/SAPER/benchmarks/results |
All argparse defaults can also be overridden at invocation time with the
usual --flag value CLI syntax.
transformers, torchnltk (with punkt and wordnet downloaded)rouge_scorescipy, numpypyahocorasick (for the entity matcher)openai (for the LLM-as-Judge)tqdmmmseqs2 binary on PATH for run_mmseqs2_baseline.pySee setup_env.sh for the reference environment bootstrap.
Citation placeholder — add the ICML 2026 workshop entry once accepted.
Prot2Text-V2/ and RAPM_official/ are local clones of their respective
upstream repositories. They are gitignored here (each carries its own
.git/ directory) — collaborators should clone them into this directory:
git clone https://github.com/pierre-pessi/prot2text-v2 Prot2Text-V2
git clone https://github.com/ZhuoluHou/RAPM RAPM_official # adjust to actual URL
Builds on SAPER (Liu et al. 2024), ProteinCLIP, Prot2Text-V2, and the RAPM benchmark protocol.