All Projects → ThilinaRajapakse → Simpletransformers

ThilinaRajapakse / Simpletransformers

Licence: apache-2.0
Transformers for Classification, NER, QA, Language Modelling, Language Generation, T5, Multi-Modal, and Conversational AI

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Simpletransformers

TorchBlocks
A PyTorch-based toolkit for natural language processing
Stars: ✭ 85 (-97.05%)
Mutual labels:  text-classification, transformers, named-entity-recognition
backprop
Backprop makes it simple to use, finetune, and deploy state-of-the-art ML models.
Stars: ✭ 229 (-92.05%)
Mutual labels:  text-classification, transformers, question-answering
Dan Jurafsky Chris Manning Nlp
My solution to the Natural Language Processing course made by Dan Jurafsky, Chris Manning in Winter 2012.
Stars: ✭ 124 (-95.7%)
Mutual labels:  question-answering, text-classification, named-entity-recognition
Pytorch-NLU
Pytorch-NLU,一个中文文本分类、序列标注工具包,支持中文长文本、短文本的多类、多标签分类任务,支持中文命名实体识别、词性标注、分词等序列标注任务。 Ptorch NLU, a Chinese text classification and sequence annotation toolkit, supports multi class and multi label classification tasks of Chinese long text and short text, and supports sequence annotation tasks such as Chinese named entity recognition, part of speech ta…
Stars: ✭ 151 (-94.76%)
Mutual labels:  text-classification, transformers, named-entity-recognition
Spark Nlp
State of the Art Natural Language Processing
Stars: ✭ 2,518 (-12.6%)
Mutual labels:  named-entity-recognition, text-classification, transformers
Bert Multitask Learning
BERT for Multitask Learning
Stars: ✭ 380 (-86.81%)
Mutual labels:  text-classification, named-entity-recognition
Spacy
💫 Industrial-strength Natural Language Processing (NLP) in Python
Stars: ✭ 21,978 (+662.86%)
Mutual labels:  text-classification, named-entity-recognition
Deeppavlov
An open source library for deep learning end-to-end dialog systems and chatbots.
Stars: ✭ 5,525 (+91.77%)
Mutual labels:  question-answering, named-entity-recognition
Bert language understanding
Pre-training of Deep Bidirectional Transformers for Language Understanding: pre-train TextCNN
Stars: ✭ 933 (-67.62%)
Mutual labels:  question-answering, text-classification
Bertweet
BERTweet: A pre-trained language model for English Tweets (EMNLP-2020)
Stars: ✭ 282 (-90.21%)
Mutual labels:  text-classification, named-entity-recognition
Chatito
🎯🗯 Generate datasets for AI chatbots, NLP tasks, named entity recognition or text classification models using a simple DSL!
Stars: ✭ 678 (-76.47%)
Mutual labels:  text-classification, named-entity-recognition
Cnn Question Classification Keras
Chinese Question Classifier (Keras Implementation) on BQuLD
Stars: ✭ 28 (-99.03%)
Mutual labels:  question-answering, text-classification
Spacy Streamlit
👑 spaCy building blocks and visualizers for Streamlit apps
Stars: ✭ 360 (-87.5%)
Mutual labels:  text-classification, named-entity-recognition
Snips Nlu
Snips Python library to extract meaning from text
Stars: ✭ 3,583 (+24.37%)
Mutual labels:  text-classification, named-entity-recognition
Hanlp
中文分词 词性标注 命名实体识别 依存句法分析 成分句法分析 语义依存分析 语义角色标注 指代消解 风格转换 语义相似度 新词发现 关键词短语提取 自动摘要 文本分类聚类 拼音简繁转换 自然语言处理
Stars: ✭ 24,626 (+754.77%)
Mutual labels:  text-classification, named-entity-recognition
Informers
State-of-the-art natural language processing for Ruby
Stars: ✭ 306 (-89.38%)
Mutual labels:  question-answering, named-entity-recognition
Nlp chinese corpus
大规模中文自然语言处理语料 Large Scale Chinese Corpus for NLP
Stars: ✭ 6,656 (+131.03%)
Mutual labels:  question-answering, text-classification
Kashgari
Kashgari is a production-level NLP Transfer learning framework built on top of tf.keras for text-labeling and text-classification, includes Word2Vec, BERT, and GPT2 Language Embedding.
Stars: ✭ 2,235 (-22.42%)
Mutual labels:  text-classification, named-entity-recognition
Turkish Bert Nlp Pipeline
Bert-base NLP pipeline for Turkish, Ner, Sentiment Analysis, Question Answering etc.
Stars: ✭ 85 (-97.05%)
Mutual labels:  question-answering, named-entity-recognition
Neuronblocks
NLP DNN Toolkit - Building Your NLP DNN Models Like Playing Lego
Stars: ✭ 1,356 (-52.93%)
Mutual labels:  question-answering, text-classification

