Prince-1 commited on
Commit
a570004
·
verified ·
1 Parent(s): 4a51cc4

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .eval_results/olmocrbench.yaml +80 -0
  2. .gitattributes +32 -0
  3. LICENSE +59 -0
  4. README.md +465 -0
  5. assets/corporate.png +3 -0
  6. assets/corporate_layout.png +3 -0
  7. assets/corporate_reading.png +3 -0
  8. assets/corporate_tablerec.png +3 -0
  9. assets/corporate_text.png +3 -0
  10. assets/excerpt.png +3 -0
  11. assets/excerpt_layout.png +3 -0
  12. assets/excerpt_text.png +3 -0
  13. assets/form.png +3 -0
  14. assets/form_layout.png +3 -0
  15. assets/form_reading.png +3 -0
  16. assets/form_tablerec.png +3 -0
  17. assets/form_text.png +3 -0
  18. assets/handwritten.png +3 -0
  19. assets/handwritten_layout.png +3 -0
  20. assets/handwritten_reading.png +3 -0
  21. assets/handwritten_tablerec.png +3 -0
  22. assets/handwritten_text.png +3 -0
  23. assets/newspaper.png +3 -0
  24. assets/newspaper_layout.png +3 -0
  25. assets/newspaper_reading.png +3 -0
  26. assets/newspaper_text.png +3 -0
  27. assets/olmocr_size_chart.png +0 -0
  28. assets/scanned_tablerec.png +3 -0
  29. assets/textbook.png +3 -0
  30. assets/textbook_layout.png +3 -0
  31. assets/textbook_reading.png +3 -0
  32. assets/textbook_text.png +3 -0
  33. cpu_fp16/chat_template.jinja +66 -0
  34. cpu_fp16/config.json +101 -0
  35. cpu_fp16/genai_config.json +86 -0
  36. cpu_fp16/processor_config.json +76 -0
  37. cpu_fp16/text.onnx +3 -0
  38. cpu_fp16/text.onnx.data +3 -0
  39. cpu_fp16/tokenizer.json +0 -0
  40. cpu_fp16/tokenizer_config.json +25 -0
  41. cpu_fp32/chat_template.jinja +66 -0
  42. cpu_fp32/config.json +101 -0
  43. cpu_fp32/genai_config.json +86 -0
  44. cpu_fp32/processor_config.json +76 -0
  45. cpu_fp32/text.onnx +3 -0
  46. cpu_fp32/text.onnx.data +3 -0
  47. cpu_fp32/tokenizer.json +0 -0
  48. cpu_fp32/tokenizer_config.json +25 -0
  49. cpu_int4/chat_template.jinja +66 -0
  50. cpu_int4/config.json +101 -0
