Configuration-driven dl4nlp model automated training and deployment method

By automating the training and deployment of deep learning NLP models using a configuration-driven approach, this technology addresses the problems of low development efficiency, large gap between training and deployment, difficulty in source code protection, and poor multi-task support in existing technologies, achieving efficient and secure automated model deployment.

CN122133762APending Publication Date: 2026-06-02WUHAN FIBERHOME PUTIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
WUHAN FIBERHOME PUTIAN INFORMATION TECH CO LTD
Filing Date
2026-02-06
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

The existing development and deployment process of deep learning NLP models suffers from problems such as low code reuse rate, long development cycle, technical gap between training and production deployment, exposure of model source code leading to intellectual property leakage, and lack of support for multiple task types.

Method used

By adopting a configuration-driven approach, the system automates data loading and preprocessing, model component instantiation and assembly, training optimization, and deployment package generation by parsing YAML configuration files. It also exports the model as a binary file using TorchScript and automatically generates a deployment package based on a template engine, thus achieving automated model training and deployment.

Benefits of technology

It achieves efficient automation of model development, reduces development and maintenance costs, improves the adaptability and iterative flexibility of models across different NLP tasks, protects intellectual property rights, simplifies deployment processes, and enhances model reliability and commercial security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122133762A_ABST
    Figure CN122133762A_ABST
Patent Text Reader

Abstract

The application provides a configuration-driven DL4NLP model automatic training and deployment method, which comprises the following steps: parsing a YAML configuration file and verifying parameters to generate a unified process configuration; automatically loading data and performing preprocessing according to the configuration to generate a model input tensor; instantiating model components through a component factory and assembling the model components into a complete network model; automatically configuring a training environment to train and evaluate the model to obtain an optimal model; exporting the model into a TorchScript format binary file; and automatically generating a standardized deployment package based on a template engine. The application abstracts the whole process of model development and deployment into a configuration-driven standardized pipeline by parsing the YAML configuration file, automatically performs data loading and preprocessing, model component instantiation and assembly, training optimization and deployment package generation, and solves the problems of low development efficiency, long cycle and technical gap between training and deployment caused by repeated code writing and manual conversion and deployment for different tasks in traditional model training and deployment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a configuration-driven method for automated training and deployment of DL4NLP models. Background Technology

[0002] Deep Learning for Natural Language Processing (DL4NLP) is an important branch of artificial intelligence, encompassing discriminative NLP tasks such as text classification, sequence labeling, text matching, and multi-task learning. With the widespread application of pre-trained language models (such as BERT, RoBERTa, and ALBERT), deep learning NLP technology has been deployed on a large scale in industry.

[0003] However, the existing development and deployment processes for deep learning NLP models have the following technical problems: 1) Low code reuse rate and long development cycle in model development:

[0004] In existing technologies, different NLP tasks require separate implementations of data loading, model building, training loops, and evaluation modules. Developing a complete model requires writing a large amount of code, resulting in low code reusability when switching tasks. Furthermore, the high coupling between model components (embedding layer, encoder, classifier) ​​means that replacing components requires modifying multiple code entries, leading to difficulties in architecture adjustments and low iteration efficiency. 2) A technological gap exists between model training and production deployment: The training code cannot be directly used for production deployment. Developers need to manually complete tasks such as writing model loading functions, encapsulating web service interfaces, configuring Docker containers, and handling environment differences. This process takes an average of 2-4 hours, and about 30% of deployment problems stem from manual conversion errors. 3) Source code exposure during model deployment leads to intellectual property leakage: The existing deployment method requires copying the Python source code file defining the model architecture to the server. The source code exists in plain text, which can be directly read and obtained by third parties, resulting in the inability to effectively protect the intellectual property rights of commercial models. 4) Existing frameworks lack unified support for multiple task types: Frameworks like PyTorch and TensorFlow only provide low-level tensor operations and lack a unified abstraction for various NLP tasks. Developers need to design separate data processing, loss functions, and evaluation metrics for tasks such as text classification, sequence labeling, and text matching. The logic of each task differs significantly, making them difficult to reuse.

