From: microsoft <huggingface.co/microsoft>Newsgroups: alt.freeweights.textSubject:

kosmos-2.5

Date: 2026-11-15Commit: ec3c805Signed: 2DC28CC7B26A283B ✓

Image text to text model with 1.4B parameters. Safetensors weights, 11.7 GB in all. Published by microsoft under MIT.

1.4B params11.7GBkosmos-2.5safetensorspermissive
FactsParams1.4BSize11.7 GBFormatssafetensorsTaskimage text to textLicenseMITFrom sourcepermissive
$ fw get microsoft/kosmos-2.5
# manifest sha256 6b0a7445fcb3… · 11.7 GB · 16 files
$ fw verify ./kosmos-2.5 microsoft/kosmos-2.5
From sourceHosted (signed)microsoft/kosmos-2.5Last check: 2026-11-15 03:23 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Runs withAIBrixBentoMLCTranslate2ExLlamaV2ExLlamaV3exofastllmFlashInferKTransformersLitServeLMCacheLMDeployLocalAImistral.rsMLC LLMMooncakeSGLangText Generation WebUItinygradTransformersTriton Inference ServervLLMXinferenceFine-tune withAccelerateAlignment HandbookAxolotlColossal-AIDeepSpeedEasyR1FlashAttentionH2O LLM StudioJAXKerasLiger KernelLitGPTLLaMA-FactoryMegatron-LMms-swiftnanotronOLMo-coreOpenRLHFOumiPEFTPyTorch Lightningsd-scriptsSimpleTunerTorchTitantorchtuneTransformer EngineTRLUnslothverlConvert withAQLMAutoRoundCore ML ToolsExecuTorchGPTQModelLLM CompressormergekitNeural CompressorOliveONNXOptimum QuantoOptimumsafetensorsTensorRT Model OptimizertorchaoEvaluate withAutoevalsDeepEvalEvaluateHELMLightEvallm-evaluation-harnessOpenCompassOpikRagassimple-evalsSWE-benchTruLensWeaveScan withAgentDojoAI Fairness 360DeepTeamDetoxifyFairlearngarakGiskardGuardrailsMCP ScannerModelScanNeMo GuardrailspicklescanpromptfooWorks withAgent Development KitAG2Google AI Edge GalleryAiderany-llmAnythingLLMBAMLbrowser-useCAMELHugging Face Chat UIChatboxCherry StudioClineCodex CLICogneeCrewAIDeerFlowdocTRDSPyEasyOCREnchantedGemini CLIGitHub MCP ServergooseGPT ResearcherGradioGraphitiGuidanceHollamaInstructorKilo CodeLangflowLangGraphLiteLLMLlamaIndexLLMLocalAGILoLLMs WebUIMCP Python SDKMem0MetaGPTNextChatOllama JavaScriptOllama PythonolmOCROpenAI Agents SDKopencodeOpenHandsotermOutlinesPage AssistPlaywright MCPPortkey AI GatewayPrivateGPTQwen CodeRWKV RunnerSemantic KernelsmolagentsStrands AgentsSuryaVaneXGrammar

Overview

Size
11.7 GB
Weights
5.50 GB (safetensors)
Parameters
1.4B
Formats
safetensors
Task
image text to text
License
MIT (permissive)
Files
16, each with a sha256
Publisher
microsoft
Added
2026-11-15
Section
alt.freeweights.text
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 03:23 UTCpassed

Model card

From the publisher at commit ec3c805. Shown as plain text with links; images open at the publisher.

Kosmos-2.5#

Microsoft Document AI | GitHub

Model description#

Kosmos-2.5 is a multimodal literate model for machine reading of text-intensive images. Pre-trained on large-scale text-intensive images, Kosmos-2.5 excels in two distinct yet cooperative transcription tasks: (1) generating spatially-aware text blocks, where each block of text is assigned its spatial coordinates within the image, and (2) producing structured text output that captures styles and structures into the markdown format. This unified multimodal literate capability is achieved through a shared decoder-only auto-regressive Transformer architecture, task-specific prompts, and flexible text representations. We evaluate Kosmos-2.5 on end-to-end document-level text recognition and image-to-markdown text generation. Furthermore, the model can be readily adapted for any text-intensive image understanding task with different prompts through supervised fine-tuning, making it a general-purpose tool for real-world applications involving text-rich images. This work also paves the way for the future scaling of multimodal large language models.

Kosmos-2.5: A Multimodal Literate Model

NOTE:#

Since this is a generative model, there is a risk of hallucination during the generation process, and it CAN NOT guarantee the accuracy of all OCR/Markdown results in the images.

Inference#

KOSMOS-2.5 is supported from Transformers >= 4.56. Find the docs here.

Markdown Task: For usage instructions, please refer to md.py.

import re
import torch
import requests
from PIL import Image, ImageDraw
from transformers import AutoProcessor, Kosmos2_5ForConditionalGeneration, infer_device

