MCPcopy Index your code
hub / github.com/Turing-Project/WriteGPT / initialize_from_context

Function initialize_from_context

LanguageNetwork/GPT2/train/modeling.py:731–741  ·  view source on GitHub ↗

same signature as sample_step

(initial_context, ignore_ids, news_config, p_for_topp=0.95, do_topk=False)

Source from the content-addressed store, hash-verified

729
730
731def 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
744def sample(news_config: GroverConfig, initial_context, eos_token, min_len, ignore_ids=None, p_for_topp=0.95,

Callers 1

sampleFunction · 0.70

Calls 2

get_shape_listFunction · 0.90
sample_stepFunction · 0.70

Tested by

no test coverage detected