Keras library for Transformer models, aiming for clarity
Top 9.5% on sourcepulse
This library provides a clean and lightweight Keras implementation of Transformer models, primarily BERT, designed for ease of modification and customization. It targets researchers and developers needing to fine-tune, pre-train, or experiment with Transformer architectures within the Keras/TensorFlow ecosystem. The key benefit is a simplified codebase that supports loading various pre-trained weights and offers extensive examples for common NLP tasks.
How It Works
The project reimplements Transformer models in Keras, focusing on a clear and modular structure. It supports loading pre-trained weights from popular models like BERT, RoBERTa, ALBERT, and T5, facilitating transfer learning. The library handles essential components like attention masks and provides utilities for pre-training from scratch, including multi-GPU and TPU support. This approach aims to reduce dependencies and improve maintainability compared to more heavily encapsulated libraries.
Quick Start & Requirements
pip install bert4keras
pip install git+https://www.github.com/bojone/bert4keras.git
TF_KERAS=1
environment variable.tf.keras
.examples
directory for usage.Highlighted Details
Maintenance & Community
The project is actively maintained by Jianlin Su, with contributions welcomed. The author's blog is at https://kexue.fm/
, and online documentation is available at http://bert4keras.spaces.ac.cn/
. A PyTorch-based alternative, bert4torch
, is also mentioned.
Licensing & Compatibility
The library is available under an unspecified license. The README does not explicitly state licensing terms, which may require clarification for commercial use or closed-source integration.
Limitations & Caveats
Versions 0.2.4 and later only support Google's version of ALBERT weights or brightmart's ALBERT weights that explicitly mention "Google". Older brightmart ALBERT weights require version 0.2.3 or the author's converted albert_zh
. Support for Keras versions prior to 2.3.0 was dropped in late 2019.
8 months ago
Inactive