(
self,
data_dict: dict=None,
is_eval: bool=False,
is_generate: bool=False,
num_return_sequences: int=8,
generation_config: Dict=dict(
do_sample=True,
top_k=50,
top_p=0.95,
# no_repeat_ngram_size=9,
)
)
| 46 | |
| 47 | |
| 48 | def forward( |
| 49 | self, |
| 50 | data_dict: dict=None, |
| 51 | is_eval: bool=False, |
| 52 | is_generate: bool=False, |
| 53 | num_return_sequences: int=8, |
| 54 | generation_config: Dict=dict( |
| 55 | do_sample=True, |
| 56 | top_k=50, |
| 57 | top_p=0.95, |
| 58 | # no_repeat_ngram_size=9, |
| 59 | ) |
| 60 | ) -> dict: |
| 61 | |
| 62 | if not is_eval: |
| 63 | return self.train_one_step(data_dict) |
| 64 | |
| 65 | if is_eval and not is_generate: |
| 66 | return self.perplexity(data_dict) |
| 67 | |
| 68 | if is_eval and is_generate: |
| 69 | return self.generate( |
| 70 | data_dict=data_dict, |
| 71 | num_return_sequences=num_return_sequences, |
| 72 | generation_config=generation_config |
| 73 | ) |
| 74 | |
| 75 | raise NotImplementedError('training status undefined!') |
| 76 | return |
| 77 | |
| 78 | |
| 79 | def loss_wrapper(self, loss: Tensor) -> Tensor: |
nothing calls this directly
no test coverage detected