> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Semantic similarity

> Learn how to use the semantic similarity test

## Definition

The semantic similarity test assesses the similarity in meaning between sentences, by measuring their closeness in semantic space using advanced natural language processing techniques.

## Taxonomy

* **Task types**: LLM.
* **Availability**: development (Continuously evaluate your models and datasets as you iterate on their versions.)
  and monitoring (Monitor a model in production, measure its health, check for drifts and set up alerts.).

## Why it matters

* Semantic similarity captures the meaning-based relationship between generated and reference text, going beyond surface-level string matching.
* This metric is particularly valuable when different phrasings can convey the same meaning, making it ideal for tasks like paraphrasing, summarization, or question answering.
* It provides a more nuanced evaluation than exact matching by considering the conceptual similarity rather than just textual similarity.

## Required columns

To compute this metric, your dataset must contain the following columns:

* **Outputs**: The generated text from your LLM
* **Ground truths**: The reference/expected text to compare against

## Test configuration examples

If you are writing a `tests.json`, here are a few valid configurations for the semantic similarity test:

```json Development theme={null}
[
  {
    "name": "Mean semantic similarity above 0.8",
    "description": "Ensure that the mean semantic similarity score is above 0.8",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "meanSemanticSimilarity",
        "operator": ">",
        "value": 0.8
      }
    ],
    "subpopulationFilters": null,
    "mode": "development",
    "usesValidationDataset": true,
    "usesTrainingDataset": false,
    "usesMlModel": true,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

```json Monitoring theme={null}
[
  {
    "name": "Mean semantic similarity above 0.8",
    "description": "Ensure that the mean semantic similarity score is above 0.8",
    "type": "performance",
    "subtype": "metricThreshold",
    "thresholds": [
      {
        "insightName": "metrics",
        "measurement": "meanSemanticSimilarity",
        "operator": ">",
        "value": 0.8
      }
    ],
    "subpopulationFilters": null,
    "mode": "monitoring",
    "usesProductionData": true,
    "evaluationWindow": 3600,
    "delayWindow": 0,
    "syncId": "b4dee7dc-4f15-48ca-a282-63e2c04e0689"
  }
]
```

## Related

* [BLEU score test](https://docs.openlayer.com/tests/catalog/bleu-score.md) - Measure n-gram based text similarity.
* [Quasi-exact match test](https://docs.openlayer.com/tests/catalog/quasi-exact-match.md) - Allow partial matches and variations.
* [Answer relevancy test](https://docs.openlayer.com/tests/catalog/answer-relevancy.md) - Measure relevance of answers to questions.
* [Aggregate metrics](https://docs.openlayer.com/tests/performance/aggregate-metrics) - Overview of all available metrics.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.