Lacax commited on
Commit
d0951d2
·
verified ·
1 Parent(s): 4afb60d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +79 -174
README.md CHANGED
@@ -1,207 +1,112 @@
1
  ---
 
 
 
 
2
  tags:
 
 
 
 
 
3
  - unsloth
 
 
 
4
  ---
5
- ---
6
- library_name: transformers
7
- pipeline_tag: image-text-to-text
8
- tags:
9
- - transformers
10
- - safetensors
11
- - unsloth
12
- - endpoints_compatible
13
-
14
- # Model Card for Model ID
15
-
16
- <!-- Provide a quick summary of what the model is/does. -->
17
-
18
-
19
-
20
- ## Model Details
21
-
22
- ### Model Description
23
-
24
- <!-- Provide a longer summary of what this model is. -->
25
-
26
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
27
-
28
- - **Developed by:** [More Information Needed]
29
- - **Funded by [optional]:** [More Information Needed]
30
- - **Shared by [optional]:** [More Information Needed]
31
- - **Model type:** [More Information Needed]
32
- - **Language(s) (NLP):** [More Information Needed]
33
- - **License:** [More Information Needed]
34
- - **Finetuned from model [optional]:** [More Information Needed]
35
-
36
- ### Model Sources [optional]
37
-
38
- <!-- Provide the basic links for the model. -->
39
-
40
- - **Repository:** [More Information Needed]
41
- - **Paper [optional]:** [More Information Needed]
42
- - **Demo [optional]:** [More Information Needed]
43
-
44
- ## Uses
45
-
46
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
47
-
48
- ### Direct Use
49
-
50
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
51
-
52
- [More Information Needed]
53
-
54
- ### Downstream Use [optional]
55
-
56
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
57
-
58
- [More Information Needed]
59
-
60
- ### Out-of-Scope Use
61
-
62
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
63
-
64
- [More Information Needed]
65
-
66
- ## Bias, Risks, and Limitations
67
-
68
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
69
-
70
- [More Information Needed]
71
-
72
- ### Recommendations
73
-
74
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
75
-
76
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
77
-
78
- ## How to Get Started with the Model
79
-
80
- Use the code below to get started with the model.
81
-
82
- [More Information Needed]
83
-
84
- ## Training Details
85
-
86
- ### Training Data
87
-
88
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
89
-
90
- [More Information Needed]
91
 
92
- ### Training Procedure
93
 
94
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
95
 
96
- #### Preprocessing [optional]
97
 
98
- [More Information Needed]
99
 
 
100
 
101
- #### Training Hyperparameters
102
-
103
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
104
-
105
- #### Speeds, Sizes, Times [optional]
106
-
107
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
108
-
109
- [More Information Needed]
110
-
111
- ## Evaluation
112
-
113
- <!-- This section describes the evaluation protocols and provides the results. -->
114
-
115
- ### Testing Data, Factors & Metrics
116
-
117
- #### Testing Data
118
-
119
- <!-- This should link to a Dataset Card if possible. -->
120
-
121
- [More Information Needed]
122
-
123
- #### Factors
124
-
125
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
126
-
127
- [More Information Needed]
128
-
129
- #### Metrics
130
-
131
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
132
-
133
- [More Information Needed]
134
-
135
- ### Results
136
-
137
- [More Information Needed]
138
-
139
- #### Summary
140
-
141
-
142
-
143
- ## Model Examination [optional]
144
-
145
- <!-- Relevant interpretability work for the model goes here -->
146
-
147
- [More Information Needed]
148
-
149
- ## Environmental Impact
150
-
151
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
152
-
153
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
154
-
155
- - **Hardware Type:** [More Information Needed]
156
- - **Hours used:** [More Information Needed]
157
- - **Cloud Provider:** [More Information Needed]
158
- - **Compute Region:** [More Information Needed]
159
- - **Carbon Emitted:** [More Information Needed]
160
-
161
- ## Technical Specifications [optional]
162
 
163
- ### Model Architecture and Objective
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
- [More Information Needed]
166
 
167
- ### Compute Infrastructure
168
 
169
- [More Information Needed]
170
 
171
- #### Hardware
 
 
172
 
173
- [More Information Needed]
 
174
 
175
- #### Software
 
 
 
176
 
177
- [More Information Needed]
178
 
179
- ## Citation [optional]
180
 
181
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
182
 
183
- **BibTeX:**
 
 
 
 
184
 
185
- [More Information Needed]
186
 
187
- **APA:**
188
 
189
- [More Information Needed]
 
 
 
 
 
 
 
190
 
191
- ## Glossary [optional]
192
 
193
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
194
 
195
- [More Information Needed]
 
 
 
196
 
197
- ## More Information [optional]
198
 
199
- [More Information Needed]
200
 
