base
mindnlp.transformers.pipelines.base.CsvPipelineDataFormat
¶
Bases: PipelineDataFormat
Support for pipelines using CSV data format.
PARAMETER | DESCRIPTION |
---|---|
output_path |
Where to save the outgoing data.
TYPE:
|
input_path |
Where to look for the input data.
TYPE:
|
column |
The column to read.
TYPE:
|
overwrite |
Whether or not to overwrite the
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.CsvPipelineDataFormat.__init__(output_path, input_path, column, overwrite=False)
¶
Initializes an instance of the CsvPipelineDataFormat class.
PARAMETER | DESCRIPTION |
---|---|
output_path |
The path to the output file. If specified, the processed data will be written to this file.
TYPE:
|
input_path |
The path to the input file. If specified, the data will be read from this file.
TYPE:
|
column |
The name of the column to process. If specified, only the data in this column will be processed.
TYPE:
|
overwrite |
Indicates whether the output file should be overwritten if it already exists. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
None
|
However, this method may raise exceptions if the input or output file paths are invalid or if there are any issues during the data processing. |
Note
- The 'output_path', 'input_path', and 'column' parameters are optional. They can be left empty or set to None if not required.
- The 'overwrite' parameter is optional and defaults to False.
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.CsvPipelineDataFormat.__iter__()
¶
Iterates over the rows of a CSV file and yields the specified columns as a dictionary.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the CsvPipelineDataFormat class.
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
FileNotFoundError
|
If the specified input file path does not exist. |
Error
|
If there are issues with reading the CSV file. |
IndexError
|
If the column index is out of range. |
KeyError
|
If the column key is not found in the row dictionary. |
TypeError
|
If the column parameter is not a valid type. |
ValueError
|
If the column parameter is not properly formatted. |
Note
- The CSV file is read using the 'r' mode.
- The CSV file is expected to have a header row.
- If self.is_multi_columns is True, the method yields a dictionary with keys from the specified column list and values from the corresponding columns in the CSV file.
- If self.is_multi_columns is False, the method yields the value from the specified column index in each row.
Example
>>> data_format = CsvPipelineDataFormat()
>>> data_format.input_path = 'data.csv'
>>> data_format.is_multi_columns = True
>>> for row in data_format:
>>> print(row)
...
>>> Output:
>>> {'col1': 'value1', 'col2': 'value2'}
>>> {'col1': 'value3', 'col2': 'value4'}
...
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.CsvPipelineDataFormat.save(data)
¶
Save the provided data object with the representation for the current [~pipelines.PipelineDataFormat
].
PARAMETER | DESCRIPTION |
---|---|
data |
The data to store.
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
658 659 660 661 662 663 664 665 666 667 668 669 |
|
mindnlp.transformers.pipelines.base.JsonPipelineDataFormat
¶
Bases: PipelineDataFormat
Support for pipelines using JSON file format.
PARAMETER | DESCRIPTION |
---|---|
output_path |
Where to save the outgoing data.
TYPE:
|
input_path |
Where to look for the input data.
TYPE:
|
column |
The column to read.
TYPE:
|
overwrite |
Whether or not to overwrite the
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.JsonPipelineDataFormat.__init__(output_path, input_path, column, overwrite=False)
¶
Initializes a JsonPipelineDataFormat object.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class.
|
output_path |
The path to the output file where the processed data will be saved.
TYPE:
|
input_path |
The path to the input file containing the data to be processed.
TYPE:
|
column |
The column in the input data to be processed.
TYPE:
|
overwrite |
Indicates whether to overwrite the existing output file if it already exists. Default is False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
FileNotFoundError
|
If the input file specified by 'input_path' does not exist. |
JSONDecodeError
|
If the input file does not contain valid JSON data. |
IOError
|
If there is an issue with reading the input file. |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.JsonPipelineDataFormat.__iter__()
¶
Iterates over the entries of the JsonPipelineDataFormat object.
PARAMETER | DESCRIPTION |
---|---|
self |
The JsonPipelineDataFormat object itself.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None |
This method iterates over the entries stored in the JsonPipelineDataFormat object and yields each entry as a dictionary. If the JsonPipelineDataFormat object is configured with multiple columns, each yielded entry is a dictionary where the keys correspond to the column names and the values are the values of the respective columns for that entry. If the JsonPipelineDataFormat object is not configured with multiple columns, each yielded entry is a single value corresponding to the first column specified in the 'column' attribute of the JsonPipelineDataFormat object.
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.JsonPipelineDataFormat.save(data)
¶
Save the provided data object in a json file.
PARAMETER | DESCRIPTION |
---|---|
data |
The data to store.
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
740 741 742 743 744 745 746 747 748 |
|
mindnlp.transformers.pipelines.base.PipedPipelineDataFormat
¶
Bases: PipelineDataFormat
Read data from piped input to the python process. For multi columns data, columns should separated by
If columns are provided, then the output will be a dictionary with {column_x: value_x}
PARAMETER | DESCRIPTION |
---|---|
output_path |
Where to save the outgoing data.
TYPE:
|
input_path |
Where to look for the input data.
TYPE:
|
column |
The column to read.
TYPE:
|
overwrite |
Whether or not to overwrite the
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.PipedPipelineDataFormat.__iter__()
¶
Iterates over input lines from the standard input and yields formatted data.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the PipedPipelineDataFormat class.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None |
Description
This method is used to iterate over input lines read from the standard input. Each line is checked for the presence of a tab character (' '). If a tab character is found, the line is split using the tab character as the delimiter. If the PipedPipelineDataFormat instance has a defined column attribute, a dictionary is yielded containing key-value pairs where the keys are the column names and the values are extracted from the corresponding line elements. If the column attribute is not defined, a tuple containing the line elements is yielded. If a line does not contain a tab character, the entire line is yielded as is.
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.PipedPipelineDataFormat.save(data)
¶
Print the data.
PARAMETER | DESCRIPTION |
---|---|
data |
The data to store.
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
801 802 803 804 805 806 807 808 |
|
mindnlp.transformers.pipelines.base.PipedPipelineDataFormat.save_binary(data)
¶
Save binary data to an output file path.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the PipedPipelineDataFormat class.
TYPE:
|
data |
The binary data to be saved. It can be either a single dictionary or a list of dictionaries.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The output file path where the binary data was saved.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
KeyError
|
If the |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline
¶
Bases: _ScikitCompat
The Pipeline class is the class from which all pipelines inherit. Refer to this class for methods shared across different pipelines.
Base class implementing pipelined operations. Pipeline workflow is defined as a sequence of the following operations:
Input -> Tokenization -> Model Inference -> Post-Processing (task dependent) -> Output
Pipeline supports running on CPU or GPU through the device argument (see below).
Some pipeline, like for instance [FeatureExtractionPipeline
] ('feature-extraction'
) output large tensor object
as nested-lists. In order to avoid dumping such large structure as textual data we provide the binary_output
forwardor argument. If set to True
, the output will be stored in the pickle format.
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline.__call__(inputs, *args, num_workers=None, batch_size=None, **kwargs)
¶
Performs the main processing logic for the Pipeline class.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the Pipeline class.
TYPE:
|
inputs |
The input data for processing. It can be a Dataset, GeneratorType, or list.
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any value. |
RAISES | DESCRIPTION |
---|---|
UserWarning
|
If the method is called more than 10 times, a warning is raised to prompt the user to use a dataset for efficiency. |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline.__init__(model, tokenizer=None, feature_extractor=None, image_processor=None, modelcard=None, task='', ms_dtype=None, binary_output=False, **kwargs)
¶
Initializes a new instance of the Pipeline class.
PARAMETER | DESCRIPTION |
---|---|
model |
The pre-trained model to be used in the pipeline.
TYPE:
|
tokenizer |
An optional pre-trained tokenizer for processing input data.
TYPE:
|
feature_extractor |
An optional feature extractor for extracting features from the input data.
TYPE:
|
image_processor |
An optional image processor for handling image data.
TYPE:
|
modelcard |
An optional model card containing information about the model.
TYPE:
|
task |
The task that the pipeline is designed to perform.
TYPE:
|
ms_dtype |
An optional data type for MindSpore computations.
TYPE:
|
binary_output |
A flag indicating whether the output should be binary.
TYPE:
|
**kwargs |
Additional keyword arguments for configuring the pipeline.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline.check_model_type(supported_models)
¶
Check if the model class is in supported by the pipeline.
PARAMETER | DESCRIPTION |
---|---|
supported_models |
The list of models supported by the pipeline, or a dictionary with model class values.
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline.forward(model_inputs, **forward_params)
¶
This method performs the forward pass of the pipeline model.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the Pipeline class.
TYPE:
|
model_inputs |
The inputs to the model for the forward pass. Type can vary depending on the model architecture and input requirements.
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method returns None as it directly returns the model outputs. |
RAISES | DESCRIPTION |
---|---|
None
|
However, the _forward method it calls may raise exceptions based on the model's implementation. |
Source code in mindnlp/transformers/pipelines/base.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
|
mindnlp.transformers.pipelines.base.Pipeline.iterate(inputs, preprocess_params, forward_params, postprocess_params)
¶
Iterates through the input data and yields the result of running each input through the pipeline.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the Pipeline class.
TYPE:
|
inputs |
The input data to iterate over.
TYPE:
|
preprocess_params |
The parameters used for preprocessing the input data.
TYPE:
|
forward_params |
The parameters used for the forward pass of the pipeline.
TYPE:
|
postprocess_params |
The parameters used for postprocessing the output data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline.postprocess(model_outputs, **postprocess_parameters)
abstractmethod
¶
Postprocess will receive the raw outputs of the _forward
method, generally tensors, and reformat them into
something more friendly. Generally it will output a list or a dict or results (containing just strings and
numbers).
Source code in mindnlp/transformers/pipelines/base.py
1063 1064 1065 1066 1067 1068 1069 1070 |
|
mindnlp.transformers.pipelines.base.Pipeline.predict(X)
¶
Scikit / Keras interface to transformers' pipelines. This method will forward to call().
Source code in mindnlp/transformers/pipelines/base.py
994 995 996 997 998 |
|
mindnlp.transformers.pipelines.base.Pipeline.preprocess(input_, **preprocess_parameters)
abstractmethod
¶
Preprocess will take the input_
of a specific pipeline and return a dictionary of everything necessary for
_forward
to run properly. It should contain at least one tensor, but might have arbitrary other items.
Source code in mindnlp/transformers/pipelines/base.py
1042 1043 1044 1045 1046 1047 1048 |
|
mindnlp.transformers.pipelines.base.Pipeline.run_multi(inputs, preprocess_params, forward_params, postprocess_params)
¶
Method that runs a series of input items through the pipeline.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the Pipeline class.
TYPE:
|
inputs |
A list of input items to be processed by the pipeline.
TYPE:
|
preprocess_params |
Parameters for preprocessing the input items.
TYPE:
|
forward_params |
Parameters for the forward pass through the pipeline.
TYPE:
|
postprocess_params |
Parameters for postprocessing the output items.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any value but processes the input items through the pipeline. |
Source code in mindnlp/transformers/pipelines/base.py
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
|
mindnlp.transformers.pipelines.base.Pipeline.run_single(inputs, preprocess_params, forward_params, postprocess_params)
¶
This method 'run_single' is a member of the 'Pipeline' class and is responsible for executing a single run of the pipeline.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the Pipeline class.
TYPE:
|
inputs |
The input data to be processed by the pipeline.
TYPE:
|
preprocess_params |
Parameters for the preprocessing step, used to configure the preprocessing behavior.
TYPE:
|
forward_params |
Parameters for the forward step, used to configure the forward pass behavior.
TYPE:
|
postprocess_params |
Parameters for the postprocessing step, used to configure the postprocessing behavior.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None. |
RAISES | DESCRIPTION |
---|---|
Any exceptions that is
|
raised by the 'preprocess', 'forward', or 'postprocess' methods called within this method will be propagated to the caller. |
Source code in mindnlp/transformers/pipelines/base.py
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
|
mindnlp.transformers.pipelines.base.Pipeline.save_pretrained(save_directory, safe_serialization=True)
¶
Save the pipeline's model and tokenizer.
PARAMETER | DESCRIPTION |
---|---|
save_directory |
A path to the directory where to saved. It will be created if it doesn't exist.
TYPE:
|
safe_serialization |
Whether to save the model using
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.Pipeline.transform(X)
¶
Scikit / Keras interface to transformers' pipelines. This method will forward to call().
Source code in mindnlp/transformers/pipelines/base.py
988 989 990 991 992 |
|
mindnlp.transformers.pipelines.base.PipelineDataFormat
¶
Base class for all the pipeline supported data format both for reading and writing. Supported data formats currently includes:
- JSON
- CSV
- stdin/stdout (pipe)
PipelineDataFormat
also includes some utilities to work with multi-columns like mapping from datasets columns to
pipelines keyword arguments through the dataset_kwarg_1=dataset_column_1
format.
PARAMETER | DESCRIPTION |
---|---|
output_path |
Where to save the outgoing data.
TYPE:
|
input_path |
Where to look for the input data.
TYPE:
|
column |
The column to read.
TYPE:
|
overwrite |
Whether or not to overwrite the
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.PipelineDataFormat.__init__(output_path, input_path, column, overwrite=False)
¶
Initializes an instance of the PipelineDataFormat class.
PARAMETER | DESCRIPTION |
---|---|
output_path |
The path to the output file. Defaults to None.
TYPE:
|
input_path |
The path to the input file. Defaults to None.
TYPE:
|
column |
The column(s) to use for data processing. Defaults to None. If multiple columns are provided, they should be comma-separated. Each column can be specified as 'name' or 'name=value' to map input and output columns.
TYPE:
|
overwrite |
Determines whether to overwrite the output file if it already exists. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return a value. |
RAISES | DESCRIPTION |
---|---|
OSError
|
If the output_path is provided and the overwrite parameter is False, and the output_path already exists on disk. |
OSError
|
If the input_path is provided and the input_path does not exist on disk. |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.PipelineDataFormat.__iter__()
abstractmethod
¶
This method 'iter' in the class 'PipelineDataFormat' is used to define an iterator for instances of the class.
PARAMETER | DESCRIPTION |
---|---|
self |
An instance of the 'PipelineDataFormat' class.
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method does not return any value explicitly but is meant to be implemented by subclasses to return an iterator. |
RAISES | DESCRIPTION |
---|---|
NotImplementedError
|
This exception is raised if the method is not implemented by a subclass. It serves as a reminder for the subclass to implement its own iteration logic. |
Source code in mindnlp/transformers/pipelines/base.py
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
|
mindnlp.transformers.pipelines.base.PipelineDataFormat.from_str(format, output_path, input_path, column, overwrite=False)
staticmethod
¶
Creates an instance of the right subclass of [~pipelines.PipelineDataFormat
] depending on format
.
PARAMETER | DESCRIPTION |
---|---|
format |
The format of the desired pipeline. Acceptable values are
TYPE:
|
output_path |
Where to save the outgoing data.
TYPE:
|
input_path |
Where to look for the input data.
TYPE:
|
column |
The column to read.
TYPE:
|
overwrite |
Whether or not to overwrite the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PipelineDataFormat
|
[ |
Source code in mindnlp/transformers/pipelines/base.py
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 |
|
mindnlp.transformers.pipelines.base.PipelineDataFormat.save(data)
abstractmethod
¶
Save the provided data object with the representation for the current [~pipelines.PipelineDataFormat
].
PARAMETER | DESCRIPTION |
---|---|
data |
The data to store.
TYPE:
|
Source code in mindnlp/transformers/pipelines/base.py
505 506 507 508 509 510 511 512 513 |
|
mindnlp.transformers.pipelines.base.PipelineDataFormat.save_binary(data)
¶
Save the provided data object as a pickle-formatted binary data on the disk.
PARAMETER | DESCRIPTION |
---|---|
data |
The data to store.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
|
Source code in mindnlp/transformers/pipelines/base.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|