mirror of https://github.com/maderix/ANE.git
optimize singleton token params in generate_text
This commit is contained in:
parent
1b792fce34
commit
65cfc3255f
|
|
@ -142,7 +142,7 @@ def softmax(x):
|
||||||
e = np.exp(x)
|
e = np.exp(x)
|
||||||
return e / np.sum(e)
|
return e / np.sum(e)
|
||||||
|
|
||||||
def generate_text(W, tok, max_tokens=64, temperature=0.8):
|
def generate_text(W, max_tokens=64, temperature=0.8):
|
||||||
tokenizer = get_tokenizer()
|
tokenizer = get_tokenizer()
|
||||||
if tokenizer is None:
|
if tokenizer is None:
|
||||||
return '[no tokenizer]'
|
return '[no tokenizer]'
|
||||||
|
|
@ -244,7 +244,7 @@ def generation_thread():
|
||||||
with S.gen_lock:
|
with S.gen_lock:
|
||||||
S.gen_status = 'idle'
|
S.gen_status = 'idle'
|
||||||
continue
|
continue
|
||||||
text = generate_text(W, get_tokenizer(), max_tokens=64, temperature=0.8)
|
text = generate_text(W, max_tokens=64, temperature=0.8)
|
||||||
with S.gen_lock:
|
with S.gen_lock:
|
||||||
S.gen_text = text
|
S.gen_text = text
|
||||||
S.gen_step = S.step
|
S.gen_step = S.step
|
||||||
|
|
@ -851,7 +851,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
W = load_weights_from_ckpt(CKPT_PATH)
|
W = load_weights_from_ckpt(CKPT_PATH)
|
||||||
if W:
|
if W:
|
||||||
text = generate_text(W, get_tokenizer(), max_tokens=64, temperature=0.8)
|
text = generate_text(W, max_tokens=64, temperature=0.8)
|
||||||
with S.gen_lock:
|
with S.gen_lock:
|
||||||
S.gen_text = text
|
S.gen_text = text
|
||||||
S.gen_step = S.step
|
S.gen_step = S.step
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue