Package: simpletransformers-le
Simple TransformersThis library is based on theTransformerslibrary by HuggingFace.Simple Transformerslets you quickly train and evaluate Transformer models. Only 3 lines of code are needed toinitialize,train, andevaluatea model.Supported Tasks:Sequence ClassificationToken Classification (NER)Question AnsweringLanguage Model Fine-TuningLanguage Model TrainingLanguage GenerationT5 ModelSeq2Seq TasksMulti-Modal ClassificationConversational AI.Text Representation Generation.Table of contentsSimple TransformersTable of contentsSetupWith CondaOptionalUsageA quick exampleExperiment Tracking with Weights and BiasesCurrent Pretrained ModelsContributors ✨How to ContributeHow to Update DocsAcknowledgementsSetupWith CondaInstallAnacondaorMinicondaPackage Manager fromhereCreate a new virtual environment and install packages.$condacreate-nstpythonpandastqdm
$condaactivatestUsing Cuda:$condainstallpytorch>=1.6cudatoolkit=11.0-cpytorchWithout using Cuda$condainstallpytorchcpuonly-cpytorchInstallsimpletransformers.$pipinstallsimpletransformersOptionalInstallWeightsandBiases(wandb) for tracking and visualizing training in a web browser.$pipinstallwandbUsageAll documentation is now live atsimpletransformers.aiSimple Transformermodels 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.Initialize a task-specific modelTrain the model withtrain_model()Evaluate the model witheval_model()Make predictions on (unlabelled) data withpredict()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-specificSimple Transformermodels, along with their task, are given below.TaskModelBinary and multi-class text classificationClassificationModelConversational AI (chatbot training)ConvAIModelLanguage generationLanguageGenerationModelLanguage model training/fine-tuningLanguageModelingModelMulti-label text classificationMultiLabelClassificationModelMulti-modal classification (text and image data combined)MultiModalClassificationModelNamed entity recognitionNERModelQuestion answeringQuestionAnsweringModelRegressionClassificationModelSentence-pair classificationClassificationModelText Representation GenerationRepresentationModelDocument RetrievalRetrievalModelPlease refer to the relevant section in thedocsfor more information on how to use these models.Example scripts can be found in theexamplesdirectory.See theChangelogfor up-to-date changes to the project.A quick examplefromsimpletransformers.classificationimportClassificationModel,ClassificationArgsimportpandasaspdimportlogginglogging.basicConfig(level=logging.INFO)transformers_logger=logging.getLogger("transformers")transformers_logger.setLevel(logging.WARNING)# Preparing train datatrain_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 dataeval_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 configurationmodel_args=ClassificationArgs(num_train_epochs=1)# Create a ClassificationModelmodel=ClassificationModel("roberta","roberta-base",args=model_args)# Train the modelmodel.train_model(train_df)# Evaluate the modelresult,model_outputs,wrong_predictions=model.eval_model(eval_df)# Make predictions with the modelpredictions,raw_outputs=model.predict(["Sam was a Wizard"])Experiment Tracking with Weights and BiasesWeights and Biases makes it incredibly easy to keep track of all your experiments. Check it out on Colab here:Current Pretrained ModelsFor a list of pretrained models, seeHugging Face docs.Themodel_typesavailable 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 correctmodel_typeandmodel_namein theargsdictionary.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💻jinschoi💻Le Nguyen Khang💻Jordi Mas📖mxa💻This project follows theall-contributorsspecification. 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 ContributeHow to Update DocsThe latest version of the docs is hosted onGithub Pages, if you want to help document Simple Transformers
below are the steps to edit the docs.
Docs are built usingJekylllibrary, refer to their webpage for a detailed explanation of how it works.InstallJekyll: Run the commandgem install bundler jekyllVisualizing the docs on your local computer:
In your terminal cd into the docs directory of this repo, eg:cd simpletransformers/docsFrom the docs directory run this command to serve the Jekyll docs locally:bundle exec jekyll serveBrowse tohttp://localhost:4000or whatever url you see in the console to visualize the docs.Edit and visualize changes:
All the section pages of our docs can be found underdocs/_docsdirectory, you can edit any file you want by following the markdown format and visualize the changes after refreshing the browser tab.AcknowledgementsNone of this would have been possible without the hard work by the HuggingFace team in developing theTransformerslibrary.<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>