Florence-2-base-ft-compat

This is a compatibility-patched version of Microsoft's Florence-2-base-ft model.

It contains patches in modeling_florence2.py to allow the model to load and generate text out-of-the-box using newer versions of the Hugging Face transformers library (specifically version 4.42.0 up to the latest 4.57.x) without triggering common errors.

Patches Applied

  1. _supports_sdpa AttributeError Fix: Prevents model load crashes on newer transformers versions that inspect attention properties before the nested language model is initialized.

  2. KV Cache NoneType / shape TypeError Fix: Resolves the crash during generation: TypeError: expected Tensor as element 0 in argument 0, but got NoneType (or 'NoneType' object has no attribute 'shape'). This happens because modern transformers caches initialize with empty placeholders (None) which the original custom code attempted to perform .shape and torch.cat on. The patch adds checks to bypass empty cache slots.

Usage

You can load this model directly using standard transformers code:

from transformers import AutoModelForCausalLM, AutoProcessor

model = AutoModelForCausalLM.from_pretrained(
    "topguy/Florence-2-base-ft-compat", 
    trust_remote_code=True
)
processor = AutoProcessor.from_pretrained(
    "topguy/Florence-2-base-ft-compat", 
    trust_remote_code=True
)

Attribution

All model weights and base architecture belong to Microsoft. Please refer to the original microsoft/Florence-2-base-ft repository for license terms and model cards.

Downloads last month
36
Safetensors
Model size
0.2B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for topguy/Florence-2-base-ft-compat

Finetuned
(23)
this model