Skip to main content

Fast CDM utilities for LaTeX tokenization, rendering, and matching

Project description

🚀 Introduction

CDM ensures the objectivity and accuracy of evaluation by rendering predicted and ground-truth LaTeX formulas into images, and then using visual feature extraction and localization techniques to perform precise character-level matching, combined with spatial position information.

FastCDM aims to address performance issues. As a high-performance optimized version of the original CDM, FastCDM employs the browser-based KaTeX rendering engine instead of traditional LaTeX compilation, resulting in significantly improved speed.

🎯 Project Goals

The core objective of FastCDM is to provide a convenient user experience during the training process, helping to advance formula recognition tasks. We are committed to:

  • Providing simple and easy-to-use API interfaces for convenient integration of evaluation within the training loop.
  • Supporting both real-time evaluation and batch evaluation modes.
  • Providing visualization tools for evaluation metrics during the training process.

Why Choose FastCDM?

  1. Extreme Performance: Based on the KaTeX rendering engine, it is tens of times faster than the traditional LaTeX compilation process.
  2. Simplified Deployment: No need to install complex LaTeX environments (ImageMagick, texlive-full, etc.).
  3. Accurate Evaluation: Adopts character detection matching methods to avoid the unfairness issues associated with traditional text metrics.
  4. Continuous Optimization: Supplements and refines CDM symbol support, with continuous iterative improvements.
  5. Easy Integration: Provides a unified API interface for easy integration into various training frameworks. Future integration with mainstream training frameworks such as PyTorch and Transformers is planned.

⚠️ Note

Although KaTeX is extremely fast, it is a lightweight solution optimized for the Web and cannot support 100% of all obscure LaTeX syntax.

For the vast majority of standard formulas, it performs perfectly. This is a reasonable and sustainable technical choice.

You can check KaTeX's support coverage here: 🔗 KaTeX Support Table


Usage

Installation

pip install fastcdm

Quick Start

from fastcdm import FastCDM

chromedriver_path = "driver/chromedriver"

# Initialize FastCDM evaluator
evaluator = FastCDM(chromedriver_path=chromedriver_path)

# Evaluate
cdm_score, recall, precision = evaluator.compute(gt="E = mc^2", pred="E + 1 = mc^2", visualize=False)

# Evaluate and visualize
cdm_score, recall, precision, vis_img = evaluator.compute(gt="E = mc^2", pred="E + 1 = mc^2", visualize=True)

Interactive Demo

We provide a visualization Demo developed with Gradio, which you can try on HuggingFace Spaces. You can also launch it locally:

python3 scripts/app.py

Contribution and Feedback

We welcome all forms of contribution, including but not limited to:

  • Submitting issue reports
  • Suggesting improvements
  • Submitting code changes (please open an issue for discussion first)

Please contact us via the project's issues.


License

This project is open-sourced under the Apache 2.0 license. You are free to use, modify, and distribute the code of this project under the terms of the license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastcdm-0.1.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastcdm-0.1.1-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file fastcdm-0.1.1.tar.gz.

File metadata

  • Download URL: fastcdm-0.1.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for fastcdm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 eed6a0d67f5bc9d82bf5ce4f3b2fefed999ea012287a11026d801b26fa4c7337
MD5 e259ffff31f1f47086457856b665e580
BLAKE2b-256 621f6b2fe7be40ca96cb125c082d5c1e379d0ac47dc75a96cda81ed52cfddc38

See more details on using hashes here.

File details

Details for the file fastcdm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fastcdm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for fastcdm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec19218d4eeb2d9870726b3f7018b526d8c0e84abc8a8f95be36fa9e8a836b92
MD5 1e0c132b3ef558fa99d1fcc688f72466
BLAKE2b-256 3d2e6e4671110a26e29e40195e3cf000092dcfa447361883eb2d4aa1ccd0bc41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page