Repository navigation
mtmd : add MiniCPM-OCR 1.0 - #98
Open
notforu777 wants to merge 1 commit into
Open
notforu777 wants to merge 1 commit into
notforu777 wants to merge 1 commit into
Conversation
Port of upstream ggml-org#30979 (a08ab75) to the fork. MiniCPM-OCR 1.0 is the MiniCPM-V 4.6 stack with projector type minicpm_ocr_1_0; the fork's 4.6 code lacks parts of upstream's preprocessing that this model's output depends on, so the new type gets them without changing 4.6: - Pillow bicubic for the overview and the slices (RESIZE_ALGO_BICUBIC_PILLOW_EXACT: the fork's Pillow resampler with Pillow's fixed-point weight rounding), no padding; - <image_id>N</image_id> before <image>; - slice sizes snapped with Python's round() (ties to even); - a 2D image grid (nx, ny) for M-RoPE positions instead of one row; - position buckets in vectors instead of a 1024-entry stack array. Pages read with the BF16 GGUF match upstream a7af149 token for token on CPU; on CUDA 37 of 40 OmniDocBench pages are identical (the rest diverge at near-tied tokens, from the fork's CUDA kernels). Assisted-by: Claude
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds OpenBMB's MiniCPM-OCR 1.0 (1.3B, Apache-2.0: text, tables as HTML, formulas as LaTeX) so Atomic Chat can
run it. Upstream support is ggml-org#30979 (merge
a08ab75, 2026-10-22).What is in it
MiniCPM-OCR 1.0 is the MiniCPM-V 4.6 stack: text model
qwen35, mmproj with the 4.6 merger in 4x mode, newprojector type
minicpm_ocr_1_0. Upstream registers the type on top of preprocessing the fork's 4.6 code does nothave yet. The new type gets that preprocessing; MiniCPM-V 4.6 itself does not change:
overview + PyTorch bicubic slices with ceil padding). New
RESIZE_ALGO_BICUBIC_PILLOW_EXACT= the fork's Pillowresampler with Pillow's fixed-point weight rounding (
+/-0.5, truncate), as upstream's. ExistingBICUBIC_PILLOWusers are untouched.<image_id>N</image_id>before<image>(use_image_id).round()(ties to even, double), via a new virtualalign_round_div()on the llava-uhd preprocessor; the default keeps the old floatstd::round.clip_n_output_tokens_x/ygive the 2D grid (n / (patch * n_merge)). The 4.6 path returns(all tokens, 1), one row.
int[1024]on the stack.VisionProjectorType.MINICPM_OCR_1_0. The converter is not ported: the app only loads GGUFs.Tested (A10, CUDA, BF16 GGUF + mmproj F16 from
AtomicChat/MiniCPM-OCR-1.0-GGUF)40 OmniDocBench pages (4 per source, seed 0),
llama-mtmd-cli --jinja --temp 0, promptText Recognition:. Thisbranch against upstream
a7af149:character in a formula) and then drift. Two of them are dense newspaper pages.
-ngl 0 --no-mmproj-offload): the same 21 chunks, thesame tokens. So the inputs match, and the CUDA difference comes from the fork's kernels, not from the port.
for comparing two builds).
llama-serverwith an image request works.Thinking (affects the app)
The model writes its transcription after the thinking block. With
--jinjaand default reasoning, llama-serversets
enable_thinking, the original template opens<think>, and the whole answer arrives inreasoning_contentwith emptycontent. This happens on upstream too. Checked on this branch:openbmb/MiniCPM-OCR-1.0-gguf(template with thinking hard-off)--reasoning off--chat-template-kwargs '{"enable_thinking": false}'For the app: either ship GGUFs whose template has thinking off, or start this model with
--reasoning off.Not in this PR
minicpmv4_7) is still not in the fork.0.74 s per 448px slice).
To ship in the app
Review, merge, cut a fork release, bump the app. Then handle thinking-off for this model (template or flag).
Assisted-by: Claude