Coder Social home page Coder Social logo

Comments (4)

meisyarahd avatar meisyarahd commented on May 28, 2024

I figured I don't have to pass the aforementioned dict key for the distillation to run. So I close this issue

from textbrewer.

meisyarahd avatar meisyarahd commented on May 28, 2024

Hi, I reopen the issue because I'm still curious about the answer to my question. Although my code is working now, I just think the performance might have been influenced since the teacher model doesn't read the "token_type_ids".

In addition to my question above, let's say I want to distill a BERT model to a bi-RNN like in this paper, will Textbrewer be able to handle this case?

from textbrewer.

airaria avatar airaria commented on May 28, 2024

Q1:
If I understand correctly, your question is: how to give different input representations to the teacher and the student? Since your teacher model takes token_type_ids while your student model doesn't.

A solution I come up with is simply adding a **kwargs parameter to your student model's forward method, so that it can accept any additional keyword arguments, for example:

class StudentModel(nn.Module):
    def forward(self, input_ids, attention_masks, labels, **kwargs):
        ...

Now you can use token_type_ids key in your inputs for the both teacher and student.

Q2:
Yes. It's able to distill BERT to Bi-RNN. You could set kd_loss_type to mse and temperature to 1 to get the same loss function as (2) in that paper.

from textbrewer.

meisyarahd avatar meisyarahd commented on May 28, 2024

Thanks! That seems to solve the issue

from textbrewer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.