A powerful tool to train and use your classification models.
Project description
A PyTorch-based library for fast prototyping and sharing of deep neural network models.
Quick Links
In this README
Getting Started using classy
If this is your first time meeting classy
, don't worry! We have plenty of resources to help you learn how it works and what it can do for you.
For starters, have a look at our amazing website and our documentation!
If you want to get your hands dirty right away, have a look at our base classy template.
Also, we have a few examples that you can look at to get to know classy
!
Installation
For a more in-depth installation guide (covering also installing from source and through docker), please visit our installation page.
If you are using one of our templates, there is a handy setup.sh
script you can use that will execute the commands to create the environment and install classy
for you.
Installing via pip
Setting up a virtual environment
We strongly recommend using Conda as the environment manager when dealing with deep learning / data science / machine learning. It's also recommended that you install the PyTorch ecosystem before installing classy
by following the instructions on pytorch.org
If you already have a Python 3 environment you want to use, you can skip to the Installing the library and dependencies section.
-
Create a Conda environment with Python 3.8+:
conda create -n classy python=3.8
-
Activate the Conda environment:
conda activate classy
Installing the library and dependencies
Simply execute
pip install classy-core
and voilà! You're all set.
Looking for some adventures? Install nightly releases directly from pypi! You will not regret it :)
Running classy
Once it is installed, classy
is available as a command line tool. It offers a wide variety of subcommands, all listed below. Detailed guides and references for each command is available in the documentation.
Every one of classy
's subcommands have a -h|--help
flag available which details the various arguments & options you can use (e.g., classy train -h
).
classy train
In its simplest form, classy train
lets you train a transformer-based neural network for one of the tasks supported by classy
(see the documentation).
classy train sentence-pair path/to/dataset/folder-or-file -n my-model
The command above will train a model to predict a label given a pair of sentences as input (e.g., Natural Language Inference or NLI) and save it under experiments/my-model
. This same model can be further used by all other classy
commands which require a classy
model (predict
, evaluate
, serve
, demo
, upload
).
classy predict
classy predict
actually has two subcommands: interactive
and file
.
The first loads the model in memory and lets you try it out through the shell directly, so that you can test the model you trained and see what it predicts given some input. It is particularly useful when your machine cannot open a port for classy demo
.
The second, instead, works on a file and produces an output where, for each input, it associates the corresponding predicted label. It is very useful when doing pre-processing or when you need to evaluate your model (although we offer classy evaluate
for that).
classy evaluate
classy evaluate
lets you evaluate your model on standard metrics for the task your model was trained upon. Simply run classy evaluate my-model path/to/file -o path/to/output/file
and it will dump the evaluation at path/to/output/file
classy serve
classy serve <model>
loads the model in memory and spawns a REST API you can use to query your model with any REST client.
classy demo
classy demo <model>
spawns a Streamlit interface which lets you quickly show and query your model.
classy describe
classy describe <task> --dataset path/to/dataset
runs some common metrics on a file formatted for the specific task. Great tool to run before training your model!
classy upload
classy upload <model>
lets you upload your classy
-trained model on the HuggingFace Hub and lets other users download / use it. (NOTE: you need a HuggingFace Hub account in order to upload to their hub)
Models uploaded via classy upload
will be available for download by other classy users by simply executing classy download username@model
.
classy download
classy download <model>
downloads a previously uploaded classy
-trained model from the HuggingFace Hub and stores it on your machine so that it is usable with any other classy
command which requires a trained model (predict
, evaluate
, serve
, demo
, upload
).
Models uploaded via classy upload
are available by doing classy download username@model
.
Enabling Shell Completion
To install shell completion, activate your conda environment and then execute
classy --install-autocomplete
From now on, whenever you activate your conda environment with classy
installed, you are going to have autocompletion when pressing [TAB]
!
Issues
You are more than welcome to file issues with either feature requests, bug reports, or general questions. If you already found a solution to your problem, don't hesitate to share it. Suggestions for new best practices and tricks are always welcome!
Contributions
We warmly welcome contributions from the community. If it is your first time as a contributor, we recommend you start by reading our CONTRIBUTING.md guide.
Small contributions can be made directly in a pull request. For contributing major features, we recommend you first create a issue proposing a design, so that it can be discussed before you risk wasting time.
Pull requests (PRs) must have one approving review and no requested changes before they are merged.
As classy
is primarily driven by SunglassesAI, we reserve the right to reject or revert contributions that we don't think are good additions or might not fit into our roadmap.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file classy-core-0.3.1.dev20220430.tar.gz
.
File metadata
- Download URL: classy-core-0.3.1.dev20220430.tar.gz
- Upload date:
- Size: 91.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75b150d6b2cdf03d9929dbe89158f61eed6871f109875a9929b454ed82e42661 |
|
MD5 | c695522f9e853b787f6b360bf857f5b9 |
|
BLAKE2b-256 | d97ac826d1269dfccb079bfc27b35ce7af782f655d915831758f4c007dd8ba94 |
File details
Details for the file classy_core-0.3.1.dev20220430-py3-none-any.whl
.
File metadata
- Download URL: classy_core-0.3.1.dev20220430-py3-none-any.whl
- Upload date:
- Size: 129.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2511b07582a0d38b57edde7a1255f273f9364fe1a9bc228e766965196fb51c0c |
|
MD5 | 263817a2e3d4ea580acaf2492a6ad13f |
|
BLAKE2b-256 | 26173cb4d4039ac3ee29847840eb8dde6308b675a6ad1e05f5c8dbed8a55fc41 |