Upload folder using huggingface_hub
Browse files- configs/agents.yaml +250 -0
- configs/ingest.yaml +74 -0
- configs/retrieval.yaml +23 -0
- configs/versions.yaml +83 -0
configs/agents.yaml
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fase 4 — grafo de agentes (docs/PLAN_RAG.md Fase 4; propuesta §6.1-6.3, §8.2).
|
| 2 |
+
prompt_version: "3" # 2: replan con memoria (DES-1), esqueleto + CLOSE + FILL; 3: prueba estructurada en `have` (el sistema la parte en goals)
|
| 3 |
+
|
| 4 |
+
k_max: 3 # intentos GENERATE->FORMALIZE->VERIFY por problema ("sin Crítico" = 1)
|
| 5 |
+
max_replans: 1
|
| 6 |
+
llm_budget: 20 # RNF-3: llamadas LLM por problema; al agotarse -> FAIL
|
| 7 |
+
|
| 8 |
+
retrieval:
|
| 9 |
+
k_mathlib: 8
|
| 10 |
+
k_informal: 3
|
| 11 |
+
n_candidates: 50
|
| 12 |
+
rerank: false # el cross-encoder son 2.4 GB más de RAM; en la muestra de 40 consultas sumó +2.5 puntos de recall (docs/DECISIONS.md #40)
|
| 13 |
+
|
| 14 |
+
lean:
|
| 15 |
+
# backend `repl` (lean-interact): `import Mathlib` una vez por corrida (~3-5 min) y ~0.3 s
|
| 16 |
+
# por teorema; `lake`: un proceso por verificación (~3 min c/u), sin estado.
|
| 17 |
+
backend: repl
|
| 18 |
+
imports: ["Mathlib", "Aesop"] # cabecera estándar de miniF2F
|
| 19 |
+
timeout_s: 600
|
| 20 |
+
max_heartbeats: 400000
|
| 21 |
+
|
| 22 |
+
# Flujo por goal (docs/PLAN_MEJORA_RAG.md Fases 2-4): el Autoformalizador escribe un esqueleto
|
| 23 |
+
# `have … := by sorry`; cada `sorry` es un goal de Lean que se cierra con la batería CLOSE (0 LLM, con
|
| 24 |
+
# las premisas recuperadas para ESE goal) y sólo los que quedan abiertos van al LLM (FILL).
|
| 25 |
+
# false = flujo anterior (prueba entera de una vez, recuperación NL por subobjetivo) — config `rag_nl`.
|
| 26 |
+
goal_mode: true
|
| 27 |
+
close:
|
| 28 |
+
k_premises: 16 # premisas por goal (canal A: prior de competición filtrado por el goal)
|
| 29 |
+
dense_channel: false # canal C (índice denso con el goal): recall@16 0.028 y hunde la fusión (DECISIONS #98)
|
| 30 |
+
timeout_s: 150 # por táctica (ProofStep); `try?` llega a 76 s en goals difíciles (cada sub-táctica con sus heartbeats)
|
| 31 |
+
# En orden; gana la primera que cierra el goal. `rag`: con premisas recuperadas; `plain`: lo que
|
| 32 |
+
# corre sin RAG (`no_rag`, `baseline_auto`; null = se omite). Medido en docs/PLAN_MEJORA_RAG.md §2.3.
|
| 33 |
+
tactics:
|
| 34 |
+
- {rag: "grind +lax [{premises}]", plain: "grind"}
|
| 35 |
+
- {rag: "nlinarith [{hints}]", plain: "nlinarith"}
|
| 36 |
+
- {rag: "grind +suggestions", plain: null} # canal B: selección nativa de Lean (Sine Qua Non)
|
| 37 |
+
- {rag: "try?", plain: "try?"}
|
| 38 |
+
|
| 39 |
+
# Demostrador especializado local (docs/PLAN_REDISENO_PROVER.md): Goedel-Prover-V2-8B en la GPU vía
|
| 40 |
+
# llama-server (puerto 8082). Etapa 0: k_root muestras sobre el teorema completo (0 API); en CLOSE, los
|
| 41 |
+
# goals que la batería no cierra se le piden como lemas (k_goal) antes de FILL. `rag_names`: en la
|
| 42 |
+
# autocorrección, el RAG sugiere nombres que existen en el Mathlib fijado para los identificadores desconocidos.
|
| 43 |
+
prover:
|
| 44 |
+
enabled: true
|
| 45 |
+
k_root: 8
|
| 46 |
+
k_goal: 2
|
| 47 |
+
max_goals: 2 # goals por intento que se le piden al demostrador (cada muestra son minutos en la GPU)
|
| 48 |
+
max_tokens: 11500 # slot de 12 288 tokens en el servidor (Q6_K, 8 slots; la GPU satura en ~70 tok/s agregados)
|
| 49 |
+
temperature: 0.8
|
| 50 |
+
correction_rounds: 1
|
| 51 |
+
rag_names: true
|
| 52 |
+
# Respaldo por API: si el demostrador no resuelve, ¿corre el bucle de agentes (PLAN → … → CRITIQUE)?
|
| 53 |
+
# Apagado: en eval-v3 costó US$0.06 en los 9 problemas no resueltos y no resolvió ninguno. Sin
|
| 54 |
+
# demostrador (servidor caído o `enabled: false`) los agentes corren siempre.
|
| 55 |
+
api_fallback: false
|
| 56 |
+
# DRAFT (Draft-Sketch-Prove): si la etapa 0 falla, el modelo de la API (`llm_draft`, con razonamiento)
|
| 57 |
+
# escribe plan + prueba informal y el demostrador recibe eso y `k_lemmas` lemas del RAG EN SU PROMPT
|
| 58 |
+
# (`k_draft` muestras). El prompt crece ~1-2k tokens: el servidor necesita slots de 16 384 (`--parallel 6`).
|
| 59 |
+
dsp: false
|
| 60 |
+
k_draft: 8 # 8 + 8 = 16 muestras; se compara con las primeras 16 de baseline_prover32 (mismas semillas, misma caché)
|
| 61 |
+
k_lemmas: 10
|
| 62 |
+
|
| 63 |
+
llm_supports_vision: false # imágenes de figuras en el prompt del Generador (sólo descripciones si false)
|
| 64 |
+
# Self-consistency del Generador (propuesta §6.3): n bocetos y se elige el "medoide" (el más parecido
|
| 65 |
+
# a los demás por solapamiento de tokens); cuesta n llamadas por intento. 1 = apagado (presupuesto RNF-3).
|
| 66 |
+
generator_samples: 1
|
| 67 |
+
sketch_max_tokens: 40000 # SKETCH (texto + razonamiento): con los 16 000 de `llm_draft`, 32 de 38 llamadas de eval-v4 se cortaron razonando, sin bloque Lean (#128)
|
| 68 |
+
|
| 69 |
+
# Configuraciones de ablación (propuesta §8.2). Cada una sobreescribe claves de arriba.
|
| 70 |
+
configs:
|
| 71 |
+
full: {}
|
| 72 |
+
no_rag: {rag: false} # misma batería CLOSE y mismo demostrador, sin premisas recuperadas, ejemplares ni sugerencias de nombres
|
| 73 |
+
no_critic: {k_max: 1}
|
| 74 |
+
rag_nl: {goal_mode: false} # el flujo de eval-v1: recuperación NL por subobjetivo y prueba entera
|
| 75 |
+
baseline_auto: {mode: baseline_auto} # 0 LLM: sólo la batería CLOSE (sin premisas) sobre el goal raíz
|
| 76 |
+
baseline_prover: {mode: baseline_prover} # 0 API: sólo el demostrador local (k_root + autocorrección con errores de Lean, sin RAG)
|
| 77 |
+
baseline_prover32: {mode: baseline_prover, prover: {k_root: 32}} # control de DRAFT: mismo presupuesto de muestras (8 + 24) sin plan ni lemas
|
| 78 |
+
dsp: {prover: {dsp: true}} # etapa 0 + DRAFT (plan y prueba informal de la API + lemas del RAG en el prompt del demostrador)
|
| 79 |
+
# Para data/eval/problems/pdf_set.jsonl (sale del PDF del corpus informal): sin ejemplares informales, que
|
| 80 |
+
# traerían la solución del propio problema. Control: baseline_prover16 (mismas 8 + 8 muestras).
|
| 81 |
+
baseline_prover16: {mode: baseline_prover, prover: {k_root: 16}}
|
| 82 |
+
dsp8: {prover: {dsp: true}, corpora: ["mathlib"]}
|
| 83 |
+
# REPAIR (0 API): la prueba fallida del demostrador con menos errores se parte en sus `have`; sus propios bloques,
|
| 84 |
+
# la batería y el demostrador sobre el lema corto (4 pasos × 4 muestras) cierran los pasos que fallan
|
| 85 |
+
repair: {prover: {repair: 2, max_goals: 4, k_goal: 4}}
|
| 86 |
+
# SKETCH: además, el modelo con razonamiento (`llm_draft`) escribe el esqueleto Lean en pasos `have … := by sorry`
|
| 87 |
+
# (texto, no JSON) y CLOSE + demostrador cierran cada paso; 2 rondas (la 2.ª ve los pasos que quedaron abiertos)
|
| 88 |
+
sketch: {prover: {repair: 2, sketch: 2, max_goals: 4, k_goal: 4}}
|
| 89 |
+
# RAG de pruebas (rag/proofs.py): las pruebas verificadas de los 3 problemas más parecidos de Lean Workbook
|
| 90 |
+
# (embeddings), primero tal cual y luego como ejemplos en el prompt del demostrador (8 + 8; control: baseline_prover16)
|
| 91 |
+
rag_proofs: {prover: {examples: 3, k_examples: 8, max_sim: 0.95}}
|
| 92 |
+
baseline_a: {mode: baseline_a} # LLM único: prueba Lean directa, sin agentes
|
| 93 |
+
baseline_b: {mode: baseline_b} # LLM único: CoT en lenguaje natural, sin verificación
|
| 94 |
+
|
| 95 |
+
prompts:
|
| 96 |
+
system: |
|
| 97 |
+
You are part of a multi-agent system that solves olympiad-level mathematics problems and certifies
|
| 98 |
+
the solutions with Lean 4 + Mathlib (tag v4.28.0-rc1). Be precise and terse. Only reference Mathlib
|
| 99 |
+
declarations that you are sure exist or that appear in the provided context. Answer in English.
|
| 100 |
+
planner: |
|
| 101 |
+
Decompose the problem into an ordered list of 1-5 subgoals (chain-of-thought), each one a claim that
|
| 102 |
+
a proof would establish on the way to the final statement. For each subgoal give: a natural-language
|
| 103 |
+
statement, a Lean-flavoured formal hint (informal, e.g. "n^2 % 4 = 0 ∨ n^2 % 4 = 1"), 2-3 short search
|
| 104 |
+
queries to find Mathlib lemmas for it (name the objects and the property: "gcd commutative", "sum of
|
| 105 |
+
consecutive integers", "prime divides product"), and its math area
|
| 106 |
+
(algebra | number_theory | combinatorics | geometry | inequalities | analysis).
|
| 107 |
+
|
| 108 |
+
## Problem (natural language)
|
| 109 |
+
{informal}
|
| 110 |
+
|
| 111 |
+
## Formal statement (Lean 4)
|
| 112 |
+
{formal}
|
| 113 |
+
|
| 114 |
+
## Similar solved problems (for analogy; cite ids if useful)
|
| 115 |
+
{exemplars}
|
| 116 |
+
|
| 117 |
+
## Replan feedback (why the previous plan failed and what is already proved; "(none)" on the first plan)
|
| 118 |
+
{feedback}
|
| 119 |
+
generator: |
|
| 120 |
+
Write a complete proof sketch in natural language for the problem, following the plan. Use the
|
| 121 |
+
retrieved Mathlib lemmas when they apply and say which ones you use by their ids (M1, M2, ...).
|
| 122 |
+
Use the worked examples only for the idea (ids I1, I2, ...). Be explicit about every algebraic step
|
| 123 |
+
so that a formalizer can turn each step into Lean tactics. The `sketch` field must contain that whole
|
| 124 |
+
proof written out, not a remark about which lemmas you use. If previous feedback is given, fix exactly
|
| 125 |
+
what it says.
|
| 126 |
+
|
| 127 |
+
## Problem
|
| 128 |
+
{informal}
|
| 129 |
+
|
| 130 |
+
## Formal statement (Lean 4)
|
| 131 |
+
{formal}
|
| 132 |
+
|
| 133 |
+
## Plan
|
| 134 |
+
{plan}
|
| 135 |
+
|
| 136 |
+
## Retrieved Mathlib lemmas
|
| 137 |
+
{lemmas}
|
| 138 |
+
|
| 139 |
+
## Similar solved problems
|
| 140 |
+
{exemplars}
|
| 141 |
+
|
| 142 |
+
## Feedback from the previous attempt
|
| 143 |
+
{feedback}
|
| 144 |
+
formalizer: |
|
| 145 |
+
Translate the proof sketch into Lean 4 tactics for the theorem below. Output ONLY the tactic block
|
| 146 |
+
that goes after `:= by` (do not repeat the theorem statement, do not add imports, do not use `sorry`,
|
| 147 |
+
`admit` or `axiom`). Prefer robust tactics (`nlinarith`, `linarith`, `norm_num`, `omega`, `simp`,
|
| 148 |
+
`ring_nf`, `positivity`, `decide`, `interval_cases`, `rcases`, `constructor`, `refine`) and the exact
|
| 149 |
+
names and signatures of the retrieved lemmas. Intermediate claims go in `have` steps. Mathlib is
|
| 150 |
+
imported (`import Mathlib`). If a previous Lean error is given, repair the proof accordingly.
|
| 151 |
+
|
| 152 |
+
## Theorem
|
| 153 |
+
{formal}
|
| 154 |
+
|
| 155 |
+
## Proof sketch
|
| 156 |
+
{sketch}
|
| 157 |
+
|
| 158 |
+
## Retrieved Mathlib lemmas (exact names and signatures)
|
| 159 |
+
{lemmas}
|
| 160 |
+
|
| 161 |
+
## Lean error from the previous attempt
|
| 162 |
+
{lean_error}
|
| 163 |
+
formalizer_skeleton: |
|
| 164 |
+
Translate the proof sketch into a Lean 4 proof SKELETON for the theorem below. Output ONLY the tactic
|
| 165 |
+
block that goes after `:= by` (do not repeat the theorem statement, do not add imports). Write each
|
| 166 |
+
intermediate claim of the sketch as its own top-level step `have hᵢ : <claim> := by <tactics>`, then
|
| 167 |
+
close the main goal from the `have`s. Keep each claim short; each step is checked by Lean on its own, and
|
| 168 |
+
a step that fails is retried with automation (`nlinarith`, `grind`, `omega`) and retrieved lemmas, so a
|
| 169 |
+
short claim with a simple proof is better than a long one. If you do not know how to prove a step, write
|
| 170 |
+
`sorry` as its proof (only as the whole proof of a `have`, never `<;> sorry` or `all_goals sorry`).
|
| 171 |
+
Mathlib is imported.
|
| 172 |
+
|
| 173 |
+
## Theorem
|
| 174 |
+
{formal}
|
| 175 |
+
|
| 176 |
+
## Proof sketch
|
| 177 |
+
{sketch}
|
| 178 |
+
|
| 179 |
+
## Retrieved Mathlib lemmas (exact names and signatures)
|
| 180 |
+
{lemmas}
|
| 181 |
+
|
| 182 |
+
## Claims already proved in previous attempts (keep these `have` statements verbatim; their proofs are reused)
|
| 183 |
+
{proved}
|
| 184 |
+
|
| 185 |
+
## Lean error from the previous attempt
|
| 186 |
+
{lean_error}
|
| 187 |
+
sketcher: |
|
| 188 |
+
Write a Lean 4 proof skeleton (Mathlib, tag v4.28.0-rc1) for the theorem below. First work out the
|
| 189 |
+
mathematical proof. Then split it into small intermediate claims, each one a top-level
|
| 190 |
+
`have name : statement := by sorry` that is easy to prove on its own: one computation, one inequality,
|
| 191 |
+
one case, one induction. State general facts with ∀ (e.g. a closed form proved by induction) and derive
|
| 192 |
+
the specific statement from them. After the `have` steps, close the goal with tactics that use them
|
| 193 |
+
(`linarith`, `nlinarith [...]`, `omega`, `simp [...]`, `norm_num [...]`, `exact ...`). Keep every `have` at
|
| 194 |
+
the top level of the proof (not inside `cases` or `induction` branches). Output exactly one ```lean4 code
|
| 195 |
+
block with the complete theorem (same name and statement), without imports.
|
| 196 |
+
Informal statement:
|
| 197 |
+
{informal}
|
| 198 |
+
Lean statement:
|
| 199 |
+
{formal}
|
| 200 |
+
Feedback on your previous skeleton:
|
| 201 |
+
{feedback}
|
| 202 |
+
fill: |
|
| 203 |
+
Prove each open Lean 4 goal below. Each goal lists its hypotheses and, after `⊢`, its target. For each
|
| 204 |
+
goal output the tactic block that proves it completely: it replaces a `sorry` exactly at that goal. Use
|
| 205 |
+
the listed lemmas (exact names and signatures) when they help. Automation (grind, nlinarith, try?)
|
| 206 |
+
already failed on these goals; its last error is shown. Do not use `sorry`.
|
| 207 |
+
|
| 208 |
+
## Theorem
|
| 209 |
+
{formal}
|
| 210 |
+
|
| 211 |
+
## Open goals
|
| 212 |
+
{goals}
|
| 213 |
+
critic: |
|
| 214 |
+
The Lean 4 kernel rejected the proof. Classify the failure and decide the next action.
|
| 215 |
+
error_type: lean_syntax (parse/tactic misuse) | missing_lemma (unknown identifier or a needed lemma
|
| 216 |
+
not available) | misformalization (the sketch does not match the formal statement) | timeout |
|
| 217 |
+
planning (the plan itself is wrong) | unknown.
|
| 218 |
+
action: retry (fix generation/formalization with your feedback) | replan (the decomposition is wrong)
|
| 219 |
+
| abandon (no reasonable fix). List any identifiers that Lean reported as unknown. Give concrete,
|
| 220 |
+
actionable feedback (which step, what to change, which tactic).
|
| 221 |
+
|
| 222 |
+
## Theorem
|
| 223 |
+
{formal}
|
| 224 |
+
|
| 225 |
+
## Proof sketch
|
| 226 |
+
{sketch}
|
| 227 |
+
|
| 228 |
+
## Lean proof attempted
|
| 229 |
+
{lean_code}
|
| 230 |
+
|
| 231 |
+
## Lean errors
|
| 232 |
+
{lean_error}
|
| 233 |
+
|
| 234 |
+
## History of attempts
|
| 235 |
+
{history}
|
| 236 |
+
baseline_a: |
|
| 237 |
+
Prove the following theorem in Lean 4 with Mathlib. Output ONLY the tactic block that goes after
|
| 238 |
+
`:= by` (no statement, no imports, no `sorry`).
|
| 239 |
+
|
| 240 |
+
## Theorem
|
| 241 |
+
{formal}
|
| 242 |
+
|
| 243 |
+
## Problem (natural language)
|
| 244 |
+
{informal}
|
| 245 |
+
baseline_b: |
|
| 246 |
+
Solve the following problem with a careful chain-of-thought proof in natural language. Then judge
|
| 247 |
+
honestly whether your proof is complete and correct (self_assessed_correct).
|
| 248 |
+
|
| 249 |
+
## Problem
|
| 250 |
+
{informal}
|
configs/ingest.yaml
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Configuración de ingesta. Sólo la sección `mathlib` se usa en Fase 1;
|
| 2 |
+
# la sección `pdf` se completa en Fase 2 (docs/PLAN_RAG.md §6.2).
|
| 3 |
+
|
| 4 |
+
mathlib:
|
| 5 |
+
raw_jsonl: "data/corpus/_raw/lsv2-mathlib-v4.28.0-rc1.jsonl"
|
| 6 |
+
out_jsonl: "data/corpus/mathlib.jsonl"
|
| 7 |
+
doc_id: "mathlib-v4.28.0-rc1"
|
| 8 |
+
docs_url_base: "https://leanprover-community.github.io/mathlib4_docs"
|
| 9 |
+
# Filtro Fase 1, tarea 3 (docs/PLAN_RAG.md): excluir ruido antes de embeber.
|
| 10 |
+
exclude_kinds: ["instance"]
|
| 11 |
+
exclude_module_prefixes: ["Mathlib.Tactic", "Mathlib.Deprecated"]
|
| 12 |
+
exclude_name_substrings: [".proof_", ".match_", "_aux"]
|
| 13 |
+
exclude_name_regex: '\.eq_(\d+|def)$' # antes ".eq_" (subcadena) también borraba lemas reales
|
| 14 |
+
|
| 15 |
+
pdf:
|
| 16 |
+
render_dpi: 200
|
| 17 |
+
# Calibrado con datos reales sobre problemas resueltos olimpiadas.pdf (docs/DECISIONS.md):
|
| 18 |
+
# filtra por tamaño mínimo del cluster (ambas dimensiones), no por cantidad de trazos.
|
| 19 |
+
vector_cluster_min_size_pt: 15.0
|
| 20 |
+
vector_cluster_min_overlap: 0.6
|
| 21 |
+
figure_crop_padding_pt: 10.0
|
| 22 |
+
# Regiones con >= N palabras de la capa de texto fuera de todo bloque de MinerU
|
| 23 |
+
# se transcriben con el VLM (Plan B acotado, docs/PLAN_RAG.md Fase 2).
|
| 24 |
+
gap_min_words: 4
|
| 25 |
+
|
| 26 |
+
# Fase 2, tarea 6 — prompts fijos y versionados (docs/PLAN_RAG.md §6.2). Cambiar
|
| 27 |
+
# `prompt_version` invalida la caché de data/parsed/<doc_id>/enrich/*.jsonl.
|
| 28 |
+
enrich:
|
| 29 |
+
prompt_version: "1"
|
| 30 |
+
math_areas: [algebra, number_theory, combinatorics, geometry, inequalities, analysis, probability, logic, other]
|
| 31 |
+
techniques: [induction, pigeonhole, invariant, extremal_principle, parity, modular_arithmetic, vieta_jumping,
|
| 32 |
+
am_gm, cauchy_schwarz, rearrangement, telescoping, generating_functions, bijection,
|
| 33 |
+
double_counting, angle_chasing, similar_triangles, power_of_a_point, coordinates,
|
| 34 |
+
trigonometry, algebraic_manipulation, factorization, bounding, case_analysis, contradiction,
|
| 35 |
+
construction, recursion, symmetry, counting]
|
| 36 |
+
transcribe: |
|
| 37 |
+
Transcribe this fragment of a Spanish mathematics book exactly as it appears, as Markdown with LaTeX.
|
| 38 |
+
Rules: inline math in $...$; displayed equations in $$...$$ on their own lines; keep the original Spanish text;
|
| 39 |
+
if a line starts with an item number such as "77." keep it at the start of the line; underbraces, dots and
|
| 40 |
+
cancellations must be rendered in LaTeX. The crop may cut through a line of text at its top or bottom edge:
|
| 41 |
+
skip any line that is not completely visible. Output only the transcription, no commentary.
|
| 42 |
+
figure: |
|
| 43 |
+
You are annotating a figure from a Spanish olympiad problem book for a retrieval system. The figure has no
|
| 44 |
+
caption; use the problem (and solution, if given) as context to name the objects correctly.
|
| 45 |
+
Describe the attached figure in English for a reader who cannot see it. Be concrete: name every visible label,
|
| 46 |
+
every geometric object, the relations among them (tangency, perpendicularity, inscribed, midpoint, ...) and
|
| 47 |
+
every value written in the figure (angles, lengths, areas). Do not solve the problem.
|
| 48 |
+
figure_type: geometric_diagram | grid | plot | table_image | other.
|
| 49 |
+
formulas: |
|
| 50 |
+
The list below contains LaTeX extracted by OCR for the formulas on the attached page, in reading order
|
| 51 |
+
(displayed and inline formulas). Compare each item against the page image. Return the same number of items in
|
| 52 |
+
the same order. Keep the original LaTeX EXACTLY unless it misrepresents the mathematics in the image
|
| 53 |
+
(wrong or missing exponent, subscript, digit, symbol or operator; garbled text). Do not reformat, do not
|
| 54 |
+
change spacing, do not translate. The boundaries of each item are fixed: the plain text before and after a
|
| 55 |
+
formula is NOT part of it — never extend an item with neighbouring words, units or the next formula, even if
|
| 56 |
+
they belong together mathematically. If an item contains garbled non-math text, remove the garbage and keep
|
| 57 |
+
only the formula. Mark changed=true only for items you modified.
|
| 58 |
+
card: |
|
| 59 |
+
You are indexing a solved problem from a Spanish olympiad problem book for a retrieval system whose queries
|
| 60 |
+
are in English. Read the problem, its solution and the figure descriptions (if any) and return, in English:
|
| 61 |
+
- context_summary: 2-3 sentences situating this problem for retrieval: what is asked, the mathematical area,
|
| 62 |
+
the key idea of the solution and the main theorems or techniques used (Contextual Retrieval style).
|
| 63 |
+
- math_area: one or more of {math_areas}.
|
| 64 |
+
- techniques: from {techniques}; add others in snake_case only if none fits.
|
| 65 |
+
- theorems_used: standard English names of the theorems/results used (e.g. "inscribed angle theorem").
|
| 66 |
+
- difficulty: integer 1 (routine) to 5 (hard olympiad).
|
| 67 |
+
- keywords: 6-12 English keywords for lexical search (objects, concepts, named results).
|
| 68 |
+
split: |
|
| 69 |
+
The text below contains the solutions to problems {prev} and {n} of a Spanish problem book, concatenated,
|
| 70 |
+
because the OCR lost the "{n}." marker at the start of solution {n}. Using the two problem statements as a
|
| 71 |
+
guide, identify where solution {n} begins and return the first line of solution {n} copied VERBATIM from the
|
| 72 |
+
text (including any LaTeX, exactly as written). If solution {n} starts with a displayed equation, return the
|
| 73 |
+
LaTeX line inside the $$ block, never the "$$" delimiter itself. If solution {n} is not present, return an
|
| 74 |
+
empty string.
|
configs/retrieval.yaml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fase 3 — servicio de recuperación (docs/PLAN_RAG.md §6.3, §8, Fase 4 tarea 7).
|
| 2 |
+
# Los valores por consulta (k, n_candidates, rerank) los fija RetrievalRequest;
|
| 3 |
+
# aquí van las plantillas por modo y los flags de ablación que aplica el orquestador.
|
| 4 |
+
|
| 5 |
+
rrf_k: 60
|
| 6 |
+
# 0 = sin límite. Evita que un módulo de Mathlib con muchas variantes del mismo
|
| 7 |
+
# lema desplace a lemas de otros módulos (docs/PLAN_RAG.md §6.3, "opcional").
|
| 8 |
+
max_per_module: 0
|
| 9 |
+
|
| 10 |
+
# Instrucción de consulta de Qwen3-Embedding ("Instruct: ...\nQuery: ..."). Los
|
| 11 |
+
# documentos se embebieron SIN instrucción, así que cambiar esto no obliga a
|
| 12 |
+
# re-indexar. `nl` es la misma instrucción con la que se midió la Fase 1.
|
| 13 |
+
query_instructions:
|
| 14 |
+
nl: "Given a mathematical query, retrieve relevant Mathlib declarations or worked problems."
|
| 15 |
+
formal: "Given a Lean 4 goal state or theorem statement, retrieve Mathlib declarations whose statements match it."
|
| 16 |
+
error: "Given a Lean 4 error message and goal, retrieve the Mathlib declaration it refers to or the closest alternatives."
|
| 17 |
+
exemplar: "Given a competition math problem, retrieve solved problems that use the same idea or technique."
|
| 18 |
+
|
| 19 |
+
# Flags de ablación (docs/PLAN_RAG.md Fase 4, tarea 7; métrica 8.3 "contribución del RAG").
|
| 20 |
+
# enabled=false -> RETRIEVE devuelve vacío y la traza lo registra igual.
|
| 21 |
+
ablation:
|
| 22 |
+
enabled: true
|
| 23 |
+
corpora: [mathlib, informal]
|
configs/versions.yaml
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fuente única de verdad de versiones (RNF-2, docs/PLAN_RAG.md §0/§9).
|
| 2 |
+
# Todo evento JSONL de traza (rag/schema.py:TraceEvent) copia este bloque.
|
| 3 |
+
# ACTUALIZAR este archivo, no hardcodear versiones en el código.
|
| 4 |
+
|
| 5 |
+
lean:
|
| 6 |
+
toolchain: "leanprover/lean4:v4.28.0-rc1"
|
| 7 |
+
mathlib_tag: "v4.28.0-rc1"
|
| 8 |
+
mathlib_commit: "5352afccd6866369be9de43f5b7ec47203555f44"
|
| 9 |
+
|
| 10 |
+
embedding:
|
| 11 |
+
model: "Qwen/Qwen3-Embedding-0.6B"
|
| 12 |
+
dim: 1024
|
| 13 |
+
# subir a Qwen/Qwen3-Embedding-4B sólo si Fase 1 muestra ganancia medible en MathlibQR (ver §7 del plan)
|
| 14 |
+
|
| 15 |
+
reranker:
|
| 16 |
+
model: "Qwen/Qwen3-Reranker-0.6B"
|
| 17 |
+
|
| 18 |
+
parser:
|
| 19 |
+
name: "mineru"
|
| 20 |
+
version: "4.0.3"
|
| 21 |
+
tier: "standard"
|
| 22 |
+
|
| 23 |
+
# Proveedor LLM/VLM (ragsolver.llm.LLM). `provider: gemini` usa GEMINI_API_KEY (.env);
|
| 24 |
+
# `provider: openai_compatible` usa `base_url` + la variable de `api_key_env` — sirve para
|
| 25 |
+
# OpenRouter (https://openrouter.ai/api/v1, OPENROUTER_API_KEY), OpenAI, Ollama o vLLM.
|
| 26 |
+
# La cuota diaria del tier gratis de Gemini es por modelo (20 req/día en 3.5-flash, medido):
|
| 27 |
+
# al agotarse se pasa al siguiente de `fallback_models`; cada resultado registra el modelo real.
|
| 28 |
+
vlm_enrichment:
|
| 29 |
+
provider: "gemini"
|
| 30 |
+
model: "gemini-3.5-flash" # visión + JSON estructurado, verificado (docs/DECISIONS.md #13, #21)
|
| 31 |
+
fallback_models: ["gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemma-4-31b-it", "gemma-4-26b-a4b-it", "gemini-3-flash-preview"]
|
| 32 |
+
temperature: 0.1
|
| 33 |
+
seed: 13
|
| 34 |
+
# provider: "openai_compatible"
|
| 35 |
+
# base_url: "https://openrouter.ai/api/v1"
|
| 36 |
+
# api_key_env: "OPENROUTER_API_KEY"
|
| 37 |
+
# model: "google/gemini-2.5-flash"
|
| 38 |
+
|
| 39 |
+
llm: # agentes (Fase 4). Experimento principal: UN solo modelo para las 5 configuraciones (sin confundir modelo y configuración)
|
| 40 |
+
provider: "openai_compatible" # OpenRouter (docs/DECISIONS.md #47); tope de gasto fijado en la cuenta
|
| 41 |
+
base_url: "https://openrouter.ai/api/v1"
|
| 42 |
+
api_key_env: "OPENROUTER_API_KEY"
|
| 43 |
+
model: "deepseek/deepseek-v4-flash-0731" # $0.04/M in, $0.16/M out; JSON schema verificado
|
| 44 |
+
fallback_models: ["google/gemini-2.5-flash-lite"]
|
| 45 |
+
temperature: 0.2
|
| 46 |
+
seed: 13 # RNF-2; determinismo "best effort" del proveedor
|
| 47 |
+
max_tokens: 4000 # salida sin razonamiento; acota costo y latencia por llamada
|
| 48 |
+
reasoning_effort: "off" # DeepSeek V4 Flash: planner 24 s sin razonar vs 76-92 s con low/medium (60×5 pares no cabrían en una noche)
|
| 49 |
+
timeout_s: 900
|
| 50 |
+
# OpenRouter: tope de precio por M tokens y, entre los que cumplen, el más barato (`sort: price`; #64 lo
|
| 51 |
+
# cambió de `sort: throughput` porque a igual tope de precio el más rápido no siempre es el más barato).
|
| 52 |
+
# `max_price` solo (sin `sort`) ya habría evitado el proveedor a $0.80/M de salida del #62.
|
| 53 |
+
# 2026-10-14 (#107): con {0.10, 0.20} sólo calificaba DeepInfra (StreamLake subió a $0.132/$0.396), saturado (429).
|
| 54 |
+
# Con {0.13, 0.30}: 8 proveedores; `sort: price` sigue usando primero DeepInfra ($0.06/$0.18) y pasa a los demás
|
| 55 |
+
# sólo cuando rechaza. eval-v1 corrió con el tope anterior.
|
| 56 |
+
provider_routing: {max_price: {prompt: 0.13, completion: 0.30}, sort: price}
|
| 57 |
+
# Alternativa gratuita usada en el desarrollo (cuota 20 req/día por modelo):
|
| 58 |
+
# provider: "gemini"; model: "gemini-3.5-flash"; fallback_models: ["gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemma-4-31b-it", "gemma-4-26b-a4b-it", "gemini-3-flash-preview"]
|
| 59 |
+
|
| 60 |
+
# Borrador de DRAFT (Draft-Sketch-Prove, configs/agents.yaml `prover.dsp`): el mismo modelo CON razonamiento.
|
| 61 |
+
# Sin razonar, un planner tarda 24 s y con razonamiento 76-92 s (#50); aquí la latencia no importa (cada
|
| 62 |
+
# muestra del demostrador son minutos de GPU) y el razonamiento es justo lo que este modelo aporta.
|
| 63 |
+
# `max_tokens` incluye el razonamiento; 16 000 a ≤ US$0.30/M ≈ US$0.005 por llamada en el peor caso.
|
| 64 |
+
llm_draft:
|
| 65 |
+
provider: "openai_compatible"
|
| 66 |
+
base_url: "https://openrouter.ai/api/v1"
|
| 67 |
+
api_key_env: "OPENROUTER_API_KEY"
|
| 68 |
+
model: "deepseek/deepseek-v4-flash-0731"
|
| 69 |
+
fallback_models: []
|
| 70 |
+
temperature: 0.2
|
| 71 |
+
seed: 13
|
| 72 |
+
max_tokens: 16000
|
| 73 |
+
reasoning_effort: "high"
|
| 74 |
+
timeout_s: 1800 # SKETCH pide hasta `sketch_max_tokens` (agents.yaml) de salida
|
| 75 |
+
provider_routing: {max_price: {prompt: 0.13, completion: 0.30}, sort: price}
|
| 76 |
+
|
| 77 |
+
index:
|
| 78 |
+
backend: "lancedb"
|
| 79 |
+
version: "0.1.0" # semver del índice; incrementar si cambia embedding_model o esquema de chunk
|
| 80 |
+
|
| 81 |
+
corpus_mathlib:
|
| 82 |
+
source: "FrenzyMath/lsv2-mathlib-v4.28.0-rc1-jsonl"
|
| 83 |
+
license: "Apache-2.0"
|