[0005] Based on the aforementioned technical issues, there is an urgent need to propose a configuration-driven method for automated training and deployment of deep learning NLP models to address problems such as low model development efficiency, a large gap between training and deployment, difficulty in protecting source code, and poor multi-task support. Summary of the Invention

[0006] This invention proposes a configuration-driven automated training and deployment method for DL4NLP models, which solves the problems of low development efficiency, large gap between training and deployment, difficulty in source code protection, and poor multi-task support in existing technologies.

[0007] The technical solution of this invention is implemented as follows: This invention provides a configuration-driven method for automated training and deployment of DL4NLP models, comprising the following steps: Configuration file parsing and validation: Parse the YAML format configuration file, map the dataset configuration, preprocessing configuration, word segmenter configuration, model configuration and training configuration in the configuration file to the corresponding strongly typed configuration objects, perform parameter validation, and generate a unified process configuration object; Data preprocessing: Based on the process configuration object, the raw data is automatically loaded and preprocessed according to the preset process to generate input tensors usable by the model; Model building: Based on the model architecture definition in the process configuration object, the component factory automatically instantiates each model component and assembles them into a complete neural network model according to the preset architecture order; Model training: Based on the training parameters in the process configuration object, the training environment is automatically configured and loop training is performed to obtain the optimal model; Model Export: Export the optimal model as a TorchScript binary file, separate from the source code; Model Deployment: Based on the task type and model configuration, a standardized deployment package containing prediction logic and service interfaces is automatically generated using a template engine.

[0008] Specifically, in the configuration file parsing and verification steps, the parameter verification includes: verifying the existence of required parameters, validating the range of parameter values, and verifying the consistency of parameter data types, and indicating the specific error location when verification fails.

[0009] Specifically, in the data preprocessing step, the corresponding data loader and data format are automatically selected according to the configured task type. Among them: text classification tasks load single-text single-label format data; multi-label classification tasks load single-text multi-label format data, with labels connected by delimiters; sequence labeling tasks load CoNLL format data, with each line containing characters and their corresponding labels; text matching tasks load text pair format data, with each text pair containing two texts to be matched and a similarity label; and joint tasks load composite format data, with a single text containing both an intent label and a slot sequence label.

[0010] Specifically, in the data preprocessing step, preprocessing is performed according to the following preset process:

[0011] Text standardization: Performs operations such as unifying uppercase and lowercase letters, converting full-width characters to half-width characters, and converting traditional Chinese characters to simplified Chinese characters;

[0012] Text cleaning phase: Remove HTML tags, control characters, and redundant whitespace;

[0013] Text standardization phase: Replace URLs, email addresses, and numeric entities with unified predefined tags;

[0014] Word segmentation stage: Supports two configuration modes, including classic word segmenters that use rule-based or statistical methods, and pre-trained language model word segmenters that use sub-word segmentation algorithms;

[0015] Encoding stage: The word segmentation results are mapped to a word index sequence, padding or truncation operations are performed to make the sequence length consistent, and attention mask vectors are generated.

[0016] Furthermore, when using a classic word segmenter, the default process also includes an automatic vocabulary building step:

[0017] Traverse the training dataset to count the frequency of each word element;

[0018] Filter low-frequency words based on a preset minimum word frequency threshold;

[0019] The remaining word units are arranged in descending order of word frequency;

[0020] After reserving special marker positions, a unique index is assigned to each lexicon to form a vocabulary that supports serialized storage and incremental updates.

[0021] Specifically, in the model building step, the model components include:

[0022] Embedding layer components include a vocabulary-based feature embedding layer for mapping discrete lexical units to dense vectors, and a pre-trained language model-based context embedding layer for generating context-sensitive word representations.

[0023] Encoder components include a convolutional neural network encoder for extracting n-gram features, a recurrent neural network encoder for modeling sequence dependencies, a Transformer encoder for capturing long-range dependencies, and an attention mechanism encoder.

