(self, decoding_type_schema=None, decoding_format='tree', source_prefix=None, *args, **kwargs)
| 82 | |
| 83 | class ConstraintSeq2SeqTrainer(Seq2SeqTrainer): |
| 84 | def __init__(self, decoding_type_schema=None, decoding_format='tree', source_prefix=None, *args, **kwargs): |
| 85 | super().__init__(*args, **kwargs) |
| 86 | |
| 87 | self.decoding_format = decoding_format |
| 88 | self.decoding_type_schema = decoding_type_schema # 在event任务中为 event schema |
| 89 | |
| 90 | # Label smoothing by sum token loss, different from different Label smootheing |
| 91 | if self.args.label_smoothing_sum and self.args.label_smoothing_factor != 0: |
| 92 | self.label_smoother = SumLabelSmoother(epsilon=self.args.label_smoothing_factor) |
| 93 | print('Using %s' % self.label_smoother) |
| 94 | elif self.args.label_smoothing_factor != 0: |
| 95 | print('Using %s' % self.label_smoother) |
| 96 | else: |
| 97 | self.label_smoother = None |
| 98 | |
| 99 | if self.args.constraint_decoding: |
| 100 | self.constraint_decoder = get_constraint_decoder(tokenizer=self.tokenizer, |
| 101 | type_schema=self.decoding_type_schema, |
| 102 | decoding_schema=self.decoding_format, |
| 103 | source_prefix=source_prefix) |
| 104 | else: |
| 105 | self.constraint_decoder = None |
| 106 | |
| 107 | def prediction_step( |
| 108 | self, |
nothing calls this directly
no test coverage detected