repo = "microsoft/kosmos-2.5"
device = "cuda:0"
dtype = torch.bfloat16
model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, dtype=dtype)
processor = AutoProcessor.from_pretrained(repo)

# sample image
url = "https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"
image = Image.open(requests.get(url, stream=True).raw)

prompt = "<md>"
inputs = processor(text=prompt, images=image, return_tensors="pt")

height, width = inputs.pop("height"), inputs.pop("width")
raw_width, raw_height = image.size
scale_height = raw_height / height
scale_width = raw_width / width

inputs = {k: v.to(device) if v is not None else None for k, v in inputs.items()}
inputs["flattened_patches"] = inputs["flattened_patches"].to(dtype)
generated_ids = model.generate(
    **inputs,
    max_new_tokens=1024,
)

generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_text[0])

OCR Task: For usage instructions, please refer to ocr.py.

import re
import torch
import requests
from PIL import Image, ImageDraw
from transformers import AutoProcessor, Kosmos2_5ForConditionalGeneration, infer_device

repo = "microsoft/kosmos-2.5"
device = "cuda:0"
dtype = torch.bfloat16
model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=device, dtype=dtype)
processor = AutoProcessor.from_pretrained(repo)

# sample image
url = "https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"
image = Image.open(requests.get(url, stream=True).raw)

# bs = 1
prompt = "<ocr>"
inputs = processor(text=prompt, images=image, return_tensors="pt")
height, width = inputs.pop("height"), inputs.pop("width")
raw_width, raw_height = image.size
scale_height = raw_height / height
scale_width = raw_width / width

# bs > 1, batch generation
# inputs = processor(text=[prompt, prompt], images=[image,image], return_tensors="pt")
# height, width = inputs.pop("height"), inputs.pop("width")
# raw_width, raw_height = image.size
# scale_height = raw_height / height[0]
# scale_width = raw_width / width[0]

inputs = {k: v.to(device) if v is not None else None for k, v in inputs.items()}
inputs["flattened_patches"] = inputs["flattened_patches"].to(dtype)
generated_ids = model.generate(
    **inputs,
    max_new_tokens=1024,
)

generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
def post_process(y, scale_height, scale_width):
    y = y.replace(prompt, "")
    if "<md>" in prompt:
        return y
    pattern = r"<bbox><x_\d+><y_\d+><x_\d+><y_\d+></bbox>"
    bboxs_raw = re.findall(pattern, y)
    lines = re.split(pattern, y)[1:]
    bboxs = [re.findall(r"\d+", i) for i in bboxs_raw]
    bboxs = [[int(j) for j in i] for i in bboxs]
    info = ""
    for i in range(len(lines)):
        box = bboxs[i]
        x0, y0, x1, y1 = box
        if not (x0 >= x1 or y0 >= y1):
            x0 = int(x0 * scale_width)
            y0 = int(y0 * scale_height)
            x1 = int(x1 * scale_width)
            y1 = int(y1 * scale_height)
            info += f"{x0},{y0},{x1},{y0},{x1},{y1},{x0},{y1},{lines[i]}"
    return info

output_text = post_process(generated_text[0], scale_height, scale_width)
print(output_text)

draw = ImageDraw.Draw(image)
lines = output_text.split("\n")
for line in lines:
    # draw the bounding box
    line = list(line.split(","))
    if len(line) < 8:
        continue
    line = list(map(int, line[:8]))
    draw.polygon(line, outline="red")
image.save("output.png")

Citation#

If you find Kosmos-2.5 useful in your research, please cite the following paper:

@article{lv2023kosmos,
  title={Kosmos-2.5: A multimodal literate model},
  author={Lv, Tengchao and Huang, Yupan and Chen, Jingye and Cui, Lei and Ma, Shuming and Chang, Yaoyao and Huang, Shaohan and Wang, Wenhui and Dong, Li and Luo, Weiyao and others},
  journal={arXiv preprint arXiv:2309.11419},
  year={2023}
}

License#

The content of this project itself is licensed under the MIT

Microsoft Open Source Code of Conduct

Files

