I was thinking about interesting idea of text detection, OCR and language model end to…
- User
I was thinking about interesting idea of text detection, OCR and language model end to end architecture. Usually it is separate models, where cropped text boxes are passed into OCR, and results are postprocessed with LLM, maybe rendering into html format. What I want is one model with all this components at once.
- Assistant
- User
This suggestion is slightly off. For example, in case of ASR, openAI developed Whisper, which takes in audio, encode it into audio tokens (hidden state vector embeddings) than do language modeling, where multiple sub-tasks are done with special tokens. E.g. VAD and no speech token, or language detection and language token. It is oversimplified explanation. Maybe something similar can be done for unified OCR.
- Assistant
- User
Is it better to use CNN encoding (e.g. YOLO-like, where output is grid 13x13x4096 features vector which can be used as an embedding vector, maybe hierarchical), visual patch tokenisation with embedding layer (e.g. VQ-VAE for 16x16 patches and visual tokens vocabulary), or combination of both?
- Assistant
- User
Ok, how about, for 512x512 image, we use CNN to get 15x15 feature vectors grid (225 vectors, at 4096 vector size it would be 2254096 / (512512) ~ 3.5 values per pixel), than append 32x32 visual tokens (16x16 pages), projected into 1024 embedding vectors for a total of 1249? Just in case - transformers do not work with tokens, in case of text BPE tokens are first passed through embedding layer and only then tensor (with size of input sequence length x hidden state) can be processed by transformer layers.
- Assistant
- User
So, theoretically it is powerful enough representation for input direction. But how to represent output so that it would allow complex analysis? e.g. overlapping text, mixed printed and handwritten, changing direction, tables diagram and figures, low resolution characters, etc. Simple per patch classification (text/no-text, angle, lang) might be not enough.
- Assistant
- User
For document level analysis we might need something more flexible. If we aim to process multi page document scan, single A4 at 300dpi will take 2480x3500 pixels, which is 5x7 chunks 512x512 each; and documents can be 100+ pages. Maybe we can do multi pass processing with image similarity search, where feature vectors are used like a queries. At each pass we process only chunks which was not yet recognised fully. So, we first get simple parts done, than try to use their results for "uncertain" parts - at 225 vectors per 512x512 chunk (excluding visual tokens) we can pass 4 chunks+recognition results (text and formatting) per 1024 context window length as an additional context.
- Assistant
- User
Can we do something like actual digital agent with RL policy, "reasoning engine" and audiovisual language transformer model (audio represented through neural audio codec) for broad range of recognition, understanding, search and modifications tasks? Not just text detection and OCR, ASR or language modeling.
- Assistant
- User
How such digital agent might be able to handle math and logic? Language models are bad at coding and math, not being able to achieve generalisation/comprehension (they do it without actual understanding). So, we need to use something different. Maybe kind of tool/model which would analyse available input, separate into "points", formalise, make hypothesis and check them. Or even generate hierarchical representation of algorithm, components and pipeline which can be used for software synthesis (NOT in a way LLMs do it, which is miserable to see; but as a part of holistic framework). Something like that.
- Assistant
- User
So we would have "sensory patterns recognition" component, for example said audiovisual language model, than abstract processing engine (including various stuff discussed above) and "agentic" parts.
- Assistant