Alexandre-Numind commited on
Commit
6636f1f
·
verified ·
1 Parent(s): 090f983

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -14
README.md CHANGED
@@ -18,8 +18,24 @@ pipeline_tag: text-generation
18
 
19
  # NuMarkdown-Qwen2.5-VL 🖋️📄 → 📝
20
 
21
- **NuMarkdown-Qwen2.5-VL** is the first reasoning vision-language trained to converts documents into clean GitHub-flavoured Markdown.
22
- It is a lightweight fine-tune of **Qwen 2.5-VL-7B** using ~10 k synthetic doc-to-Markdown pairs, GRPO RL phase pass with a layout-centric reward.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  ---
25
 
@@ -34,24 +50,41 @@ It is a lightweight fine-tune of **Qwen 2.5-VL-7B** using ~10 k synthetic doc-to
34
  ## Quick start: 🤗 Transformers
35
 
36
  ```python
 
 
 
37
  from PIL import Image
38
- from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
39
 
40
- model_id = "NM-dev/NuMarkdown-Qwen2.5-VL"
41
- tok = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
42
- proc = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
43
- model = AutoModelForCausalLM.from_pretrained(
44
  model_id,
45
- torch_dtype="bfloat16",
 
 
 
 
 
 
46
  device_map="auto",
47
  trust_remote_code=True,
48
  )
49
 
50
- img = Image.open("invoice_scan.png")
51
- inputs = proc(text="Convert this to Markdown with reasoning.", image=img,
52
- return_tensors="pt").to(model.device)
53
- out = model.generate(**inputs, max_new_tokens=1024)
54
- print(tok.decode(out[0], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
55
  ```
56
 
57
 
@@ -69,7 +102,7 @@ img = Image.open("invoice_scan.png")
69
  prompt = proc(text="Convert this to Markdown with reasoning.", image=img,
70
  return_tensors="np") # numpy arrays for vLLM
71
 
72
- params = SamplingParameters(max_tokens=1024, temperature=0.2, top_p=0.95)
73
  result = llm.generate([{"prompt": prompt}], params)[0].outputs[0].text
74
  print(result)
75
  ```
 
18
 
19
  # NuMarkdown-Qwen2.5-VL 🖋️📄 → 📝
20
 
21
+ **NuMarkdown-Qwen2.5-VL** is the first reasoning vision-language model trained to converts documents into clean GitHub-flavoured Markdown.
22
+ It is a lightweight fine-tune of **Qwen 2.5-VL-7B** using ~10 k synthetic doc-to-Markdown pairs, followed by a RL phase (GRPO) with a layout-centric reward.
23
+
24
+ By increasing the output length by 10% to 20%, the model outperform model of it's size and is competitive with top close source reasoning model
25
+
26
+ ---
27
+ ## Results
28
+
29
+ (we plan to realease a markdown arena -similar to llmArena- for complex table to markdown format)
30
+
31
+ Winrate of our model vs open source alternative:
32
+
33
+ //
34
+
35
+
36
+ Winrate vs close source alternative:
37
+
38
+ //
39
 
40
  ---
41
 
 
50
  ## Quick start: 🤗 Transformers
51
 
52
  ```python
53
+ from __future__ import annotations
54
+
55
+ import torch
56
  from PIL import Image
57
+ from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
58
 
59
+ model_id = "NM-dev/NuMarkdown-Qwen2.5-VL"
60
+
61
+ processor = AutoProcessor.from_pretrained(
 
62
  model_id,
63
+ trust_remote_code=True,
64
+ )
65
+
66
+ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
67
+ model_id,
68
+ torch_dtype=torch.bfloat16,
69
+ attn_implementation="flash_attention_2",
70
  device_map="auto",
71
  trust_remote_code=True,
72
  )
73
 
74
+ img = Image.open("invoice_scan.png").convert("RGB")
75
+ messages = [{
76
+ "role": "user",
77
+ "content": [
78
+ {"type": "image"},
79
+ ],
80
+ }]
81
+ prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
82
+ enc = processor(text=prompt, images=[img], return_tensors="pt").to(model.device)
83
+
84
+ with torch.no_grad():
85
+ out = model.generate(**enc, max_new_tokens=1024)
86
+
87
+ print(processor.decode(out[0], skip_special_tokens=True))
88
  ```
89
 
90
 
 
102
  prompt = proc(text="Convert this to Markdown with reasoning.", image=img,
103
  return_tensors="np") # numpy arrays for vLLM
104
 
105
+ params = SamplingParameters(max_tokens=1024, temperature=0.8, top_p=0.95)
106
  result = llm.generate([{"prompt": prompt}], params)[0].outputs[0].text
107
  print(result)
108
  ```