Package: kashgari-tf
KashgariOverview|Performance|Quick start|Documentation|中文文档|Contributing🎉🎉🎉 We are proud to announce that we entirely rewrote Kashgari with tf.keras, now Kashgari comes with easier to understand API and is faster! 🎉🎉🎉OverviewKashgari is a simple and powerful NLP Transfer learning framework, build a state-of-art model in 5 minutes for named entity recognition (NER), part-of-speech tagging (PoS), and text classification tasks.Human-friendly. Kashgari's code is straightforward, well documented and tested, which makes it very easy to understand and modify.Powerful and simple. Kashgari allows you to apply state-of-the-art natural language processing (NLP) models to your text, such as named entity recognition (NER), part-of-speech tagging (PoS) and classification.Built-in transfer learning. Kashgari built-in pre-trained BERT and Word2vec embedding models, which makes it very simple to transfer learning to train your model.Fully scalable. Kashgari provides a simple, fast, and scalable environment for fast experimentation, train your models and experiment with new approaches using different embeddings and model structure.Production Ready. Kashgari could export model withSavedModelformat for tensorflow serving, you could directly deploy it on the cloud.Our GoalAcademic usersEasier experimentation to prove their hypothesis without coding from scratch.NLP beginnersLearn how to build an NLP project with production level code quality.NLP developersBuild a production level classification/labeling model within minutes.PerformanceTaskLanguageDatasetScoreDetailNamed Entity RecognitionChinesePeople's Daily Ner Corpus94.46(F1)Text Labeling Performance ReportTutorialsHere is a set of quick tutorials to get you started with the library:Tutorial 1: Text ClassificationTutorial 2: Text LabelingTutorial 3: Language EmbeddingThere are also articles and posts that illustrate how to use Kashgari:15 分钟搭建中文文本分类模型基于 BERT 的中文命名实体识别（NER)BERT/ERNIE 文本分类和部署五分钟搭建一个基于BERT的NER模型Multi-Class Text Classification with Kashgari in 15 minutesQuick startRequirements and Installation🎉🎉🎉 We renamed again for consistency and clarity. From now on, it is allkashgari. 🎉🎉🎉The project is based on Python 3.6+, because it is 2019 and type hinting is cool.Backendpypi versiondescTensorFlow 2.xpip install 'kashgari>=2.0.0'coming soonTensorFlow 1.14+pip install 'kashgari>=1.0.0,<2.0.0'current versionKeraspip install 'kashgari<1.0.0'legacy versionFind more info about the name changing.Example UsageLet's run an NER labeling model with Bi_LSTM Model.fromkashgari.corpusimportChineseDailyNerCorpusfromkashgari.tasks.labelingimportBiLSTM_Modeltrain_x,train_y=ChineseDailyNerCorpus.load_data('train')test_x,test_y=ChineseDailyNerCorpus.load_data('test')valid_x,valid_y=ChineseDailyNerCorpus.load_data('valid')model=BiLSTM_Model()model.fit(train_x,train_y,valid_x,valid_y,epochs=50)"""_________________________________________________________________Layer (type)                 Output Shape              Param #=================================================================input (InputLayer)           (None, 97)                0_________________________________________________________________layer_embedding (Embedding)  (None, 97, 100)           320600_________________________________________________________________layer_blstm (Bidirectional)  (None, 97, 256)           235520_________________________________________________________________layer_dropout (Dropout)      (None, 97, 256)           0_________________________________________________________________layer_time_distributed (Time (None, 97, 8)             2056_________________________________________________________________activation_7 (Activation)    (None, 97, 8)             0=================================================================Total params: 558,176Trainable params: 558,176Non-trainable params: 0_________________________________________________________________Train on 20864 samples, validate on 2318 samplesEpoch 1/5020864/20864 [==============================] - 9s 417us/sample - loss: 0.2508 - acc: 0.9333 - val_loss: 0.1240 - val_acc: 0.9607"""Run with GPT-2 Embeddingfromkashgari.embeddingsimportGPT2Embeddingfromkashgari.corpusimportChineseDailyNerCorpusfromkashgari.tasks.labelingimportBiGRU_Modeltrain_x,train_y=ChineseDailyNerCorpus.load_data('train')valid_x,valid_y=ChineseDailyNerCorpus.load_data('valid')gpt2_embedding=GPT2Embedding('<path-to-gpt-model-folder>',sequence_length=30)model=BiGRU_Model(gpt2_embedding)model.fit(train_x,train_y,valid_x,valid_y,epochs=50)Run with Bert Embeddingfromkashgari.embeddingsimportBERTEmbeddingfromkashgari.tasks.labelingimportBiGRU_Modelfromkashgari.corpusimportChineseDailyNerCorpusbert_embedding=BERTEmbedding('<bert-model-folder>',sequence_length=30)model=BiGRU_Model(bert_embedding)train_x,train_y=ChineseDailyNerCorpus.load_data()model.fit(train_x,train_y)SponsorsSupport this project by becoming a sponsor. Your issues and feature request will be prioritized.[Become a sponsor]ContributingThanks for your interest in contributing! There are many ways to get involved; start with thecontributor guidelinesand then check these open issues for specific tasks.Feel free to join the WeChat group if you want to more involved in Kashgari's development.ReferenceThis library is inspired by and references following frameworks and papers.flair - A very simple framework for state-of-the-art Natural Language Processing (NLP)anago - Bidirectional LSTM-CRF and ELMo for Named-Entity Recognition, Part-of-Speech TaggingChinese-Word-Vectors