# Repository Briefing: tensorflow/lingvo
> Source: https://repoforai.com/repo/tensorflow/lingvo (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/tensorflow/lingvo
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: B+ (73/100 · Maintenance 26/35 · Adoption 21/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Docker, GPU, CLI
- **Momentum**: 2,868 ★ total (+0 24h / +0 7d) · 452 forks
- **Topics**: `asr`, `distributed`, `gpu-computing`, `language-model`, `lm`, `machine-translation`, `mnist`, `nlp`, `research`, `seq2seq`, `speech`, `speech-recognition`
- **When to Use**: Best for: Research teams reproducing Lingvo-based speech, translation, or language-model experiments, or extending existing task configurations on controlled TensorFlow environments. Skip if: Your primary need is a production LLM inference endpoint, or you have no Lingvo code to reuse and want a simpler TensorFlow training stack.

## Overview
```text
### Architecture & Core Mechanics
Lingvo is a Python framework for building and training TensorFlow models, with an emphasis on sequence modeling. Task-specific parameter modules under `lingvo/tasks/` expose named model configurations selected through `--model`. The pip entry point is `python3 -m lingvo.trainer`; a source build produces `bazel-bin/lingvo/trainer`. In the MNIST workflow, `lingvo.tools.keras2ckpt` prepares the input data, the trainer runs synchronously on CPU, and a separate `--job=evaler_test` process uses the same log directory to evaluate saved checkpoints.

The log layout separates run inspection from checkpoint state. `control/` holds `params.txt`, per-layer size analysis in `model_analysis.txt`, the training TensorFlow GraphDef in `train.pbtxt`, and TensorBoard events. `train/` holds the checkpoint metadata and `ckpt-*` files. Users can develop new model configurations on top of the pip package; changing framework internals or implementing new custom ops is better done from source.

### Key Capabilities & Differentiators
Lingvo's value is in training configurations tied to specific research models. It includes LibriSpeech 960-hour grapheme and wordpiece ASR configurations; WMT14 English–German Transformer, RNMT, and XEnDec configurations; and a word-level language model using sampled softmax. The task library also includes LeNet5 for image classification, StarNet configurations for KITTI and Waymo, and Waymo DeepFusion for lidar–camera 3D detection.

The examples span local CPU training, larger machine translation runs on a GPU cluster, and training on Cloud TPU. The published GShard-related configuration `lm.synthetic_packed_input.DenseLm1T16x16` targets a one-trillion-parameter language model on Cloud TPU v3-512 with 512-way model parallelism. That is a specific training configuration with synthetic packed input, not an inference throughput benchmark or evidence that arbitrary models can use the same topology.

### Trade-offs & Limitations
Lingvo is most compelling when an existing research configuration saves more work than adopting its training conventions costs. For a new TensorFlow model without a Lingvo dependency, Keras is a more direct starting point. For an already-trained LLM that needs an online endpoint, a dedicated inference server is the better comparison: the Lingvo workflows here center on training, checkpointing, and evaluation rather than a request-serving API or serving performance targets.

The pip path keeps the framework fixed and is convenient for model-level customization. A Bazel build provides control over framework code and custom ops, but adds TensorFlow, compiler, and accelerator compatibility work. Backward compatibility is not guaranteed: the release history records changes to beam-search arguments and outputs, as well as layer variable initialization rules. Pin the environment and budget for migration tests rather than assuming a framework upgrade is a drop-in change.

### Hardware & Deployment Guide
Start with the pip package or the image defined by `docker/lib.dockerfile` to run the local MNIST workflow. For framework or custom-op changes, use Bazel and `docker/dev.Dockerfile` as the build-environment reference. The source setup lists TensorFlow 2.7 and g++ 7.3 as the officially supported compiler; the CPU build is `bazel build -c opt //lingvo:trainer`, and the GPU build adds `--config=cuda`. These are self-managed execution paths; the larger examples require provisioning the relevant GPU cluster or Cloud TPU resources.

Do not apply the source setup's TensorFlow version to every wheel. Release 0.11.0 required TensorFlow 2.7; 0.12.0 required 2.9 and supported up to TensorFlow 2.10 and Python 3.10. Version 0.14.0 added Python 3.11+ support, raised the minimum to Python 3.9, and dropped 3.8. Pin a known-working version and validate import, training, checkpoint restore, and evaluation on the target stack before committing to a larger run.
```

## Key Capabilities
```text
- Model selection: `--model` selects a task parameter class; the LeNet5 example uses `mnist.LeNet5` with pip and `image.mnist.LeNet5` with Bazel.
- Execution: `--run_locally=cpu --mode=sync` runs the local training example; `--job=evaler_test` selects test evaluation, normally in a separate process.
- Run artifacts: `logdir/control` contains parameters, layer-size analysis, a training GraphDef, and TensorBoard events; `logdir/train` holds checkpoint files and their index of saved checkpoints.
- Research configurations: LibriSpeech ASR, WMT English–German translation, LeNet5, and StarNet/DeepFusion 3D detection cover distinct task families.
- Distributed scale: `DenseLm1T16x16` is a trillion-parameter language-model configuration with synthetic packed input, targeting 512-way model parallelism on Cloud TPU v3-512.
- Build and packaging: pip installs a fixed framework version; a Bazel source build supports framework and custom-op changes, with separate Docker configurations for the two paths.
```

## Quick Start / Clone
```bash
cd /tmp/mnist
curl -O https://raw.githubusercontent.com/tensorflow/lingvo/master/lingvo/tasks/image/params/mnist.py
python3 -m lingvo.trainer --run_locally=cpu --mode=sync --model=mnist.LeNet5 --logdir=/tmp/mnist/log
```
