# bojone/bert4keras

keras implement of transformers for humans

Repository: https://github.com/bojone/bert4keras
Canonical: https://ross.abutalabs.com/products/bert4keras
Homepage: https://kexue.fm/archives/6915
Language: Python
License: Apache-2.0
License Family: permissive
Last push: 2024-11-11T15:41:47+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 2564, "days_push": 660, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 5415, forks 919 (observed 2026-08-28T04:09:17.809644+00:00)

## What it is
A lightweight, clean reimplementation of BERT and other transformer models (RoBERTa, ALBERT, T5, GPT, ELECTRA, NEZHA) for Keras/tf.keras. It supports loading pretrained weights, finetuning, and pretraining from scratch with TPU/multi-GPU support.

## Use cases
- finetune bert on keras
- load pretrained transformer weights in keras
- pretrain a language model from scratch
- build seq2seq models with attention masks
- use chinese pretrained models like roberta or electra
- implement custom transformer models in keras

## When to choose
- you want a simple, hackable keras implementation of transformers for finetuning or research
- you need to load Chinese pretrained model weights (RoBERTa-wwm, ELECTRA, NEZHA) in keras
- you prefer lightweight code over Hugging Face's larger ecosystem
- you are on legacy TensorFlow 1.x / Keras 2.x stacks

## When to avoid
- you need modern PyTorch or the latest Hugging Face Transformers ecosystem
- you use recent TensorFlow 2.x features or Keras 3
- you need production-grade maintained tooling with broad community support

## Facets
- artifact type: library
- maturity: maintenance
- function: machine-learning, deep-learning, nlp, llm-training
- domain: deep-learning, large-language-models
- platform: python
- tags: keras, bert, transformers, pretrained-models, finetuning, tensorflow, natural-language-processing

## Member repositories
- bojone/bert4keras (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:09:17.809644+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:57:45.173761+00:00, confidence not recorded.
  - readme: https://github.com/bojone/bert4keras (fetched 2026-08-28T04:09:17.809644+00:00, sha bf7d34f80dfe)
  - registry_pypi: https://pypi.org/pypi/bert4keras/json (fetched 2026-08-29T08:52:19.617538+00:00, sha e8b2787a9491)
- Data as of 2026-08-30T08:39:29.467469+00:00.
