Halgorithem scores each claim using cosine similarity between sentence embeddings, then applies rule-based adjustments for numbers and negation before classifying the result. The entire scoring process is deterministic and runs locally — no external model API calls are made.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TangibleResearch/Halgorithem/llms.txt
Use this file to discover all available pages before exploring further.
Base scoring
Every chunk and every claim is encoded to a 384-dimensional vector by SentenceTransformerall-MiniLM-L6-v2. Chunk embeddings are computed once when documents are loaded; claim embeddings are computed at verification time.
Cosine similarity is computed via sentence_transformers.util.cos_sim(), which returns a value in the range [−1.0, 1.0]. In practice, sentence embeddings are non-negative, so scores sit between 0.0 and 1.0.
support_score() is a public method on Halgorithm — you can call it directly to score a single claim against a single chunk without running the full pipeline.
support_score() returns the raw cosine similarity before any adjustments. The adjusted score used for final classification is computed inside check_claim_against_chunks().Score adjustments
After the raw similarity is computed for each chunk, two adjustments are applied before the best chunk is selected:Number subset bonus (+0.10)
If every number found in the claim is also present in the chunk, a+0.10 bonus is added (capped at 1.0). This rewards chunks that contain the specific figures the claim is making — a useful signal when multiple chunks have similar semantic content but only one has the right numbers.
Negation mismatch penalty (−0.30)
Ifhas_negation_mismatch() detects that the claim and chunk disagree on negation, and the current score is at or above threshold, a −0.30 penalty is applied. This can push a borderline WEAK_SUPPORT score down into HALLUCINATION territory.
best_score and returned in the result dict.
Score ranges and verdicts
| Score range | Status |
|---|---|
>= 0.65 | SUPPORTED |
>= threshold and < 0.65 | WEAK_SUPPORT |
< threshold | HALLUCINATION |
| Number or negation conflict | CONTRADICTION (overrides score) |
0.65 boundary for SUPPORTED is hardcoded. Only the lower boundary — between WEAK_SUPPORT and HALLUCINATION — moves when you change threshold.
Effect of chunking parameters on scoring accuracy
Thesentences_per_chunk and sentence_overlap constructor parameters directly affect how much context each chunk carries, which in turn affects cosine similarity scores.
sentences_per_chunk— larger values give each chunk more semantic context, which can improve similarity for claims that span multiple sentences. Very large values dilute the embedding with unrelated content, reducing precision.sentence_overlap— overlap of1or more ensures that a claim sitting at the boundary between two sentences is still covered by at least one chunk. Setting this to0can cause boundary claims to score lower than they should.
sentences_per_chunk=2 and sentence_overlap=1 work well. For longer, more discursive documents, increasing sentences_per_chunk to 3 or 4 often improves recall.