License Downloads

All Contributors

Simple Transformers

This library is based on the Transformers library by HuggingFace. Simple Transformers lets you quickly train and evaluate Transformer models. Only 3 lines of code are needed to initialize, train, and evaluate a model.

Supported Tasks:

  • Sequence Classification
  • Token Classification (NER)
  • Question Answering
  • Language Model Fine-Tuning
  • Language Model Training
  • Language Generation
  • T5 Model
  • Seq2Seq Tasks
  • Multi-Modal Classification
  • Conversational AI.
  • Text Representation Generation.

Table of contents

Setup

With Conda

  1. Install Anaconda or Miniconda Package Manager from here
  2. Create a new virtual environment and install packages.
$ conda create -n st python pandas tqdm
$ conda activate st

Using Cuda:

$ conda install pytorch>=1.6 cudatoolkit=11.0 -c pytorch

Without using Cuda

$ conda install pytorch cpuonly -c pytorch
  1. Install simpletransformers.
$ pip install simpletransformers

Optional

  1. Install Weights and Biases (wandb) for tracking and visualizing training in a web browser.
$ pip install wandb

Usage

All documentation is now live at simpletransformers.ai

Simple Transformer models are built with a particular Natural Language Processing (NLP) task in mind. Each such model comes equipped with features and functionality designed to best fit the task that they are intended to perform. The high-level process of using Simple Transformers models follows the same pattern.

  1. Initialize a task-specific model
  2. Train the model with train_model()
  3. Evaluate the model with eval_model()
  4. Make predictions on (unlabelled) data with predict()

However, there are necessary differences between the different models to ensure that they are well suited for their intended task. The key differences will typically be the differences in input/output data formats and any task specific features/configuration options. These can all be found in the documentation section for each task.

The currently implemented task-specific Simple Transformer models, along with their task, are given below.

Task Model
Binary and multi-class text classification ClassificationModel
Conversational AI (chatbot training) ConvAIModel
Language generation LanguageGenerationModel
Language model training/fine-tuning LanguageModelingModel
Multi-label text classification MultiLabelClassificationModel
Multi-modal classification (text and image data combined) MultiModalClassificationModel
Named entity recognition NERModel
Question answering QuestionAnsweringModel
Regression ClassificationModel
Sentence-pair classification ClassificationModel
Text Representation Generation RepresentationModel
Document Retrieval RetrievalModel
  • Please refer to the relevant section in the docs for more information on how to use these models.
  • Example scripts can be found in the examples directory.
  • See the Changelog for up-to-date changes to the project.

A quick example

from simpletransformers.classification import ClassificationModel, ClassificationArgs
import pandas as pd
import logging


logging.basicConfig(level=logging.INFO)
transformers_logger = logging.getLogger("transformers")
transformers_logger.setLevel(logging.WARNING)

# Preparing train data
train_data = [
    ["Aragorn was the heir of Isildur", 1],
    ["Frodo was the heir of Isildur", 0],
]
train_df = pd.DataFrame(train_data)
train_df.columns = ["text", "labels"]

# Preparing eval data
eval_data = [
    ["Theoden was the king of Rohan", 1],
    ["Merry was the king of Rohan", 0],
]
eval_df = pd.DataFrame(eval_data)
eval_df.columns = ["text", "labels"]

# Optional model configuration
model_args = ClassificationArgs(num_train_epochs=1)

# Create a ClassificationModel
model = ClassificationModel(
    "roberta", "roberta-base", args=model_args
)

