Draft: Output tensor of logits from DAN prediction for LM rescoring
closes #142 (closed)
Merge request reports
Activity
changed milestone to %ML Prod - Summer 2023
requested review from @starride
By M Generali on 2023-07-25T12:50:38 (imported from GitLab)
assigned to @mgenerali
By M Generali on 2023-07-25T12:50:38 (imported from GitLab)
added 1 commit
- 5800285c - add tot_confidence_score
By M Generali on 2023-07-25T13:11:16 (imported from GitLab)
181 187 confidence_scores.append( 182 188 torch.max(torch.softmax(pred[:, :], dim=1), dim=1).values 183 189 ) 190 tot_confidence_scores.append(torch.softmax(pred[:, :], dim=1)) Why do you need to store confidence scores?
Only
tot_pred
will be used byctc_decoder
(and you will need tolog_softmax
it, see PyLaia)changed this line in version 4 of the diff
- Resolved by Marie Generali
202 214 confidence_scores = ( 203 215 torch.cat(confidence_scores, dim=1).cpu().detach().numpy() 204 216 ) 217 tot_confidence_scores = ( 218 torch.cat(tot_confidence_scores, dim=1).cpu().detach().numpy() 219 ) 205 220 attention_maps = torch.cat(attention_maps, dim=1).cpu().detach().numpy() 206 221 207 222 # Remove bot and eot tokens 208 223 predicted_tokens = predicted_tokens[:, 1:] 224 tot_pred = tot_pred[:, 1:, :] changed this line in version 2 of the diff
202 214 confidence_scores = ( 203 215 torch.cat(confidence_scores, dim=1).cpu().detach().numpy() 204 216 ) 217 tot_confidence_scores = ( 218 torch.cat(tot_confidence_scores, dim=1).cpu().detach().numpy() 219 ) 205 220 attention_maps = torch.cat(attention_maps, dim=1).cpu().detach().numpy() 206 221 207 222 # Remove bot and eot tokens 208 223 predicted_tokens = predicted_tokens[:, 1:] 224 tot_pred = tot_pred[:, 1:, :] 209 225 prediction_len[torch.eq(reached_end, False)] = self.max_chars - 1 210 226 predicted_tokens = [ 211 227 predicted_tokens[i, : prediction_len[i]] for i in range(batch_size) 212 228 ] 229 tot_pred = [tot_pred[i, : prediction_len[i], :] for i in range(batch_size)] changed this line in version 3 of the diff
With
tot_pred
andpredicted_len
, you have everything you need to callctc_decoder
like in PyLaia.Description Variable name in PyLaia Variable name in DAN Batched logits batch_features
tot_pred
Actual sequence size batch_sizes
prediction_len
The only thing is that you will probably need to add fake
blank
tokens between repeated tokens (otherwise they will be merged).assigned to @mgenerali and unassigned @tlavigne
added 25 commits
- 22fde851...b2eca150 - 15 earlier commits
- 3f43f90c - Remove post processing as it's not used
- de30cee4 - Remove curriculum code
- b7813cb8 - Always use the same dropout scheduler function
- 1f59967d - Reorganization
- fa87c2e2 - Compute dataset statistics after extraction/formatting
- 44c856fd - output all logits
- 120ba7b5 - add tot_confidence_score
- c56545b7 - remove print
- 8ee0c3ad - correct wrong truncation
- 0ceedae7 - remove unused variables
Toggle commit listadded 33 commits
-
1b5cac8d...08a96bf6 - 20 commits from branch
main
- 08a96bf6...09099a0f - 3 earlier commits
- c2f2853f - correct wrong truncation
- b45aa14b - remove unused variables
- 98273a9c - Trigger gitlab pages deploy
- 2e3e738b - output all logits
- 292bb8a7 - add tot_confidence_score
- f43888e6 - remove print
- 76249e43 - correct wrong truncation
- 89c03d77 - remove unused variables
- c6bdba7d - add lm option
- 63483436 - pre-commmit
Toggle commit list-
1b5cac8d...08a96bf6 - 20 commits from branch
mentioned in merge request !274 (merged)