[Paper Review] imitation: Clean Imitation Learning Implementations
This paper introduces *imitation*, a modern, open-source Python library for imitation and reward learning in PyTorch, offering 7 well-tested, modular algorithms including GAIL, AIRL, BC, DAgger, and preference-based learning. It achieves expert-level performance across benchmark environments with 98% test coverage, type safety, and a consistent API, enabling reliable baselines and extensible research.
imitation provides open-source implementations of imitation and reward learning algorithms in PyTorch. We include three inverse reinforcement learning (IRL) algorithms, three imitation learning algorithms and a preference comparison algorithm. The implementations have been benchmarked against previous results, and automated tests cover 98% of the code. Moreover, the algorithms are implemented in a modular fashion, making it simple to develop novel algorithms in the framework. Our source code, including documentation and examples, is available at https://github.com/HumanCompatibleAI/imitation
Motivation & Objective
- To provide a modern, actively maintained, and well-tested library for imitation and reward learning algorithms to support reliable research.
- To address the lack of consistent, high-quality implementations of imitation learning algorithms that are often outdated, poorly documented, or built on deprecated frameworks.
- To enable researchers to easily compare, benchmark, and extend algorithms through a unified API and modular architecture.
- To ensure implementation reliability via comprehensive testing (98% coverage), static type checking, and standardized evaluation protocols.
- To support the development of novel algorithms by offering reusable components and extensible design patterns.
Proposed method
- Implement seven core algorithms—three IRL (MCE-IRL, density-based, AIRL), three imitation (BC, DAgger, GAIL), and one preference-based (DRLHP)—using PyTorch and Stable Baselines3.
- Design a consistent interface via a base class *BaseImitationAlgorithm*, enabling seamless comparison and configuration across all algorithms.
- Structure code into modular components: policy and reward networks, RL algorithms, optimizers, and rollout collection utilities, allowing independent configuration and extension.
- Subclass existing algorithms (e.g., GAIL and AIRL both inherit from *AdversarialTrainer*) to share training logic while differing only in discriminator design.
- Integrate automated testing (98% coverage), static type checking (via mypy/pytype), and configuration management via Sacred for reproducibility.
- Provide comprehensive documentation, examples, and evaluation best practices, including warnings about variable-horizon environments that can bias results.
Experimental results
Research questions
- RQ1Can a modern, well-documented, and well-tested library for imitation and reward learning improve reproducibility and reliability in RL research?
- RQ2How do the performance and stability of the implemented algorithms compare to prior results and to each other across standard benchmark environments?
- RQ3To what extent does modular, consistent API design facilitate the implementation and comparison of novel imitation learning algorithms?
- RQ4Can automated testing and type checking significantly reduce implementation bugs in complex RL codebases?
- RQ5How does the library’s design support both baseline evaluation and the development of new algorithms?
Key findings
- The *imitation* library achieves expert-level performance on most benchmark environments, with returns normalized to 1.0 for expert policies and 0.0 for random policies, demonstrating strong learning capability.
- All algorithms were benchmarked against prior results, confirming that the implementations reproduce state-of-the-art performance, except for AIRL on Ant and DAgger on Hopper, which may stem from environment differences rather than algorithmic failure.
- The test suite covers 98% of the codebase, and static type checking via mypy and pytype is applied throughout, significantly improving code reliability and maintainability.
- The library outperforms or matches all alternative implementations in key metrics: number of algorithms, project activity, test coverage, type safety, and extensibility, as shown in Table 1.
- The modular design allows users to freely swap policy networks, reward models, RL algorithms, and optimizers without code changes, enabling rapid experimentation and extension.
- The library is actively maintained, with 103 approved PRs in six months, and uses modern backends (PyTorch, Stable Baselines3), unlike many legacy libraries still relying on deprecated frameworks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.