"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "d1f5ca1afd03e38f45062b2a06f1846a7c290da4"
Unverified Commit c8d719ff authored by Joao Gante's avatar Joao Gante Committed by GitHub
Browse files

Generate: precision fix in compute_transition_scores doctests (#21251)

parent e1cd7863
......@@ -975,12 +975,12 @@ class GenerationMixin:
>>> generated_tokens = outputs.sequences[:, input_length:]
>>> for tok, score in zip(generated_tokens[0], transition_scores[0]):
... # | token | token string | logits | probability
... print(f"| {tok:5d} | {tokenizer.decode(tok):8s} | {score.numpy():.4f} | {np.exp(score.numpy()):.2%}")
| 262 | the | -1.4136 | 24.33%
| 1110 | day | -2.6089 | 7.36%
| 618 | when | -2.0096 | 13.40%
| 356 | we | -1.8593 | 15.58%
| 460 | can | -2.5083 | 8.14%
... print(f"| {tok:5d} | {tokenizer.decode(tok):8s} | {score.numpy():.3f} | {np.exp(score.numpy()):.2%}")
| 262 | the | -1.414 | 24.33%
| 1110 | day | -2.609 | 7.36%
| 618 | when | -2.010 | 13.40%
| 356 | we | -1.859 | 15.58%
| 460 | can | -2.508 | 8.14%
>>> # Example 2: Reconstruct the sequence scores from Beam Search
>>> outputs = model.generate(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment