gibberish_score between 0 and 1. A higher score suggests that the surrounding text is more characteristic of random character sequences or OCR-generated noise than coherent language. Consequently, entities with higher gibberish scores are more likely to be false positives.
Why gibberish detection
Transformer-based NER models are typically trained on well-formed natural language, where they learn to identify entities using both the words themselves and their surrounding linguistic context. When the input contains gibberish, OCR artifacts, or random character sequences, these contextual cues become unreliable or disappear entirely. As a result, the model is more prone to producing spurious entity predictions or missing true entities, leading to reduced precision and overall performance. Gibberish detection provides an additional quality signal that helps distinguish reliable entity predictions from those made on degraded or nonsensical text.Enabling gibberish detection (new in 4.4)
Setenable_gibberish_detection to true at the top level of a request to the ner/text or ner/files endpoint:
Request Body
Reading the score
Each entity in the response contains agibberish_score field.
The
gibberish_score field is only present when enable_gibberish_detection is set to true. When the option is off (the default), the field is omitted entirely.Response
- Entities in the first, clean sentence have scores close to
0. - The second is a plausible sentence, but includes an invented name and a typo. The entities have
gibberish_scoreof around0.40. - In the third sentence, which has several misspellings, the first entity is surrounded with cleaner text and scores lower (below
0.40). The second entity has a score higher than0.60, because its context is somewhat nonsensical text. - The entities in the last sentence, representing a random OCR output, have scores close or equal to
1.0.
- A value near
0means the entity is within a coherent, meaningful text. - A value near
1means the surrounding text is likely gibberish. - Different thresholds may be selected depending on the data. A higher cut-off value is stricter about what it flags as gibberish.