mathpix-ocr
БесплатноБез исполняемых скриптовНе проверенMathpix OCR for LaTeX extraction with balanced ternary checkpoints
от plurigrid★ 73 звезды на GitHubОб этом скилле
mathpix-ocr - Balanced Ternary OCR Pipeline for LaTeX → ACSet Extraction
Overview
Integrates TeglonLabs/mathpix-gem for mathematical OCR with the music-topos ACSet parallel rewriting system. Uses seed 1069 balanced ternary checkpoints for resilient PDF batch processing.
The 1069 Connection
mathpix-gem shares our canonical seed:
# From mathpix-gem/lib/mathpix/balanced_ternary.rb
# 1×3⁶ - 1×3⁵ - 1×3⁴ + 1×3³ + 1×3² + 1×3¹ + 1×3⁰ = 1069
SEED_1069_PATTERN = [+1, -1, -1, +1, +1, +1, +1].freeze
# Semantics progression:
# +1 (high confidence) → -1 (descent) → -1 (exploration) →
# +1 (recovery) → +1 (convergence) → +1 (stability) → +1 (completion)
This maps directly to our TAP states and GF(3) arithmetic.
Architecture
┌─────────────────────────────────────────────────────────────────────────────┐
│ Mathpix OCR → ACSet Pipeline │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ PDF/Image Balanced Ternary ACSet Schema │
│ │ Checkpoints │ │
│ ▼ │ ▼ │
│ ┌────────┐ ┌─────────────────┴─────────────────┐ ┌──────────────┐ │
│ │Mathpix │───▶│ +1 → -1 → -1 → +1 → +1 → +1 → +1 │───▶│ @present Sch │ │
│ │ OCR │ │ ─── ─── ─── ─── ─── ─── ─── │ │ Type::Ob │ │
│ └────────┘ │ 729 -243 -81 +27 +9 +3 +1 │ │ Term::Ob │ │
│ │ └─────────────────┬─────────────────┘ └──────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ LaTeX AST Confidence Colored ACSet │
│ (extracted) Sequence (with TAP states) │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
MCP Server Configuration
Add to .ruler/ruler.toml:
[mcp_servers.mathpix]
command = "ruby"
args = ["-I", "lib", "-r", "mathpix/mcp", "-e", "Mathpix::MCP.serve"]
env = { MATHPIX_APP_ID = "${MATHPIX_APP_ID}", MATHPIX_APP_KEY = "${MATHPIX_APP_KEY}" }
description = "Mathematical OCR with balanced ternary checkpoints"
Or via Claude MCP config:
{
"mcpServers": {
"mathpix": {
"command": "bundle",
"args": ["exec", "ruby", "-r", "mathpix", "-e", "Mathpix::MCP.serve"],
"env": {
"MATHPIX_APP_ID": "${MATHPIX_APP_ID}",
"MATHPIX_APP_KEY": "${MATHPIX_APP_KEY}",
"GF3_SEED": "1069"
}
}
}
}
MCP Tools Available
| Tool | Description | TAP State |
|---|---|---|
convert_image |
Single image → LaTeX | LIVE |
convert_document |
PDF/DOCX → structured output | LIVE |
batch_convert |
Multiple files with checkpoints | VERIFY |
check_batch_status |
Poll batch progress | VERIFY |
get_batch_results |
Retrieve completed batch | BACKFILL |
list_conversions |
History of all conversions | BACKFILL |
configure |
Update API settings | VERIFY |
health_check |
Test API connectivity | ERGODIC |
smart_pdf_batch |
Auto-chunked large PDFs | LIVE → VERIFY → BACKFILL |
LaTeX → ACSet Extraction
Type Structure Mapping
# rama_acset_parallel.jl integration
struct LHoTTMapping
latex::String
type_structure::Dict{Symbol, Any}
confidence::Float64
tap_state::TAPState
checkpoint_trit::Int # -1, 0, or +1
end
function mathpix_to_acset(latex::String, seed::UInt64=0x42D)
# Parse LaTeX to detect type-theoretic constructs
constructs = extract_constructs(latex)
# Create ACSet with colored parts
@acset LHoTTACSet begin
Type = length(constructs.types)
Term = length(constructs.terms)
typeof = constructs.type_assignments
# Color each part via SplitMix64
end
end
Construct Detection
# Ruby extraction layer
module Mathpix
class LHoTTExtractor
PATTERNS = {
dependent_type: /\\Pi.*?:\\s*\\mathsf\{Type\}/,
identity_type: /\\mathsf\{Id\}.*?\\left\(.*?\\right\)/,
transport: /\\mathsf\{transport\}/,
univalence: /\\mathsf\{ua\}/,
fibration: /\\to\\s*\\mathsf\{Type\}/
}.freeze
def extract(latex)
PATTERNS.map { |name, pattern|
{ construct: name, matches: latex.scan(pattern) }
}.reject { |r| r[:matches].empty? }
end
end
end
Balanced Ternary Checkpoints
For large PDFs, mathpix-gem uses 7-trit checkpoints:
class BatchProcessor
CHECKPOINT_PATTERN = BalancedTernary::SEED_1069_PATTERN
def process_with_checkpoints(pages)
pages.each_sli
Установить mathpix-ocr в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл mathpix-ocr?
Mathpix OCR for LaTeX extraction with balanced ternary checkpoints
Как установить скилл mathpix-ocr?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mathpix-ocr запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic