Compare Texts
Semantic text comparison powered by LLM.
Compares text_a and text_b with the model in one of four modes (similarity, diff, contradiction, dedup) and routes to match or no_match.
This operator compares two text inputs using a configurable comparison mode and routes to match/no_match ports based on the result.
Operations
- Similarity: Computes a semantic similarity score (0-1) between two texts.
- Diff: Identifies meaningful semantic differences (not character-level) between texts.
- Contradiction: Detects factual contradictions between two texts with evidence from each.
- Dedup: Assesses whether two texts are duplicates or near-duplicates based on a configurable threshold.
Use Cases
- Detecting duplicate support tickets or content submissions.
- Comparing policy documents for contradictions or drift.
- Validating consistency between source material and generated content.
- Flagging conflicting information across data sources.
How it works
- Merges the upstream payload with the node config (config wins); throws
Missing 'text_a'orMissing 'text_b'when empty. - Builds a mode-specific system prompt asking for strict JSON, and a user message
Context:(optional) +Text A:+Text B:; calls the model attemperature: 0. - Parses the answer as JSON (code fences removed, first
{to last}as fallback); an unparseable answer goes toerrorwithraw_content. - Picks the port:
similarityanddedup→matchwhenscore >= threshold;diff→matchwhendifferencesis empty;contradiction→matchwhencontradictionsis empty. - Returns
score,assessment,details,is_match,differences,contradictions,rawandportat the top level.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-compare-policy",
"label": "Compare policy versions",
"operator_slug": "ai.compare",
"operator_version": "1.0.0",
"config": {
"text_a": "{{ $json.previous_policy }}",
"text_b": "{{ $json.new_policy }}",
"comparison_mode": "similarity",
"threshold": 0.85,
"language": "en",
"llm_provider_id": "wf-llm-provider-xxxx",
"invocation_mode": "sync"
}
}{
"ok": true,
"data": {
"score": 0.91,
"assessment": "Both texts describe the same refund policy.",
"details": {
"overlaps": [
"30-day window",
"original payment method"
],
"gaps": []
},
"is_match": true,
"differences": [],
"contradictions": [],
"raw": null,
"port": "match"
},
"port": "match"
}Configuration
-
llm_provider_idstring Optional -
The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.
-
invocation_modestring Optional -
Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.
-
timeout_msinteger Optional -
Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.
-
comparison_modestring Optional -
The type of comparison to perform.
-
thresholdnumber Optional -
Match threshold for dedup mode (0-1). Scores at or above this value route to the match port.
-
languagestring Optional -
Output language code (e.g., "en", "es").
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
threshold - Applies to
similarityas well asdedup(default 0.8), and is written into the dedup prompt. Ignored bydiffandcontradiction. -
text_a, text_b, context - Not in the config schema, but read from the config first and then from the upstream payload.
-
timeout_ms - Stream mode only: idle timeout between chunks, default 600000. In sync mode it is not applied to the request.
-
execution - Declared but ignored: neither the worker nor the engine reads
retryOnFail,maxTries,waitBetweenTries,continueOnFail,alwaysOutputDataortimeout_msfrom this block.
Output ports
match default The mode's match rule holds (see operation). An unknown comparison_mode uses the similarity prompt but always routes here.
{
"score": 0.91,
"assessment": "Both texts describe the same refund policy.",
"details": {
"overlaps": [
"30-day window",
"original payment method"
],
"gaps": []
},
"is_match": true,
"differences": [],
"contradictions": [],
"raw": null,
"port": "match"
}no_match The score is below threshold (similarity, dedup), or differences or contradictions were found (diff, contradiction).
{
"score": 0.4,
"assessment": "Text B changes the refund window.",
"details": {},
"is_match": false,
"differences": [
{
"category": "changed",
"description": "Refund window goes from 30 to 14 days."
}
],
"contradictions": [],
"raw": null,
"port": "no_match"
}error A text is missing, the model call failed, or the answer was not JSON.
{
"error": "Failed to parse comparison result from LLM output.",
"raw_content": "The texts are mostly similar."
}In expressions
What a later node can read from this node's output with $("Compare Texts").item.json.<path> (write your node's label instead of Compare Texts). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through match, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Compare Texts").item.json.scoreSimilarity or match score (0-1). | ||
$("Compare Texts").item.json.assessmentHuman-readable assessment of the comparison. | ||
$("Compare Texts").item.json.detailsMode-specific detailed results. | ||
$("Compare Texts").item.json.is_matchWhether the texts match (dedup/similarity). | ||
$("Compare Texts").item.json.differencesList of semantic differences (diff mode). | ||
$("Compare Texts").item.json.contradictionsList of factual contradictions (contradiction mode). | ||
$("Compare Texts").item.json.details.overlaps | — | |
$("Compare Texts").item.json.details.gaps | — | |
$("Compare Texts").item.json.raw | — | |
$("Compare Texts").item.json.port | — |
— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).
Errors
| Message | Port | Cause and fix |
|---|---|---|
Missing 'text_a' | error | text_a (or text_b) is empty. |
Failed to parse comparison result from LLM output. | error | The answer was not a JSON object; the trimmed answer is in data.raw_content. |
[AiCompare] Missing 'llm_provider_id' in node config (LlmProviderModel.id, e.g. 'wf-llm-provider-*'). The legacy 'model_id' alias is no longer supported — update the node config to use 'llm_provider_id'. | error | llm_provider_id is empty or not a string. Pick an LLM provider record with chat capability. |
LLM Invocation Error: <backend message> | error | The backend rejected the call: unknown or inactive provider record, provider error, quota or content filter. Check the provider record and the backend logs. |
LLM Invocation Error: empty response from backend (<transport error>) | error | Sync mode: the HTTP call to the backend failed (network error, non-2xx status or timeout). Long prompts often hit the request timeout; switch to invocation_mode: "stream". |
RemoteApiService.stream: idle timeout after <timeout_ms>ms | error | Stream mode: no chunk arrived within timeout_ms. A failed stream request shows RemoteApiService.stream: HTTP <status> — <body> instead. |
Input contract
-
text_astring Required -
First text for comparison.
-
text_bstring Required -
Second text for comparison.
-
contextstring Optional -
Optional context to inform the comparison.
Output contract
-
scorenumber Optional -
Similarity or match score (0-1).
-
assessmentstring Optional -
Human-readable assessment of the comparison.
-
detailsobject Optional -
Mode-specific detailed results.
-
is_matchboolean Optional -
Whether the texts match (dedup/similarity).
-
differencesarray<object> Optional -
List of semantic differences (diff mode).
-
contradictionsarray<object> Optional -
List of factual contradictions (contradiction mode).
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "ai.compare",
"name": "Compare Texts",
"category": "ai",
"version": "1.0.0",
"description": "Semantic text comparison powered by LLM.\n\nThis operator compares two text inputs using a configurable comparison mode and routes to match/no_match ports based on the result.\n\n**Operations**\n- **Similarity:** Computes a semantic similarity score (0-1) between two texts.\n- **Diff:** Identifies meaningful semantic differences (not character-level) between texts.\n- **Contradiction:** Detects factual contradictions between two texts with evidence from each.\n- **Dedup:** Assesses whether two texts are duplicates or near-duplicates based on a configurable threshold.\n\n**Use Cases**\n- Detecting duplicate support tickets or content submissions.\n- Comparing policy documents for contradictions or drift.\n- Validating consistency between source material and generated content.\n- Flagging conflicting information across data sources.",
"capabilities": [
"ai",
"nlp",
"comparison",
"text"
],
"config_schema": {
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.",
"x-ui-widget": "llm-provider-picker",
"x-llm-provider-capabilities": [
"chat"
]
},
"invocation_mode": {
"type": "string",
"title": "Invocation Mode",
"description": "Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.",
"enum": [
"sync",
"stream"
],
"default": "sync"
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.",
"minimum": 1000
},
"comparison_mode": {
"type": "string",
"title": "Comparison Mode",
"description": "The type of comparison to perform.",
"enum": [
"similarity",
"diff",
"contradiction",
"dedup"
],
"default": "similarity"
},
"threshold": {
"type": "number",
"title": "Match Threshold",
"description": "Match threshold for dedup mode (0-1). Scores at or above this value route to the match port.",
"default": 0.8
},
"language": {
"type": "string",
"title": "Language",
"description": "Output language code (e.g., \"en\", \"es\").",
"default": "en"
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"properties": {
"text_a": {
"type": "string",
"description": "First text for comparison."
},
"text_b": {
"type": "string",
"description": "Second text for comparison."
},
"context": {
"type": "string",
"description": "Optional context to inform the comparison."
}
},
"required": [
"text_a",
"text_b"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"score": {
"type": "number",
"description": "Similarity or match score (0-1)."
},
"assessment": {
"type": "string",
"description": "Human-readable assessment of the comparison."
},
"details": {
"type": "object",
"description": "Mode-specific detailed results."
},
"is_match": {
"type": "boolean",
"description": "Whether the texts match (dedup/similarity)."
},
"differences": {
"type": "array",
"items": {
"type": "object"
},
"description": "List of semantic differences (diff mode)."
},
"contradictions": {
"type": "array",
"items": {
"type": "object"
},
"description": "List of factual contradictions (contradiction mode)."
}
}
},
"ports": [
{
"port_id": "match",
"label": "Match",
"is_default": true
},
{
"port_id": "no_match",
"label": "No Match"
},
{
"port_id": "error",
"label": "Error"
}
],
"execution_mode": "async",
"tags": [
"ai",
"compare",
"similarity",
"dedup",
"nlp"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"llm_provider_id": {
"type": "string",
"title": "LLM Provider",
"description": "The `id` of a `LlmProviderModel` record (e.g. `wf-llm-provider-*`). The orchestrator delegates to the backend: `POST /cognitive-infrastructure/cognitive-assets/llm-provider/invoke` for sync mode, or `POST /chat/conversation/execute/stream-ephemeral` (SSE) for stream mode. The backend resolves endpoint + api-key + deployment from the record and routes to the correct adapter.",
"x-ui-widget": "llm-provider-picker",
"x-llm-provider-capabilities": [
"chat"
]
},
"invocation_mode": {
"type": "string",
"title": "Invocation Mode",
"description": "Transport for the LLM call. `sync` blocks until the full response arrives. `stream` consumes tokens via SSE (required for long generations). Default `sync`.",
"enum": [
"sync",
"stream"
],
"default": "sync"
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Maximum time to wait for the invocation to complete (or idle timeout between chunks in stream mode). Default 30000 for sync, 600000 for stream.",
"minimum": 1000
},
"comparison_mode": {
"type": "string",
"title": "Comparison Mode",
"description": "The type of comparison to perform.",
"enum": [
"similarity",
"diff",
"contradiction",
"dedup"
],
"default": "similarity"
},
"threshold": {
"type": "number",
"title": "Match Threshold",
"description": "Match threshold for dedup mode (0-1). Scores at or above this value route to the match port.",
"default": 0.8
},
"language": {
"type": "string",
"title": "Language",
"description": "Output language code (e.g., \"en\", \"es\").",
"default": "en"
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"properties": {
"text_a": {
"type": "string",
"description": "First text for comparison."
},
"text_b": {
"type": "string",
"description": "Second text for comparison."
},
"context": {
"type": "string",
"description": "Optional context to inform the comparison."
}
},
"required": [
"text_a",
"text_b"
]
}{
"type": "object",
"properties": {
"score": {
"type": "number",
"description": "Similarity or match score (0-1)."
},
"assessment": {
"type": "string",
"description": "Human-readable assessment of the comparison."
},
"details": {
"type": "object",
"description": "Mode-specific detailed results."
},
"is_match": {
"type": "boolean",
"description": "Whether the texts match (dedup/similarity)."
},
"differences": {
"type": "array",
"items": {
"type": "object"
},
"description": "List of semantic differences (diff mode)."
},
"contradictions": {
"type": "array",
"items": {
"type": "object"
},
"description": "List of factual contradictions (contradiction mode)."
}
}
}[
{
"port_id": "match",
"label": "Match",
"is_default": true
},
{
"port_id": "no_match",
"label": "No Match"
},
{
"port_id": "error",
"label": "Error"
}
]Execution
- Execution
async- Stateful
- No
- Retries (
retryOnFail) - No
- Capabilities
ainlpcomparisontext- Tags
aicomparesimilaritydedupnlp
Notes and limits
- In
diffandcontradictionmodes the score direction is 1 = identical / consistent.is_matchcomes from the model when given (dedup), otherwise it mirrors the chosen port. - A missing
scorecounts as 0 for routing and is returned asnull. - The worker returns its fields at the top level instead of inside
data, so the engine stores the whole return value as the node output:portandrawappear in$jsonnext to the result fields. - The model call goes through the Sommatic AI backend, which resolves the provider record named by
llm_provider_id(endpoint, credentials, deployment); the orchestrator never holds provider keys.invocation_mode: "sync"(default) waits for the full answer;"stream"reads it as server-sent events and joins the chunks. timeout_msonly takes effect in stream mode, as the idle time allowed between chunks (default 600000). In sync mode the value is logged but not applied to the HTTP request, so the platform's default request timeout governs.- In stream mode the backend endpoint does not apply sampling settings, so the fixed
temperature: 0only takes effect in sync mode. - No automatic retries: the engine does not honour
execution.retryOnFail,maxTriesorwaitBetweenTriesfor this node; a failed call goes straight toerror.
Reviewed against the orchestrator code · 31e874b · 2026-11-26