[0024] Pooling layer components include first-label pooling for extracting CLS position representations, average pooling for calculating sequence mean, max pooling for extracting the most salient features, and attention pooling for weighted aggregation;

[0025] Task Header Components: These include a classification header for outputting class probabilities, a conditional random field header for outputting the optimal label sequence, and a matching header for outputting similarity scores.

[0026] Furthermore, the convolutional neural network encoder uses multi-scale one-dimensional convolutional kernels to extract n-gram features of different granularities, and obtains the global representation of the sequence through nonlinear activation and max pooling operations; the recurrent neural network encoder uses long short-term memory networks or gated recurrent units to perform temporal modeling of the sequence, and supports bidirectional encoding to simultaneously capture forward and backward context information; the Transformer encoder uses a multi-head self-attention mechanism to model the dependencies between arbitrary positions within the sequence.

[0027] Specifically, model training includes the following steps:

[0028] Initialization phase: Based on the training parameters in the process configuration object, an optimizer, learning rate scheduler, and loss function are created; the loss function is automatically selected according to the task type: cross-entropy loss is used for text classification tasks; binary cross-entropy loss is used for multi-label classification tasks; negative log-likelihood loss of conditional random fields is used for sequence labeling tasks; and cross-entropy loss or contrastive loss is used for text matching tasks.

[0029] Iteration phase: Traverse the training data by round, perform forward propagation to calculate loss, backpropagation to calculate gradient, and parameter update;

[0030] Validation Phase: After each round of training, the model performance is evaluated on the validation set. Evaluation metrics are calculated based on the task type: for text classification, accuracy, precision, recall, and F1 score are used as evaluation metrics; for multi-label classification, micro-average F1, macro-average F1, and Hamming loss are used as evaluation metrics; for sequence labeling, entity-level precision, recall, and F1 score are used as evaluation metrics; and for text matching, accuracy, AUC, and F1 score are used as evaluation metrics.

[0031] Early stopping phase: If the validation metrics do not improve for several consecutive rounds, training is terminated and the optimal model parameters are retained.

[0032] Specifically, the model export method includes the following steps:

[0033] Construct example tensors that conform to the input specifications based on the model configuration;

[0034] Set the model to evaluation mode and disable randomness operations;

[0035] The tracking interface is invoked to record the model's computation process on example inputs and generate a computation graph representation.

[0036] Serialize the computation graph and parameter weights into a TorchScript binary file;

[0037] If the tracking process fails because the model contains dynamic control flow, a rollback mechanism is triggered, and the model weight file and the necessary model architecture definition source code are saved instead.

[0038] Specifically, model deployment includes the following steps:

[0039] Create a standardized model catalog;

[0040] Copy the model file, configuration file, vocabulary file, and label mapping file to the model directory;

[0041] Select the corresponding predictor template based on the task type, fill in the parameters, and then render and generate the predictor code.

[0042] Render and generate the web service entry code;

[0043] Render and generate Docker container configuration files and startup scripts;

[0044] Generate a runtime dependency manifest file.

[0045] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) This invention receives and parses a unified YAML configuration file, abstracts the entire process of model development and deployment into a configuration-driven standardized pipeline, automatically executes data loading and preprocessing, model component instantiation and assembly, training optimization and deployment package generation, solves the problems of low development efficiency, long cycle and technical gap between training and deployment caused by the need to repeatedly write code for different tasks and manually convert deployment in traditional model training and deployment, realizes automation from configuration to runnable service, and greatly reduces the human cost and technical threshold of development and operation and maintenance; (2) This invention decomposes the data processing flow into configurable normalization, cleaning, standardization, word segmentation and encoding stages by designing a standardized preprocessing pipeline and adopting a model construction scheme with factory pattern and component registration mechanism. It also decouples the model into independent components such as embedding layer, encoder, pooling layer and task head. This overcomes the problems of low code reusability and difficulty in architecture adjustment caused by the lack of unified support for multiple tasks and high component coupling in existing frameworks. It significantly improves the adaptability and iterative flexibility of the model in different NLP tasks. (3) This invention serializes the complete preprocessing, model and postprocessing logic into the model training file during the training phase and reuses the same set of logic and files during inference deployment. At the same time, it introduces a mechanism to automatically export the model into TorchScript binary format, which solves the problem of model performance degradation caused by inconsistent training and prediction data processing. Furthermore, by encapsulating and protecting the model source code, it avoids the risk of intellectual property leakage caused by the exposure of the source code during deployment, thereby improving the reliability and commercial security of the model. (4) Based on the template engine, this invention dynamically renders and generates a complete deployment package containing a standardized directory structure, predictor code, service interface and Docker container configuration according to the task type and configuration. It solves the problems of cumbersome process and easy error caused by the need to manually write service code and configure container environment in the traditional deployment method, realizes the standardization of model deployment, and provides a solid foundation for the rapid deployment, stable operation and subsequent operation and maintenance of services. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 This is a flowchart illustrating the configuration-driven automated training and deployment method for DL4NLP models according to the present invention.

