Scripts2026年7月4日·1 分钟阅读

OpenNMT-py — Open Source Neural Machine Translation in PyTorch

OpenNMT-py is a PyTorch-based toolkit for neural machine translation and sequence-to-sequence modeling, supporting Transformer, RNN, and large language model architectures with production-ready training and inference.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
OpenNMT-py
直接安装命令
npx -y tokrepo@latest install 348581fd-7761-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

OpenNMT is an open-source neural machine translation ecosystem started by Harvard NLP and SYSTRAN. The PyTorch version (OpenNMT-py) provides a flexible toolkit for training Transformer and RNN-based sequence-to-sequence models, and has expanded to support large language model fine-tuning and inference. It is used in research and production translation systems worldwide.

What OpenNMT-py Does

  • Train Transformer and RNN encoder-decoder models for translation
  • Fine-tune and serve large language models with LoRA/quantization support
  • Multi-GPU and distributed training with mixed-precision support
  • Beam search, random sampling, and constrained decoding for inference
  • Vocabulary building, data preprocessing, and tokenization pipelines

Architecture Overview

OpenNMT-py uses a modular architecture with configurable encoders, decoders, attention mechanisms, and generators. Configuration is YAML-driven, making experiments reproducible. The training loop supports gradient accumulation, learning rate scheduling, and checkpoint averaging. The inference server supports REST API translation with batching. Recent versions integrate CTranslate2 for optimized production inference.

Self-Hosting & Configuration

  • Install via pip: pip install OpenNMT-py
  • Requires Python 3.8+ and PyTorch
  • All configuration through YAML files for reproducibility
  • Multi-GPU training via PyTorch distributed data parallel
  • Production serving with the built-in REST translation server

Key Features

  • Full Transformer and RNN architectures with copy mechanism and coverage
  • LLM support for fine-tuning and inference with quantization
  • CTranslate2 integration for fast production-grade translation
  • SentencePiece and BPE tokenization built into the pipeline
  • Comprehensive documentation with step-by-step tutorials

Comparison with Similar Tools

  • Hugging Face Transformers — broader model hub; OpenNMT-py is optimized specifically for translation workflows
  • Fairseq — Meta's sequence modeling toolkit; OpenNMT-py has a simpler YAML-driven interface
  • MarianMT — lightweight C++ translation engine; OpenNMT-py offers more flexibility for research
  • Argos Translate — offline translation app; OpenNMT-py is the underlying training and model toolkit

FAQ

Q: Can I use OpenNMT-py for non-translation tasks? A: Yes. OpenNMT-py supports any sequence-to-sequence task including summarization, dialogue, and grammatical error correction.

Q: Does OpenNMT-py support LLM fine-tuning? A: Yes. Recent versions support LoRA adapters and quantization (4-bit, 8-bit) for fine-tuning large language models.

Q: How do I deploy a trained model? A: Use the built-in REST server or export to CTranslate2 format for optimized CPU/GPU inference in production.

Q: What tokenization does OpenNMT-py support? A: SentencePiece (unigram and BPE), BPE with subword-nmt, and character-level tokenization.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产