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

How to train a task with soft label? #1337

Closed
chawannut157 opened this issue Aug 25, 2021 · 1 comment
Closed

How to train a task with soft label? #1337

chawannut157 opened this issue Aug 25, 2021 · 1 comment

Comments

@chawannut157
Copy link

chawannut157 commented Aug 25, 2021

I'm quite new to Jiant and trying to implement knowledge distillation method.
https://arxiv.org/abs/1904.09482

Basically given soft labels (One sample): Y = [0.3,0.4,0.3] and logit(X) = [0.2,0.3,0.5].
The costs function can be KL divergence, cross entropy etc.

Can you suggest how to extend the framework to support such task?
First, it seems like I need to adjust this part which should not be too hard

logits = self.head(unpooled=encoder_output.unpooled, spans=batch.spans)
if compute_loss:
loss_fct = nn.CrossEntropyLoss()
loss = loss_fct(logits.view(-1, self.head.num_labels), batch.label_id.view(-1),)
return LogitsAndLossOutput(logits=logits, loss=loss, other=encoder_output.other)
else:
return LogitsOutput(logits=logits, other=encoder_output.other)

Then I need to change batch.label_id.view(-1) to support the format of soft labels.
Can you guide on this one? Is there a similar task that already do this?

@sleepinyourhat
Copy link
Contributor

My impression is that the hard label format is baked in in a few places, so you'll have to do some significant investigation on your own to make this change, and it's out of scope for what we currently support. That said, @zphang might be able say more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants