All Projects → Novetta → Adaptnlp

Novetta / Adaptnlp

Licence: apache-2.0
An easy to use Natural Language Processing library and framework for predicting, training, fine-tuning, and serving up state-of-the-art NLP models.

Projects that are alternatives of or similar to Adaptnlp

Machine Learning Notebooks
Machine Learning notebooks for refreshing concepts.
Stars: ✭ 222 (-20.14%)
Mutual labels:  jupyter-notebook, natural-language-processing, deep-learning-tutorial
Trainyourownyolo
Train a state-of-the-art yolov3 object detector from scratch!
Stars: ✭ 399 (+43.53%)
Mutual labels:  jupyter-notebook, gpu, deep-learning-tutorial
Dive Into Dl Pytorch
本项目将《动手学深度学习》(Dive into Deep Learning)原书中的MXNet实现改为PyTorch实现。
Stars: ✭ 14,234 (+5020.14%)
Mutual labels:  jupyter-notebook, natural-language-processing, deep-learning-tutorial
Pytorch Transformers Classification
Based on the Pytorch-Transformers library by HuggingFace. To be used as a starting point for employing Transformer models in text classification tasks. Contains code to easily train BERT, XLNet, RoBERTa, and XLM models for text classification.
Stars: ✭ 229 (-17.63%)
Mutual labels:  jupyter-notebook, natural-language-processing
Practical 1
Oxford Deep NLP 2017 course - Practical 1: word2vec
Stars: ✭ 220 (-20.86%)
Mutual labels:  jupyter-notebook, natural-language-processing
Text summarization with tensorflow
Implementation of a seq2seq model for summarization of textual data. Demonstrated on amazon reviews, github issues and news articles.
Stars: ✭ 226 (-18.71%)
Mutual labels:  jupyter-notebook, natural-language-processing
Pytorch graph Rel
A PyTorch implementation of GraphRel
Stars: ✭ 204 (-26.62%)
Mutual labels:  jupyter-notebook, natural-language-processing
Pytorch Bert Crf Ner
KoBERT와 CRF로 만든 한국어 개체명인식기 (BERT+CRF based Named Entity Recognition model for Korean)
Stars: ✭ 236 (-15.11%)
Mutual labels:  jupyter-notebook, natural-language-processing
Nn
🧑‍🏫 50! Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠
Stars: ✭ 5,720 (+1957.55%)
Mutual labels:  jupyter-notebook, deep-learning-tutorial
Malaya
Natural Language Toolkit for bahasa Malaysia, https://malaya.readthedocs.io/
Stars: ✭ 239 (-14.03%)
Mutual labels:  jupyter-notebook, natural-language-processing
Nplusminer
NPlusMiner + GUI | NVIDIA/AMD/CPU miner | AI | Autoupdate | MultiRig remote management
Stars: ✭ 75 (-73.02%)
Mutual labels:  api-rest, gpu
Graph Convolution Nlp
Graph Convolution Network for NLP
Stars: ✭ 208 (-25.18%)
Mutual labels:  jupyter-notebook, natural-language-processing
Gluon Api
A clear, concise, simple yet powerful and efficient API for deep learning.
Stars: ✭ 2,322 (+735.25%)
Mutual labels:  jupyter-notebook, deep-learning-tutorial
Aind Nlp
Coding exercises for the Natural Language Processing concentration, part of Udacity's AIND program.
Stars: ✭ 202 (-27.34%)
Mutual labels:  jupyter-notebook, natural-language-processing
Bertviz
Tool for visualizing attention in the Transformer model (BERT, GPT-2, Albert, XLNet, RoBERTa, CTRL, etc.)
Stars: ✭ 3,443 (+1138.49%)
Mutual labels:  jupyter-notebook, natural-language-processing
Deeplearning.ai Notes
These are my notes which I prepared during deep learning specialization taught by AI guru Andrew NG. I have used diagrams and code snippets from the code whenever needed but following The Honor Code.
Stars: ✭ 262 (-5.76%)
Mutual labels:  jupyter-notebook, deep-learning-tutorial
Deepnlp Models Pytorch
Pytorch implementations of various Deep NLP models in cs-224n(Stanford Univ)
Stars: ✭ 2,760 (+892.81%)
Mutual labels:  jupyter-notebook, natural-language-processing
Nlpython
This repository contains the code related to Natural Language Processing using python scripting language. All the codes are related to my book entitled "Python Natural Language Processing"
Stars: ✭ 265 (-4.68%)
Mutual labels:  jupyter-notebook, natural-language-processing
Germanwordembeddings
Toolkit to obtain and preprocess german corpora, train models using word2vec (gensim) and evaluate them with generated testsets
Stars: ✭ 189 (-32.01%)
Mutual labels:  jupyter-notebook, natural-language-processing
Keras Acgan
Auxiliary Classifier Generative Adversarial Networks in Keras
Stars: ✭ 196 (-29.5%)
Mutual labels:  jupyter-notebook, gpu