16 files · 11.7 GBWeights 5.50 GB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 16 files with their sha256
FileSizesha256
.gitattributes1.62 KB003395074787669c1e51a681b2fedf650e04feefe715a14fec86b7b0dbdfcb83
README.md6.20 KB8b9a21d5d2f85ca3cf1a649502f7ca5a8b55af621f256b5f9ef05d1430d06853
ckpt.pt6.17 GB676d0efd1dddf3785644918dd598d7734f9ed6e3eb59f806299ca8b7aefa0967
config.json4.06 KBab7796c802da786df0d2ccf1cab634b831ac742e75cbd3bf9a305ee64e6bd5d0
generation_config.json178 B6ff1351b6a1bc18f890c14bb6f08bdb7db7b056fd7df44ab4cc90d9f832d0091
md.py1.10 KB8eb5cb694f9781be7a25084a8f2dc334b16b86c439c0a9b927bd31fbfc6f24a3
model-00001-of-00002.safetensors5.00 GBe4be3da9ff4d8a8a564e8605a914a12f5f8b38ac5927a042c1a161e86d603e42
model-00002-of-00002.safetensors503 MBf5b29cbcd5cd448e0309b7f7ffcb50d629f4ef5b635530554983d126f382dac9
model.safetensors.index.json56.5 KB7a1efccef236dea0c422e37d1584fa27b28c3dea5a09a98e2d6ef53c83a4830c
ocr.py2.49 KBe50ea8cb0f84278d8a903c6e67a2a606b348ce263a4179f356a2c34833d08429
output.png1.66 MBd95e7707ae64bea0e864438f3efdf5a501c46714afc3a909b84a29c3feca0b16
preprocessor_config.json107 Bef824d8f3f414c73cf63f2005deeaabee79fa91ad9b882b35d653fb296903116
receipt_00008.png1.85 MB58716693a6c0733358e66e64d7064a5a845424280bb55f9b5fa137b1af8c92fe
special_tokens_map.json629 Bb4858d44e300e3ee192731fd9e2e4ad2a4a77b2fdebc5825ffb0dcd7005f8e04
tokenizer.json8.86 MBdc6c14e44d21900b521716c453225aa9bcb9bb4fa79fd7d0915da47fa8911469
tokenizer_config.json1.43 MB4d8bb069d946acd2b843e50cf287c4059c327a8af3dcdfd3fd609e1717ca1f55
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
ec3c8051b6 pinned now2026-11-15 03:23 UTC16 files · 11.7 GB

Use it

$ fw get microsoft/kosmos-2.5
# manifest sha256 6b0a7445fcb3… · 11.7 GB · 16 files
$ fw verify ./kosmos-2.5 microsoft/kosmos-2.5
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/microsoft/kosmos-2.5.json --dir ./kosmos-2.5 $ python3 fw.py verify ./kosmos-2.5 ./microsoft__kosmos-2.5.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download microsoft/kosmos-2.5 --revision ec3c8051b697166514a31d646cfa36d6ef4c93d7 --local-dir ./kosmos-2.5
transformersLoad the weights in Python.
import os os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com" from transformers import AutoModelForImageTextToText, AutoProcessor processor = AutoProcessor.from_pretrained("microsoft/kosmos-2.5", revision="ec3c8051b697166514a31d646cfa36d6ef4c93d7") model = AutoModelForImageTextToText.from_pretrained("microsoft/kosmos-2.5", revision="ec3c8051b697166514a31d646cfa36d6ef4c93d7", device_map="auto")
vLLMServe an OpenAI-compatible API.
$ HF_ENDPOINT=https://freeweights.allternit.com vllm serve microsoft/kosmos-2.5 --revision ec3c8051b697166514a31d646cfa36d6ef4c93d7

License

Name
MIT License
Id
MIT
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
README.md
Text sha256
8b9a21d5d2f85ca3cf1a649502f7ca5a8b55af621f256b5f9ef05d1430d06853
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: microsoft <huggingface.co/microsoft>Newsgroups: alt.freeweights.textSubject: kosmos-2.5Date: 2026-11-15Commit: ec3c805Signed: 2DC28CC7B26A283B ✓
Upstream
microsoft/kosmos-2.5
Pinned commit
ec3c8051b697166514a31d646cfa36d6ef4c93d7
Manifest
kosmos-2.5.json · .minisig
Manifest sha256
6b0a7445fcb3132bac32f9b1b753cdda806e90d603c073d112c516f7c5dc114e
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 03:23 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/microsoft/kosmos-2.5.json $ curl -O https://freeweights.allternit.com/manifests/microsoft/kosmos-2.5.json.minisig $ minisign -Vm kosmos-2.5.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

No related models in this catalog.Nothing here lists this model as its parent, and it names no parent.
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download microsoft/kosmos-2.5
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. kosmos-2.5.json. Provenance. Takedown history: none.
From: laion <huggingface.co/laion>Subject: a2-rl-e2egit_large-50-32B
From: laion <huggingface.co/laion>Subject: a3-rl-DCAgent_exp_rpt_e2egit-large-15-8B
From: laion <huggingface.co/laion>Subject: a3-rl-DCAgent_exp_rpt_e2egit-v2-10-8B
From: laion <huggingface.co/laion>Subject: a3-rl-DCAgent_exp_rpt_pymethods2test-large-80-8B
From: laion <huggingface.co/laion>Subject: a3-rl-DCAgent_exp_rpt_unitsyn-python-large-10-8B
From: laion <huggingface.co/laion>Subject: a3-rl-DCAgent_mix_h2_language_proportional-65-8B