Explainable Semantic Textual Similarity via Dissimilar Span Detection
Organizations: School of Computation, Information and Technology Technical University of Munich · Munich Center for Machine Learning (MCML)
Abstract
Semantic Textual Similarity (STS) is a crucial component of many Natural Language Processing (NLP) applications. However, existing approaches typically reduce semantic nuances to a single score, limiting interpretability. To address this, we introduce the task of Dissimilar Span Detection (DSD), which aims to identify semantically differing spans between pairs of texts. This can help users understand which particular words or tokens negatively affect the similarity score, or be used to improve performance in STS-dependent downstream tasks. Furthermore, we release a new dataset suitable for the task, the Span Similarity Dataset (SSD), developed through a semi-automated pipeline combining large language models (LLMs) with human verification. We propose and evaluate different baseline methods for DSD, both unsupervised, based on LIME, SHAP, LLMs, and our own method, as well as an additional supervised approach. While LLMs and supervised models achieve the highest performance, overall results remain low, highlighting the complexity of the task. Finally, we set up an additional experiment that shows how DSD can lead to increased performance in the specific task of paraphrase detection.
Figures & tables
| Sentence 1 | Sentence 2 | Span Similarity | Sentence Similarity |
|---|---|---|---|
| It only utilizes {{a few refineries}} in the Northeast. | It only utilizes {{numerous facilities}} in the Northeast. | 0 | 0 |
| It was {{restored}} in the {{1980s}} . | It was {{destroyed}} in the {{eighties}} . | 0,1 | 0 |
| Thank you for {{wasting my money}} . | Thank you for {{misusing my funds}} . | 1 | 1 |
| There are depots at {{Quilpie}} and {{Roma}} . | There are depots at {{Brisbane}} and {{Sydney}} . | 0,0 | 0 |
| Attribute | Value |
|---|---|
| Sentence pairs | 1,000 |
| Span pairs | 1,296 |
| Dissimilar span pairs | 648 (50 %) |
| Equivalent span pairs | 648 (50 %) |
| Dissimilar sentence pairs | 571 (57 %) |
| Equivalent sentence pairs | 429 (43 %) |
| Agreement | Inter-annotator | Annotator-dataset |
|---|---|---|
| Span boundaries | 0.74 (0.05) | 0.67 (0.03) |
| Span labels | 0.87 (0.05) | 0.91 (0.04) |
| Span count | 0.66 (0.06) | 0.61 (0.07) |
| SSD | SemEval-2016 | ||||||
| Method | Model Size | F1-Global | F1-NoDiff | F1-Diff | Eval. Time | F1-Diff | Eval. Time |
| LIME all-mpnet-base-v2 (0.001) | 109M | 0.463 | 0.782 | 0.223 | 1981.81 | 0.109 | 199.89 |
| SHAP all-MiniLM-L6-v2 (0.010) | 22.7M | 0.366 | 0.434 | 0.131 | 44.47 | 0.306 | 4.52 |
| Embedding all-mpnet-base-v2 (0.006) | 109M | 0.469 | 0.529 | 0.423 | 11.28 | 0.352 | 1.13 |
| Embedding text-embedding-004 (0.005) | Billions | 0.547 | 0.666 | 0.459 | 611.42 | 0.338 | 34.57 |
| LLM Claude 3.5 Sonnet | Billions | 0.750 | 0.895 | 0.640 | 337.80 | 0.389 | 39.22 |
| Model | STS | STS+DSD |
|---|---|---|
| all-MiniLM-L6-v2 (0.65, 8 10 -3 ) | 0.720 | 0.808 |
| all-mpnet-base-v2 (0.63, 8 10 -3 ) | 0.795 | 0.868 |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| NoDiff | Time | ||||
| Method | Model | Precision | Recall | F1 | (minutes) |
| LIME | all-MiniLM-L6-v2 (0.010) | 0.253 (0.010) | 0.395 (0.029) | 0.269 (0.013) | 120.88 |
| all-mpnet-base-v2 (0.001) | 0.154 (0.017) | 0.093 (0.011) | 0.109 (0.011) | 199.89 | |
| SHAP | all-MiniLM-L6-v2 (0.005) | 0.247 (0.012) | 0.529 (0.025) | 0.306 (0.016) | 4.52 |
| all-mpnet-base-v2 (0.001) | 0.243 (0.016) | 0.480 (0.022) | 0.293 (0.019) | 21.58 | |
| Embedding | all-MiniLM-L6-v2 (0.005) | 0.249 (0.015) | 0.842 (0.051) | 0.362 (0.019) | 0.38 |
| Sentence 1 | Sentence 2 | Method | Annotation |
| Following the Civil War, the plantation house was destroyed by hurricanes. | Before the Civil War, hurricanes destroyed the plantation house. | Reference Annotation | {{Before the Civil War}} , hurricanes destroyed the plantation house. |
| LIME all-MiniLM-L6-v2 | {{Before the}} Civil {{War}} , hurricanes destroyed the {{plantation house.}} | ||
| SHAP all-MiniLM-L6-v2 | Before the Civil War {{,}} hurricanes destroyed the plantation house {{.}} | ||
| Embedding all-MiniLM-L6-v2 | Before the Civil War, hurricanes destroyed the plantation house. | ||
| Embedding text-embedding-3-large | {{Before}} the Civil War, hurricanes destroyed the plantation house. | ||
| LLM GPT-4o | Before {{the Civil War}} , hurricanes destroyed the plantation house. |
| do |
| do |
| Dataset | License | Homepage |
|---|---|---|
| Span Similarity Dataset (SSD) | CC BY-SA 4.0 | https://dmlls.github.io/dissimilar-span-detection |
| SemEval-2016 Task 2 Dataset | CC BY-SA 4.0 | https://alt.qcri.org/semeval2016/task2 |
| Model | License | Homepage |
|---|---|---|
| all-MiniLM-L6-v2 | Apache License 2.0 | https://huggingface.co/sentence- transformers/all-MiniLM-L6-v2 |
| all-mpnet-base-v2 | Apache License 2.0 | https://huggingface.co/sentence- transformers/all-mpnet-base-v2 |
| text-embedding-3-large | Proprietary | https://platform.openai.com/docs/guides/embeddings/#embedding-models |
| text-embedding-004 | Proprietary | https://ai.google.dev/gemini-api/docs/embeddings |
| GPT-4o | Proprietary | https://openai.com/index/hello-gpt-4o |
| Llama 3.3 70B Instruct | Llama 3.3 Community License Agreement | https://www.llama.com/docs/model-cards-and-prompt-formats/llama3_3/ |
Semantic Textual Similarity
Semantic Textual Similarity measures how closely two texts match in meaning, supporting comparison, retrieval, clustering, and evaluation.
See all 44 papers