返回排行榜

codertimo/BERT-pytorch

Python

Google AI 2018 BERT pytorch implementation

berttransformerpytorchnlplanguage-model
Star 增长趋势
Star
6.5k
Forks
1.3k
周增长
Issues
57
2k4k6k
2023年1月2024年3月2025年5月2026年7月
制品库PyPIpip install bert-pytorch
README

BERT-pytorch

LICENSE GitHub issues GitHub stars CircleCI PyPI PyPI - Status Documentation Status

Pytorch implementation of Google AI's 2018 BERT, with simple annotation

BERT 2018 BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding Paper URL : https://arxiv.org/abs/1810.04805

Introduction

Google AI's BERT paper shows the amazing result on various NLP task (new 17 NLP tasks SOTA), including outperform the human F1 score on SQuAD v1.1 QA task. This paper proved that Transformer(self-attention) based encoder can be powerfully used as alternative of previous language model with proper language model training method. And more importantly, they showed us that this pre-trained language model can be transfer into any NLP task without making task specific model architecture.

This amazing result would be record in NLP history, and I expect many further papers about BERT will be published very soon.

This repo is implementation of BERT. Code is very simple and easy to understand fastly. Some of these codes are based on The Annotated Transformer

Currently this project is working on progress. And the code is not verified yet.

Installation

pip install bert-pytorch

Quickstart

NOTICE : Your corpus should be prepared with two sentences in one line with tab(\t) separator

0. Prepare your corpus

Welcome to the \t the jungle\n
I can stay \t here all night\n

or tokenized corpus (tokenization is not in package)

Wel_ _come _to _the \t _the _jungle\n
_I _can _stay \t _here _all _night\n

1. Building vocab based on your corpus

bert-vocab -c data/corpus.small -o data/vocab.small

2. Train your own BERT model

bert -c data/corpus.small -v data/vocab.small -o output/bert.model

Language Model Pre-training

In the paper, authors shows the new language model training methods, which are "masked language model" and "predict next sentence".

Masked Language Model

Original Paper : 3.3.1 Task #1: Masked LM

Input Sequence  : The man went to [MASK] store with [MASK] dog
Target Sequence :                  the                his

Rules:

Randomly 15% of input token will be changed into something, based on under sub-rules

  1. Randomly 80% of tokens, gonna be a [MASK] token
  2. Randomly 10% of tokens, gonna be a [RANDOM] token(another word)
  3. Randomly 10% of tokens, will be remain as same. But need to be predicted.

Predict Next Sentence

Original Paper : 3.3.2 Task #2: Next Sentence Prediction

Input : [CLS] the man went to the store [SEP] he bought a gallon of milk [SEP]
Label : Is Next

Input = [CLS] the man heading to the store [SEP] penguin [MASK] are flight ##less birds [SEP]
Label = NotNext

"Is this sentence can be continuously connected?"

understanding the relationship, between two text sentences, which is not directly captured by language modeling

Rules:

  1. Randomly 50% of next sentence, gonna be continuous sentence.
  2. Randomly 50% of next sentence, gonna be unrelated sentence.

Author

Junseong Kim, Scatter Lab (codertimo@gmail.com / junseong.kim@scatterlab.co.kr)

License

This project following Apache 2.0 License as written in LICENSE file

Copyright 2018 Junseong Kim, Scatter Lab, respective BERT contributors

Copyright (c) 2018 Alexander Rush : The Annotated Trasnformer

相关仓库
datawhalechina/leedl-tutorial

《李宏毅深度学习教程》(李宏毅老师推荐👍,苹果书🍎),PDF下载地址:https://github.com/datawhalechina/leedl-tutorial/releases

Jupyter NotebookOthermachine-learningdeep-learning
16.7k3.1k
graykode/nlp-tutorial

Natural Language Processing Tutorial for Deep Learning Researchers

Jupyter NotebookMIT Licensenlpnatural-language-processing
reddit.com/r/MachineLearning/comments/amfinl/project_nlptutoral_repository_who_is_studying/
14.9k3.9k
PaddlePaddle/PaddleNLP

Easy-to-use and powerful LLM and SLM library with awesome model zoo.

PythonPyPIApache License 2.0nlpembedding
paddlenlp.readthedocs.io
13k3k
jina-ai/clip-as-service

🏄 Scalable embedding, reasoning, ranking for images and sentences with CLIP

PythonPyPIOtherbertsentence-encoding
clip-as-service.jina.ai
12.8k2.1k
NielsRogge/Transformers-Tutorials

This repository contains demos I made with the Transformers library by HuggingFace.

Jupyter NotebookMIT Licensetransformerspytorch
11.7k1.7k
huggingface/tokenizers

💥 Fast State-of-the-Art Tokenizers optimized for Research and Production

Rustcrates.ioApache License 2.0nlpnatural-language-processing
huggingface.co/docs/tokenizers
10.9k1.2k
ymcui/Chinese-BERT-wwm

Pre-Training with Whole Word Masking for Chinese BERT(中文BERT-wwm系列模型)

PythonPyPIApache License 2.0chinese-berttensorflow
ieeexplore.ieee.org/document/9599397
10.2k1.4k
brightmart/nlp_chinese_corpus

大规模中文自然语言处理语料 Large Scale Chinese Corpus for NLP

MIT Licensechinese-datasetchinese-corpus
9.9k1.6k
fishaudio/Bert-VITS2

vits2 backbone with multilingual-bert

PythonPyPIGNU Affero General Public License v3.0bertbert-vits2
8.8k1.3k
jessevig/bertviz

BertViz: Visualize Attention in Transformer Models

PythonPyPIApache License 2.0natural-language-processingmachine-learning
8.1k886
MaartenGr/BERTopic

Leveraging BERT and c-TF-IDF to create easily interpretable topics.

PythonPyPIMIT Licenseberttransformers
maartengr.github.io/BERTopic/
7.8k909
NVIDIA/FasterTransformer

Transformer related optimization, including BERT, GPT

C++Apache License 2.0pytorchtransformer
6.4k935