Views
No views yet
| 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 |
transformers and qwen_vl_utils:1from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
5 "Teklia/DAI-cards-nested",
6 torch_dtype=torch.bfloat16,
7 attn_implementation="flash_attention_2",
8 device_map="auto",
9)
10
11processor = AutoProcessor.from_pretrained("Teklia/DAI-cards-nested")
12
13messages = [
14 {
15 "role": "user",
16 "content": [
17 {
18 "type": "image",
19 "image": "12e74aa3-4d7d-47b4-b46b-7013b9a1f251.jpg",
20 },
21 {"type": "text", "text": "Extrait les informations en XML."},
22 ],
23 }
24]
25
26# Preparation for inference
27text = processor.apply_chat_template(
28 messages, tokenize=False, add_generation_prompt=True
29)
30image_inputs, video_inputs = process_vision_info(messages)
31inputs = processor(
32 text=[text],
33 images=image_inputs,
34 videos=video_inputs,
35 padding=True,
36 return_tensors="pt",
37)
38inputs = inputs.to("cuda")
39
40# Inference: Generation of the output
41generated_ids = model.generate(**inputs, max_new_tokens=1024)
42generated_ids_trimmed = [
43 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
44]
45output_text = processor.batch_decode(
46 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
47)
48print(output_text[0])1<root>
2 <Décès>
3 <Défunt>
4 <Nom>Choisnard</Nom>
5 <Prénom>Marie Madelaine</Prénom>
6 <Sexe>F</Sexe>
7 <DateDeNaissance>23 juillet 1753</DateDeNaissance>
8 <LieuDeNaissance>Ambroise (Indre-et-Loire)</LieuDeNaissance>
9 <Profession>journalière</Profession>
10 <Statut>veuf(ve)</Statut>
11 </Défunt>
12 <Conjoint>
13 <Nom>Rocheriou</Nom>
14 <Prénom>Pierre</Prénom>
15 <Statut>décédé(e)</Statut>
16 </Conjoint>
17 <Père>
18 <Nom>Choisnard</Nom>
19 <Prénom>Michel</Prénom>
20 </Père>
21 <Mère>
22 <Nom>Dubeuf</Nom>
23 <Prénom>Louise</Prénom>
24 </Mère>
25 </Décès>
26 <Date>
27 <Année>1826</Année>
28 <Mois>septembre</Mois>
29 <Jour>5</Jour>
30 </Date>
31</root>@misc{qwen2.5-VL,
title = {Qwen2.5-VL},
url = {https://qwenlm.github.io/blog/qwen2.5-vl/},
author = {Qwen Team},
month = {January},
year = {2025}
}