Skip to main content
Beta Gibberish detection scores how nonsensical the text around each detected entity is, which helps you detect false positives. Noisy input, such as text extracted from low-quality scans via OCR, can cause entities to be detected where there is none. When you enable gibberish detection, every detected entity is returned with a 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)

Set enable_gibberish_detection to true at the top level of a request to the ner/text or ner/files endpoint:
Request Body
{
    "text": [
        "The contract was signed by Laura Bennett on June 3rd.",
        "Attn: Krell Vontanix, Dept of Aurellian Affiars",
        "Recipt frm company Nothern Suplly Co, it cnts ref 4471xz asd",
        "Cotpan lnvol'ce N0 4rZ9 Rrnlk zq## Xy9kp"
    ],
    "enable_gibberish_detection": true
}

Reading the score

Each entity in the response contains a gibberish_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": [
            {
                "text": "Laura",
                "location": {
                    "stt_idx": 27,
                    "end_idx": 32
                },
                "label": "NAME_GIVEN",
                "likelihood": 0.9249095916748047,
                "validation_results": [],
                "gibberish_score": 0.0001703500747680664
            },
            {
                "text": "Laura Bennett",
                "location": {
                    "stt_idx": 27,
                    "end_idx": 40
                },
                "label": "NAME",
                "likelihood": 0.9158932566642761,
                "validation_results": [],
                "gibberish_score": 0.0001703500747680664
            },
            {
                "text": "Bennett",
                "location": {
                    "stt_idx": 33,
                    "end_idx": 40
                },
                "label": "NAME_FAMILY",
                "likelihood": 0.9399955868721008,
                "validation_results": [],
                "gibberish_score": 0.03785803640799792
            },
            {
                "text": "June 3rd",
                "location": {
                    "stt_idx": 44,
                    "end_idx": 52
                },
                "label": "DATE",
                "likelihood": 0.9454799294471741,
                "validation_results": [],
                "gibberish_score": 0.1005928173080051
            }
        ],
        "entities_present": true,
        "characters_processed": 53,
        "languages_detected": {
            "en": 0.9993266463279724
        }
    },
    {
        "entities": [
            {
                "text": "Krell",
                "location": {
                    "stt_idx": 6,
                    "end_idx": 11
                },
                "label": "NAME_GIVEN",
                "likelihood": 0.9069240093231201,
                "validation_results": [],
                "gibberish_score": 0.3707108026617384
            },
            {
                "text": "Krell Vontanix",
                "location": {
                    "stt_idx": 6,
                    "end_idx": 20
                },
                "label": "NAME",
                "likelihood": 0.906118224064509,
                "validation_results": [],
                "gibberish_score": 0.40363886910682156
            },
            {
                "text": "Vontanix",
                "location": {
                    "stt_idx": 12,
                    "end_idx": 20
                },
                "label": "NAME_FAMILY",
                "likelihood": 0.9207147657871246,
                "validation_results": [],
                "gibberish_score": 0.40363886910682156
            },
            {
                "text": "Dept of Aurellian Affiars",
                "location": {
                    "stt_idx": 22,
                    "end_idx": 47
                },
                "label": "ORGANIZATION",
                "likelihood": 0.9109159633517265,
                "validation_results": [],
                "gibberish_score": 0.40363886910682156
            }
        ],
        "entities_present": true,
        "characters_processed": 47,
        "languages_detected": {
            "en": 0.5085869431495667
        }
    },
    {
        "entities": [
            {
                "text": "Nothern Suplly Co",
                "location": {
                    "stt_idx": 19,
                    "end_idx": 36
                },
                "label": "ORGANIZATION",
                "likelihood": 0.8835725784301758,
                "validation_results": [],
                "gibberish_score": 0.38497073599686615
            },
            {
                "text": "4471xz asd",
                "location": {
                    "stt_idx": 50,
                    "end_idx": 60
                },
                "label": "NUMERICAL_PII",
                "likelihood": 0.8458981911341349,
                "validation_results": [],
                "gibberish_score": 0.6274604711816052
            }
        ],
        "entities_present": true,
        "characters_processed": 60,
        "languages_detected": {
            "en": 0.49856317043304443
        }
    },
    {
        "entities": [
            {
                "text": "N0 4rZ9",
                "location": {
                    "stt_idx": 16,
                    "end_idx": 23
                },
                "label": "LOCATION",
                "likelihood": 0.25443747888008755,
                "validation_results": [],
                "gibberish_score": 0.9964572315753586
            },
            {
                "text": "N0 4rZ9",
                "location": {
                    "stt_idx": 16,
                    "end_idx": 23
                },
                "label": "LOCATION_ZIP",
                "likelihood": 0.30771060287952423,
                "validation_results": [],
                "gibberish_score": 0.9964572315753586
            },
            {
                "text": "0 4rZ9",
                "location": {
                    "stt_idx": 17,
                    "end_idx": 23
                },
                "label": "VEHICLE_ID",
                "likelihood": 0.18630204796791078,
                "validation_results": [],
                "gibberish_score": 0.9964572315753586
            },
            {
                "text": "rZ9",
                "location": {
                    "stt_idx": 20,
                    "end_idx": 23
                },
                "label": "PASSWORD",
                "likelihood": 0.17115056018034616,
                "validation_results": [],
                "gibberish_score": 0.9964572315753586
            },
            {
                "text": "rnlk zq",
                "location": {
                    "stt_idx": 25,
                    "end_idx": 32
                },
                "label": "PASSWORD",
                "likelihood": 0.3922242820262909,
                "validation_results": [],
                "gibberish_score": 0.9964572315753586
            },
            {
                "text": "Xy9kp",
                "location": {
                    "stt_idx": 35,
                    "end_idx": 40
                },
                "label": "PASSWORD",
                "likelihood": 0.6181477636098862,
                "validation_results": [],
                "gibberish_score": 1
            }
        ],
        "entities_present": true,
        "characters_processed": 40,
        "languages_detected": {}
    }
]
This example demonstates that the higher the score, the stronger the false-positive candidate:
  1. Entities in the first, clean sentence have scores close to 0.
  2. The second is a plausible sentence, but includes an invented name and a typo. The entities have gibberish_score of around 0.40.
  3. 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 than 0.60, because its context is somewhat nonsensical text.
  4. The entities in the last sentence, representing a random OCR output, have scores close or equal to 1.0.
The score should be interpreted as a signal rather than a verdict:
  • A value near 0 means the entity is within a coherent, meaningful text.
  • A value near 1 means 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.
Some entity types are not natural language. Values such as passwords, account and card numbers, API keys, license plates, and other high-entropy identifiers may score high even when they are correctly detected, simply because the value itself looks random. A high score should be treated as a reason to review an entity, instead of a proof that it is a false positive.

Limitations

Text detected as Chinese, Japanese, or Korean is currently not evaluated and returns a gibberish_score of 0.0, as the scoring signals are unreliable for these languages.