Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples for using PyTorch models? #27

Closed
githubrandomuser2017 opened this issue Sep 1, 2020 · 4 comments
Closed

Examples for using PyTorch models? #27

githubrandomuser2017 opened this issue Sep 1, 2020 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@githubrandomuser2017
Copy link

The LIT documentation says Framework-agnostic and compatible with TensorFlow, PyTorch, and more, but I'm having a hard time figuring out what exactly I need to do in order to run a PyTorch model in LIT. To be specific, I would like to use PyTorch models written using the TorchText library and/or the HuggingFace Transformers library.

When I looked through the code in https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/models/glue_models.py, I see references to tf.keras and tf.GradientTape, which are obviously for TensorFlow.

Would it be possible for you to please add one or two examples showing how to use PyTorch with LIT?

@iftenney iftenney added the documentation Improvements or additions to documentation label Sep 1, 2020
@wmmxk
Copy link

wmmxk commented Sep 1, 2020

There is a package for interpreting pytorch model here: https://captum.ai/tutorials/IMDB_TorchText_Interpret

@iftenney
Copy link
Collaborator

iftenney commented Sep 1, 2020

Yup - we'll release something for this very soon. The existing examples use TensorFlow on the backend, but everything from the Model class is returned as NumPy arrays so you can pretty much just replace the TF lines with their PyTorch equivalents.

@githubrandomuser2017
Copy link
Author

@wmmxk Thank you. That Captum package looks awesome.

@iftenney
Copy link
Collaborator

iftenney commented Sep 3, 2020

Pytorch demo added in #29 - see https://github.com/PAIR-code/lit/blob/main/lit_nlp/examples/simple_pytorch_demo.py

@iftenney iftenney closed this as completed Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants