Skip to content

fix: count symmetric STS pairs once - #4958

Merged
KennethEnevoldsen merged 3 commits into
embeddings-benchmark:mainfrom
GioiaZheng:test/sts-normalized-pair-quality
Aug 4, 2026
Merged

KennethEnevoldsen merged 3 commits into
embeddings-benchmark:mainfrom
GioiaZheng:test/sts-normalized-pair-quality

Conversation

@GioiaZheng

@GioiaZheng GioiaZheng commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • canonicalize text STS sentence pairs before writing the existing unique_pairs statistic, so (a, b) and (b, a) count as one pair;
  • apply the same calculation to per-subset statistics and multilingual overall statistics, where duplicates across subsets are visible in the aggregate count;
  • add focused coverage for both within-split swapped pairs and swapped pairs across multilingual subsets.

Scope

This revision follows the review feedback to reuse unique_pairs. It removes the proposed pair_overlap field and the separate cross-split quality-check path. Train/validation/test overlap is not reported by this change because descriptive statistics remain split-based.

Validation

  • pytest tests/test_abstasks/test_sts_statistics.py tests/test_abstasks/test_task_metadata.py::test_descriptive_statistics_mock_tasks -q --disable-warnings — 31 passed
  • ruff check mteb/abstasks/sts.py tests/test_abstasks/test_sts_statistics.py
  • ruff format --check mteb/abstasks/sts.py tests/test_abstasks/test_sts_statistics.py
  • mypy mteb/abstasks/sts.py
  • git diff --check

Close #4901

@GioiaZheng
GioiaZheng marked this pull request as ready for review July 20, 2026 17:16
Comment thread mteb/abstasks/sts.py Outdated
labels_statistics = calculate_score_statistics(score)

return AnySTSDescriptiveStatistics(
pair_overlap: dict[str, int] | None = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have unique_pairs. I think would be better to just a bit update it instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I can make the existing STS unique_pairs count order-insensitive and drop the new pair_overlap field. That would catch swapped duplicates within a split, but not overlap across train/validation/test from #4901. Would you prefer narrowing this PR to the within-split check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall our statistics are split based. I think overlap across subsets can be computed in overall

@GioiaZheng GioiaZheng changed the title test: detect symmetric STS pair leakage fix: count symmetric STS pairs once Jul 22, 2026
Comment thread mteb/abstasks/sts.py Outdated
Comment on lines +255 to +267
column1, column2 = self.column_names
if (
isinstance(column1, str)
and isinstance(column2, str)
and len(self.metadata.modalities) == 1
and self.metadata.modalities[0] == "text"
):
pair_stats["unique_pairs"] = len(
_canonical_text_pair_keys(
_load_col(column1),
_load_col(column2),
)
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better to modify here

unique_pairs = len({(tuple(r1), tuple(r2)) for r1, r2 in zip(all_h1, all_h2)})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this into calculate_pair_modality_statistics with an opt-in symmetric=True for STS, so directional pair-classification tasks keep their existing behavior. I also added a regression test for the default ordered case. All checks are green now.

@isaac-chung isaac-chung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like all of @Samoed 's comments have been addressed.

@KennethEnevoldsen
KennethEnevoldsen merged commit f49193c into embeddings-benchmark:main Aug 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a normalized STS pair quality check

4 participants