Model reference · open weights
Florence-2-large is an open-weight language model from florence-community. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | florence-community |
|---|---|
| Type | Language models |
| Task | Vision + text |
| Parameters (lead) | 777M |
| Context | 4k tokens |
| Runs with | transformers |
| Released | 2025-09-11 |
| Popularity | 319k downloads / month |
| Licence | Open weights |
About
[!NOTE] This is the repository for official transformers converted checkpoint of Microsoft's Florence model.
This is a continued pretrained version of Florence-2-large model with 4k context length, only 0.1B samples are used for continue pretraining, thus it might not be trained well. In addition, OCR task has been updated with line separator ('\n'). COCO OD AP 39.8
Florence-2 is an advanced vision foundation model that uses a prompt-based approach to handle a wide range of vision and vision-language tasks. Florence-2 can interpret simple text prompts to perform tasks like captioning, object detection, and segmentation. It leverages our FLD-5B dataset, containing 5.4 billion annotations across 126 million images, to master multi-task learning. The model's sequence-to-sequence architecture enables it to excel in both zero-shot and fine-tuned settings, proving to be a competitive vision foundation model.
Resources and Technical Documentation:
| Model | Model size | Model Description |
|---|---|---|
| Florence-2-base[HF] | 0.23B | Pretrained model with FLD-5B |
| Florence-2-large[HF] | 0.77B | Pretrained model with FLD-5B |
| Florence-2-base-ft[HF] | 0.23B | Finetuned model on a colletion of downstream tasks |
| Florence-2-large-ft[HF] | 0.77B | Finetuned model on a colletion of downstream tasks |
Use the code below to get started with the model.
import torch
import requests
from PIL import Image
from transformers import AutoProcessor, Florence2ForConditionalGeneration, BitsAndBytesConfig
model = Florence2ForConditionalGeneration.from_pretrained(
"florence-community/Florence-2-large",
dtype=torch.bfloat16,
device_map="auto",
)
processor = AutoProcessor.from_pretrained("florence-community/Florence-2-large")
url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
task_prompt = ""
inputs = processor(text=task_prompt, images=image, return_tensors="pt").to(model.device, torch.bfloat16)
generated_ids = model.generate(
**inputs,
max_new_tokens=1024,
num_beams=3,
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
image_size = image.size
parsed_answer = processor.post_process_generation(generated_text, task=task_prompt, image_size=image_size)
print(parsed_answer)
This model is capable of performing different tasks through changing the prompts.
First, let's define a function to run a prompt.
Here are the tasks Florence-2 could perform:
prompt = ""
run_example(prompt)
prompt = ""
run_example(prompt)
prompt = ""
run_example(prompt)
caption to phrase grounding task requires additional text input, i.e. caption.
Caption to phrase grounding results format: {'': {'bboxes': [[x1, y1, x2, y2], ...], 'labels': ['', '', ...]}}
task_prompt = ""
results = run_example(task_prompt, text_input="A green car parked in front of a yellow building.")
OD results format: {'': {'bboxes': [[x1, y1, x2, y2], ...], 'labels': ['label1', 'label2', ...]} }
prompt = ""
run_example(prompt)
Dense region caption results format: {'' : {'bboxes': [[x1, y1, x2, y2], ...], 'labels': ['label1', 'label2', ...]} }
prompt = ""
run_example(prompt)
Dense region caption results format: {'': {'bboxes': [[x1, y1, x2, y2], ...], 'labels': ['', '', ...]}}
prompt = ""
run_example(prompt)
prompt = ""
run_example(prompt)
OCR with region output format: {'': {'quad_boxes': [[x1, y1, x2, y2, x3, y3, x4, y4], ...], 'labels': ['text1', ...]}}
prompt = ""
run_example(prompt)
The following table presents the zero-shot performance of generalist vision foundation models on image captioning and object detection evaluation tasks. These models have not been exposed to the training data of the evaluation tasks during their training phase.
| Method | #params | COCO Cap. test CIDEr | NoCaps val CIDEr | TextCaps val CIDEr | COCO Det. val2017 mAP |
|---|---|---|---|---|---|
| Flamingo | 80B | 84.3 | - | - | - |
| Florence-2-base | 0.23B | 133.0 | 118.7 | 70.1 | 34.7 |
| Florence-2-large | 0.77B | 135.6 | 120.8 | 72.8 | 37.5 |
The following table continues the comparison with performance on other vision-language evaluation tasks.
| Method | Flickr30k test R@1 | Refcoco val Accuracy | Refcoco test-A Accuracy | Refcoco test-B Accuracy | Refcoco+ val Accuracy | Refcoco+ test-A Accuracy | Refcoco+ test-B Accuracy | Refcocog val Accuracy | Refcocog test Accuracy | Refcoco RES val mIoU |
|---|---|---|---|---|---|---|---|---|---|---|
| Kosmos-2 | 78.7 | 52.3 | 57.4 | 47.3 | 45.5 | 50.7 | 42.2 | 60.6 | 61.7 | - |
| Florence-2-base | 83.6 |
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys florence-community-florence-2-large for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (florence-community-florence-2-large below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/chat/completions \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"florence-community-florence-2-large","messages":[{"role":"user","content":"Hello"}]}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.