formula
Some checks failed
build_docker / essential (pull_request) Successful in 0s
build_docker / build_cpu (pull_request) Has been cancelled
build_docker / build_gpu (pull_request) Has been cancelled
build_docker / build_easyocr (pull_request) Has been cancelled
build_docker / build_easyocr_gpu (pull_request) Has been cancelled
build_docker / build_doctr (pull_request) Has been cancelled
build_docker / build_doctr_gpu (pull_request) Has been cancelled
build_docker / build_raytune (pull_request) Has been cancelled

This commit is contained in:
2026-01-19 17:14:55 +01:00
parent 506f447d46
commit b1539fd79f
2 changed files with 56 additions and 16 deletions

View File

@@ -4678,11 +4678,11 @@ _Toc14106979"><span style="mso-bookmark:_Toc437515557"><span lang="ES" style="te
<p class="MsoNormal"><span lang="ES">La evaluación rigurosa de sistemas OCR requiere métricas estandarizadas que permitan comparaciones objetivas. Las métricas fundamentales se basan en la distancia de edición de Levenshtein.</span></p>
<h4><span lang="ES">Distancia de Levenshtein</span></h4>
<p class="MsoNormal"><span lang="ES">La distancia de Levenshtein (Levenshtein, 1966) entre dos cadenas es el número mínimo de operaciones de edición (inserción, eliminación, sustitución) necesarias para transformar una cadena en otra. Formalmente, para dos cadenas <i>a</i> y <i>b</i>:</span></p>
<p class="MsoNormal"><span lang="ES">$$d(a,b) = \min(\text{inserciones} + \text{eliminaciones} + \text{sustituciones})$$</span></p>
<p class="MsoNormal" style="text-align:center"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>d</mi><mo stretchy="false">(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo stretchy="false">)</mo><mo>=</mo><mo>min</mo><mo stretchy="false">(</mo><mtext>inserciones</mtext><mo>+</mo><mtext>eliminaciones</mtext><mo>+</mo><mtext>sustituciones</mtext><mo stretchy="false">)</mo></mrow></math></p>
<p class="MsoNormal"><span lang="ES">Esta métrica es fundamental para calcular tanto CER como WER.</span></p>
<h4><span lang="ES">Character Error Rate (CER)</span></h4>
<p class="MsoNormal"><span lang="ES">El CER mide el error a nivel de carácter y se calcula como:</span></p>
<p class="MsoNormal"><span lang="ES">$$CER = \frac{S + D + I}{N}$$</span></p>
<p class="MsoNormal" style="text-align:center"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi><mi>E</mi><mi>R</mi><mo>=</mo><mfrac><mrow><mi>S</mi><mo>+</mo><mi>D</mi><mo>+</mo><mi>I</mi></mrow><mrow><mi>N</mi></mrow></mfrac></mrow></math></p>
<p class="MsoNormal"><span lang="ES">Donde:</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">S = número de sustituciones de caracteres</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">D = número de eliminaciones de caracteres</span></p>
@@ -4695,7 +4695,7 @@ _Toc14106979"><span style="mso-bookmark:_Toc437515557"><span lang="ES" style="te
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><b>Búsqueda y archivo</b>: CER &lt; 5% puede ser suficiente</span></p>
<h4><span lang="ES">Word Error Rate (WER)</span></h4>
<p class="MsoNormal"><span lang="ES">El WER mide el error a nivel de palabra, utilizando la misma fórmula pero considerando palabras como unidades:</span></p>
<p class="MsoNormal"><span lang="ES">$$WER = \frac{S_w + D_w + I_w}{N_w}$$</span></p>
<p class="MsoNormal" style="text-align:center"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>W</mi><mi>E</mi><mi>R</mi><mo>=</mo><mfrac><mrow><msub><mi>S</mi><mi>w</mi></msub><mo>+</mo><msub><mi>D</mi><mi>w</mi></msub><mo>+</mo><msub><mi>I</mi><mi>w</mi></msub></mrow><mrow><msub><mi>N</mi><mi>w</mi></msub></mrow></mfrac></mrow></math></p>
<p class="MsoNormal"><span lang="ES">El WER es generalmente mayor que el CER, ya que un solo error de carácter puede invalidar una palabra completa. La relación típica es WER ≈ 2-3 × CER para texto en español.</span></p>
<h4><span lang="ES">Otras Métricas Complementarias</span></h4>
<p class="MsoNormal"><span lang="ES"><b>Precision y Recall a nivel de palabra</b>: Útiles cuando se evalúa la capacidad del sistema para detectar palabras específicas.</span></p>
@@ -4808,16 +4808,18 @@ _Toc14106979"><span style="mso-bookmark:_Toc437515557"><span lang="ES" style="te
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">Parámetros de regularización (dropout, weight decay)</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><b>Umbrales de decisión en tiempo de inferencia</b> (relevante para este trabajo)</span></p>
<p class="MsoNormal"><span lang="ES">El problema de HPO puede formalizarse como:</span></p>
<p class="MsoNormal"><span lang="ES">$$\lambda^* = \arg\min_{\lambda \in \Lambda} \mathcal{L}(M_\lambda, D_{val})$$</span></p>
<p class="MsoNormal" style="text-align:center"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>λ</mi><mo>*</mo></msup><mo>=</mo><mi>\arg</mi><msub><mo>min</mo><mrow><mi>λ</mi><mo></mo><mi>Λ</mi></mrow></msub><mi></mi><mo stretchy="false">(</mo><msub><mi>M</mi><mi>λ</mi></msub><mo>,</mo><msub><mi>D</mi><mrow><mi>v</mi><mi>a</mi><mi>l</mi></mrow></msub><mo stretchy="false">)</mo></mrow></math></p>
<p class="MsoNormal"><span lang="ES">Donde:</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">$\lambda$ es un vector de hiperparámetros</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">$\Lambda$ es el espacio de búsqueda</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">$M_\lambda$ es el modelo configurado con $\lambda$</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">$\mathcal{L}$ es la función de pérdida</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">$D_{val}$ es el conjunto de validación</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>λ</mi></mrow></math> es un vector de hiperparámetros</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Λ</mi></mrow></math> es el espacio de búsqueda</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>M</mi><mi>λ</mi></msub></mrow></math> es el modelo configurado con <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>λ</mi></mrow></math></span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi></mi></mrow></math> es la función de pérdida</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>D</mi><mrow><mi>v</mi><mi>a</mi><mi>l</mi></mrow></msub></mrow></math> es el conjunto de validación</span></p>
<h4><span lang="ES">Métodos de Optimización</span></h4>
<p class="MsoNormal"><span lang="ES"><b>Grid Search (Búsqueda en rejilla)</b>:</span></p>
<p class="MsoNormal"><span lang="ES">El método más simple consiste en evaluar todas las combinaciones posibles de valores discretizados de los hiperparámetros. Para $k$ hiperparámetros con $n$ valores cada uno, requiere $n^k$ evaluaciones.</span></p>
El método más simple consiste en evaluar todas las combinaciones posibles de valores discretizados de los hiperparámetros. Para <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>k</mi></mrow></math> hiperparámetros con <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>n</mi></mrow></math> valores cada uno, requiere <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>n</mi><mi>k</mi></msup></mrow></math> evaluaciones.
<p class="MsoNormal"><span lang="ES">Ventajas:</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">Exhaustivo y reproducible</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">Fácil de paralelizar</span></p>
@@ -4841,12 +4843,18 @@ _Toc14106979"><span style="mso-bookmark:_Toc437515557"><span lang="ES" style="te
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><b>Random Forests</b>: Manejan bien espacios de alta dimensión y variables categóricas</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES"><b>Tree-structured Parzen Estimator (TPE)</b>: Modela densidades en lugar de la función objetivo</span></p>
<h4><span lang="ES">Tree-structured Parzen Estimator (TPE)</span></h4>
<p class="MsoNormal"><span lang="ES">TPE, propuesto por Bergstra et al. (2011) e implementado en Optuna, es particularmente efectivo para HPO. En lugar de modelar $p(y|\lambda)$ directamente, TPE modela:</span></p>
<p class="MsoNormal"><span lang="ES">$$p(\lambda|y) = \begin{cases} l(\lambda) &amp; \text{si } y &lt; y^<i> \\ g(\lambda) &amp; \text{si } y \geq y^</i> \end{cases}$$</span></p>
<p class="MsoNormal"><span lang="ES">Donde $y^*$ es un umbral (típicamente el percentil 15-25 de las observaciones), $l(\lambda)$ es la densidad de hiperparámetros con buen rendimiento, y $g(\lambda)$ es la densidad de hiperparámetros con mal rendimiento.</span></p>
TPE, propuesto por Bergstra et al. (2011) e implementado en Optuna, es particularmente efectivo para HPO. En lugar de modelar <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">|</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow></math> directamente, TPE modela:
<p class="MsoNormal" style="text-align:center"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>p</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">|</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mrow><mo fence="true" form="prefix" stretchy="true">{</mo><mtable><mtr><mtd columnalign="left"><mi>l</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo></mtd><mtd columnalign="left"><mtext>si </mtext><mi>y</mi><mo>&lt;</mo><msup><mi>y</mi><mo>*</mo></msup></mtd></mtr><mtr><mtd columnalign="left"><mi>g</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo></mtd><mtd columnalign="left"><mtext>si </mtext><mi>y</mi><mo></mo><msup><mi>y</mi><mo>*</mo></msup></mtd></mtr></mtable></mrow></mrow></math></p>
Donde <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>y</mi><mo>*</mo></msup></mrow></math> es un umbral (típicamente el percentil 15-25 de las observaciones), <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>l</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow></math> es la densidad de hiperparámetros con buen rendimiento, y <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>g</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow></math> es la densidad de hiperparámetros con mal rendimiento.
<p class="MsoNormal"><span lang="ES">La función de adquisición Expected Improvement se aproxima como:</span></p>
<p class="MsoNormal"><span lang="ES">$$EI(\lambda) \propto \frac{l(\lambda)}{g(\lambda)}$$</span></p>
<p class="MsoNormal"><span lang="ES">Configuraciones con alta probabilidad bajo $l$ y baja probabilidad bajo $g$ tienen mayor Expected Improvement.</span></p>
<p class="MsoNormal" style="text-align:center"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>E</mi><mi>I</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo><mo></mo><mfrac><mrow><mi>l</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow><mrow><mi>g</mi><mo stretchy="false">(</mo><mi>λ</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow></math></p>
Configuraciones con alta probabilidad bajo <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>l</mi></mrow></math> y baja probabilidad bajo <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>g</mi></mrow></math> tienen mayor Expected Improvement.
<p class="MsoNormal"><span lang="ES"><b>Ventajas de TPE</b>:</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">Maneja naturalmente espacios condicionales (hiperparámetros que dependen de otros)</span></p>
<p class="MsoListParagraphCxSpMiddle" style="margin-left:36pt;text-indent:-18pt"><span lang="ES" style="font-family:Symbol">·</span><span lang="ES" style="font-size:7pt">     </span><span lang="ES">Eficiente para espacios de alta dimensión</span></p>