Skip to main content

Translate Latex articles through LLM and compile them into PDF

Project description

TransGPTex

Python Version License: MIT

TransGPTex 是一个用于将 LaTeX 文章翻译成中文(或者其他语言)并编译成 PDF 的工具。它通过使用大型语言模型 (LLM) 来实现高质量的翻译。

快速开始

20240719更新:openai推出了便宜的gpt-4o-mini模型,速度快、在latex方面效果也很不错,因此之后打算迁移到默认以gpt-4o-mini模型为翻译后端的版本。 20240719更新:openai推出了便宜的gpt-4o-mini模型,速度快、在latex方面效果也很不错,因此之后打算迁移到默认以gpt-4o-mini模型为翻译后端的版本。

目前可以直接这样使用gpt-4o-mini作为翻译LLM: 目前可以直接这样使用gpt-4o-mini作为翻译LLM:

# 申请llm api key,windows使用set,linux使用export
set LLM_API_KEY="申请的llm api key"

# 翻译,使用gpt-4o-mini模型
tgtex https://arxiv.org/abs/xxxx.xxxxx -o "paper title" -llm_model gpt-4o-mini -end_point {api端点 官方或者中转端点}

功能特性

  • 支持从 arXiv 直接下载 LaTeX 源码。
  • 支持翻译单个 LaTeX 文件或整个 LaTeX 项目。
  • 支持自定义翻译语言和翻译模型。
  • 支持编译生成 PDF 文件。

安装

pip install transgptex

快速开始

通过命令行:

# 设置API key
export LLM_API_KEY="glm api key"

# 从 arXiv 翻译并编译整个文章项目
tgtex https://arxiv.org/abs/paper_id -o output/path

# 翻译整个 LaTeX 项目
tgtex --own_tex_project -o output/path path/to/your/latex/project

# 翻译单个 LaTeX 文件
tgtex --single_tex -o output.tex path/to/your/latex/file.tex

# 获取帮助
tgtex -h

几个核心的配置:

  • llm_model: 选择使用的 LLM 模型,默认为 glm-4-air。
  • end_point: LLM 推理端点 URL,默认为 https://open.bigmodel.cn/api/paas/v4/。
  • qps: LLM API 的每秒查询数,默认为 5。
  • api_key: 请配置在环境变量LLM_API_KEY中。

如果使用其他模型可以修改llm_modelend_point来实现。比如使用deepseek-v2模型,则可以改为:

# 设置LLM API KEY
export LLM_API_KEY="deepseek api key"

# 调用deepseek模型进行翻译
tgtex https://arxiv.org/abs/paper_id -o output/path -llm_model deepseek-chat -end_point https://api.deepseek.com/v1

许可

TransGPTex 项目采用 MIT 许可证。

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

transgptex-0.0.9-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file transgptex-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: transgptex-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.7

File hashes

Hashes for transgptex-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f3ed0709569de754d9fd7c4882ed2b1fb32dcdd6ee972ae610c12e1217dd9b7f
MD5 40b861afc34e443d4bab841eb25e9a06
BLAKE2b-256 78b8f7cebb3f4127eda278d502e1661e099cb305f88ab4c2ec99f703a278142c

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