-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Fix reformer CI #21254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix reformer CI #21254
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2377,15 +2377,17 @@ def forward( | |
| >>> tokenizer.add_special_tokens({"mask_token": "[MASK]"}) # doctest: +IGNORE_RESULT | ||
| >>> inputs = tokenizer("The capital of France is [MASK].", return_tensors="pt") | ||
|
|
||
| >>> # resize model's embedding matrix | ||
| >>> model.resize_token_embeddings(new_num_tokens=model.config.vocab_size + 1) # doctest: +IGNORE_RESULT | ||
|
|
||
| >>> with torch.no_grad(): | ||
| ... logits = model(**inputs).logits | ||
|
|
||
| >>> # retrieve index of [MASK] | ||
| >>> mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[0].nonzero(as_tuple=True)[0] | ||
|
|
||
| >>> predicted_token_id = logits[0, mask_token_index].argmax(axis=-1) | ||
| >>> tokenizer.decode(predicted_token_id) | ||
| 'it' | ||
| >>> predicted_token = tokenizer.decode(predicted_token_id) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. output is random |
||
| ``` | ||
|
|
||
| ```python | ||
|
|
@@ -2396,8 +2398,7 @@ def forward( | |
| ... ) | ||
|
|
||
| >>> outputs = model(**inputs, labels=labels) | ||
| >>> round(outputs.loss.item(), 2) | ||
| 7.09 | ||
| >>> loss = round(outputs.loss.item(), 2) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. output is random |
||
| ``` | ||
| """ | ||
| return_dict = return_dict if return_dict is not None else self.config.use_return_dict | ||
|
|
@@ -2494,8 +2495,7 @@ def forward( | |
| ... logits = model(**inputs).logits | ||
|
|
||
| >>> predicted_class_id = logits.argmax().item() | ||
| >>> model.config.id2label[predicted_class_id] | ||
| 'LABEL_0' | ||
| >>> label = model.config.id2label[predicted_class_id] | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. output is random, as this checkpoint is not seq. classification model. |
||
| ``` | ||
|
|
||
| ```python | ||
|
|
@@ -2507,8 +2507,6 @@ def forward( | |
|
|
||
| >>> labels = torch.tensor(1) | ||
| >>> loss = model(**inputs, labels=labels).loss | ||
| >>> round(loss.item(), 2) | ||
| 0.68 | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. output is random, as this checkpoint is not seq. classification model. |
||
| ``` | ||
| """ | ||
| return_dict = return_dict if return_dict is not None else self.config.use_return_dict | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tiny model checkpoint has some issue. Using fast tokenizer, we get vocab size 1000, while using slow tokenizer, it is 320 (something like that).
This is due to the fact the tiny model creation (the old version) sometimes fail to convert a fast tokenizer to slow tokenizer, and it's not clear to me if the slow tokenizer was uploaded separately after the creation, or if there is something strange and the creation gives a slow tokenizer anyway but with smaller vocab size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(it's would be better to eventually use the v2 of tiny model creation script though for doctest if necessary)