Skip to main content

cMSCI — Calibrated Multimodal Semantic Coherence Index

PyPI Python License: MIT

Score how semantically coherent a text / image / audio triple is, with a single calibrated metric.

cMSCI evaluates coherence using pre-aligned embedding spaces (CLIP for text–image, CLAP for text–audio), Gramian-volume geometry, distribution calibration, contrastive margins against hard negatives, a trained cross-space bridge for the image–audio channel, and probabilistic uncertainty weighting.

On a 100-sample human evaluation (5 raters), cMSCI correlates with human coherence judgments at Spearman ρ = 0.785 (p < 1e-6), versus 0.558 for the uncalibrated MSCI baseline.

Install

pip install cmsci

Or the latest development version straight from GitHub:

pip install "cmsci @ git+https://github.com/Pratik25priyanshu20/MultiModal-Coherence-Evaluation-and-Generation.git#subdirectory=cmsci-package"

All trained artifacts (calibration statistics, Ex-MCR projector, cross-space bridge, probabilistic adapters, negative-bank indexes — ~9 MB) are bundled; the CLIP and CLAP backbones download automatically from Hugging Face on first use.

Usage

Python

from cmsci import CoherenceScorer

scorer = CoherenceScorer()
result = scorer.score(
    text="rain falling in a dense forest",
    image="scene.png",     # optional
    audio="rain.wav",      # optional
    domain="nature",       # optional hint for harder negatives
)

print(result.cmsci)           # calibrated coherence score
print(result.msci)            # legacy weighted-cosine baseline
print(result.st_i, result.st_a, result.si_a)   # channel similarities
print(result.variant_scores)  # ablation variants A–F
print(result.uncertainty)     # probabilistic uncertainty estimates

Batch scoring:

results = scorer.score_batch([
    {"text": "waves on a beach", "image": "beach.jpg", "audio": "waves.wav"},
    {"text": "a busy city street", "image": "street.jpg", "audio": "traffic.wav"},
])

Command line

cmsci --text "rain falling in a dense forest" --image scene.png --audio rain.wav
cmsci --text "..." --image scene.png --json     # full result as JSON

How it works

Stage Component
Embedding CLIP (openai/clip-vit-base-patch32) for text/image, CLAP (laion/clap-htsat-unfused) for text/audio
Geometry Gramian volume of the embedding set — 0 = aligned, 1 = orthogonal
Calibration Per-channel z-score normalization from baseline statistics
Contrastive Margin vs. hard negatives from the bundled embedding indexes
Cross-space Trained 590K-param bridge enables the image–audio channel
Uncertainty ProbVLM-style adapters adaptively weight channels

Scores are calibrated against the paper's baseline distribution. For very different domains, recalibration is possible — point CMSCI_ASSETS_DIR at a directory with your own artifacts/cmsci_calibration.json (same layout as the bundled assets).

Configuration

Env var Effect
CMSCI_ASSETS_DIR Use a custom assets directory instead of the bundled one
CMSCI_CACHE_DIR Embedding cache location (default ~/.cache/cmsci)

Notes

  • Missing assets degrade gracefully: without the bridge the si_a channel is omitted; without calibration, raw uncalibrated scores are returned.
  • CPU works fine for scoring; GPU is only beneficial for large batches.

Citation

If you use cMSCI in academic work, please cite the accompanying paper (reference to be added upon publication).

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmsci-0.1.1.tar.gz (8.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmsci-0.1.1-py3-none-any.whl (8.9 MB view details)

Uploaded Python 3

File details

Details for the file cmsci-0.1.1.tar.gz.

File metadata

  • Download URL: cmsci-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.0

File hashes

Hashes for cmsci-0.1.1.tar.gz
Algorithm Hash digest
SHA256 adb8697c4e814d02bf56e94399930677ff2f0b0f67b7720a5766eab11e9604dd
MD5 896c0b56d95edca3661405f479ae49da
BLAKE2b-256 1a6cba8c1cb9aac76eb9faf4dd87fac8849b91ecb58937387b05460eddb6a329

See more details on using hashes here.

File details

Details for the file cmsci-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cmsci-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.0

File hashes

Hashes for cmsci-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef59a5743b286bea6706b162768e9c6ab3395e97fe60cd92e819d695c1b79b4e
MD5 93cafc40f01e24461e4339fd1005381c
BLAKE2b-256 3ea912d0d425c70d52630d1c5732431d01e97b111e9fc2f20a22ea861448ca1f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page