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

Bert models / transformers package #716

Closed
ghost opened this issue Mar 30, 2020 · 3 comments
Closed

Bert models / transformers package #716

ghost opened this issue Mar 30, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 30, 2020

Hi guys,

Hope you are doing all well !

I was wondering if DeepDetect is compatible to load models like camemBERT or flauBert with Tensorflow.

More widely, any models processed by the transformers package, for text classification/sentiment analysis tasks.

Cheers,
X

@beniz
Copy link
Collaborator

beniz commented Mar 30, 2020

Hi, it's compatible with pytorch's models from or derived from Huggingface's package. It may not be fully documented yet, see #616 for inference and there are examples within the unit tests https://github.com/jolibrain/deepdetect/blob/master/tests/ut-torchapi.cc#L64

You'd need to export the models via torchscript so that that they are usable with torch C++ API, this can be achieved with this script, https://github.com/jolibrain/deepdetect/blob/master/tools/torch/trace_pytorch_transformers.py

If you decide to go this route, feel free to ask for help here.

@ghost
Copy link
Author

ghost commented Mar 30, 2020

There are 2 projects I wanted to load through deepdetect.

But I have no clue how to start

@fantes
Copy link
Contributor

fantes commented Mar 30, 2020

Hi
the general principle for current version of deepdetect is (1) that torch models have to be dumped/exported as scripted versions outside of deepdetect , and (2) then loaded as torch::jit::script inside of deepdetect.

  1. First part can be done
  1. Second part is done inside deepdetect/src/backends/torch/torchlib.cc , at first sight, you do not need to change anything here, because flaubert or camembert are basically the same as bert, at least from a structure / api point of view, so you can tell dede you are using bert, and just give the .pt and vocab.dat you want to use. up - to -date doc for doing so is at bert + gpt2 inference + training wrt torch 1.3.1 and transformers 2.2.1 #673

@beniz beniz closed this as completed Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants