Text Similarity

Compare two pieces of text and get a similarity score between 0 and 1 using cosine similarity on word-frequency vectors.

Get API Key

Overview

Use Cases

  • Duplicate content detection
  • Plagiarism checking
  • Search and recommendation relevance scoring
  • Document clustering and deduplication
  • FAQ matching and chatbot response selection

Features

Cosine similarity on bag-of-words vectors
Normalised score between 0 (no overlap) and 1 (identical)
Case-insensitive, punctuation-agnostic tokenisation
Fast, in-memory computation β€” no external ML model required

API Endpoints

Compare Text Similarity

Compares two texts and returns a cosine similarity score.

POST
https://api.requiems.xyz/v1/ai/similarity

Parameters

Name Type Required Description
text1 string Required The first text to compare.
text2 string Required The second text to compare.

Try it out

Live Demo
Request

The first text to compare.

The second text to compare.

Response Fields

Field Type Description
similarity number Cosine similarity score between the two texts, in the range [0, 1].
method string The algorithm used. Currently always 'cosine'.

Code Examples

curl -X POST https://api.requiems.xyz/v1/ai/similarity \
  -H "requiems-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text1": "The cat sat on the mat", "text2": "A cat was sitting on a mat"}'

Error Responses

validation_failed

One or both text fields are missing or empty.

bad_request

The request body is missing or malformed.

internal_error

Unexpected server error.

Frequently Asked Questions