A high level framework and library for running, training, and deploying state-of-the-art Natural Language Processing (NLP) models for end to end tasks.

AdaptNLP allows users ranging from beginner python coders to experienced machine learning engineers to leverage state-of-the-art NLP models and training techniques in one easy-to-use python package.

Built atop Zalando Research's Flair and Hugging Face's Transformers library, AdaptNLP provides Machine Learning Researchers and Scientists a modular and adaptive approach to a variety of NLP tasks with an Easy API for training, inference, and deploying NLP-based microservices.

Key Features

  • Full Guides and API Documentation
  • Tutorial Jupyter/Google Colab Notebooks
  • Unified API for NLP Tasks with SOTA Pretrained Models (Adaptable with Flair and Transformer's Models)
    • Token Tagging
    • Sequence Classification
    • Embeddings
    • Question Answering
    • Summarization
    • Translation
    • Text Generation
    • More in development
  • Training and Fine-tuning Interface
    • Integration with Transformer's Trainer Module for fast and easy transfer learning with custom datasets
    • Jeremy's ULM-FIT approach for transfer learning in NLP
    • Fine-tuning Transformer's language models and task-specific predictive heads like Flair's SequenceClassifier
  • Rapid NLP Model Deployment with Sebastián's FastAPI Framework
    • Containerized FastAPI app
    • Immediately deploy any custom trained Flair or AdaptNLP model
  • Dockerizing AdaptNLP with GPUs
    • Easily build and run AdaptNLP containers leveraging NVIDIA GPUs with Docker

Quick Start

Requirements and Installation for Linux/Mac

Note: AdaptNLP will be using the latest stable torch version (v1.7 as of 11/2/20) which requires Python 3.7+. Please downgrade torch<=1.6 if using Python 3.6

Virtual Environment

To avoid dependency clustering and issues, it would be wise to install AdaptNLP in a virtual environment. To create a new python 3.7+ virtual environment, run this command and then activate it however your operating system specifies:

python -m venv venv-adaptnlp
AdaptNLP Install

Install using pip in your virtual environment:

pip install adaptnlp

If you want to work on AdaptNLP, pip install adaptnlp[dev] will install its development tools.

Requirements and Installation for Windows

PyTorch Install

PyTorch needs to be manually installed on Windows environments. If it's not already installed, proceed to http://pytorch.org/get-started/locally to select your preferences and then run the given install command. Note that the current version of PyTorch we use relies on cuda 10.1.

AdaptNLP Install

Install using pip:

pip install adaptnlp

If you want to work on AdaptNLP, pip install adaptnlp[dev] will install its development tools.

Examples and General Use

Once you have installed AdaptNLP, here are a few examples of what you can run with AdaptNLP modules:

Named Entity Recognition with EasyTokenTagger
from adaptnlp import EasyTokenTagger

## Example Text
example_text = "Novetta's headquarters is located in Mclean, Virginia."

## Load the token tagger module and tag text with the NER model 
tagger = EasyTokenTagger()
sentences = tagger.tag_text(text=example_text, model_name_or_path="ner")

## Output tagged token span results in Flair's Sentence object model
for sentence in sentences:
    for entity in sentence.get_spans("ner"):
        print(entity)

English Sentiment Classifier EasySequenceClassifier
from adaptnlp import EasySequenceClassifier 
from pprint import pprint

## Example Text
example_text = "This didn't work at all"

## Load the sequence classifier module and classify sequence of text with the multi-lingual sentiment model 
classifier = EasySequenceClassifier()
sentences = classifier.tag_text(
    text=example_text,
    model_name_or_path="nlptown/bert-base-multilingual-uncased-sentiment",
    mini_batch_size=1,
)

## Output labeled text results in Flair's Sentence object model
print("Tag Score Outputs:\n")
for sentence in sentences:
    pprint({sentence.to_original_text(): sentence.labels})

Span-based Question Answering EasyQuestionAnswering
from adaptnlp import EasyQuestionAnswering 
from pprint import pprint

## Example Query and Context 
query = "What is the meaning of life?"
context = "Machine Learning is the meaning of life."
top_n = 5

## Load the QA module and run inference on results 
qa = EasyQuestionAnswering()
best_answer, best_n_answers = qa.predict_qa(query=query, context=context, n_best_size=top_n, mini_batch_size=1, model_name_or_path="distilbert-base-uncased-distilled-squad")

## Output top answer as well as top 5 answers
print(best_answer)
pprint(best_n_answers)
Summarization EasySummarizer
from adaptnlp import EasySummarizer

# Text from encyclopedia Britannica on Einstein
text = """Einstein would write that two “wonders” deeply affected his early years. The first was his encounter with a compass at age five. 
          He was mystified that invisible forces could deflect the needle. This would lead to a lifelong fascination with invisible forces. 
          The second wonder came at age 12 when he discovered a book of geometry, which he devoured, calling it his 'sacred little geometry 
          book'. Einstein became deeply religious at age 12, even composing several songs in praise of God and chanting religious songs on 
          the way to school. This began to change, however, after he read science books that contradicted his religious beliefs. This challenge 
          to established authority left a deep and lasting impression. At the Luitpold Gymnasium, Einstein often felt out of place and victimized 
          by a Prussian-style educational system that seemed to stifle originality and creativity. One teacher even told him that he would 
          never amount to anything."""

summarizer = EasySummarizer()

# Summarize
summaries = summarizer.summarize(text = text, model_name_or_path="t5-small", mini_batch_size=1, num_beams = 4, min_length=0, max_length=100, early_stopping=True)

print("Summaries:\n")
for s in summaries:
    print(s, "\n")
Translation EasyTranslator
from adaptnlp import EasyTranslator

text = ["Machine learning will take over the world very soon.",
        "Machines can speak in many languages.",]

translator = EasyTranslator()

# Translate
translations = translator.translate(text = text, t5_prefix="translate English to German", model_name_or_path="t5-small", mini_batch_size=1, min_length=0, max_length=100, early_stopping=True)

print("Translations:\n")
for t in translations:
    print(t, "\n")

Tutorials

Look in the Tutorials directory for a quick introduction to the library and its very simple and straight forward use cases:

NLP Tasks

  1. Token Classification: NER, POS, Chunk, and Frame Tagging
    • Open In Colab
  2. Sequence Classification: Sentiment
    • Open In Colab
  3. Embeddings: Transformer Embeddings e.g. BERT, XLM, GPT2, XLNet, roBERTa, ALBERT
    • Open In Colab
  4. Question Answering: Span-based Question Answering Model
    • Open In Colab
  5. Summarization: Abstractive and Extractive
    • Open In Colab
  6. Translation: Seq2Seq
    • Open In Colab

Custom Fine-Tuning and Training with Transformer Models

  • Fine-tuning a Transformers Language Model
    • Open In Colab

Checkout the documentation for more information.

REST Service

We use FastAPI for standing up endpoints for serving state-of-the-art NLP models with AdaptNLP.

Swagger Example

The REST directory contains more detail on deploying a REST API locally or with docker in a very easy and fast way.

Docker

AdaptNLP official docker images are up on Docker Hub.

Images have AdaptNLP installed from source in developer mode with tutorial notebooks available, and will default to launching a jupyter server from where you can start running the tutorial and workshop notebooks.

Images can build with GPU support if NVIDA-Docker is correctly installed.

Pull and Run AdaptNLP Immediately

Simply run an image with AdaptNLP installed from source in developer mode by running:

docker run -itp 8888:8888 achangnovetta/adaptnlp:latest

Run an image with AdaptNLP running on GPUs if you have nvidia drivers and nvidia-docker 19.03+ installed:

docker run -itp 8888:8888 --gpus all achangnovetta/adaptnlp:latest

Check localhost:8888 or localhost:8888/lab to access the container notebook servers.

Build

Refer to the docker/ directory and run the following to build and run adaptnlp from the available images.

Note: A container with GPUs enabled requires Docker version 19.03+ and nvida-docker installed

# From the repo directory
docker build -t achangnovetta/adaptnlp:latest -f docker/runtime/Dockerfile.cuda11.0-runtime-ubuntu18.04-py3.8 .
docker run -itp 8888:8888 achangnovetta/adaptnlp:latest

If you want to use CUDA compatible GPUs

docker run -itp 8888:8888 --gpus all achangnovetta/adaptnlp:latest

Check localhost:8888 or localhost:8888/lab to access the container notebook servers.

Contact

Please contact the author Andrew Chang at [email protected] with questions or comments regarding AdaptNLP.

Follow us on Twitter at @achang1618 and @AdaptNLP for updates and NLP dialogue.

License

This project is licensed under the terms of the Apache 2.0 license.

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].