[0048] Figure 2 This is a flowchart of the configuration-driven model construction process in an embodiment of the present invention.

[0049] Figure 3 This is a flowchart illustrating the model export process in an embodiment of the present invention.

[0050] Figure 4 This is a flowchart illustrating the model deployment process in an embodiment of the present invention.

[0051] Figure 5 This is an interaction timing diagram of each module in an embodiment of the present invention. Detailed Implementation

[0052] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0053] Reference Figures 1 to 5 As shown, this invention provides a configuration-driven method for automated training and deployment of DL4NLP models, including the following steps:

[0054] Step 1: Configuration file parsing and verification

[0055] This step aims to parse the user-provided declarative configuration file into a strongly typed configuration object that the program can process, and to perform parameter validity validation. The specific method is as follows:

[0056] First, read the YAML file and parse it into a dictionary structure;

[0057] Secondly, iterate through each configuration segment, obtain the corresponding configuration class based on the configuration segment name, and map the dictionary parameters to configuration class instances (that is, map the dataset configuration, preprocessing configuration, word segmenter configuration, model configuration and training configuration in the configuration file to the corresponding strongly typed configuration objects respectively).

[0058] Next, the existence of required parameters is validated, and the range and type of parameter values ​​are validated.

[0059] Finally, assemble the instances of each configuration segment to generate a complete PipelineConfig object. If verification fails, throw an exception and indicate the specific error location.

[0060] This invention uses YAML format as the configuration file carrier and designs a hierarchical configuration structure; the configuration file contains five top-level configuration sections:

[0061] The dataset configuration section defines the task type and data path;

[0062] The preprocessing configuration section defines the sequence length and word frequency threshold;

[0063] The tokenizer configuration section defines the tokenization method and the pre-trained model;

[0064] The model configuration section defines the model architecture and component parameters;

[0065] The training configuration section (train) defines the optimizer and training hyperparameters.

[0066] To ensure type safety and parameter validation, this invention employs a DataClass mechanism to define the configuration structure. Each configuration segment corresponds to an independent configuration class, and these configuration classes form a hierarchical structure through composition. The top-level configuration class (PipelineConfig) aggregates all sub-configuration classes to form a complete configuration object model. This design supports static type checking and default value inference for configuration parameters.

[0067] Step 2: Data Preprocessing

[0068] This step automatically loads and preprocesses data according to the configuration to generate a tensor dataset that can be used for model training. Specifically, it automatically loads the original data and performs preprocessing according to the preset process based on the process configuration object to generate input tensors that can be used by the model.

[0069] Loading data of multiple task types:

[0070] This invention designs a unified data loader interface that automatically selects the corresponding loading strategy based on the task type configuration:

[0071] Text classification task (tc) loads single-text, single-label format data;

[0072] Multi-label classification task (MTC) loads single-text multi-label format data, with labels connected by delimiters;

[0073] The sequence labeling task (st) loads CoNLL formatted data, with each line containing characters and their corresponding labels;

[0074] The text matching task (tm) loads text pair formatted data, where each text pair contains two texts to be matched and a similarity label.

