#116·chandra

[Bug] Model generates massive gibberish/hallucination with specific text combination

Author: serusiyaCreated Aug 31, 2026Updated Aug 31, 2026

Description

When using the Chandra OCR model on specific images, the model breaks and outputs a massive amount of gibberish instead of the correct text. It seems like the model fails to output the EOS (End of Sentence) token properly in this edge case.

Specifically, this issue seems to be triggered whenever the image contains special text frames or bordered text boxes.

Environment

  • OS: Ubuntu 24.04.4 LTS
  • Python version: 3.12
  • Chandra version: 0.2.0

Steps to Reproduce

Whenever the image contains these types of specific text boxes/borders, the OCR process generates gibberish.

import torch from chandra.model import InferenceManager from chandra.model.schema import BatchInputItem from chandra.input import load_file

manager = InferenceManager(method="hf") #[cite: 1]

image_path = "0487.jpg" imgs = load_file(image_path, config={"page_range": None}) #[cite: 1]

batch = [BatchInputItem(image=imgs[0], prompt_type="ocr_layout")] #[cite: 1]

with torch.inference_mode(): #[cite: 1] results = manager.generate(batch) #[cite: 1]

print(results[0].markdown)

Input used (cropped examples of the problematic text boxes): Image Image Image Image

Actual Output

Image

Original Images (Full size)

Image Image Image Image