@@ -334,26 +334,10 @@ def from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs):
334
334
335
335
def save_model_config (self , save_dir ):
336
336
"""
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`.
344
338
345
339
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.
357
341
"""
358
342
# Save model config
359
343
model_config_file = os .path .join (save_dir , self .model_config_file )
@@ -374,11 +358,26 @@ def save_model_config(self, save_dir):
374
358
375
359
def save_pretrained (self , save_dir ):
376
360
"""
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.
379
368
380
369
Args:
381
370
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/')
382
381
"""
383
382
assert os .path .isdir (
384
383
save_dir ), "save_dir ({}) is not available." .format (save_dir )
0 commit comments