Skip to content
Catalog

cn8/text-similarity

Send two aligned lists — candidates and references — and the service compares them

Learn more about Text Similarity
Text NLPsyncInstant previewtextanalysisnlp

Try it

Text A (candidate)Text B (reference)

Result

Results show up here

The sample input is ready — just hit Run.

Overview

Send two aligned lists — candidates and references — and the service compares them pair by pair. For each pair you get precision (how much of the candidate appears in the reference), recall (how much of the reference appears in the candidate), and F1 (the balanced score combining the two). Comparison is at the token level, so it captures meaning rather than exact wording. Responses are synchronous — one request, one set of scores per pair.

Key capabilities

Precision / recall / F1

Three scores per pair — precision (coverage of the candidate in the reference), recall (coverage of the reference in the candidate), and F1 (the balanced combination).

Token-level matching

Compares texts token by token in meaning space, for a more nuanced score than whole-sentence matching.

Pairwise list input

Send aligned candidates and references arrays; you get one result per pair, in the same order.

Multilingual

Works across many languages out of the box.

When to use it

Duplicate detection

Find near-duplicate content using a threshold on F1.

Paraphrase detection

Check whether two sentences convey the same meaning (high F1).

Generation eval

Compare a generated text against a reference to measure how well meaning is preserved.

Input & output

input

A candidates array and a references array of strings, aligned by index.

JSON body

output

One {precision, recall, f1} result per (candidate, reference) pair.

JSON

Guides & tips

How it works

  • You send aligned candidates and references arrays, and each pair is scored on how closely the two texts match in meaning.
  • precision measures how much of the candidate appears in the reference; recall measures how much of the reference appears in the candidate; f1 balances the two.
  • Results come back in the same order as your input: results[i] is the score for (candidates[i], references[i]). Both arrays must be the same length.

Choosing F1 vs precision/recall

  • Use f1 for general "are these the same?" questions — it's the balanced, all-round metric.
  • Use precision to ask "is the candidate a faithful subset of the reference?" (e.g. translation or paraphrase fidelity).
  • Use recall to ask "does the candidate cover everything in the reference?" (e.g. summary completeness).

Specs

Latency
Typically 0.3–1 second per pair
Async
false
Rate Limit
Per API key
Max Input
A few hundred tokens per text

Schema

Request body

candidatesrequiredarray<string>

Candidate texts (e.g. generated outputs or queries).

referencesrequiredarray<string>

Reference texts. Must be the same length as candidates — pairs are matched by index.

Response

results[].precisionnumber

How much of the candidate is present in the reference, from 0 to 1.

results[].recallnumber

How much of the reference is present in the candidate, from 0 to 1.

results[].f1number

The balanced combination of precision and recall, from 0 to 1. The main similarity score.

Pricing

Billed per request.

ServiceUnitPrice
Text Similarityitem$0.004/request

Cost is per request, not per pair — batch as many comparisons as you can per call.

FAQ

Related models