mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 17:29:22 +01:00
Improve logit viewer format
This commit is contained in:
parent
6d6f40e8f8
commit
c0b119c3a3
@ -20,11 +20,12 @@ def get_next_logits(prompt, state, use_samplers, previous):
|
|||||||
scores = output['logits'][-1][-1]
|
scores = output['logits'][-1][-1]
|
||||||
|
|
||||||
probs = torch.softmax(scores, dim=-1, dtype=torch.float)
|
probs = torch.softmax(scores, dim=-1, dtype=torch.float)
|
||||||
topk_values, topk_indices = torch.topk(probs, k=20, largest=True, sorted=True)
|
topk_values, topk_indices = torch.topk(probs, k=25, largest=True, sorted=True)
|
||||||
topk_values = [f"{float(i):.5f}" for i in topk_values]
|
topk_values = [f"{float(i):.5f}" for i in topk_values]
|
||||||
|
tokens = [shared.tokenizer.decode(i) for i in topk_indices]
|
||||||
|
|
||||||
output = ''
|
output = ''
|
||||||
for row in list(zip(topk_values, shared.tokenizer.convert_ids_to_tokens(topk_indices))):
|
for row in list(zip(topk_values, tokens)):
|
||||||
output += f"{row[0]} - {row[1]}\n"
|
output += f"{row[0]} - {row[1]}\n"
|
||||||
|
|
||||||
return output, previous
|
return output, previous
|
||||||
|
Loading…
Reference in New Issue
Block a user