Doc styler examples (#14953)
* Fix bad examples * Add black formatting to style_doc * Use first nonempty line * Put it at the right place * Don't add spaces to empty lines * Better templates * Deal with triple quotes in docstrings * Result of style_doc * Enable mdx treatment and fix code examples in MDXs * Result of doc styler on doc source files * Last fixes * Break copy from
This commit is contained in:
@@ -64,13 +64,13 @@ CANINE works on raw characters, so it can be used without a tokenizer:
|
||||
>>> from transformers import CanineModel
|
||||
>>> import torch
|
||||
|
||||
>>> model = CanineModel.from_pretrained('google/canine-c') # model pre-trained with autoregressive character loss
|
||||
>>> model = CanineModel.from_pretrained("google/canine-c") # model pre-trained with autoregressive character loss
|
||||
|
||||
>>> text = "hello world"
|
||||
>>> # use Python's built-in ord() function to turn each character into its unicode code point id
|
||||
>>> input_ids = torch.tensor([[ord(char) for char in text]])
|
||||
|
||||
>>> outputs = model(input_ids) # forward pass
|
||||
>>> outputs = model(input_ids) # forward pass
|
||||
>>> pooled_output = outputs.pooler_output
|
||||
>>> sequence_output = outputs.last_hidden_state
|
||||
```
|
||||
@@ -81,13 +81,13 @@ sequences to the same length):
|
||||
```python
|
||||
>>> from transformers import CanineTokenizer, CanineModel
|
||||
|
||||
>>> model = CanineModel.from_pretrained('google/canine-c')
|
||||
>>> tokenizer = CanineTokenizer.from_pretrained('google/canine-c')
|
||||
>>> model = CanineModel.from_pretrained("google/canine-c")
|
||||
>>> tokenizer = CanineTokenizer.from_pretrained("google/canine-c")
|
||||
|
||||
>>> inputs = ["Life is like a box of chocolates.", "You never know what you gonna get."]
|
||||
>>> encoding = tokenizer(inputs, padding="longest", truncation=True, return_tensors="pt")
|
||||
|
||||
>>> outputs = model(**encoding) # forward pass
|
||||
>>> outputs = model(**encoding) # forward pass
|
||||
>>> pooled_output = outputs.pooler_output
|
||||
>>> sequence_output = outputs.last_hidden_state
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user