base
mindnlp.engine.train_args.OptimizerNames
¶
Bases: ExplicitEnum
Stores the acceptable string identifiers for optimizers.
Source code in mindnlp/engine/train_args/base.py
78 79 80 81 82 83 |
|
mindnlp.engine.train_args.TrainingArguments
dataclass
¶
TrainingArguments is the subset of the arguments we use in our example scripts which relate to the training loop itself.
PARAMETER | DESCRIPTION |
---|---|
output_dir |
The output directory where the model predictions and checkpoints will be written.
TYPE:
|
overwrite_output_dir |
If
TYPE:
|
do_train |
Whether to run training or not. This argument is not directly used by [
TYPE:
|
do_eval |
Whether to run evaluation on the validation set or not. Will be set to
TYPE:
|
do_predict |
Whether to run predictions on the test set or not. This argument is not directly used by [
TYPE:
|
evaluation_strategy |
The evaluation strategy to adopt during training. Possible values are:
TYPE:
|
prediction_loss_only |
When performing evaluation and generating predictions, only returns the loss.
TYPE:
|
per_device_train_batch_size |
The batch size per GPU/XPU/TPU/MPS/NPU core/CPU for training.
TYPE:
|
per_device_eval_batch_size |
The batch size per GPU/XPU/TPU/MPS/NPU core/CPU for evaluation.
TYPE:
|
gradient_accumulation_steps |
Number of updates steps to accumulate the gradients for, before performing a backward/update pass. When using gradient accumulation, one step is counted as one step with backward pass. Therefore, logging,
evaluation, save will be conducted every
TYPE:
|
eval_accumulation_steps |
Number of predictions steps to accumulate the output tensors for, before moving the results to the CPU. If left unset, the whole predictions are accumulated on GPU/NPU/TPU before being moved to the CPU (faster but requires more memory).
TYPE:
|
eval_delay |
Number of epochs or steps to wait for before the first evaluation can be performed, depending on the evaluation_strategy.
TYPE:
|
learning_rate |
The initial learning rate for [
TYPE:
|
weight_decay |
The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights in [
TYPE:
|
adam_beta1 |
The beta1 hyperparameter for the [
TYPE:
|
adam_beta2 |
The beta2 hyperparameter for the [
TYPE:
|
adam_epsilon |
The epsilon hyperparameter for the [
TYPE:
|
max_grad_norm |
Maximum gradient norm (for gradient clipping).
TYPE:
|
num_train_epochs(`float`, |
Total number of training epochs to perform (if not an integer, will perform the decimal part percents of the last epoch before stopping training).
TYPE:
|
max_steps |
If set to a positive number, the total number of training steps to perform. Overrides
TYPE:
|
lr_scheduler_type |
The scheduler type to use. See the documentation of [
TYPE:
|
lr_scheduler_kwargs |
The extra arguments for the lr_scheduler. See the documentation of each scheduler for possible values.
TYPE:
|
warmup_ratio |
Ratio of total training steps used for a linear warmup from 0 to
TYPE:
|
warmup_steps |
Number of steps used for a linear warmup from 0 to
TYPE:
|
log_level |
Logger log level to use on the main process. Possible choices are the log levels as strings: 'debug',
'info', 'warning', 'error' and 'critical', plus a 'passive' level which doesn't set anything and keeps the
current log level for the Transformers library (which will be
TYPE:
|
log_level_replica |
Logger log level to use on replicas. Same choices as
TYPE:
|
log_on_each_node |
In multinode distributed training, whether to log using
TYPE:
|
logging_dir |
TensorBoard log directory. Will default to output_dir/runs/**CURRENT_DATETIME_HOSTNAME**.
TYPE:
|
logging_strategy |
The logging strategy to adopt during training. Possible values are:
TYPE:
|
logging_first_step |
Whether to log the first
TYPE:
|
logging_steps |
Number of update steps between two logs if
TYPE:
|
logging_nan_inf_filter |
Whether to filter
TYPE:
|
save_strategy |
The checkpoint save strategy to adopt during training. Possible values are:
TYPE:
|
save_steps |
Number of updates steps before two checkpoint saves if
TYPE:
|
save_total_limit |
If a value is passed, will limit the total amount of checkpoints. Deletes the older checkpoints in
TYPE:
|
save_safetensors |
Use safetensors saving and loading for state dicts instead of
default
TYPE:
|
save_on_each_node |
When doing multi-node distributed training, whether to save models and checkpoints on each node, or only on the main one. This should not be activated when the different nodes use the same storage as the files will be saved with the same names for each node.
TYPE:
|
save_only_model |
When checkpointing, whether to only save the model, or also the optimizer, scheduler & rng state.
Note that when this is true, you won't be able to resume training from checkpoint.
This enables you to save storage by not storing the optimizer, scheduler & rng state.
You can only load the model using
TYPE:
|
use_cpu |
Whether or not to use cpu. If set to False, we will use cuda or mps device if available.
TYPE:
|
seed |
Random seed that will be set at the beginning of training. To ensure reproducibility across runs, use the
[
TYPE:
|
data_seed |
Random seed to be used with data samplers. If not set, random generators for data sampling will use the
same seed as
TYPE:
|
jit_mode_eval |
Whether or not to use MindSpore jit trace for inference.
TYPE:
|
use_ipex |
Use Intel extension for MindSpore when it is available.
TYPE:
|
bf16 |
Whether to use bf16 16-bit (mixed) precision training instead of 32-bit training. Requires Ampere or higher NVIDIA architecture or using CPU (use_cpu) or Ascend NPU. This is an experimental API and it may change.
TYPE:
|
fp16 |
Whether to use fp16 16-bit (mixed) precision training instead of 32-bit training.
TYPE:
|
fp16_opt_level |
For
TYPE:
|
fp16_backend |
This argument is deprecated. Use
TYPE:
|
half_precision_backend |
The backend to use for mixed precision training. Must be one of
TYPE:
|
bf16_full_eval |
Whether to use full bfloat16 evaluation instead of 32-bit. This will be faster and save memory but can harm metric values. This is an experimental API and it may change.
TYPE:
|
fp16_full_eval |
Whether to use full float16 evaluation instead of 32-bit. This will be faster and save memory but can harm metric values.
TYPE:
|
local_rank |
Rank of the process during distributed training.
TYPE:
|
ddp_backend |
The backend to use for distributed training. Must be one of
TYPE:
|
tpu_num_cores |
When training on TPU, the number of TPU cores (automatically passed by launcher script).
TYPE:
|
dataloader_drop_last |
Whether to drop the last incomplete batch (if the length of the dataset is not divisible by the batch size) or not.
TYPE:
|
eval_steps |
Number of update steps between two evaluations if
TYPE:
|
dataloader_num_workers |
Number of subprocesses to use for data loading (MindSpore only). 0 means that the data will be loaded in the main process.
TYPE:
|
past_index |
Some models like TransformerXL or XLNet can make use of
the past hidden states for their predictions. If this argument is set to a positive int, the
TYPE:
|
run_name |
TYPE:
|
disable_tqdm |
Whether or not to disable the tqdm progress bars and table of metrics produced by
[
TYPE:
|
remove_unused_columns |
Whether or not to automatically remove the columns unused by the model forward method.
TYPE:
|
label_names |
The list of keys in your dictionary of inputs that correspond to the labels. Will eventually default to the list of argument names accepted by the model that contain the word "label",
except if the model used is one of the
TYPE:
|
load_best_model_at_end |
Whether or not to load the best model found during training at the end of training. When this option is
enabled, the best checkpoint will always be saved. See
When set to
TYPE:
|
metric_for_best_model |
Use in conjunction with If you set this value,
TYPE:
|
greater_is_better |
Use in conjunction with
TYPE:
|
ignore_data_skip |
When resuming training, whether or not to skip the epochs and batches to get the data loading at the same
stage as in the previous training. If set to
TYPE:
|
fsdp |
Use MindSpore Distributed Parallel Training (in distributed training only). A list of options along the following:
TYPE:
|
fsdp_config |
Config to be used with fsdp (MindSpore Distributed Parallel Training). The value is either a location of
fsdp json config file (e.g., A List of config and its options:
- min_num_params (
TYPE:
|
deepspeed |
Use Deepspeed. This is an experimental feature and its API may
evolve in the future. The value is either the location of DeepSpeed json config file (e.g.,
TYPE:
|
accelerator_config |
Config to be used with the internal A list of config and its options:
- split_batches (
TYPE:
|
label_smoothing_factor |
The label smoothing factor to use. Zero means no label smoothing, otherwise the underlying onehot-encoded
labels are changed from 0s and 1s to
TYPE:
|
debug |
Enable one or more debug features. This is an experimental feature. Possible options are:
The options should be separated by whitespaces.
TYPE:
|
optim |
The optimizer to use: adamw, sgd.
TYPE:
|
optim_args |
Optional arguments that are supplied to AnyPrecisionAdamW.
TYPE:
|
group_by_length |
Whether or not to group together samples of roughly the same length in the training dataset (to minimize padding applied and be more efficient). Only useful if applying dynamic padding.
TYPE:
|
length_column_name |
Column name for precomputed lengths. If the column exists, grouping by length will use these values rather
than computing them on train startup. Ignored unless
TYPE:
|
report_to |
The list of integrations to report the results and logs to. Supported platforms are
TYPE:
|
ddp_find_unused_parameters |
When using distributed training, the value of the flag
TYPE:
|
ddp_bucket_cap_mb |
When using distributed training, the value of the flag
TYPE:
|
ddp_broadcast_buffers |
When using distributed training, the value of the flag
TYPE:
|
dataloader_persistent_workers |
If True, the data loader will not shut down the worker processes after a dataset has been consumed once.
This allows to maintain the workers Dataset instances alive. Can potentially speed up training, but will
increase RAM usage. Will default to
TYPE:
|
dataloader_prefetch_factor |
Number of batches loaded in advance by each worker. 2 means there will be a total of 2 * num_workers batches prefetched across all workers.
TYPE:
|
skip_memory_metrics |
Whether to skip adding of memory profiler reports to metrics. This is skipped by default because it slows down the training and evaluation speed.
TYPE:
|
push_to_hub |
Whether or not to push the model to the Hub every time the model is saved. If this is activated,
If
TYPE:
|
resume_from_checkpoint |
The path to a folder with a valid checkpoint for your model. This argument is not directly used by
[
TYPE:
|
hub_model_id |
The name of the repository to keep in sync with the local output_dir. It can be a simple model ID in
which case the model will be pushed in your namespace. Otherwise it should be the whole repository name,
for instance Will default to the name of
TYPE:
|
hub_strategy |
Defines the scope of what is pushed to the Hub and when. Possible values are:
TYPE:
|
hub_token |
The token to use to push the model to the Hub. Will default to the token in the cache folder obtained with
TYPE:
|
hub_private_repo |
If True, the Hub repo will be set to private.
TYPE:
|
hub_always_push |
Unless this is
TYPE:
|
recompute |
If True, use gradient checkpointing to save memory at the expense of slower backward pass.
TYPE:
|
recompute_kwargs |
Key word arguments to be passed to the
TYPE:
|
include_inputs_for_metrics |
Whether or not the inputs will be passed to the
TYPE:
|
ray_scope |
The scope to use when doing hyperparameter search with Ray. By default,
TYPE:
|
ddp_timeout |
The timeout for
TYPE:
|
use_mps_device |
This argument is deprecated.
TYPE:
|
nn_compile |
This will use the best defaults for the [ This flag and the whole compile API is experimental and subject to change in future releases.
TYPE:
|
nn_compile_backend |
The backend to use in Refer to the MindSpore doc for possible values and note that they may change across MindSpore versions. This flag is experimental and subject to change in future releases.
TYPE:
|
nn_compile_mode |
The mode to use in Refer to the MindSpore doc for possible values and note that they may change across MindSpore versions. This flag is experimental and subject to change in future releases.
TYPE:
|
split_batches |
Whether or not the accelerator should split the batches yielded by the dataloaders across the devices during distributed training. If set to round multiple of the number of processes you are using (such as GPUs).
TYPE:
|
include_tokens_per_second |
Whether or not to compute the number of tokens per second per device for training speed metrics. This will iterate over the entire training dataloader once beforehand, and will slow down the entire process.
TYPE:
|
include_num_input_tokens_seen |
Whether or not to track the number of input tokens seen throughout training. May be slower in distributed training as gather operations must be called.
TYPE:
|
neftune_noise_alpha |
If not
TYPE:
|
Source code in mindnlp/engine/train_args/base.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 |
|
mindnlp.engine.train_args.TrainingArguments.ddp_timeout_delta: timedelta
property
¶
The actual timeout for mindspore.communication.init since it expects a timedelta variable.
mindnlp.engine.train_args.TrainingArguments.eval_batch_size: int
property
¶
The actual batch size for evaluation (may differ from per_gpu_eval_batch_size
in distributed training).
mindnlp.engine.train_args.TrainingArguments.local_process_index
property
¶
The index of the local process used.
mindnlp.engine.train_args.TrainingArguments.n_device
property
¶
Returns the number of devices used for training.
PARAMETER | DESCRIPTION |
---|---|
self |
The object instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return a value. |
RAISES | DESCRIPTION |
---|---|
None
|
This method does not raise any exceptions. |
mindnlp.engine.train_args.TrainingArguments.parallel_mode
property
¶
The current mode used for parallelism if multiple GPUs/TPU cores are available. One of:
ParallelMode.NOT_PARALLEL
: no parallelism (CPU or one GPU).ParallelMode.NOT_DISTRIBUTED
: several GPUs in one single process (usesnn.DataParallel
).ParallelMode.DISTRIBUTED
: several GPUs, each having its own process (usesnn.DistributedDataParallel
).ParallelMode.TPU
: several TPU cores.
mindnlp.engine.train_args.TrainingArguments.process_index
property
¶
The index of the current process used.
mindnlp.engine.train_args.TrainingArguments.should_log
property
¶
Whether or not the current process should produce log.
mindnlp.engine.train_args.TrainingArguments.should_save
property
¶
Whether or not the current process should write to disk, e.g., to save models and checkpoints.
mindnlp.engine.train_args.TrainingArguments.train_batch_size: int
property
¶
The actual batch size for training (may differ from per_gpu_train_batch_size
in distributed training).
mindnlp.engine.train_args.TrainingArguments.world_size
property
¶
The number of processes used in parallel.
mindnlp.engine.train_args.TrainingArguments.__post_init__()
¶
This method initializes the TrainingArguments class instance after its creation.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the TrainingArguments class.
|
RETURNS | DESCRIPTION |
---|---|
None. This method does not return any value. |
RAISES | DESCRIPTION |
---|---|
-ValueError
|
If the evaluation strategy requires non-zero evaluation steps or logging steps are zero. |
-FutureWarning
|
If using |
-ValueError
|
If the logging strategy requires non-zero logging steps or steps are not an integer. |
-ValueError
|
If the saving steps are not an integer when required. |
-ValueError
|
If |
-ValueError
|
If the saving steps are not a multiple of evaluation steps for |
-ValueError
|
If |
-ValueError
|
If both |
-ValueError
|
If both |
-ValueError
|
If lr_scheduler_type is reduce_lr_on_plateau but eval strategy or mindspore is not available. |
-ValueError
|
If warmup_ratio is not in the range [0,1] or if both warmup_ratio and warmup_steps are provided. |
-ValueError
|
If dataset_prefetch_factor is set without dataset_num_workers > 1. |
Source code in mindnlp/engine/train_args/base.py
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
|
mindnlp.engine.train_args.TrainingArguments.__str__()
¶
This method returns a string representation of the TrainingArguments object.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the TrainingArguments class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method returns a string representation of the TrainingArguments object. |
Source code in mindnlp/engine/train_args/base.py
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
|
mindnlp.engine.train_args.TrainingArguments.get_process_log_level()
¶
Returns the log level to be used depending on whether this process is the main process of node 0, main process of node non-0, or a non-main process.
For the main process the log level defaults to the logging level set (logging.WARNING
if you didn't do
anything) unless overridden by log_level
argument.
For the replica processes the log level defaults to logging.WARNING
unless overridden by log_level_replica
argument.
The choice between the main and replica process settings is made according to the return value of should_log
.
Source code in mindnlp/engine/train_args/base.py
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 |
|
mindnlp.engine.train_args.TrainingArguments.get_warmup_steps(num_training_steps)
¶
Get number of steps used for a linear warmup.
Source code in mindnlp/engine/train_args/base.py
1329 1330 1331 1332 1333 1334 1335 1336 |
|
mindnlp.engine.train_args.TrainingArguments.main_process_first(local=True, desc='work')
¶
A context manager for MindSpore distributed environment where on needs to do something on the main process, while blocking replicas, and when it's finished releasing the replicas.
One such use is for datasets
's map
feature which to be efficient should be run once on the main process,
which upon completion saves a cached version of results and which then automatically gets loaded by the
replicas.
PARAMETER | DESCRIPTION |
---|---|
local |
if
TYPE:
|
desc |
a work description to be used in debug logs
TYPE:
|
Source code in mindnlp/engine/train_args/base.py
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 |
|
mindnlp.engine.train_args.TrainingArguments.set_dataloader(train_batch_size=8, eval_batch_size=8, drop_last=False, num_workers=0, pin_memory=True, persistent_workers=False, prefetch_factor=None, auto_find_batch_size=False, ignore_data_skip=False, sampler_seed=None)
¶
A method that regroups all arguments linked to the dataloaders creation.
PARAMETER | DESCRIPTION |
---|---|
drop_last |
Whether to drop the last incomplete batch (if the length of the dataset is not divisible by the batch size) or not.
TYPE:
|
num_workers |
Number of subprocesses to use for data loading (MindSpore only). 0 means that the data will be loaded in the main process.
TYPE:
|
pin_memory |
Whether you want to pin memory in data loaders or not. Will default to
TYPE:
|
persistent_workers |
If True, the data loader will not shut down the worker processes after a dataset has been consumed
once. This allows to maintain the workers Dataset instances alive. Can potentially speed up training,
but will increase RAM usage. Will default to
TYPE:
|
prefetch_factor |
Number of batches loaded in advance by each worker. 2 means there will be a total of 2 * num_workers batches prefetched across all workers.
TYPE:
|
ignore_data_skip |
When resuming training, whether or not to skip the epochs and batches to get the data loading at the
same stage as in the previous training. If set to
TYPE:
|
sampler_seed |
Random seed to be used with data samplers. If not set, random generators for data sampling will use the
same seed as
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_dataloader(train_batch_size=16, eval_batch_size=64)
>>> args.per_device_train_batch_size
16
Source code in mindnlp/engine/train_args/base.py
1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 |
|
mindnlp.engine.train_args.TrainingArguments.set_evaluate(strategy='no', steps=500, batch_size=8, accumulation_steps=None, delay=None, loss_only=False, jit_mode=False)
¶
A method that regroups all arguments linked to evaluation.
PARAMETER | DESCRIPTION |
---|---|
strategy |
The evaluation strategy to adopt during training. Possible values are:
Setting a
TYPE:
|
steps |
Number of update steps between two evaluations if
TYPE:
|
batch_size |
The batch size per device (GPU/TPU core/CPU...) used for evaluation.
TYPE:
|
accumulation_steps |
Number of predictions steps to accumulate the output tensors for, before moving the results to the CPU. If left unset, the whole predictions are accumulated on GPU/TPU before being moved to the CPU (faster but requires more memory).
TYPE:
|
delay |
Number of epochs or steps to wait for before the first evaluation can be performed, depending on the evaluation_strategy.
TYPE:
|
loss_only |
Ignores all outputs except the loss.
TYPE:
|
jit_mode |
Whether or not to use MindSpore jit trace for inference.
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_evaluate(strategy="steps", steps=100)
>>> args.eval_steps
100
Source code in mindnlp/engine/train_args/base.py
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 |
|
mindnlp.engine.train_args.TrainingArguments.set_logging(strategy='steps', steps=500, report_to='none', level='passive', first_step=False, nan_inf_filter=False, on_each_node=False, replica_level='passive')
¶
A method that regroups all arguments linked to logging.
PARAMETER | DESCRIPTION |
---|---|
strategy |
The logging strategy to adopt during training. Possible values are:
TYPE:
|
steps |
Number of update steps between two logs if
TYPE:
|
level |
Logger log level to use on the main process. Possible choices are the log levels as strings:
TYPE:
|
report_to |
The list of integrations to report the results and logs to. Supported platforms are
TYPE:
|
first_step |
Whether to log and evaluate the first
TYPE:
|
nan_inf_filter |
Whether to filter
TYPE:
|
on_each_node |
In multinode distributed training, whether to log using
TYPE:
|
replica_level |
Logger log level to use on replicas. Same choices as
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_logging(strategy="steps", steps=100)
>>> args.logging_steps
100
Source code in mindnlp/engine/train_args/base.py
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 |
|
mindnlp.engine.train_args.TrainingArguments.set_lr_scheduler(name='linear', num_epochs=3.0, max_steps=-1, warmup_ratio=0, warmup_steps=0)
¶
A method that regroups all arguments linked to the learning rate scheduler and its hyperparameters.
PARAMETER | DESCRIPTION |
---|---|
name |
The scheduler type to use. See the documentation of [
TYPE:
|
num_epochs(`float`, |
Total number of training epochs to perform (if not an integer, will perform the decimal part percents of the last epoch before stopping training).
TYPE:
|
max_steps |
If set to a positive number, the total number of training steps to perform. Overrides
TYPE:
|
warmup_ratio |
Ratio of total training steps used for a linear warmup from 0 to
TYPE:
|
warmup_steps |
Number of steps used for a linear warmup from 0 to
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_lr_scheduler(name="cosine", warmup_ratio=0.05)
>>> args.warmup_ratio
0.05
Source code in mindnlp/engine/train_args/base.py
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 |
|
mindnlp.engine.train_args.TrainingArguments.set_optimizer(name='adamw_torch', learning_rate=5e-05, weight_decay=0, beta1=0.9, beta2=0.999, epsilon=1e-08, args=None)
¶
A method that regroups all arguments linked to the optimizer and its hyperparameters.
PARAMETER | DESCRIPTION |
---|---|
name |
The optimizer to use:
TYPE:
|
learning_rate |
The initial learning rate.
TYPE:
|
weight_decay |
The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights.
TYPE:
|
beta1 |
The beta1 hyperparameter for the adam optimizer or its variants.
TYPE:
|
beta2 |
The beta2 hyperparameter for the adam optimizer or its variants.
TYPE:
|
epsilon |
The epsilon hyperparameter for the adam optimizer or its variants.
TYPE:
|
args |
Optional arguments that are supplied to AnyPrecisionAdamW (only useful when
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_optimizer(name="adamw", beta1=0.8)
>>> args.optim
'adamw'
Source code in mindnlp/engine/train_args/base.py
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 |
|
mindnlp.engine.train_args.TrainingArguments.set_save(strategy='steps', steps=500, total_limit=None, on_each_node=False)
¶
A method that regroups all arguments linked to checkpoint saving.
PARAMETER | DESCRIPTION |
---|---|
strategy |
The checkpoint save strategy to adopt during training. Possible values are:
TYPE:
|
steps |
Number of updates steps before two checkpoint saves if
TYPE:
|
total_limit |
If a value is passed, will limit the total amount of checkpoints. Deletes the older checkpoints in
TYPE:
|
on_each_node |
When doing multi-node distributed training, whether to save models and checkpoints on each node, or only on the main one. This should not be activated when the different nodes use the same storage as the files will be saved with the same names for each node.
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_save(strategy="steps", steps=100)
>>> args.save_steps
100
Source code in mindnlp/engine/train_args/base.py
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 |
|
mindnlp.engine.train_args.TrainingArguments.set_testing(batch_size=8, loss_only=False, jit_mode=False)
¶
A method that regroups all basic arguments linked to testing on a held-out dataset.
Calling this method will automatically set self.do_predict
to True
.
PARAMETER | DESCRIPTION |
---|---|
batch_size |
The batch size per device (GPU/TPU core/CPU...) used for testing.
TYPE:
|
loss_only |
Ignores all outputs except the loss.
TYPE:
|
jit_mode |
Whether or not to use MindSpore jit trace for inference.
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_testing(batch_size=32)
>>> args.per_device_eval_batch_size
32
Source code in mindnlp/engine/train_args/base.py
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 |
|
mindnlp.engine.train_args.TrainingArguments.set_training(learning_rate=5e-05, batch_size=8, weight_decay=0, num_epochs=3, max_steps=-1, gradient_accumulation_steps=1, seed=42, recompute=False)
¶
A method that regroups all basic arguments linked to the training.
Calling this method will automatically set self.do_train
to True
.
PARAMETER | DESCRIPTION |
---|---|
learning_rate |
The initial learning rate for the optimizer.
TYPE:
|
batch_size |
The batch size per device (GPU/TPU core/CPU...) used for training.
TYPE:
|
weight_decay |
The weight decay to apply (if not zero) to all layers except all bias and LayerNorm weights in the optimizer.
TYPE:
|
num_train_epochs(`float`, |
Total number of training epochs to perform (if not an integer, will perform the decimal part percents of the last epoch before stopping training).
TYPE:
|
max_steps |
If set to a positive number, the total number of training steps to perform. Overrides
TYPE:
|
gradient_accumulation_steps |
Number of updates steps to accumulate the gradients for, before performing a backward/update pass. When using gradient accumulation, one step is counted as one step with backward pass. Therefore,
logging, evaluation, save will be conducted every
TYPE:
|
seed |
Random seed that will be set at the beginning of training. To ensure reproducibility across runs, use
the [
TYPE:
|
recompute |
If True, use gradient checkpointing to save memory at the expense of slower backward pass.
TYPE:
|
>>> from transformers import TrainingArguments
>>> args = TrainingArguments("working_dir")
>>> args = args.set_training(learning_rate=1e-4, batch_size=32)
>>> args.learning_rate
1e-4
Source code in mindnlp/engine/train_args/base.py
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 |
|
mindnlp.engine.train_args.TrainingArguments.to_dict()
¶
Serializes this instance while replace Enum
by their values (for JSON serialization support). It obfuscates
the token values by removing their value.
Source code in mindnlp/engine/train_args/base.py
1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 |
|
mindnlp.engine.train_args.TrainingArguments.to_json_string()
¶
Serializes this instance to a JSON string.
Source code in mindnlp/engine/train_args/base.py
1355 1356 1357 1358 1359 |
|
mindnlp.engine.train_args.TrainingArguments.to_sanitized_dict()
¶
Sanitized serialization to use with TensorBoard’s hparams
Source code in mindnlp/engine/train_args/base.py
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
|
mindnlp.engine.train_args.ParallelMode
¶
Bases: Enum
Represents the different modes of parallel processing supported by the system.
This class defines an enumeration for the various modes of parallel processing that can be utilized by the system. It inherits from the Enum class, providing a structured way to define and work with
parallel processing modes within the system.
Source code in mindnlp/engine/train_args/base.py
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 |
|