201
- ## Model Card Authors [optional]
202
 
203
- [More Information Needed]
204
 
205
- ## Model Card Contact
206
 
207
- [More Information Needed]
 
1
  ---
2
+ language:
3
+ - es
4
+ license: apache-2.0
5
+ base_model: unsloth/DeepSeek-OCR-2
6
  tags:
7
+ - ocr
8
+ - receipt
9
+ - invoice
10
+ - vision
11
+ - fine-tuned
12
  - unsloth
13
+ - lora
14
+ - json-extraction
15
+ pipeline_tag: image-text-to-text
16
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ # DeepSeek OCR LoRA — Extracción estructurada de tickets y facturas
19
 
20
+ ## Descripción
21
 
22
+ Este modelo es un **LoRA fine-tuning** sobre [`unsloth/DeepSeek-OCR-2`](https://huggingface.co/unsloth/DeepSeek-OCR-2), entrenado para analizar imágenes de **tickets de compra, recibos y facturas** y devolver su contenido en formato **JSON estructurado**.
23
 
24
+ El objetivo principal del proyecto fue académico: estudiar el comportamiento de un modelo de visión multimodal al ser adaptado para extraer información con una estructura de salida fija.
25
 
26
+ El modelo está diseñado principalmente para documentos en **español**.
27
 
28
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ ## Salida esperada
31
+
32
+ Dado una imagen de ticket o factura, el modelo devuelve un JSON con la siguiente estructura:
33
+
34
+ ```json
35
+ {
36
+ "comercio": "Nombre del establecimiento",
37
+ "fecha": "DD/MM/AAAA",
38
+ "cif": "B12345678",
39
+ "productos": [
40
+ {
41
+ "producto": "Nombre del producto",
42
+ "cantidad": 2,
43
+ "precio": 3.50
44
+ }
45
+ ],
46
+ "precio_total": 7.00
47
+ }
48
+ ```
49
 
50
+ ---
51
 
52
+ ## Uso
53
 
54
+ Este modelo requiere cargar el modelo base por separado y aplicar el LoRA encima:
55
 
56
+ ```python
57
+ from transformers import AutoModelForCausalLM, AutoProcessor
58
+ from peft import PeftModel
59
 
60
+ BASE_MODEL_ID = "unsloth/DeepSeek-OCR-2"
61
+ LORA_ID = "Lacax/deepseek_ocr_lora"
62
 
63
+ processor = AutoProcessor.from_pretrained(BASE_MODEL_ID)
64
+ model = AutoModelForCausalLM.from_pretrained(BASE_MODEL_ID)
65
+ model = PeftModel.from_pretrained(model, LORA_ID)
66
+ ```
67
 
68
+ > **Nota:** El repo del LoRA es privado. Se requiere un `HF_TOKEN` con acceso al repo `Lacax/deepseek_ocr_lora`. El modelo base `unsloth/DeepSeek-OCR-2` es público.
69
 
70
+ ---
71
 
72
+ ## Datos de entrenamiento
73
 
74
+ - **Tipo:** Imágenes de tickets y facturas reales (fotografías propias)
75
+ - **Tamaño:** ~100 imágenes
76
+ - **Formato:** Cada imagen asociada a su JSON ground truth con la estructura descrita arriba
77
+ - **Idioma:** Español
78
+ - **Origen:** Dataset propio, no publicado
79
 
80
+ ---
81
 
82
+ ## Estadísticas de entrenamiento
83
 
84
+ | Parámetro | Valor |
85
+ |------------------------|-------------|
86
+ | Épocas completadas | 3 |
87
+ | Duración total | ~4607 s (~77 min) |
88
+ | Muestras / segundo | 0.40 |
89
+ | Pérdida final (train) | 0.0399 |
90
+ | Framework | Unsloth + PEFT |
91
+ | Plataforma | RunPod (GPU cloud) |
92
 
93
+ ---
94
 
95
+ ## Limitaciones
96
 
97
+ - Dataset pequeño (~100 imágenes): el modelo puede no generalizar bien a formatos de ticket muy distintos a los usados en entrenamiento.
98
+ - Entrenado únicamente con documentos en español; rendimiento no garantizado en otros idiomas.
99
+ - Proyecto de carácter académico/experimental, no validado en producción.
100
+ - La pérdida baja de entrenamiento (0.04) puede indicar cierto sobreajuste al dataset propio.
101
 
102
+ ---
103
 
104
+ ## Modelo base
105
 
106
+ - [`unsloth/DeepSeek-OCR-2`](https://huggingface.co/unsloth/DeepSeek-OCR-2)
107
 
108
+ ---
109
 
110
+ ## Autor
111
 
112
+ **Lacax** Proyecto de estudio personal sobre fine-tuning de modelos de visión multimodal.