(alpha, bounds: Union[float, Tuple[float, float]], prompt_ind: int,
word_inds: Optional[torch.Tensor]=None)
| 263 | |
| 264 | |
| 265 | def update_alpha_time_word(alpha, bounds: Union[float, Tuple[float, float]], prompt_ind: int, |
| 266 | word_inds: Optional[torch.Tensor]=None): |
| 267 | if type(bounds) is float: |
| 268 | bounds = 0, bounds |
| 269 | start, end = int(bounds[0] * alpha.shape[0]), int(bounds[1] * alpha.shape[0]) |
| 270 | if word_inds is None: |
| 271 | word_inds = torch.arange(alpha.shape[2]) |
| 272 | alpha[: start, prompt_ind, word_inds] = 0 |
| 273 | alpha[start: end, prompt_ind, word_inds] = 1 |
| 274 | alpha[end:, prompt_ind, word_inds] = 0 |
| 275 | return alpha |
| 276 | |
| 277 | |
| 278 | def get_time_words_attention_alpha(prompts, num_steps, |
no outgoing calls
no test coverage detected