same signature as sample_step
(initial_context, ignore_ids, news_config, p_for_topp=0.95, do_topk=False)
| 729 | |
| 730 | |
| 731 | def initialize_from_context(initial_context, ignore_ids, news_config, p_for_topp=0.95, do_topk=False): |
| 732 | """ same signature as sample_step""" |
| 733 | batch_size, _ = get_shape_list(initial_context, expected_rank=2) |
| 734 | |
| 735 | context_output = sample_step(tokens=initial_context, ignore_ids=ignore_ids, news_config=news_config, |
| 736 | batch_size=batch_size, p_for_topp=p_for_topp, cache=None, do_topk=do_topk) |
| 737 | return { |
| 738 | 'tokens': tf.concat([initial_context, context_output['new_tokens'][:, None]], 1), |
| 739 | 'cache': context_output['new_cache'], |
| 740 | 'probs': context_output['new_probs'][:, None] |
| 741 | } |
| 742 | |
| 743 | |
| 744 | def sample(news_config: GroverConfig, initial_context, eos_token, min_len, ignore_ids=None, p_for_topp=0.95, |
no test coverage detected