[0075] The joint task loads composite data, where a single text contains both intent labels and slot sequence labels.

[0076] This invention designs a pipeline-style text preprocessing architecture that executes five processing stages sequentially:

[0077] Text standardization: Perform standardization operations such as unifying capitalization, converting full-width characters to half-width characters, and converting traditional Chinese characters to simplified Chinese characters to eliminate differences in text format;

[0078] Text cleaning stage: Remove HTML tags, control characters, and unnecessary whitespace and other noisy content to extract valid text information;

[0079] Text standardization stage: Replace special entities such as URLs, email addresses, and numbers with unified predefined tags to reduce vocabulary size and enhance model generalization ability;

[0080] Word segmentation stage: Supports two word segmentation configuration modes, including a classic word segmenter that uses rule or statistical methods to segment Chinese and English words, and a pre-trained language model word segmenter that uses a sub-word segmentation algorithm;

[0081] Encoding stage: The word segmentation results are mapped to a word index sequence, padding or truncation operations are performed to make the sequence length consistent, and attention mask vectors are generated.

[0082] Furthermore, for scenarios using classic word segmenters, this invention automatically constructs a vocabulary based on the training corpus. The specific process is as follows:

[0083] Traverse the training dataset to count the frequency of each word element;

[0084] Filter low-frequency words based on a preset minimum word frequency threshold;

[0085] The remaining word units are arranged in descending order of word frequency;

[0086] After reserving special marker positions (filler characters, unknown characters), a unique index is assigned to each lexical unit to build a complete vocabulary that supports serialized storage and incremental updates.

[0087] Step 3: Model Building

[0088] This step automatically instantiates each model component according to the configuration file and assembles them into a complete neural network model according to the preset architecture. The specific method is as follows: according to the model architecture definition in the process configuration object, each model component is automatically instantiated through the component factory and assembled into a complete neural network model according to the preset architecture order.

[0089] This invention employs a factory pattern and a registration mechanism to achieve decoupled management of model components. The system maintains a component registry, mapping configuration identifiers to corresponding component implementation classes. The model components comprise four layers:

[0090] Embedding layer components include a vocabulary-based feature embedding layer for mapping discrete lexical units to dense vectors, and a pre-trained language model-based context embedding layer for generating context-sensitive word representations.

[0091] Encoder components include a convolutional neural network encoder for extracting n-gram features, a recurrent neural network encoder for modeling sequence dependencies, a Transformer encoder for capturing long-range dependencies, and an attention mechanism encoder.

[0092] Pooling layer components include first-label pooling for extracting CLS position representations, average pooling for calculating sequence mean, max pooling for extracting the most salient features, and attention pooling for weighted aggregation;

[0093] Task Header Components: These include a classification header for outputting class probabilities, a conditional random field header for outputting the optimal label sequence, and a matching header for outputting similarity scores.

[0094] like Figure 2 As shown, this invention reads the model configuration segment through the model builder and executes the following assembly process:

[0095] First, parse the embedding layer configuration and call the embedding layer factory to create the corresponding instance;

[0096] Secondly, parse the encoder configuration and call the encoder factory to create the corresponding instance;

[0097] Next, parse the pooling layer configuration and call the pooling layer factory to create the corresponding instance;

[0098] Then, select and instantiate the corresponding task header based on the task type;

[0099] Finally, the components are connected in the order of "embedding layer → encoder → pooling layer → task head" to build a complete model.

[0100] In this embodiment, the feature embedding layer maps word indices to dense vector representations based on a trainable embedding matrix, and supports loading pre-trained word vectors for initialization. The input is a sequence of word indices, and the output is the corresponding sequence of embedding vectors. The pre-trained language model embedding layer loads a pre-trained Transformer encoder to encode the input sequence into a context-dependent hidden state sequence, and supports parameter freezing to reduce computational overhead and prevent overfitting.

[0101] In this embodiment, the convolutional neural network encoder uses multi-scale one-dimensional convolutional kernels to extract n-gram features of different granularities and obtains the global representation of the sequence through nonlinear activation and max pooling operations; the recurrent neural network encoder uses long short-term memory networks or gated recurrent units to perform temporal modeling of the sequence and supports bidirectional encoding to simultaneously capture forward and backward context information; the Transformer encoder uses a multi-head self-attention mechanism to model the dependencies between any positions within the sequence.

[0102] Step 4: Model Training

[0103] This step automatically performs model training, validation, and testing based on the configuration, achieving end-to-end model optimization. Specifically, it automatically configures the training environment and performs iterative training based on the training parameters in the process configuration object to obtain the optimal model. Specifically, model training includes the following steps: Initialization phase: Based on the training parameters in the process configuration object, create the optimizer (such as AdamW), learning rate scheduler, and loss function; Iteration phase: Traverse the training data by round, perform forward propagation to calculate loss, backpropagation to calculate gradient, and parameter update; Validation phase: Evaluate model performance on the validation set after each round of training; Early stopping phase: If the validation metrics do not improve for several consecutive rounds, training is terminated and the optimal model parameters are retained.

[0104] In this embodiment, the loss function is automatically selected according to the task type: cross-entropy loss is used for text classification tasks; binary cross-entropy loss is used for multi-label classification tasks, which supports independent prediction of each label; negative log-likelihood loss of conditional random fields is used for sequence labeling tasks, which models the global dependency of label sequences; and cross-entropy loss or contrastive loss is used for text matching tasks.

[0105] In this embodiment, the model performance is evaluated by calculating corresponding evaluation metrics based on different task types: For text classification tasks, the model's accuracy, precision, recall, and F1 score are calculated as evaluation metrics. For multi-label classification tasks, the model's micro-average F1, macro-average F1, and Hamming loss are calculated as evaluation metrics. For sequence labeling tasks, the precision, recall, and F1 score at the entity level of the model are calculated as evaluation metrics. For text matching tasks, the model accuracy, AUC, and F1 score are calculated as evaluation metrics.

[0106] Step 5: Model Export

[0107] This step exports the trained model to TorchScript format, separating the model source code from the computation graph to protect intellectual property rights. Figure 3 As shown, the specific steps include:

[0108] First, construct example tensors that conform to the input specifications based on the model configuration;

[0109] Secondly, set the model to evaluation mode and turn off random operations (such as Dropout).

[0110] Next, the tracking interface is called to record the model's computation process on the example input, generating a computation graph representation;

[0111] Finally, the computation graph and parameter weights are serialized into a TorchScript binary file.

[0112] In practice, some models contain dynamic control flow (such as data-dependent conditional branches and variable-length loops), which cannot be exported by tracing. This invention implements an automatic detection mechanism: first, it attempts to execute TorchScript export. If a tracing exception is captured, it is marked as a model that protects dynamic control flow and falls back to the traditional deployment method—saving the model weight file and the necessary model definition source code. The export mode flag is recorded in the deployment configuration for use by the subsequent deployment code generation module.

[0113] TorchScript is a model serialization mechanism provided by PyTorch. It converts Python models into intermediate representations through tracing or scripting, storing them as binary files independent of the source code. The exported model has the following characteristics: it does not contain Python source code, only the computation graph and parameters; it can be deployed independently of the Python runtime environment; and it supports computation graph optimization to improve inference efficiency.

[0114] Step Six: Model Deployment

[0115] This step automatically generates a standardized deployment package containing prediction logic and service interfaces based on the task type and model configuration using the Jinja2 template engine, such as... Figure 4 As shown, it includes the following steps:

[0116] Create a standardized model catalog;

[0117] Copy the model file (TorchScript file or weight file), configuration file, vocabulary file, and label mapping file to the model directory;

[0118] Select the corresponding predictor template based on the task type, fill in the parameters, and then render and generate the predictor code.

[0119] Render and generate the web service entry code, and encapsulate the HTTP interface;

[0120] Render and generate Docker container configuration files and startup scripts;

[0121] Generate a runtime dependency manifest file, declaring the Python packages required at runtime.

