guillaume-be / rust-bert

Rust native ready-to-use NLP pipelines and transformer-based models (BERT, DistilBERT, GPT2,...)
https://docs.rs/crate/rust-bert
Apache License 2.0
2.51k stars 211 forks source link

Electra w/Sequence classification? #413

Open jondot opened 10 months ago

jondot commented 10 months ago

I've been reading the code, but unsure if sequence classification is supported in some undocumented way with ELECTRA?

guillaume-be commented 10 months ago

Hello @jondot ,

You are correct this is currently missing. It is probably straightforward to add and I could publish an update, unless you would like to work on this?

jondot commented 10 months ago

I haven't yet studied the mechanics of implementing such a thing, I can't manage to keep up (just learned about ELECTRA's existence via a model I need to use), I'm wondering if this is something you can point some learning material for me and I'd have a high chances of success?

jondot commented 10 months ago

@guillaume-be from what I could study from the code, having a TokenClassifier already -- I would just copy it and change the copied structs and such to SequenceClassfier, the rest is again just copying around, there's no new logic that separates a Token and Sequence classifier other than the stuff in the pipeline. Inside the models it's all similar. So having that Electra has a token classifier, the job is already done for the sequence classifier. Is that a correct assumption?

guillaume-be commented 10 months ago

I would recommend checking a combination of the following resources:

If you have a candidate model that is useful it would also be great to publish these weights and register them in the pretrained models -- this would allow adding a test for your implementation