.eval_results/olmocrbench.yaml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - dataset:
2
+ id: allenai/olmOCR-bench
3
+ task_id: overall
4
+ value: 83.3
5
+ source:
6
+ url: https://huggingface.co/datalab-to/surya-ocr-2
7
+ name: Surya OCR 2 Model Card
8
+ user: vikp
9
+
10
+ - dataset:
11
+ id: allenai/olmOCR-bench
12
+ task_id: arxiv_math
13
+ value: 88.3
14
+ source:
15
+ url: https://huggingface.co/datalab-to/surya-ocr-2
16
+ name: Surya OCR 2 Model Card
17
+ user: vikp
18
+
19
+ - dataset:
20
+ id: allenai/olmOCR-bench
21
+ task_id: old_scans_math
22
+ value: 81.4
23
+ source:
24
+ url: https://huggingface.co/datalab-to/surya-ocr-2
25
+ name: Surya OCR 2 Model Card
26
+ user: vikp
27
+
28
+ - dataset:
29
+ id: allenai/olmOCR-bench
30
+ task_id: table_tests
31
+ value: 86.6
32
+ source:
33
+ url: https://huggingface.co/datalab-to/surya-ocr-2
34
+ name: Surya OCR 2 Model Card
35
+ user: vikp
36
+
37
+ - dataset:
38
+ id: allenai/olmOCR-bench
39
+ task_id: old_scans
40
+ value: 41.8
41
+ source:
42
+ url: https://huggingface.co/datalab-to/surya-ocr-2
43
+ name: Surya OCR 2 Model Card
44
+ user: vikp
45
+
46
+ - dataset:
47
+ id: allenai/olmOCR-bench
48
+ task_id: headers_footers
49
+ value: 92.5
50
+ source:
51
+ url: https://huggingface.co/datalab-to/surya-ocr-2
52
+ name: Surya OCR 2 Model Card
53
+ user: vikp
54
+
55
+ - dataset:
56
+ id: allenai/olmOCR-bench
57
+ task_id: multi_column
58
+ value: 82.4
59
+ source:
60
+ url: https://huggingface.co/datalab-to/surya-ocr-2
61
+ name: Surya OCR 2 Model Card
62
+ user: vikp
63
+
64
+ - dataset:
65
+ id: allenai/olmOCR-bench
66
+ task_id: long_tiny_text
67
+ value: 93.7
68
+ source:
69
+ url: https://huggingface.co/datalab-to/surya-ocr-2
70
+ name: Surya OCR 2 Model Card
71
+ user: vikp
72
+
73
+ - dataset:
74
+ id: allenai/olmOCR-bench
75
+ task_id: baseline
76
+ value: 99.7
77
+ source:
78
+ url: https://huggingface.co/datalab-to/surya-ocr-2
79
+ name: Surya OCR 2 Model Card
80
+ user: vikp
.gitattributes CHANGED
@@ -33,3 +33,35 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ excerpt.png filter=lfs diff=lfs merge=lfs -text
37
+ excerpt_text.png filter=lfs diff=lfs merge=lfs -text
38
+ excerpt_layout.png filter=lfs diff=lfs merge=lfs -text
39
+ scanned_tablerec.png filter=lfs diff=lfs merge=lfs -text
40
+ olmocr_size_chart.png filter=lfs diff=lfs merge=lfs -text
41
+ newspaper.png filter=lfs diff=lfs merge=lfs -text
42
+ newspaper_text.png filter=lfs diff=lfs merge=lfs -text
43
+ newspaper_layout.png filter=lfs diff=lfs merge=lfs -text
44
+ newspaper_reading.png filter=lfs diff=lfs merge=lfs -text
45
+ textbook.png filter=lfs diff=lfs merge=lfs -text
46
+ textbook_text.png filter=lfs diff=lfs merge=lfs -text
47
+ textbook_layout.png filter=lfs diff=lfs merge=lfs -text
48
+ textbook_reading.png filter=lfs diff=lfs merge=lfs -text
49
+ form.png filter=lfs diff=lfs merge=lfs -text
50
+ form_text.png filter=lfs diff=lfs merge=lfs -text
51
+ form_layout.png filter=lfs diff=lfs merge=lfs -text
52
+ form_reading.png filter=lfs diff=lfs merge=lfs -text
53
+ form_tablerec.png filter=lfs diff=lfs merge=lfs -text
54
+ handwritten.png filter=lfs diff=lfs merge=lfs -text
55
+ handwritten_text.png filter=lfs diff=lfs merge=lfs -text
56
+ handwritten_layout.png filter=lfs diff=lfs merge=lfs -text
57
+ handwritten_reading.png filter=lfs diff=lfs merge=lfs -text
58
+ handwritten_tablerec.png filter=lfs diff=lfs merge=lfs -text
59
+ corporate.png filter=lfs diff=lfs merge=lfs -text
60
+ corporate_text.png filter=lfs diff=lfs merge=lfs -text
61
+ corporate_layout.png filter=lfs diff=lfs merge=lfs -text
62
+ corporate_reading.png filter=lfs diff=lfs merge=lfs -text
63
+ corporate_tablerec.png filter=lfs diff=lfs merge=lfs -text
64
+ cpu_fp16/text.onnx.data filter=lfs diff=lfs merge=lfs -text
65
+ cpu_fp32/text.onnx.data filter=lfs diff=lfs merge=lfs -text
66
+ cpu_int4/text.onnx.data filter=lfs diff=lfs merge=lfs -text
67
+ cuda_fp16/text.onnx.data filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AI PUBS OPEN RAIL-M LICENSE (MODIFIED)
2
+
3
+ Version 0.1, March 2, 2023 (Modified)
4
+ http://licenses.ai/
5
+
6
+ PLEASE READ THESE TERMS CAREFULLY BEFORE USING THE MODEL OR A DERIVATIVE WORKS OF THE MODEL MADE AVAILABLE IN CONNECTION WITH THESE TERMS. BY DOWNLOADING, REPRODUCING, DISTRIBUTING OR USING THE MODEL OR A DERIVATIVE WORK OF THE MODEL IN ANY MANNER, YOU (“YOU”) AGREE TO BE BOUND BY THESE TERMS (THE “AGREEMENT”) TO THE EXCLUSION OF ALL OTHER TERMS. YOU REPRESENT AND WARRANT THAT YOU HAVE THE AUTHORITY TO ENTER INTO THIS AGREEMENT; IF YOU ARE ENTERING INTO THIS AGREEMENT ON BEHALF OF AN ORGANIZATION OR ENTITY, REFERENCES TO AND “YOU” IN THIS AGREEMENT, REFER TO THAT ORGANIZATION OR ENTITY. IF YOU DO NOT AGREE TO ALL OF THE FOLLOWING, YOU MAY NOT DOWNLOAD, REPRODUCE, DISTRIBUTE OR USE THE MODEL OR A DERIVATIVE WORK OF THE MODEL IN ANY MANNER.
7
+ Section I: PREAMBLE
8
+ This OpenRAIL-M License, as modified, is generally applicable to any machine-learning Model.
9
+ The “Open” nomenclature indicates that the licensed Model is be freely accessible to downstream and other users. The “RAIL” nomenclature indicates that there are use restrictions prohibiting the use of the Model. These restrictions are intended to avoid potential misuse. This License specifies that the use restrictions in the original License must apply to such derivatives.
10
+ NOW THEREFORE, You and Licensor agree as follows:
11
+ 1. Definitions
12
+ (a) “Complementary Material” means the applicable source code and scripts used to define, run, load, benchmark or evaluate the Model, and used to prepare data for training or evaluation, if any. This includes any accompanying documentation, tutorials, examples, and any related information, if any. Complementary Material is not licensed under this License.
13
+ (b) "Contribution" means any work, including the original version of the Model and any modifications or additions to that Model or Derivatives of the Model thereof, that is intentionally submitted to Licensor for inclusion in the Model by the rights owner or by an individual or legal entity authorized to submit on behalf of the rights owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Model, but excluding communication that is conspicuously marked or otherwise designated in writing by the rights owner as "Not a Contribution."
14
+ (c) "Contributor" means Licensor and any individual or legal entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Model.
15
+ (d) “Data” means a collection of information and/or content extracted from the dataset used with the Model, including to train, pretrain, or otherwise evaluate the Model. The Data is not licensed under this License.
16
+ (e) “Derivatives of the Model” means all modifications to the Model, works based on the Model, or any other model which is created or initialized by transfer of patterns of the weights, parameters, activations or output of the Model, to the other model, in order to cause the other model to perform similarly to the Model, including - but not limited to - distillation methods entailing the use of intermediate data representations or methods based on the generation of synthetic data by the Model for training the other model.
17
+ (f) “Distribution” means any transmission, reproduction, publication, distribution, or other sharing of the Model or Derivatives of the Model to a third party, including providing the Model as a hosted service made available by electronic or other remote means, including but not limited to API-based or web access.
18
+ (g) “Harm” includes but is not limited to physical, mental, psychological, financial and reputational damage, pain, or loss
19
+ (h) "License" means the terms and conditions for use, reproduction, and Distribution as defined in this document.
20
+ (i) “Licensor” means the rights owner or entity authorized by the rights owner that is granting the License, including the persons or entities that may have rights in the Model and/or distributing the Model.
21
+ (j) “Model” means any accompanying machine-learning based assemblies (including checkpoints), consisting of learnt weights, parameters (including optimizer states), corresponding to the model architecture as embodied in the Complementary Material, that have been trained or tuned, in whole or in part on the Data, using the Complementary Material.
22
+ (k) “Output” means the results of operating a Model as embodied in informational content resulting therefrom.
23
+ (l) “Third Parties” means individuals or legal entities that are not under common control with Licensor or You.
24
+ (m) "You" (or "Your") means an individual or legal entity exercising permissions granted by this License and/or making use of the Model for whichever purpose and in any field of use, including usage of the Model in an end-use application, including but not limited to a chatbot, translator, or image generator.
25
+ Section II: INTELLECTUAL PROPERTY RIGHTS
26
+ Both copyright and patent grants may apply to the Model and Derivatives of the Model. The Model and Derivatives of the Model are subject to additional terms as described in Section III, which shall govern the use of the Model and Derivatives of the Model even in the event Section II is held unenforceable.
27
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare, publicly display, publicly perform, sublicense, and distribute the Model and Derivatives of the Model.
28
+ 3. Grant of Patent License. Subject to the terms and conditions of this License and where and as applicable, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this paragraph) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Model and/or Derivatives of the Model where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Model or Derivatives of the Model to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Model or Derivative of the Model and/or a Contribution incorporated within the Model or Derivative of the Model constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for the Model and/or Derivative of the Model shall terminate as of the date such litigation is asserted or filed.
29
+ Section III: CONDITIONS OF USAGE, DISTRIBUTION AND REDISTRIBUTION
30
+ 4. Distribution and Redistribution. You may host the Model or Derivatives of the Model for remote access by Third Parties, including but not limited to software-as-a-service, reproduce, or Distribute copies of the Model or Derivatives of the Model thereof in any medium, with or without modifications, provided that You meet the conditions in this Section III:
31
+ (a) Use-based restrictions in paragraph 5 MUST be included as an enforceable provision by You in any type of legal agreement (for example, a license) governing the use and/or distribution of the Model or Derivatives of the Model, and You shall give notice to subsequent users You Distribute to, that the Model and Derivatives of the Model are subject to paragraph 5;
32
+ (b) You must give any Third Party recipients of the Model or Derivatives of the Model a copy of this License;
33
+ (c) You must cause any modified files to carry prominent notices stating that You changed the files; and
34
+ (d) You must retain all copyright, patent, trademark, and attribution notices excluding those notices that do not pertain to any part of the Model or Derivatives of the Model.
35
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions, consistent with paragraph 4.a., for use, reproduction, or Distribution of Your modifications, or for any such Derivatives of the Model as a whole, provided Your use, reproduction, and Distribution of the Model otherwise complies with the conditions stated in this License.
36
+ 5. Use-based restrictions. The restrictions set forth in Attachment A are considered Use-based restrictions. Accordingly, You cannot use the Model or the Derivatives of the Model in violation of such restrictions. You may use the Model subject to this License, including only for lawful purposes and in accordance with the License. Use may include creating any content with, fine-tuning, updating, running, training, evaluating and/or re-parametrizing the Model. You shall require all of Your users who use the Model or a Derivative of the Model to comply with the terms of this paragraph 5.
37
+ 6. The Output You Generate. Except as set forth herein, Licensor claims no rights in the Output You generate using the Model. You are solely responsible for the Output you generate and its subsequent uses. No use of the Output can contravene any provision as stated in the License.
38
+ 7. Attribution. In connection with any Output, or use of Distribution of any Model or Derivatives of the Model, You agree to give appropriate credit and attribution to Licensor, provide a link to the original Model or Derivatives of the Model, provide a copy of this License, and identify any changes You have made to the Model or Derivatives of the Model (collectively, the “Attribution”). The Attribution must not suggest endorsement by any Licensor.
39
+ 8. Share-a-Like. As a condition to the license and authorizations herein, You agree to apply this License (to the exclusion of all others) to any and all copies of the Model, Derivatives of the Model, any changes or improvements to the Model or Derivatives of the Model, and to the Output and any derivatives, changes or improvements to or of the Output.
40
+ Section IV: OTHER PROVISIONS
41
+ 9. Updates and Runtime Restrictions. To the maximum extent permitted by law, Licensor reserves the right to restrict (remotely or otherwise) usage of the Model in violation of this License, update the Model through electronic means, or cause modification to the Output resulting from updates to the Model based.
42
+ 10. Trademarks and related. Nothing in this License permits You to make use of Licensors’ trademarks, trade names, logos or to otherwise suggest endorsement or misrepresent the relationship between the parties; and any rights not expressly granted herein are reserved by the Licensors.
43
+ 11. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Model (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Model and Derivatives of the Model, and assume any risks associated with Your exercise of permissions under this License.
44
+ 12. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Model (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
45
+ 13. Accepting Warranty or Additional Liability. While Distributing the Model or Derivatives of the Model, You may choose to charge a fee in exchange for support, warranty, indemnity, or other obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor or Licensor, and only if You agree to indemnify, defend, and hold each Contributor and the Licensor harmless for any liability incurred by, or claims asserted against, such Contributor or Licensor by reason of your accepting any such warranty or additional liability.
46
+ 14. If any provision of this License is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein.
47
+ END OF TERMS AND CONDITIONS
48
+
49
+  Attachment A
50
+ USE RESTRICTIONS
51
+ As conditions to the Licenses set forth in this Agreement, You agree not to use, reproduce, modify, create or Distribute the Model, Derivatives of the Model, or Output (collectively, “Use”) in any of the following ways:
52
+ 1. Legal:
53
+ (a) In any way that violates any applicable national, federal, state, local or international law or regulation; or
54
+ (b) to directly or indirectly infringe or misappropriate any third party intellectual property rights (including those of Licensor or any Contributor)
55
+ 2. Commercial:
56
+ (a) for any purpose if You (your employer, or the entity you are affiliated with) generated more than five million US Dollars ($5,000,000) in gross revenue in the prior year, except where Your Use is limited to personal use or research purposes;
57
+ (b) for any purpose if You (your employer, or the entity you are affiliated with) has raised more than five million US dollars ($5,000,000) in total equity or debt funding from any source, except where Your Use is limited to personal use or research purposes; or
58
+ (c) for any purpose if You (your employer, or the entity you are affiliated with) provides or otherwise makes available any product or service that competes with any product or service offered by or made available by Licensor or any of its affiliates.
59
+ Commercial and broader use licenses may be available from Licensor at the following URL: https://www.datalab.to/
README.md ADDED
@@ -0,0 +1,465 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: onnxruntime
3
+ license: openrail
4
+ license_link: LICENSE
5
+ tags:
6
+ - ocr
7
+ - pdf
8
+ - markdown
9
+ - layout
10
+ - onnx
11
+ - onnxruntime
12
+ base_model:
13
+ - datalab-to/surya-ocr-2
14
+ ---
15
+
16
+ <p align="center">
17
+ <img src="datalab-logo.png" alt="Datalab Logo" width="150"/>
18
+ </p>
19
+
20
+ <h1 align="center">Datalab</h1>
21
+ <p align="center">
22
+ <strong>State of the Art models for Document Intelligence</strong>
23
+ </p>
24
+ <p align="center">
25
+ <a href="https://www.datalab.to"><img src="https://img.shields.io/badge/Homepage-datalab.to-blue" alt="Homepage"></a>
26
+ <a href="https://documentation.datalab.to"><img src="https://img.shields.io/badge/Docs-Read%20the%20docs-blue" alt="Docs"></a>
27
+ <a href="https://www.datalab.to/playground"><img src="https://img.shields.io/badge/Datalab Playground-Try%20it-orange" alt="Datalab Playground"></a>
28
+ </p>
29
+
30
+ <hr/>
31
+
32
+ # Surya
33
+
34
+ Surya is a 650M param OCR model with these features:
35
+
36
+ - Accuracy - scores 83.3% on [olmOCR-bench](https://huggingface.co/datasets/allenai/olmOCR-bench) (top under 3B params)
37
+ - Speed - throughput of 5 pages/s on an RTX 5090
38
+ - Multilingual - scores 87.2% on an internal benchmark set of 91 languages (more [here](#multilingual))
39
+ - Layout analysis (table, image, header, etc.) with reading order
40
+ - Table recognition (rows + columns)
41
+
42
+ It works on a range of documents (see [usage](#usage) and [benchmarks](#benchmarks)).
43
+
44
+ ## Try Datalab's Managed Platform
45
+
46
+ Our managed platform runs both Surya, and variants of our highest accuracy model, [Chandra](https://github.com/datalab-to/chandra).
47
+
48
+ Get started with **$5 in free credits** — [sign up](https://www.datalab.to/?utm_source=gh-surya) (takes under 30 seconds) or try our free [public playground](https://www.datalab.to/playground?utm_source=gh-surya).
49
+
50
+ ## Model Information
51
+
52
+ <img src="assets/olmocr_size_chart.png" width="700"/>
53
+
54
+
55
+ | Detection | OCR |
56
+ |:----------------------------------------------------------------:|:-----------------------------------------------------------------------:|
57
+ | <img src="assets/excerpt.png" width="140"/> | <img src="assets/excerpt_text.png" width="140"/> |
58
+
59
+ | Layout | Table Recognition |
60
+ |:------------------------------------------------------------------:|:-------------------------------------------------------------:|
61
+ | <img src="assets/excerpt_layout.png" width="140"/> | <img src="assets/scanned_tablerec.png" width="140"/> |
62
+
63
+
64
+ Surya is named for the [Hindu sun god](https://en.wikipedia.org/wiki/Surya), who has universal vision.
65
+
66
+ ## Examples
67
+
68
+ | Name | Detection | OCR | Layout | Order | Table Rec |
69
+ |-------------------|:-----------------------------------:|------------------------------------------:|---------------------------------------------:|------------------------------------------------:|------------------------------------------------:|
70
+ | Newspaper | [Image](assets/newspaper.png) | [Image](assets/newspaper_text.png) | [Image](assets/newspaper_layout.png) | [Image](assets/newspaper_reading.png) | |
71
+ | Textbook | [Image](assets/textbook.png) | [Image](assets/textbook_text.png) | [Image](assets/textbook_layout.png) | [Image](assets/textbook_reading.png) | |
72
+ | Tax Form | [Image](assets/form.png) | [Image](assets/form_text.png) | [Image](assets/form_layout.png) | [Image](assets/form_reading.png) | [Image](assets/form_tablerec.png) |
73
+ | Handwritten Notes | [Image](assets/handwritten.png) | [Image](assets/handwritten_text.png) | [Image](assets/handwritten_layout.png) | [Image](assets/handwritten_reading.png) | [Image](assets/handwritten_tablerec.png) |
74
+ | Corporate Doc | [Image](assets/corporate.png) | [Image](assets/corporate_text.png) | [Image](assets/corporate_layout.png) | [Image](assets/corporate_reading.png) | [Image](assets/corporate_tablerec.png) |
75
+
76
+ # Commercial usage
77
+
78
+ The Surya code is licensed under Apache 2.0. The model weights use a modified AI Pubs Open Rail-M license (free for research, personal use, and startups under $5M funding/revenue). For broader commercial licensing of the model weights, visit our pricing page [here](https://www.datalab.to/pricing?utm_source=gh-surya).
79
+
80
+ # Installation
81
+
82
+ Install with:
83
+
84
+ ```shell
85
+ pip install surya-ocr
86
+ ```
87
+
88
+ # Usage
89
+
90
+ Surya 2 runs layout, OCR, and table recognition through a single VLM served
91
+ by `vllm` (GPU) or `llama.cpp` (CPU / Apple Silicon). The inference manager
92
+ will spawn one for you on first use; you can also point it at an existing
93
+ server via `SURYA_INFERENCE_URL=http://host:port/v1`.
94
+
95
+ - Inspect the settings in `surya/settings.py`. You can override any setting via env var (e.g. `SURYA_INFERENCE_BACKEND=vllm`).
96
+ - Text detection and OCR errors are separate models.
97
+
98
+ ## Interactive App
99
+
100
+ I've included a streamlit app that lets you interactively try Surya on images or PDF files. Run it with:
101
+
102
+ ```shell
103
+ pip install streamlit pdftext
104
+ surya_gui
105
+ ```
106
+
107
+ ## OCR (text recognition)
108
+
109
+ This command will write out a json file with the detected text and bboxes:
110
+
111
+ ```shell
112
+ surya_ocr DATA_PATH
113
+ ```
114
+
115
+ - `DATA_PATH` can be an image, pdf, or folder of images/pdfs
116
+ - `--images` will save images of the pages and detected blocks (optional)
117
+ - `--output_dir` specifies the directory to save results to instead of the default
118
+ - `--page_range` specifies the page range to process in the PDF, specified as a single number, a comma separated list, a range, or comma separated ranges - example: `0,5-10,20`.
119
+
120
+ The `results.json` file contains a dict keyed by input filename (no extension). Each value is a list of page dicts. Each page dict contains:
121
+
122
+ - `blocks` - per-block OCR results in reading order
123
+ - `label` - canonicalized layout label (e.g. `Text`, `SectionHeader`, `Table`, `Equation`, `Picture`, `Form`, `PageHeader`, ...). See `surya/layout/label.py:LAYOUT_PRED_RELABEL` for the full canonical-name set.
124
+ - `raw_label` - original label emitted by the model, before canonicalization
125
+ - `reading_order` - 0-indexed position in layout output
126
+ - `html` - block content as HTML (math wrapped in `<math>...</math>`, tables as `<table>...</table>`, etc.). `""` if the block was skipped
127
+ - `polygon` - 4-corner polygon in `[[x0,y0],[x1,y0],[x1,y1],[x0,y1]]` order
128
+ - `bbox` - axis-aligned `[x0, y0, x1, y1]` derived from the polygon
129
+ - `confidence` - mean per-token probability across the block's decode (0-1)
130
+ - `skipped` - true if the block was a visual label (e.g. Picture) and not OCR'd
131
+ - `error` - true if the block OCR call failed
132
+ - `image_bbox` - `[0, 0, width, height]` for the page image
133
+
134
+ **Performance tips**
135
+
136
+ Throughput is governed by the inference backend, not a `RECOGNITION_BATCH_SIZE` env var. With `vllm`, raise `--max-num-seqs` / `--max-num-batched-tokens` (or `SURYA_INFERENCE_PARALLEL` on the client side) to keep more pages in flight. With `llama.cpp`, set `SURYA_INFERENCE_PARALLEL` to match `--parallel` on `llama-server`.
137
+
138
+ ### From python
139
+
140
+ ```python
141
+ from PIL import Image
142
+ from surya.inference import SuryaInferenceManager
143
+ from surya.recognition import RecognitionPredictor
144
+
145
+ manager = SuryaInferenceManager()
146
+ recognition_predictor = RecognitionPredictor(manager)
147
+
148
+ # Default: full-page OCR. One VLM call per page; returns layout + content as
149
+ # HTML <div data-bbox=... data-label=...> blocks.
150
+ predictions = recognition_predictor([Image.open(IMAGE_PATH)])
151
+
152
+ # Block mode: pre-run layout, then per-block OCR. Auto-selected when
153
+ # `layout_results` is passed.
154
+ from surya.layout import LayoutPredictor
155
+ layout = LayoutPredictor(manager)
156
+ layouts = layout([Image.open(IMAGE_PATH)])
157
+ predictions = recognition_predictor([Image.open(IMAGE_PATH)], layouts)
158
+ ```
159
+
160
+
161
+ ## Text line detection
162
+
163
+ This command will write out a json file with the detected bboxes.
164
+
165
+ ```shell
166
+ surya_detect DATA_PATH
167
+ ```
168
+
169
+ - `DATA_PATH` can be an image, pdf, or folder of images/pdfs
170
+ - `--images` will save images of the pages and detected text lines (optional)
171
+ - `--output_dir` specifies the directory to save results to instead of the default
172
+ - `--page_range` specifies the page range to process in the PDF, specified as a single number, a comma separated list, a range, or comma separated ranges - example: `0,5-10,20`.
173
+
174
+ The `results.json` file will contain a json dictionary where the keys are the input filenames without extensions. Each value will be a list of dictionaries, one per page of the input document. Each page dictionary contains:
175
+
176
+ - `bboxes` - detected bounding boxes for text
177
+ - `bbox` - the axis-aligned rectangle for the text line in (x1, y1, x2, y2) format. (x1, y1) is the top left corner, and (x2, y2) is the bottom right corner.
178
+ - `polygon` - the polygon for the text line in (x1, y1), (x2, y2), (x3, y3), (x4, y4) format. The points are in clockwise order from the top left.
179
+ - `confidence` - the confidence of the model in the detected text (0-1)
180
+ - `vertical_lines` - vertical lines detected in the document
181
+ - `bbox` - the axis-aligned line coordinates.
182
+ - `page` - the page number in the file
183
+ - `image_bbox` - the bbox for the image in (x1, y1, x2, y2) format. (x1, y1) is the top left corner, and (x2, y2) is the bottom right corner. All line bboxes will be contained within this bbox.
184
+
185
+ **Performance tips**
186
+
187
+ Detection is a torch model. `DETECTOR_BATCH_SIZE` defaults to an auto-picked value at runtime; override the env var to control VRAM usage on GPU and raise it on larger cards.
188
+
189
+ ### From python
190
+
191
+ ```python
192
+ from PIL import Image
193
+ from surya.detection import DetectionPredictor
194
+
195
+ det_predictor = DetectionPredictor()
196
+ predictions = det_predictor([Image.open(IMAGE_PATH)])
197
+ ```
198
+
199
+ ## Layout and reading order
200
+
201
+ This command will write out a json file with the detected layout and reading order.
202
+
203
+ ```shell
204
+ surya_layout DATA_PATH
205
+ ```
206
+
207
+ - `DATA_PATH` can be an image, pdf, or folder of images/pdfs
208
+ - `--images` will save images of the pages and detected text lines (optional)
209
+ - `--output_dir` specifies the directory to save results to instead of the default
210
+ - `--page_range` specifies the page range to process in the PDF, specified as a single number, a comma separated list, a range, or comma separated ranges - example: `0,5-10,20`.
211
+
212
+ The `results.json` file contains a dict keyed by input filename (no extension). Each value is a list of page dicts. Each page dict contains:
213
+
214
+ - `bboxes` - layout boxes in reading order
215
+ - `polygon` - 4-corner polygon `[[x0,y0],[x1,y0],[x1,y1],[x0,y1]]`
216
+ - `bbox` - axis-aligned `[x0, y0, x1, y1]` derived from the polygon
217
+ - `label` - canonicalized label. One of `Caption`, `Footnote`, `Equation`, `ListGroup`, `PageHeader`, `PageFooter`, `Picture`, `SectionHeader`, `Table`, `Text`, `Figure`, `Code`, `Form`, `TableOfContents`, `ChemicalBlock`, `Diagram`, `Bibliography`, `BlankPage`
218
+ - `raw_label` - original label emitted by the model
219
+ - `position` - 0-indexed reading order
220
+ - `count` - model's token estimate for OCR'ing this block (rounded to multiples of 50; used to size the per-block decode budget)
221
+ - `confidence` - mean per-token probability across the layout decode (0-1)
222
+ - `image_bbox` - `[0, 0, width, height]`
223
+ - `raw` - raw JSON the layout model emitted, for debugging
224
+ - `error` - true if the layout call failed
225
+
226
+ **Performance tips**
227
+
228
+ Layout runs through the shared inference backend. Throughput tuning is the same as OCR — see Performance tips above.
229
+
230
+ ### From python
231
+
232
+ ```python
233
+ from PIL import Image
234
+ from surya.inference import SuryaInferenceManager
235
+ from surya.layout import LayoutPredictor
236
+
237
+ layout_predictor = LayoutPredictor(SuryaInferenceManager())
238
+ layout_predictions = layout_predictor([Image.open(IMAGE_PATH)])
239
+ ```
240
+
241
+ ## Table Recognition
242
+
243
+ This command will write out a json file with the detected table cells and row/column ids, along with row/column bounding boxes. If you want to get cell positions and text, along with nice formatting, check out the [marker](https://github.com/datalab-to/marker) repo. You can use the `TableConverter` to detect and extract tables in images and PDFs. It supports output in json (with bboxes), markdown, and html.
244
+
245
+ ```shell
246
+ surya_table DATA_PATH
247
+ ```
248
+
249
+ - `DATA_PATH` can be an image, pdf, or folder of images/pdfs
250
+ - `--images` will save annotated row + column overlays alongside the json (optional)
251
+ - `--output_dir` specifies the directory to save results to instead of the default
252
+ - `--page_range` specifies the page range to process in the PDF, specified as a single number, a comma separated list, a range, or comma separated ranges - example: `0,5-10,20`.
253
+ - `--skip_table_detection` tells table recognition not to detect tables first. Use this if your image is already cropped to a table.
254
+
255
+ The `results.json` file contains a dict keyed by input filename (no extension). Each value is a list of per-table dicts. Each table dict contains:
256
+
257
+ - `rows` - detected table rows in reading order
258
+ - `polygon` / `bbox` - row geometry (same convention as everywhere else)
259
+ - `row_id` - 0-indexed row id
260
+ - `cols` - detected table columns
261
+ - `polygon` / `bbox` - column geometry
262
+ - `col_id` - 0-indexed column id
263
+ - `cells` - geometric row × column intersections (simple mode)
264
+ - `polygon` / `bbox` - cell geometry
265
+ - `row_id`, `col_id`, `cell_id`
266
+ - `html` - full `<table>...</table>` HTML (only populated when `predict_full` is used; handles spanning cells / header rows). `null` in simple mode.
267
+ - `mode` - `"simple"` or `"full"`
268
+ - `image_bbox` - the table crop bbox
269
+ - `error` - true if the table_rec call failed
270
+ - `raw` - raw model output, for debugging
271
+
272
+ **Performance tips**
273
+
274
+ Table recognition routes through the shared VLM. Throughput tuning is the same as OCR.
275
+
276
+ ### From python
277
+
278
+ ```python
279
+ from PIL import Image
280
+ from surya.inference import SuryaInferenceManager
281
+ from surya.table_rec import TableRecPredictor
282
+
283
+ table_rec_predictor = TableRecPredictor(SuryaInferenceManager())
284
+
285
+ # Default: rows + columns only, cells derived from intersections.
286
+ table_predictions = table_rec_predictor([Image.open(IMAGE_PATH)])
287
+
288
+ # Or full HTML output (better for spanning cells / headers):
289
+ # table_predictions = table_rec_predictor.predict_full([image])
290
+ ```
291
+
292
+ ## Math / equations
293
+
294
+ Surya 2 handles math inline as part of full-page OCR — recognized equations
295
+ come back inside `<math>...</math>` tags in the same HTML output as
296
+ surrounding prose, in KaTeX-compatible LaTeX. No separate LaTeX OCR pass.
297
+
298
+ # Inference Backends
299
+
300
+ Layout / OCR / table_rec all share one VLM, served either by `vllm` (GPU) or `llama.cpp` (CPU / Apple Silicon). The `SuryaInferenceManager` will spawn one automatically; you can also point at a pre-running server:
301
+
302
+ ```bash
303
+ # Attach to an existing vllm
304
+ export SURYA_INFERENCE_BACKEND=vllm
305
+ export SURYA_INFERENCE_URL=http://localhost:8000/v1
306
+ ```
307
+
308
+ | Setting | Default | Notes |
309
+ |-----------------------------------|-----------------------------------|--------------------------------------------------------|
310
+ | `SURYA_INFERENCE_BACKEND` | auto (vllm if NVIDIA, else llamacpp) | `vllm` \| `llamacpp` \| unset (auto) |
311
+ | `SURYA_INFERENCE_URL` | (auto-spawn) | Attach to a running OpenAI-compatible server |
312
+ | `SURYA_INFERENCE_PARALLEL` | 8 | Client-side concurrency to the backend |
313
+ | `SURYA_GUIDED_LAYOUT` | true | JSON-schema-constrained layout decode |
314
+
315
+ # Limitations
316
+
317
+ - This is specialized for document OCR. Performance on photos or natural scenes is not the goal.
318
+ - Layout / OCR / table_rec all need a running inference backend (vllm or llama.cpp). Detection runs purely on torch and works without it.
319
+
320
+ ## Troubleshooting
321
+
322
+ If OCR isn't working properly:
323
+
324
+ - Try increasing resolution of the image so the text is bigger. If the resolution is already very high, try decreasing it to no more than a `2048px` width.
325
+ - Preprocessing the image (binarizing, deskewing, etc) can help with very old/blurry images.
326
+ - You can adjust `DETECTOR_BLANK_THRESHOLD` and `DETECTOR_TEXT_THRESHOLD` if you don't get good results. `DETECTOR_BLANK_THRESHOLD` controls the space between lines - any prediction below this number will be considered blank space. `DETECTOR_TEXT_THRESHOLD` controls how text is joined - any number above this is considered text. `DETECTOR_TEXT_THRESHOLD` should always be higher than `DETECTOR_BLANK_THRESHOLD`, and both should be in the 0-1 range. Looking at the heatmap from the debug output of the detector can tell you how to adjust these (if you see faint things that look like boxes, lower the thresholds, and if you see bboxes being joined together, raise the thresholds).
327
+
328
+ # Manual install
329
+
330
+ If you want to develop surya, you can install it manually with [uv](https://docs.astral.sh/uv/):
331
+
332
+ ```bash
333
+ git clone https://github.com/datalab-to/surya.git
334
+ cd surya
335
+ uv sync --group dev # installs runtime + dev deps
336
+ uv run surya_ocr ... # or `uv shell` to enter the venv
337
+ ```
338
+
339
+ # Benchmarks
340
+
341
+ Surya 2 is a single VLM that handles layout analysis, OCR (full-page or
342
+ per-block), and table recognition in one model. We evaluate end-to-end on
343
+ [olmOCR-bench](https://huggingface.co/datasets/allenai/olmOCR-bench) — the
344
+ standard quality benchmark for document parsers.
345
+
346
+ ## olmOCR-bench
347
+
348
+ Pareto-optimal, and best in class under 3B params.
349
+
350
+ | Model | Params | Score |
351
+ |-----------------------------|----------:|---------:|
352
+ | Infinity-Parser2-Pro | 35.1B | 87.6 |
353
+ | Chandra OCR 2 (Datalab) | 5.3B | 85.9 |
354
+ | dots.mocr | 3.0B | 83.9 |
355
+ | **Surya OCR 2** (Datalab) | **0.65B** | **83.3** |
356
+ | LightOnOCR 2-1B \* | 1.0B | 83.2 |
357
+ | Chandra OCR 1 (Datalab) | 9.0B | 83.1 |
358
+ | olmOCR (anchored) | 8.3B | 77.4 |
359
+ | GOT OCR | 0.6B | 48.3 |
360
+
361
+ \* **LightOnOCR 2-1B** uses a different benchmark methodology than the other entries (see their [release notes](https://huggingface.co/lightonai/LightOnOCR-2-1B)); the score is included for context but is not directly comparable.
362
+
363
+ Comparison scores from the [olmOCR-bench dataset card](https://huggingface.co/datasets/allenai/olmOCR-bench).
364
+
365
+ Surya 2, per-source pass rate on the `default` preset (8,413 tests total):
366
+
367
+ | ArXiv | Base | Hdr/Ftr | TinyTxt | MultCol | OldScan | OldMath | Tables |
368
+ |------:|-----:|--------:|--------:|--------:|--------:|--------:|-------:|
369
+ | 88.3 | 99.7 | 92.5 | 93.7 | 82.4 | 41.8 | 81.4 | 86.6 |
370
+
371
+ ## Multilingual
372
+
373
+ We also evaluate Surya 2 against a 91-language internal benchmark covering
374
+ text accuracy, layout, tables, math, and reading order in documents drawn
375
+ from each language.
376
+
377
+ **Overall pass rate: 87.2% across 91 languages.** 38 of the
378
+ 91 languages score ≥ 90%; 76 score ≥ 80%.
379
+
380
+ Top 15 widely-spoken languages:
381
+
382
+ | Code | Language | Score |
383
+ |------|-------------|------:|
384
+ | `ar` | Arabic | 72.7% |
385
+ | `bn` | Bengali | 82.7% |
386
+ | `zh` | Chinese | 82.5% |
387
+ | `en` | English | 92.3% |
388
+ | `fr` | French | 89.3% |
389
+ | `de` | German | 89.7% |
390
+ | `hi` | Hindi | 82.2% |
391
+ | `it` | Italian | 93.0% |
392
+ | `ja` | Japanese | 86.2% |
393
+ | `ko` | Korean | 86.7% |
394
+ | `fa` | Persian | 82.3% |
395
+ | `pt` | Portuguese | 86.1% |
396
+ | `ru` | Russian | 88.8% |
397
+ | `es` | Spanish | 90.7% |
398
+ | `vi` | Vietnamese | 73.2% |
399
+
400
+ See [https://github.com/datalab-to/surya/blob/master/static/docs/multilingual.md](https://github.com/datalab-to/surya/blob/master/static/docs/multilingual.md) for the full 91-language table.
401
+
402
+ ## Throughput
403
+
404
+ Full-page OCR, 96 DPI input (~2,400 output tokens/page average), measured
405
+ client-side against a running inference server.
406
+
407
+ ### RTX 5090 (vllm)
408
+
409
+ `vllm/vllm-openai:v0.20.1`, single RTX 5090 (32 GB).
410
+
411
+ | Concurrency | Pages/s | Tokens/s | p50 (ms) | p95 (ms) | avg tok/page |
412
+ |------------:|--------:|----------:|---:|---:|---:|
413
+ | 128 | 5.35 | 12,884 | 18,915 | 42,538 | 2,410 |
414
+
415
+ ### Apple Silicon (llama.cpp / Metal)
416
+
417
+ `llama-server` with Metal backend.
418
+
419
+ | `--parallel` | Pages/s | Tokens/s | p50 (ms) | p95 (ms) | avg tok/page | Power |
420
+ |-------------:|---------:|---------:|---:|---:|---:|---:|
421
+ | 8 | 0.108 | 254 | 59,313 | 129,173 | 2,360 | ~30 W |
422
+
423
+ ## Reproducing
424
+
425
+ We score Surya 2 on olmOCR-bench by serving the model with `vllm` (or
426
+ `llama.cpp`) and running the olmOCR-bench harness from
427
+ [allenai/olmocr](https://github.com/allenai/olmocr), with some adjustments applied to account for our output HTML format.
428
+
429
+ # Training
430
+
431
+ Layout, OCR, and table recognition all share a single vision-language model
432
+ (Qwen3.5-style architecture, ~650M params). It's trained on diverse document
433
+ images to emit either a layout JSON or a full-page HTML output, depending on
434
+ prompt. Text-line detection is a separate small torch model — a modified
435
+ EfficientViT segformer trained from scratch on document line annotations.
436
+
437
+ If you want help finetuning Surya on your own data, or to use our managed
438
+ training stack, reach us at [email protected].
439
+
440
+ # Thanks
441
+
442
+ This work would not have been possible without amazing open source AI work:
443
+
444
+ - [Qwen3-VL](https://huggingface.co/Qwen) from Alibaba
445
+ - [vllm](https://github.com/vllm-project/vllm) and [llama.cpp](https://github.com/ggerganov/llama.cpp) for inference
446
+ - [Segformer](https://arxiv.org/pdf/2105.15203.pdf) from NVIDIA
447
+ - [EfficientViT](https://github.com/mit-han-lab/efficientvit) from MIT
448
+ - [timm](https://github.com/huggingface/pytorch-image-models) from Ross Wightman
449
+ - [transformers](https://github.com/huggingface/transformers) from huggingface
450
+ - [CRAFT](https://github.com/clovaai/CRAFT-pytorch), a great scene text detection model
451
+
452
+ Thank you to everyone who makes open source AI possible.
453
+
454
+ # Citation
455
+
456
+ If you use surya (or the associated models) in your work or research, please consider citing us using the following BibTeX entry:
457
+
458
+ ```bibtex
459
+ @misc{paruchuri2025surya,
460
+ author = {Vikas Paruchuri and Datalab Team},
461
+ title = {Surya: A lightweight document OCR and analysis toolkit},
462
+ year = {2025},
463
+ howpublished = {\url{https://github.com/datalab-to/surya}},
464
+ note = {GitHub repository},
465
+ }
assets/corporate.png ADDED

Git LFS Details

  • SHA256: 03e5004c5ee8b24c09d81c6b735ff057038d58e3e87d09a5aac68ce1fcd09249
  • Pointer size: 131 Bytes
  • Size of remote file: 168 kB
assets/corporate_layout.png ADDED

Git LFS Details

  • SHA256: c472d16817b87a322f40b31f3689209d729d56e82418558b0185060dfe3d5a2b
  • Pointer size: 131 Bytes
  • Size of remote file: 167 kB
assets/corporate_reading.png ADDED

Git LFS Details

  • SHA256: fa9471e99827a94aa4d6889e05880ff920cca195d8ddd66192e02242fcdedf30
  • Pointer size: 131 Bytes
  • Size of remote file: 168 kB
assets/corporate_tablerec.png ADDED

Git LFS Details

  • SHA256: c1861b87e15f50bad581b46e82b9a38f85b74900d1fdb9088fe780698b57a493
  • Pointer size: 131 Bytes
  • Size of remote file: 163 kB
assets/corporate_text.png ADDED

Git LFS Details

  • SHA256: 893c5924fe66740b77a73afeb0d41f4139814f6cbaed2850e4743793b380b99c
  • Pointer size: 131 Bytes
  • Size of remote file: 166 kB
assets/excerpt.png ADDED

Git LFS Details

  • SHA256: 9d1913fc79fb9bea3e632622c9d2064a4c60485fbfaba2e67cfb48c2668ad149
  • Pointer size: 131 Bytes
  • Size of remote file: 339 kB
assets/excerpt_layout.png ADDED

Git LFS Details

  • SHA256: 924b81dba774c3c66ae09f6874334a3bcdcca75b330179fb1854964f262b15a7
  • Pointer size: 131 Bytes
  • Size of remote file: 345 kB
assets/excerpt_text.png ADDED

Git LFS Details

  • SHA256: baddec3a08b69949d737f6ec3322bb70a37cf9acb6681c91ff41a9c2f1f23965
  • Pointer size: 131 Bytes
  • Size of remote file: 543 kB
assets/form.png ADDED

Git LFS Details

  • SHA256: 60fb6bfde4d790cf5c97c11bc8697746e3a49fd6004325d8c25aa3ce1600edc5
  • Pointer size: 131 Bytes
  • Size of remote file: 513 kB
assets/form_layout.png ADDED

Git LFS Details

  • SHA256: 631c09dc21bd05a1a81d981fd33ad6f5d0830d3e750bfae189a355fe4509dff9
  • Pointer size: 131 Bytes
  • Size of remote file: 508 kB
assets/form_reading.png ADDED

Git LFS Details

  • SHA256: e88bac7fb15d375be5d4f115b3558007398952b3bd4cd03ebd84a567be6867a9
  • Pointer size: 131 Bytes
  • Size of remote file: 519 kB
assets/form_tablerec.png ADDED

Git LFS Details

  • SHA256: d799c78d495c19cf6e68e73b48459a16331eb80bc569540e17471f29ab4a7a4f
  • Pointer size: 131 Bytes
  • Size of remote file: 511 kB
assets/form_text.png ADDED

Git LFS Details

  • SHA256: 7c40b723392652b65ab18be779bcb9b6396e65f718b9bdea1071e26e543c67b1
  • Pointer size: 131 Bytes
  • Size of remote file: 330 kB
assets/handwritten.png ADDED

Git LFS Details

  • SHA256: 3c7623a26db006f332d7db8e5c0e21861311352622502698abe8b689c8ab3421
  • Pointer size: 131 Bytes
  • Size of remote file: 178 kB
assets/handwritten_layout.png ADDED

Git LFS Details

  • SHA256: ad0e4ae387b843bda64b51e132b1e5ea8003b5ad49aeddafe9681a0968cd51d7
  • Pointer size: 131 Bytes
  • Size of remote file: 185 kB
assets/handwritten_reading.png ADDED

Git LFS Details

  • SHA256: 5cc6662224cacbb0a26c7890aedffeffa7d12a4592115737c7104fa661b058ac
  • Pointer size: 131 Bytes
  • Size of remote file: 185 kB
assets/handwritten_tablerec.png ADDED

Git LFS Details

  • SHA256: 5e3f7820dc76b4480afe350fa4b7263b87e15615109cae40b3c591d0b5be5785
  • Pointer size: 131 Bytes
  • Size of remote file: 171 kB
assets/handwritten_text.png ADDED

Git LFS Details

  • SHA256: 9686cfab491a74085e70957093bd381b6202a1311269ebd18e210982cd2cf4ab
  • Pointer size: 131 Bytes
  • Size of remote file: 298 kB
assets/newspaper.png ADDED

Git LFS Details

  • SHA256: 1a07a43797b78ffa8db5b4d11e7c2668d58d38a94cfa81a6cdd8d50750b62b9e
  • Pointer size: 132 Bytes
  • Size of remote file: 5.65 MB
assets/newspaper_layout.png ADDED

Git LFS Details

  • SHA256: 139c8fd411526b85d2ff600a1912874ae5f23f6d77c1ec3d9319b73a64dd2e7e
  • Pointer size: 132 Bytes
  • Size of remote file: 5.6 MB
assets/newspaper_reading.png ADDED

Git LFS Details

  • SHA256: c18c2eb0c39de94267f11bd97091b6542f130dd05a93142a5e5f007b9a435253
  • Pointer size: 132 Bytes
  • Size of remote file: 5.65 MB
assets/newspaper_text.png ADDED

Git LFS Details

  • SHA256: 364de91c602c902faf13c33628192efbeb1a28fc1b853265563f7946fddbb271
  • Pointer size: 132 Bytes
  • Size of remote file: 1.88 MB
assets/olmocr_size_chart.png ADDED
assets/scanned_tablerec.png ADDED

Git LFS Details

  • SHA256: 86091b59d376bb658e331eb9abd3d32fd214b822eafc994685712db968f48147
  • Pointer size: 131 Bytes
  • Size of remote file: 345 kB
assets/textbook.png ADDED

Git LFS Details

  • SHA256: 0070c7f61aae00201f9764bf4a01d6c8ab301718f9f9c62522b9eb24ae0890f7
  • Pointer size: 131 Bytes
  • Size of remote file: 193 kB
assets/textbook_layout.png ADDED

Git LFS Details

  • SHA256: 2711fcd2183f9397306817c083a9377134647ab11521293732031e0e780571da
  • Pointer size: 131 Bytes
  • Size of remote file: 195 kB
assets/textbook_reading.png ADDED

Git LFS Details

  • SHA256: 81d14c7a6d77872fc21a2743f03b7ce4124f6301c97aa7e6de425b73396d2259
  • Pointer size: 131 Bytes
  • Size of remote file: 201 kB
assets/textbook_text.png ADDED

Git LFS Details

  • SHA256: 7950d981fdf94b499d27db1bfad4e62aaf139ba7be44f88bbe1d411729c10d8f
  • Pointer size: 131 Bytes
  • Size of remote file: 226 kB
cpu_fp16/chat_template.jinja ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if messages[0].role == 'system' %}
46
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
47
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
48
+ {%- endif %}
49
+ {%- for message in messages %}
50
+ {%- set content = render_content(message.content, true)|trim %}
51
+ {%- if message.role == "system" %}
52
+ {%- if not loop.first %}
53
+ {{- raise_exception('System message must be at the beginning.') }}
54
+ {%- endif %}
55
+ {%- elif message.role == "user" %}
56
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
57
+ {%- elif message.role == "assistant" %}
58
+ {{- '<|im_start|>' + message.role + '\n' + content }}
59
+ {{- '<|im_end|>\n' }}
60
+ {%- else %}
61
+ {{- raise_exception('Unexpected message role.') }}
62
+ {%- endif %}
63
+ {%- endfor %}
64
+ {%- if add_generation_prompt %}
65
+ {{- '<|im_start|>assistant\n' }}
66
+ {%- endif %}
cpu_fp16/config.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "eos_token_id": 248044,
6
+ "image_token_id": 11,
7
+ "model_type": "qwen3_5",
8
+ "num_nextn_predict_layers": 1,
9
+ "text_config": {
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "attn_output_gate": true,
13
+ "bos_token_id": null,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 248044,
16
+ "full_attention_interval": 4,
17
+ "head_dim": 256,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 1024,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 3584,
22
+ "layer_types": [
23
+ "linear_attention",
24
+ "linear_attention",
25
+ "linear_attention",
26
+ "full_attention",
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention"
47
+ ],
48
+ "linear_conv_kernel_dim": 4,
49
+ "linear_key_head_dim": 128,
50
+ "linear_num_key_heads": 16,
51
+ "linear_num_value_heads": 16,
52
+ "linear_value_head_dim": 128,
53
+ "mamba_ssm_dtype": "float32",
54
+ "max_position_embeddings": 262144,
55
+ "mlp_only_layers": [],
56
+ "model_type": "qwen3_5_text",
57
+ "mtp_num_hidden_layers": 1,
58
+ "mtp_use_dedicated_embeddings": false,
59
+ "num_attention_heads": 8,
60
+ "num_hidden_layers": 24,
61
+ "num_key_value_heads": 2,
62
+ "pad_token_id": null,
63
+ "partial_rotary_factor": 0.25,
64
+ "rms_norm_eps": 1e-06,
65
+ "rope_parameters": {
66
+ "mrope_interleaved": true,
67
+ "mrope_section": [
68
+ 11,
69
+ 11,
70
+ 10
71
+ ],
72
+ "partial_rotary_factor": 0.25,
73
+ "rope_theta": 10000000,
74
+ "rope_type": "default"
75
+ },
76
+ "tie_word_embeddings": true,
77
+ "use_cache": true,
78
+ "vocab_size": 65425
79
+ },
80
+ "tie_word_embeddings": true,
81
+ "transformers_version": "5.10.2",
82
+ "video_token_id": 12,
83
+ "vision_config": {
84
+ "deepstack_visual_indexes": [],
85
+ "depth": 12,
86
+ "hidden_act": "gelu_pytorch_tanh",
87
+ "hidden_size": 768,
88
+ "in_channels": 3,
89
+ "initializer_range": 0.02,
90
+ "intermediate_size": 3072,
91
+ "model_type": "qwen3_5_vision",
92
+ "num_heads": 12,
93
+ "num_position_embeddings": 2304,
94
+ "out_hidden_size": 1024,
95
+ "patch_size": 16,
96
+ "spatial_merge_size": 2,
97
+ "temporal_patch_size": 2
98
+ },
99
+ "vision_end_token_id": 10,
100
+ "vision_start_token_id": 9
101
+ }
cpu_fp16/genai_config.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": {
3
+ "bos_token_id": 1,
4
+ "context_length": 262144,
5
+ "decoder": {
6
+ "session_options": {
7
+ "log_id": "onnxruntime-genai",
8
+ "provider_options": []
9
+ },
10
+ "filename": "text.onnx",
11
+ "head_size": 256,
12
+ "hidden_size": 1024,
13
+ "inputs": {
14
+ "inputs_embeds": "inputs_embeds",
15
+ "attention_mask": "attention_mask",
16
+ "position_ids": "position_ids",
17
+ "past_key_names": "past_key_values.%d.key",
18
+ "past_value_names": "past_key_values.%d.value"
19
+ },
20
+ "outputs": {
21
+ "logits": "logits",
22
+ "present_key_names": "present.%d.key",
23
+ "present_value_names": "present.%d.value"
24
+ },
25
+ "num_attention_heads": 8,
26
+ "num_hidden_layers": 24,
27
+ "num_key_value_heads": 2
28
+ },
29
+ "eos_token_id": 248044,
30
+ "pad_token_id": 248044,
31
+ "type": "qwen3_5",
32
+ "vocab_size": 65425,
33
+ "embedding": {
34
+ "filename": "embedding.onnx",
35
+ "inputs": {
36
+ "input_ids": "input_ids",
37
+ "image_features": "image_features"
38
+ },
39
+ "outputs": {
40
+ "inputs_embeds": "inputs_embeds"
41
+ },
42
+ "session_options": {
43
+ "log_id": "onnxruntime-genai",
44
+ "provider_options": []
45
+ }
46
+ },
47
+ "vision": {
48
+ "filename": "vision.onnx",
49
+ "config_filename": "processor_config.json",
50
+ "spatial_merge_size": 2,
51
+ "tokens_per_second": 2.0,
52
+ "patch_size": 16,
53
+ "window_size": 64,
54
+ "inputs": {
55
+ "pixel_values": "pixel_values",
56
+ "image_grid_thw": "image_grid_thw"
57
+ },
58
+ "outputs": {
59
+ "image_features": "image_features"
60
+ },
61
+ "session_options": {
62
+ "log_id": "onnxruntime-genai",
63
+ "provider_options": []
64
+ }
65
+ },
66
+ "image_token_id": 151655,
67
+ "video_token_id": 151656,
68
+ "vision_start_token_id": 151652
69
+ },
70
+ "search": {
71
+ "diversity_penalty": 0.0,
72
+ "do_sample": false,
73
+ "early_stopping": true,
74
+ "length_penalty": 1.0,
75
+ "max_length": 262144,
76
+ "min_length": 0,
77
+ "no_repeat_ngram_size": 0,
78
+ "num_beams": 1,
79
+ "num_return_sequences": 1,
80
+ "past_present_share_buffer": false,
81
+ "repetition_penalty": 1.0,
82
+ "temperature": 1.0,
83
+ "top_k": 50,
84
+ "top_p": 1.0
85
+ }
86
+ }
cpu_fp16/processor_config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "processor": {
3
+ "name": "qwen3_vl_image_processor",
4
+ "transforms": [
5
+ {
6
+ "operation": {
7
+ "name": "decode_image",
8
+ "type": "DecodeImage",
9
+ "attrs": {
10
+ "color_space": "RGB"
11
+ }
12
+ }
13
+ },
14
+ {
15
+ "operation": {
16
+ "name": "convert_to_rgb",
17
+ "type": "ConvertRGB"
18
+ }
19
+ },
20
+ {
21
+ "operation": {
22
+ "name": "resize",
23
+ "type": "Resize",
24
+ "attrs": {
25
+ "width": 540,
26
+ "height": 360,
27
+ "smart_resize": 1,
28
+ "min_pixels": 65536,
29
+ "max_pixels": 16777216,
30
+ "patch_size": 16,
31
+ "merge_size": 2
32
+ }
33
+ }
34
+ },
35
+ {
36
+ "operation": {
37
+ "name": "rescale",
38
+ "type": "Rescale",
39
+ "attrs": {
40
+ "rescale_factor": 0.00392156862745098
41
+ }
42
+ }
43
+ },
44
+ {
45
+ "operation": {
46
+ "name": "normalize",
47
+ "type": "Normalize",
48
+ "attrs": {
49
+ "mean": [
50
+ 0.5,
51
+ 0.5,
52
+ 0.5
53
+ ],
54
+ "std": [
55
+ 0.5,
56
+ 0.5,
57
+ 0.5
58
+ ],
59
+ "qwen3_vl": 1
60
+ }
61
+ }
62
+ },
63
+ {
64
+ "operation": {
65
+ "name": "patch_image",
66
+ "type": "PatchImage",
67
+ "attrs": {
68
+ "patch_size": 16,
69
+ "temporal_patch_size": 2,
70
+ "merge_size": 2
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
76
+ }
cpu_fp16/text.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0875b00ffcc69afac6e9d0b9d41b2af9991f24e478d99d32083553724f0c18f0
3
+ size 434813
cpu_fp16/text.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a16e3996a2af7e53b74bdb352c63c92cce584a45ec5a3eabaf211fd44c97938
3
+ size 1197574144
cpu_fp16/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
cpu_fp16/tokenizer_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": null,
4
+ "eos_token": "<|im_end|>",
5
+ "extra_special_tokens": [
6
+ "<|im_start|>",
7
+ "<|object_ref_start|>",
8
+ "<|object_ref_end|>",
9
+ "<|box_start|>",
10
+ "<|box_end|>",
11
+ "<|quad_start|>",
12
+ "<|quad_end|>",
13
+ "<|vision_start|>",
14
+ "<|vision_end|>",
15
+ "<|image_pad|>",
16
+ "<|video_pad|>"
17
+ ],
18
+ "is_local": true,
19
+ "local_files_only": false,
20
+ "model_max_length": 262144,
21
+ "pad_token": "<|endoftext|>",
22
+ "processor_class": "Qwen3VLProcessor",
23
+ "tokenizer_class": "TokenizersBackend",
24
+ "unk_token": "<unk>"
25
+ }
cpu_fp32/chat_template.jinja ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if messages[0].role == 'system' %}
46
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
47
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
48
+ {%- endif %}
49
+ {%- for message in messages %}
50
+ {%- set content = render_content(message.content, true)|trim %}
51
+ {%- if message.role == "system" %}
52
+ {%- if not loop.first %}
53
+ {{- raise_exception('System message must be at the beginning.') }}
54
+ {%- endif %}
55
+ {%- elif message.role == "user" %}
56
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
57
+ {%- elif message.role == "assistant" %}
58
+ {{- '<|im_start|>' + message.role + '\n' + content }}
59
+ {{- '<|im_end|>\n' }}
60
+ {%- else %}
61
+ {{- raise_exception('Unexpected message role.') }}
62
+ {%- endif %}
63
+ {%- endfor %}
64
+ {%- if add_generation_prompt %}
65
+ {{- '<|im_start|>assistant\n' }}
66
+ {%- endif %}
cpu_fp32/config.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "eos_token_id": 248044,
6
+ "image_token_id": 11,
7
+ "model_type": "qwen3_5",
8
+ "num_nextn_predict_layers": 1,
9
+ "text_config": {
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "attn_output_gate": true,
13
+ "bos_token_id": null,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 248044,
16
+ "full_attention_interval": 4,
17
+ "head_dim": 256,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 1024,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 3584,
22
+ "layer_types": [
23
+ "linear_attention",
24
+ "linear_attention",
25
+ "linear_attention",
26
+ "full_attention",
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention"
47
+ ],
48
+ "linear_conv_kernel_dim": 4,
49
+ "linear_key_head_dim": 128,
50
+ "linear_num_key_heads": 16,
51
+ "linear_num_value_heads": 16,
52
+ "linear_value_head_dim": 128,
53
+ "mamba_ssm_dtype": "float32",
54
+ "max_position_embeddings": 262144,
55
+ "mlp_only_layers": [],
56
+ "model_type": "qwen3_5_text",
57
+ "mtp_num_hidden_layers": 1,
58
+ "mtp_use_dedicated_embeddings": false,
59
+ "num_attention_heads": 8,
60
+ "num_hidden_layers": 24,
61
+ "num_key_value_heads": 2,
62
+ "pad_token_id": null,
63
+ "partial_rotary_factor": 0.25,
64
+ "rms_norm_eps": 1e-06,
65
+ "rope_parameters": {
66
+ "mrope_interleaved": true,
67
+ "mrope_section": [
68
+ 11,
69
+ 11,
70
+ 10
71
+ ],
72
+ "partial_rotary_factor": 0.25,
73
+ "rope_theta": 10000000,
74
+ "rope_type": "default"
75
+ },
76
+ "tie_word_embeddings": true,
77
+ "use_cache": true,
78
+ "vocab_size": 65425
79
+ },
80
+ "tie_word_embeddings": true,
81
+ "transformers_version": "5.10.2",
82
+ "video_token_id": 12,
83
+ "vision_config": {
84
+ "deepstack_visual_indexes": [],
85
+ "depth": 12,
86
+ "hidden_act": "gelu_pytorch_tanh",
87
+ "hidden_size": 768,
88
+ "in_channels": 3,
89
+ "initializer_range": 0.02,
90
+ "intermediate_size": 3072,
91
+ "model_type": "qwen3_5_vision",
92
+ "num_heads": 12,
93
+ "num_position_embeddings": 2304,
94
+ "out_hidden_size": 1024,
95
+ "patch_size": 16,
96
+ "spatial_merge_size": 2,
97
+ "temporal_patch_size": 2
98
+ },
99
+ "vision_end_token_id": 10,
100
+ "vision_start_token_id": 9
101
+ }
cpu_fp32/genai_config.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": {
3
+ "bos_token_id": 1,
4
+ "context_length": 262144,
5
+ "decoder": {
6
+ "session_options": {
7
+ "log_id": "onnxruntime-genai",
8
+ "provider_options": []
9
+ },
10
+ "filename": "text.onnx",
11
+ "head_size": 256,
12
+ "hidden_size": 1024,
13
+ "inputs": {
14
+ "inputs_embeds": "inputs_embeds",
15
+ "attention_mask": "attention_mask",
16
+ "position_ids": "position_ids",
17
+ "past_key_names": "past_key_values.%d.key",
18
+ "past_value_names": "past_key_values.%d.value"
19
+ },
20
+ "outputs": {
21
+ "logits": "logits",
22
+ "present_key_names": "present.%d.key",
23
+ "present_value_names": "present.%d.value"
24
+ },
25
+ "num_attention_heads": 8,
26
+ "num_hidden_layers": 24,
27
+ "num_key_value_heads": 2
28
+ },
29
+ "eos_token_id": 248044,
30
+ "pad_token_id": 248044,
31
+ "type": "qwen3_5",
32
+ "vocab_size": 65425,
33
+ "embedding": {
34
+ "filename": "embedding.onnx",
35
+ "inputs": {
36
+ "input_ids": "input_ids",
37
+ "image_features": "image_features"
38
+ },
39
+ "outputs": {
40
+ "inputs_embeds": "inputs_embeds"
41
+ },
42
+ "session_options": {
43
+ "log_id": "onnxruntime-genai",
44
+ "provider_options": []
45
+ }
46
+ },
47
+ "vision": {
48
+ "filename": "vision.onnx",
49
+ "config_filename": "processor_config.json",
50
+ "spatial_merge_size": 2,
51
+ "tokens_per_second": 2.0,
52
+ "patch_size": 16,
53
+ "window_size": 64,
54
+ "inputs": {
55
+ "pixel_values": "pixel_values",
56
+ "image_grid_thw": "image_grid_thw"
57
+ },
58
+ "outputs": {
59
+ "image_features": "image_features"
60
+ },
61
+ "session_options": {
62
+ "log_id": "onnxruntime-genai",
63
+ "provider_options": []
64
+ }
65
+ },
66
+ "image_token_id": 151655,
67
+ "video_token_id": 151656,
68
+ "vision_start_token_id": 151652
69
+ },
70
+ "search": {
71
+ "diversity_penalty": 0.0,
72
+ "do_sample": false,
73
+ "early_stopping": true,
74
+ "length_penalty": 1.0,
75
+ "max_length": 262144,
76
+ "min_length": 0,
77
+ "no_repeat_ngram_size": 0,
78
+ "num_beams": 1,
79
+ "num_return_sequences": 1,
80
+ "past_present_share_buffer": true,
81
+ "repetition_penalty": 1.0,
82
+ "temperature": 1.0,
83
+ "top_k": 50,
84
+ "top_p": 1.0
85
+ }
86
+ }
cpu_fp32/processor_config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "processor": {
3
+ "name": "qwen3_vl_image_processor",
4
+ "transforms": [
5
+ {
6
+ "operation": {
7
+ "name": "decode_image",
8
+ "type": "DecodeImage",
9
+ "attrs": {
10
+ "color_space": "RGB"
11
+ }
12
+ }
13
+ },
14
+ {
15
+ "operation": {
16
+ "name": "convert_to_rgb",
17
+ "type": "ConvertRGB"
18
+ }
19
+ },
20
+ {
21
+ "operation": {
22
+ "name": "resize",
23
+ "type": "Resize",
24
+ "attrs": {
25
+ "width": 540,
26
+ "height": 360,
27
+ "smart_resize": 1,
28
+ "min_pixels": 65536,
29
+ "max_pixels": 16777216,
30
+ "patch_size": 16,
31
+ "merge_size": 2
32
+ }
33
+ }
34
+ },
35
+ {
36
+ "operation": {
37
+ "name": "rescale",
38
+ "type": "Rescale",
39
+ "attrs": {
40
+ "rescale_factor": 0.00392156862745098
41
+ }
42
+ }
43
+ },
44
+ {
45
+ "operation": {
46
+ "name": "normalize",
47
+ "type": "Normalize",
48
+ "attrs": {
49
+ "mean": [
50
+ 0.5,
51
+ 0.5,
52
+ 0.5
53
+ ],
54
+ "std": [
55
+ 0.5,
56
+ 0.5,
57
+ 0.5
58
+ ],
59
+ "qwen3_vl": 1
60
+ }
61
+ }
62
+ },
63
+ {
64
+ "operation": {
65
+ "name": "patch_image",
66
+ "type": "PatchImage",
67
+ "attrs": {
68
+ "patch_size": 16,
69
+ "temporal_patch_size": 2,
70
+ "merge_size": 2
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
76
+ }
cpu_fp32/text.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbfd23ae84c7d152b392413222663addc0f5dd182acd7ef497ddb7d68cf91c83
3
+ size 411759
cpu_fp32/text.onnx.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b837aaf83685c5cfdd4efe579cadf3e3fea9149931f473f7945b830be97f73c5
3
+ size 2328039424
cpu_fp32/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
cpu_fp32/tokenizer_config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": null,
4
+ "eos_token": "<|im_end|>",
5
+ "extra_special_tokens": [
6
+ "<|im_start|>",
7
+ "<|object_ref_start|>",
8
+ "<|object_ref_end|>",
9
+ "<|box_start|>",
10
+ "<|box_end|>",
11
+ "<|quad_start|>",
12
+ "<|quad_end|>",
13
+ "<|vision_start|>",
14
+ "<|vision_end|>",
15
+ "<|image_pad|>",
16
+ "<|video_pad|>"
17
+ ],
18
+ "is_local": true,
19
+ "local_files_only": false,
20
+ "model_max_length": 262144,
21
+ "pad_token": "<|endoftext|>",
22
+ "processor_class": "Qwen3VLProcessor",
23
+ "tokenizer_class": "TokenizersBackend",
24
+ "unk_token": "<unk>"
25
+ }
cpu_int4/chat_template.jinja ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if messages[0].role == 'system' %}
46
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
47
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
48
+ {%- endif %}
49
+ {%- for message in messages %}
50
+ {%- set content = render_content(message.content, true)|trim %}
51
+ {%- if message.role == "system" %}
52
+ {%- if not loop.first %}
53
+ {{- raise_exception('System message must be at the beginning.') }}
54
+ {%- endif %}
55
+ {%- elif message.role == "user" %}
56
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
57
+ {%- elif message.role == "assistant" %}
58
+ {{- '<|im_start|>' + message.role + '\n' + content }}
59
+ {{- '<|im_end|>\n' }}
60
+ {%- else %}
61
+ {{- raise_exception('Unexpected message role.') }}
62
+ {%- endif %}
63
+ {%- endfor %}
64
+ {%- if add_generation_prompt %}
65
+ {{- '<|im_start|>assistant\n' }}
66
+ {%- endif %}
cpu_int4/config.json ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "eos_token_id": 248044,
6
+ "image_token_id": 11,
7
+ "model_type": "qwen3_5",
8
+ "num_nextn_predict_layers": 1,
9
+ "text_config": {
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "attn_output_gate": true,
13
+ "bos_token_id": null,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 248044,
16
+ "full_attention_interval": 4,
17
+ "head_dim": 256,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 1024,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 3584,
22
+ "layer_types": [
23
+ "linear_attention",
24
+ "linear_attention",
25
+ "linear_attention",
26
+ "full_attention",
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention"
47
+ ],
48
+ "linear_conv_kernel_dim": 4,
49
+ "linear_key_head_dim": 128,
50
+ "linear_num_key_heads": 16,
51
+ "linear_num_value_heads": 16,
52
+ "linear_value_head_dim": 128,
53
+ "mamba_ssm_dtype": "float32",
54
+ "max_position_embeddings": 262144,
55
+ "mlp_only_layers": [],
56
+ "model_type": "qwen3_5_text",
57
+ "mtp_num_hidden_layers": 1,
58
+ "mtp_use_dedicated_embeddings": false,
59
+ "num_attention_heads": 8,
60
+ "num_hidden_layers": 24,
61
+ "num_key_value_heads": 2,
62
+ "pad_token_id": null,
63
+ "partial_rotary_factor": 0.25,
64
+ "rms_norm_eps": 1e-06,
65
+ "rope_parameters": {
66
+ "mrope_interleaved": true,
67
+ "mrope_section": [
68
+ 11,
69
+ 11,
70
+ 10
71
+ ],
72
+ "partial_rotary_factor": 0.25,
73
+ "rope_theta": 10000000,
74
+ "rope_type": "default"
75
+ },
76
+ "tie_word_embeddings": true,
77
+ "use_cache": true,
78
+ "vocab_size": 65425
79
+ },
80
+ "tie_word_embeddings": true,
81
+ "transformers_version": "5.10.2",
82
+ "video_token_id": 12,
83
+ "vision_config": {
84
+ "deepstack_visual_indexes": [],
85
+ "depth": 12,
86
+ "hidden_act": "gelu_pytorch_tanh",
87
+ "hidden_size": 768,
88
+ "in_channels": 3,
89
+ "initializer_range": 0.02,
90
+ "intermediate_size": 3072,
91
+ "model_type": "qwen3_5_vision",
92
+ "num_heads": 12,
93
+ "num_position_embeddings": 2304,
94
+ "out_hidden_size": 1024,
95
+ "patch_size": 16,
96
+ "spatial_merge_size": 2,
97
+ "temporal_patch_size": 2
98
+ },
99
+ "vision_end_token_id": 10,
100
+ "vision_start_token_id": 9
101
+ }