[0122] This invention uses a template engine to achieve parameterized generation of deployment code. The template library is divided into three categories according to function:

[0123] The predictor template encapsulates the logic for model loading, preprocessing, inference, and postprocessing, and is differentiated by task type (text classification, sequence labeling, text matching, joint task).

[0124] Service templates encapsulate HTTP interface definitions and request processing logic;

[0125] A container template encapsulates Docker image build configurations and service startup scripts.

[0126] The predictor is the core component of the deployment package, encapsulating the complete inference process. The generation process renders the template based on the following parameters:

[0127] The task type determines the input / output format and post-processing logic;

[0128] The model export mode determines the model loading method (TorchScript loading or native PyTorch loading).

[0129] The type of word segmenter determines the text encoding method;

[0130] The sequence length parameter determines the input tensor size, and the generated predictor supports single-line inference and batch inference interfaces.

[0131] The deployment package generated by this invention follows a standardized structure: the model directory stores binary model files and configuration files to protect the source code; the predictor file encapsulates the inference logic; the service entry file provides a RESTful API interface; the Docker configuration file defines the image building process and runtime environment; the dependency manifest file declares runtime dependencies; and the startup script provides one-click startup capability. This standardized structure supports directly building Docker images and deploying them as microservices.

[0132] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A configuration-driven method for automated training and deployment of DL4NLP models, characterized in that, Includes the following steps: Configuration file parsing and validation: Parse the YAML format configuration file, map the dataset configuration, preprocessing configuration, word segmenter configuration, model configuration and training configuration in the configuration file to the corresponding strongly typed configuration objects, perform parameter validation, and generate a unified process configuration object; Data preprocessing: Based on the process configuration object, the raw data is automatically loaded and preprocessed according to the preset process to generate input tensors usable by the model; Model building: Based on the model architecture definition in the process configuration object, the component factory automatically instantiates each model component and assembles them into a complete neural network model according to the preset architecture order; Model training: Based on the training parameters in the process configuration object, the training environment is automatically configured and loop training is performed to obtain the optimal model; Model Export: Export the optimal model as a TorchScript binary file, separate from the source code; Model Deployment: Based on the task type and model configuration, a standardized deployment package containing prediction logic and service interfaces is automatically generated using a template engine.

2. The configuration-driven DL4NLP model automated training and deployment method as described in claim 1, characterized in that, In the configuration file parsing and verification steps, the parameter verification specifically includes: verifying the existence of required parameters, validating the range of parameter values, and verifying the consistency of parameter data types, and indicating the specific error location when verification fails.

3. The method for automated training and deployment of a configuration-driven DL4NLP model as described in claim 1, characterized in that, In the data preprocessing step, the corresponding data loader and data format are automatically selected according to the configured task type. Specifically: text classification tasks load single-text single-label format data; multi-label classification tasks load single-text multi-label format data, with labels connected by delimiters; sequence labeling tasks load CoNLL format data, with each line containing characters and their corresponding labels; text matching tasks load text pair format data, with each text pair containing two texts to be matched and a similarity label; and joint tasks load composite format data, with each single text containing both an intent label and a slot sequence label.

4. The method for automated training and deployment of a configuration-driven DL4NLP model as described in claim 1, characterized in that, In the data preprocessing step, preprocessing is performed according to the following preset process: Text standardization: Performs operations such as unifying uppercase and lowercase letters, converting full-width characters to half-width characters, and converting traditional Chinese characters to simplified Chinese characters; Text cleaning phase: Remove HTML tags, control characters, and redundant whitespace; Text standardization phase: Replace URLs, email addresses, and numeric entities with unified predefined tags; Word segmentation stage: Supports two configuration modes, including classic word segmenters that use rule-based or statistical methods, and pre-trained language model word segmenters that use sub-word segmentation algorithms; Encoding stage: The word segmentation results are mapped to a word index sequence, padding or truncation operations are performed to make the sequence length consistent, and attention mask vectors are generated.

