examples/basics/scorers/content-similarity/README.md
This example demonstrates how to use Mastra's Content Similarity Scorer to evaluate the textual similarity between input and output content.
Clone the repository and navigate to the project directory:
git clone https://github.com/mastra-ai/mastra
cd examples/basics/scorers/content-similarity
Install dependencies:
pnpm install --ignore-workspace
Run the example:
pnpm start
The Content Similarity Scorer evaluates textual similarity between input and output content using various similarity metrics. It measures:
The example includes three scenarios:
Each scenario demonstrates:
The example will output:
createContentSimilarityScorer: Function that creates the content similarity scorer instancescorer.run(): Method to evaluate input/output pairs for content similarity
{ input, output } where:
input: Array of chat messages (e.g., [{ role: 'user', content: 'text' }])output: Response object (e.g., { role: 'assistant', text: 'response' })score: Numerical similarity score (0-1)