# Train the model
model.train_model(train_df)

# Evaluate the model
result, model_outputs, wrong_predictions = model.eval_model(eval_df)

# Make predictions with the model
predictions, raw_outputs = model.predict(["Sam was a Wizard"])

Experiment Tracking with Weights and Biases

  • Weights and Biases makes it incredibly easy to keep track of all your experiments. Check it out on Colab here: Open In Colab

Current Pretrained Models

For a list of pretrained models, see Hugging Face docs.

The model_types available for each task can be found under their respective section. Any pretrained model of that type found in the Hugging Face docs should work. To use any of them set the correct model_type and model_name in the args dictionary.


Contributors

Thanks goes to these wonderful people (emoji key):


hawktang

💻

Mabu Manaileng

💻

Ali Hamdi Ali Fadel

💻

Tovly Deutsch

💻

hlo-world

💻

huntertl

💻

Yann Defretin

💻 📖 💬 🤔

Manuel

📖 💻

Gilles Jacobs

📖

shasha79

💻

Mercedes Garcia

💻

Hammad Hassan Tarar

💻 📖

Todd Cook

💻

Knut O. Hellan

💻 📖

nagenshukla

💻

flaviussn

💻 📖

Marc Torrellas

🚧

Adrien Renaud

💻

jacky18008

💻

Matteo Senese

💻

sarthakTUM

📖 💻

djstrong

💻

Hyeongchan Kim

📖

Pradhy729

💻 🚧

Iknoor Singh

📖

Gabriel Altay

💻

flozi00

📖 💻 🚧

alexysdussier

💻

Jean-Louis Queguiner

📖

aced125

💻

Laksh1997

💻

Changlin_NLP

💻

jpotoniec

💻

fcggamou

💻 📖

guy-mor

🐛 💻

Cahya Wirawan

💻

BjarkePedersen

💻

tekkkon

💻

Amit Garg

💻

caprone

🐛

Ather Fawaz

💻

Santiago Castro

📖

taranais

💻

Pablo N. Marino

💻 📖

Anton Kiselev

💻 📖

Alex

💻

Karthik Ganesan

💻

Zhylko Dima

💻

Jonatan Kłosko

💻

sarapapi

💻 💬

Abdul

💻

James Milliman

📖

Suraj Parmar

📖

KwanHong Lee

💬

Erik Fäßler

💻

Thomas Søvik

💬

Gagandeep Singh

💻 📖

Andrea Esuli

💻

DM2493

💻

Nick Doiron

💻

Abhinav Gupta

💻

Martin H. Normark

📖

Mossad Helali

💻

calebchiam

💻

Daniele Sartiano

💻

tuner007

📖

xia jiang

💻

Hendrik Buschmeier

📖

Mana Borwornpadungkitti

📖

rayline

💻

Mehdi Heidari

💻

William Roe

💻

Álvaro Abella Bascarán

💻

Brett Fazio

📖

Viet-Tien

💻

Bisola Olasehinde

💻 📖

William Chen

📖

Reza Ebrahimi

📖

gabriben

📖

Prashanth Kurella

💻

dopc

💻

Tanish Tyagi

📖

kongyurui

💻

Andrew Lensen

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

If you should be on this list but you aren't, or you are on the list but don't want to be, please don't hesitate to contact me!


How to Contribute

How to Update Docs

The latest version of the docs is hosted on Github Pages, if you want to help document Simple Transformers below are the steps to edit the docs. Docs are built using Jekyll library, refer to their webpage for a detailed explanation of how it works.

  1. Install Jekyll: Run the command gem install bundler jekyll
  2. Visualizing the docs on your local computer: In your terminal cd into the docs directory of this repo, eg: cd simpletransformers/docs From the docs directory run this command to serve the Jekyll docs locally: bundle exec jekyll serve Browse to http://localhost:4000 or whatever url you see in the console to visualize the docs.
  3. Edit and visualize changes: All the section pages of our docs can be found under docs/_docs directory, you can edit any file you want by following the markdown format and visualize the changes after refreshing the browser tab.

Acknowledgements

None of this would have been possible without the hard work by the HuggingFace team in developing the Transformers library.

<div>Icon for the Social Media Preview made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].