5. The configuration-driven DL4NLP model automated training and deployment method as described in claim 4, characterized in that, When using a classic word segmenter, the default workflow also includes an automatic vocabulary building step: Traverse the training dataset to count the frequency of each word element; Filter low-frequency words based on a preset minimum word frequency threshold; The remaining word units are arranged in descending order of word frequency; After reserving special marker positions, a unique index is assigned to each lexicon to form a vocabulary that supports serialized storage and incremental updates.

6. The method for automated training and deployment of a configuration-driven DL4NLP model as described in claim 1, characterized in that, In the model building step, the model components include: Embedding layer components include a vocabulary-based feature embedding layer for mapping discrete lexical units to dense vectors, and a pre-trained language model-based context embedding layer for generating context-sensitive word representations. Encoder components include a convolutional neural network encoder for extracting n-gram features, a recurrent neural network encoder for modeling sequence dependencies, a Transformer encoder for capturing long-range dependencies, and an attention mechanism encoder. Pooling layer components include first-label pooling for extracting CLS position representations, average pooling for calculating sequence mean, max pooling for extracting the most salient features, and attention pooling for weighted aggregation; Task Header Components: These include a classification header for outputting class probabilities, a conditional random field header for outputting the optimal label sequence, and a matching header for outputting similarity scores.

7. The configuration-driven DL4NLP model automated training and deployment method as described in claim 6, characterized in that, The convolutional neural network encoder uses multi-scale one-dimensional convolutional kernels to extract n-gram features of different granularities and obtains the global representation of the sequence through nonlinear activation and max pooling operations; the recurrent neural network encoder uses long short-term memory networks or gated recurrent units to perform temporal modeling of the sequence and supports bidirectional encoding to capture forward and backward context information simultaneously; the Transformer encoder uses a multi-head self-attention mechanism to model the dependencies between any positions within the sequence.

8. The method for automated training and deployment of a configuration-driven DL4NLP model as described in claim 1, characterized in that, Model training includes the following steps: Initialization phase: Based on the training parameters in the process configuration object, an optimizer, learning rate scheduler, and loss function are created; the loss function is automatically selected according to the task type: cross-entropy loss is used for text classification tasks; binary cross-entropy loss is used for multi-label classification tasks; negative log-likelihood loss of conditional random fields is used for sequence labeling tasks; and cross-entropy loss or contrastive loss is used for text matching tasks. Iteration phase: Traverse the training data by round, perform forward propagation to calculate loss, backpropagation to calculate gradient, and parameter update; Validation Phase: After each round of training, the model performance is evaluated on the validation set. Evaluation metrics are calculated based on the task type: for text classification, accuracy, precision, recall, and F1 score are used as evaluation metrics; for multi-label classification, micro-average F1, macro-average F1, and Hamming loss are used as evaluation metrics; for sequence labeling, entity-level precision, recall, and F1 score are used as evaluation metrics; and for text matching, accuracy, AUC, and F1 score are used as evaluation metrics. Early stopping phase: If the validation metrics do not improve for several consecutive rounds, training is terminated and the optimal model parameters are retained.

9. The configuration-driven DL4NLP model automated training and deployment method as described in claim 1, characterized in that, The model export method includes the following steps: Construct example tensors that conform to the input specifications based on the model configuration; Set the model to evaluation mode and disable randomness operations; The tracking interface is invoked to record the model's computation process on example inputs and generate a computation graph representation. Serialize the computation graph and parameter weights into a TorchScript binary file; If the tracking process fails because the model contains dynamic control flow, a rollback mechanism is triggered, and the model weight file and the necessary model architecture definition source code are saved instead.

10. The configuration-driven DL4NLP model automated training and deployment method as described in claim 1, characterized in that, Model deployment includes the following steps: Create a standardized model catalog; Copy the model file, configuration file, vocabulary file, and label mapping file to the model directory; Select the corresponding predictor template based on the task type, fill in the parameters, and then render and generate the predictor code. Render and generate the web service entry code; Render and generate Docker container configuration files and startup scripts; Generate a runtime dependency manifest file.