Package: thinc
Thinc: A refreshing functional take on deep learning, compatible with your favorite librariesFrom the makers ofspaCyandProdigyThincis alightweight deep learning librarythat offers
an elegant, type-checked, functional-programming API forcomposing models,
with support for layers defined in other frameworks such asPyTorch,
TensorFlow and MXNet. You can use Thinc as an interface layer, a standalone
toolkit or a flexible way to develop new models. Previous versions of Thinc have
been running quietly in production in thousands of companies, via bothspaCyandProdigy. We wrote the new
version to let userscompose, configure and deploy custom modelsbuilt with
their favorite framework.🔥 FeaturesType-checkyour model definitions with custom types andmypyplugin.WrapPyTorch,TensorFlowandMXNetmodels for use in your network.Concisefunctional-programmingapproach to model definition, using
composition rather than inheritance.Optional custom infix notation viaoperator overloading.Integratedconfig systemto describe trees of objects and hyperparameters.Choice ofextensible backends.Read more →🚀 QuickstartThinc is compatible withPython 3.6+and runs onLinux,macOSandWindows. The latest releases with binary wheels are available frompip. Before you install Thinc and its
dependencies, make sure that yourpip,setuptoolsandwheelare up to
date. For the most recent releases, pip 19.3 or newer is recommended.pipinstall-Upipsetuptoolswheel
pipinstallthincSee theextended installation docsfor
details on optional dependencies for different backends and GPU. You might also
want toset up static type checkingto
take advantage of Thinc's type system.⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the
packagedataclasseswithpip uninstall dataclasses, since it may have been
installed by PyTorch and is incompatible with Python 3.7+.📓 Selected examples and notebooksAlso see the/examplesdirectory andusage documentationfor more examples. Most examples
are Jupyter notebooks – to launch them onGoogle Colab(with GPU support!) click on
the button next to the notebook name.NotebookDescriptionintro_to_thincEverything you need to know to get started. Composing and training a model on the MNIST data, using config files, registering custom functions and wrapping PyTorch, TensorFlow and MXNet models.transformers_tagger_bertHow to use Thinc,transformersand PyTorch to train a part-of-speech tagger. From model definition and config to the training loop.pos_tagger_basic_cnnImplementing and training a basic CNN for part-of-speech tagging model without external dependencies and using different levels of Thinc's config system.parallel_training_rayHow to set up synchronous and asynchronous parameter server training with Thinc andRay.View more →📖 Documentation & usage guidesDocumentationDescriptionIntroductionEverything you need to know.Concept & DesignThinc's conceptual model and how it works.Defining and using modelsHow to compose models and update state.Configuration systemThinc's config system and function registry.Integrating PyTorch, TensorFlow & MXNetInteroperability with machine learning frameworksLayers APIWeights layers, transforms, combinators and wrappers.Type CheckingType-check your model definitions and more.🗺 What's whereModuleDescriptionthinc.apiUser-facing API.All classes and functions should be imported from here.thinc.typesCustomtypes and dataclasses.thinc.modelTheModelclass. All Thinc models are an instance (not a subclass) ofModel.thinc.layersThe layers. Each layer is implemented in its own module.thinc.shimsInterface for external models implemented in PyTorch, TensorFlow etc.thinc.lossFunctions to calculate losses.thinc.optimizersFunctions to create optimizers. Currently supports "vanilla" SGD, Adam and RAdam.thinc.schedulesGenerators for different rates, schedules, decays or series.thinc.backendsBackends fornumpyandcupy.thinc.configConfig parsing and validation and function registry system.thinc.utilUtilities and helper functions.🐍 Development notesThinc usesblackfor auto-formatting,flake8for linting andmypyfor type checking. All code is
written compatible withPython 3.6+, with type hints wherever possible. See
thetype referencefor more details on
Thinc's custom types.👷‍♀️ Building Thinc from sourceBuilding Thinc from source requires the full dependencies listed inrequirements.txtto be installed. You'll also need a
compiler to build the C extensions.gitclonehttps://github.com/explosion/thinccdthinc
python-mvenv.envsource.env/bin/activate
pipinstall-Upipsetuptoolswheel
pipinstall-rrequirements.txt
pipinstall--no-build-isolation.Alternatively, install in editable mode:pipinstall-rrequirements.txt
pipinstall--no-build-isolation--editable.Or by settingPYTHONPATH:exportPYTHONPATH=`pwd`pipinstall-rrequirements.txt
pythonsetup.pybuild_ext--inplace🚦 Running testsThinc comes with anextensive test suite. The following should
all pass and not report any warnings or errors:python-mpytestthinc# test suitepython-mmypythinc# type checkspython-mflake8thinc# lintingTo view test coverage, you can runpython -m pytest thinc --cov=thinc. We aim
for a 100% test coverage. This doesn't mean that we meticulously write tests for
every single line – we ignore blocks that are not relevant or difficult to test
and make sure that the tests execute all code paths.