Resources

What's New in the Torch Ecosystem - posit::conf(2023)

Presented by Daniel Falbel torch is an R port of PyTorch, a scientific computing library that enables fast and easy creation and training of deep learning models. In this talk, you will learn about the latest features and developments in torch, such as luz, a higher-level interface that simplifies your model training code, and vetiver, a new integration that allows you to deploy your torch models with just a few lines of code. You will also see how torch works well with other R packages and tools to enhance your data science workflow. Whether you are new to torch or already an experienced user, this talk will show you how torch can help you tackle your data science challenges and inspire you to build your own models. Presented at Posit Conference, between Sept 19-20 2023, Learn more at posit.co/conference. -------------------------- Talk Track: Lightning talks. Session Code: TALK-1163

image: thumbnail.jpg

Transcript#

This transcript was generated automatically and may contain errors.

Hi everyone, my name is Daniel, I'm a software engineer at Posit, and today I'm going to talk about what is new in the Torch ecosystem.

But first, what exactly is Torch? So Torch is a port of PyTorch for R, and it's essentially a scientific computing library providing a consistent API for computing on arrays and matrices, but it has strong support for hardware acceleration, so you can run these computations on your GPU to make them much faster. And it also has support for a built-in automatic differentiation system in the package, so it can be used for statistical and deep learning modeling. It is also a deep learning framework, so it implements most of the building blocks of modern deep learning models, such as layers and optimizers.

Getting started with Torch

But Torch is a big project, and just like a big city, it's hard to find your way around it when you are getting started, and we hope this is much better now because we recently announced the Deep Learning and Scientific Computing with R Torch book. This book was written by Sigrid K. Dana, my colleague at Posit, and it is available for free online, or you can buy it from CRCpress, and it covers the basics of deep learning as well as really implementing the models in Torch and R.

luz: a higher-level interface

But still, navigating in large cities is hard, and it's much easier if you have the metro, and that's what Luce is for Torch. So Luce abstracts away much of the boilerplate code that you need to write when training deep learning models with Torch, and its API is inspired by Fast.ai and Keras, which are successful libraries in Python, and so it's still very flexible and extensible with callbacks, metrics, and et cetera.

So with Luce, you write your model exactly the same way you would write when using raw Torch, but instead of manually handling a lot of details, such as moving the model to the correct device or manually iterating over your data, you let Luce do everything for you. So your code is cleaner, and it's also much less error prone.

So your code is cleaner, and it's also much less error prone.

TabNet, brulee, and Hugging Face integrations

But sometimes you don't want to learn all the details and everything, and you can pick a taxi, and that's what TabNet and Brule help in Torch. They are actually just tidy models extensions powered by Torch that you can call with single liners like this to train neural network models on tabular data, and they can also be used in your usual tidy models workflows and vet deployments and et cetera.

And finally, it's nice to talk with the local community. So we recently announced hugging face integrations. So we have the Torch package and the HF hub. With HF hub, you can download large models hosted in the hugging face hub. For example, if you were in Jeremy Howard's talk where he downloaded a llama model into Python, you can do this in R using HF hub and then load the model weights into R. And Torch can be used to use the exact same preprocessing pipelines as they use when training the model. So you get the exact same result.

So in theory, you can run these models directly in R without even having a Python installation.

And thank you very much. Next week, we'll be teaching Torch in the workshops for Ukraine project. And it's a nice opportunity if you want to learn more about Torch and get started. Thank you.