Instructions to use Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE") model = AutoModelForImageTextToText.from_pretrained("Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE
- SGLang
How to use Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE with Docker Model Runner:
docker model run hf.co/Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE
Qwen2.5-VL-7B-Instruct Index Cards Nested
Introduction
This version of QWEN2.5-VL-7B is specialized for document parsing on French index cards. It was fine-tuned as part of the DAI-CReTDHI project.
Training
The model is a QWEN2.5-VL-7B-Instruct fine-tuned on French index cards using LoRA.
Parameters:
- Image width: 800 pixels
- LoRa rank: 8
- LoRa alpha: 32
- Epochs: 10 (about 4k steps)
Wandb: https://wandb.ai/starride-teklia/DAI-CReTDHI/runs/hk78u308
Evaluation
| Set | CER (%) | WER (%) | F1 @ 0.0 (%) | F1 @ 0.3 (%) | N samples | N entities |
|---|---|---|---|---|---|---|
| QWEN2.5-VL-7B Flat | 10.23 | 18.07 | 83.6 | 91.96 | 55 | 808 |
| QWEN2.5-VL-7B Nested | 5.48 | 15.94 | 84.86 | 92.27 | 58 | 909 |
Usage
Here we show a code snippet to show you how to use the model with transformers and qwen_vl_utils:
- Prediction script
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
"Teklia/DAI-cards-nested",
torch_dtype=torch.bfloat16,
attn_implementation="flash_attention_2",
device_map="auto",
)
processor = AutoProcessor.from_pretrained("Teklia/DAI-cards-nested")
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "12e74aa3-4d7d-47b4-b46b-7013b9a1f251.jpg",
},
{"type": "text", "text": "Extrait les informations en XML."},
],
}
]
# Preparation for inference
text = processor.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")
# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=1024)
generated_ids_trimmed = [
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text[0])
- Output
<root>
<Décès>
<Défunt>
<Nom>Choisnard</Nom>
<Prénom>Marie Madelaine</Prénom>
<Sexe>F</Sexe>
<DateDeNaissance>23 juillet 1753</DateDeNaissance>
<LieuDeNaissance>Ambroise (Indre-et-Loire)</LieuDeNaissance>
<Profession>journalière</Profession>
<Statut>veuf(ve)</Statut>
</Défunt>
<Conjoint>
<Nom>Rocheriou</Nom>
<Prénom>Pierre</Prénom>
<Statut>décédé(e)</Statut>
</Conjoint>
<Père>
<Nom>Choisnard</Nom>
<Prénom>Michel</Prénom>
</Père>
<Mère>
<Nom>Dubeuf</Nom>
<Prénom>Louise</Prénom>
</Mère>
</Décès>
<Date>
<Année>1826</Année>
<Mois>septembre</Mois>
<Jour>5</Jour>
</Date>
</root>
Citation
To cite the original QWEN2.5-VL model:
@misc{qwen2.5-VL,
title = {Qwen2.5-VL},
url = {https://qwenlm.github.io/blog/qwen2.5-vl/},
author = {Qwen Team},
month = {January},
year = {2025}
}
- Downloads last month
- 3
Model tree for Teklia/Qwen2.5-VL-7B-DAI-CReTDHI-IndexCardsNested-KIE
Base model
Qwen/Qwen2.5-VL-7B-Instruct