Skip to content

Commit 70e3ef5

Browse files
yingyibiaoZeyuChen
andauthored
fix model_utils docstrings (#557)
Co-authored-by: Zeyu Chen <[email protected]>
1 parent 29a8147 commit 70e3ef5

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

paddlenlp/transformers/model_utils.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -334,26 +334,10 @@ def from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs):
334334

335335
def save_model_config(self, save_dir):
336336
"""
337-
Saves model configuration and related resources (model state) as files
338-
under `save_directory`. The model configuration would be saved into a file named
339-
"model_config.json", and model state would be saved into a file
340-
named "model_state.pdparams".
341-
342-
The `save_directory` can be used in `from_pretrained` as argument value
343-
of `pretrained_model_name_or_path` to re-load the trained model.
337+
Saves model configuration to a file named "model_config.json" under `save_dir`.
344338
345339
Args:
346-
save_directory (str): Directory to save files into.
347-
348-
Example:
349-
.. code-block::
350-
351-
from paddlenlp.transformers import BertForSequenceClassification
352-
353-
model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
354-
model.save_pretrained('trained_model')
355-
# reload from save_directory
356-
model = BertForSequenceClassification.from_pretrained('trained_model')
340+
save_dir (str): Directory to save model_config file into.
357341
"""
358342
# Save model config
359343
model_config_file = os.path.join(save_dir, self.model_config_file)
@@ -374,11 +358,26 @@ def save_model_config(self, save_dir):
374358

375359
def save_pretrained(self, save_dir):
376360
"""
377-
Saves model configuration and related resources (model state) to files
378-
under `save_dir`.
361+
Saves model configuration and related resources (model state) as files
362+
under `save_dir`. The model configuration would be saved into a file named
363+
"model_config.json", and model state would be saved into a file
364+
named "model_state.pdparams".
365+
366+
The `save_dir` can be used in `from_pretrained` as argument value
367+
of `pretrained_model_name_or_path` to re-load the trained model.
379368
380369
Args:
381370
save_dir (str): Directory to save files into.
371+
372+
Example:
373+
.. code-block::
374+
375+
from paddlenlp.transformers import BertForSequenceClassification
376+
377+
model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
378+
model.save_pretrained('./trained_model/')
379+
# reload from save_directory
380+
model = BertForSequenceClassification.from_pretrained('./trained_model/')
382381
"""
383382
assert os.path.isdir(
384383
save_dir), "save_dir ({}) is not available.".format(save_dir)

0 commit comments

Comments
 (0)