Text analysis model training method and device, text analysis model application method and device, equipment and medium
Through the text analysis model training method, the multi-layer encoder and decoder network are used to encode and decode the text data of urban management, which solves the problem that the existing urban management methods cannot cover all urban problems, and achieves efficient, accurate and intelligent urban management.
Patent Information
- Application Number
- CN202411710681.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-11
AI Technical Summary
The existing urban management methods cannot cover all types of urban problems, and require manual judgment, which cannot achieve efficient, accurate and intelligent operation and management of the entire city.
Through a text analysis model training method, the original text data is obtained, text classification is performed according to the text content, and a text classification database is generated. The data is encoded and decoded using a multi-layer encoder network and a multi-layer decoder network to train the target text analysis model.
It has realized adaptive response to various urban problems, improved the model's ability to extract data features, reduced human resources investment, and improved the intelligence and automation of urban management.
Smart Images

Figure CN119807410A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application belong to the field of model training and application technology, and in particular, relate to a text analysis model training method, application method, device, equipment and medium. Background Art
[0002] With the acceleration of urbanization, the rapid expansion of urban scale has brought greater challenges to urban development and urban life security, which ultimately led to various problems such as traffic congestion, environmental pollution, and resource allocation. Urban intelligent management is an effective target strategy to deal with these problems. Through data analysis and intelligent decision support, it optimizes resource allocation, alleviates traffic congestion, improves environmental quality, and ultimately improves the efficiency of public services.
[0003] At present, there are some intelligent urban management methods for various urban problems. However, most of them are aimed at solving specific urban problems and cannot cover all types of urban problems. At the same time, urban planners are required to make active manual judgments, which makes it impossible to achieve efficient, accurate and intelligent operation and management of the entire city. Summary of the invention
[0004] The embodiments of the present application provide a text analysis model training method, application method, device, equipment and medium to solve the technical problem that the current urban management method cannot cover all types of urban problems and requires manual judgment.
[0005] In a first aspect, an embodiment of the present application provides a text analysis model training method, the method comprising:
[0006] Get the original text data;
[0007] Performing text classification on the original text data according to text content to obtain a text classification database, wherein the text content includes text characters, target questions, and target strategies corresponding to the original text data;
[0008] Encode the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database;
[0009] Decoding the encoded vector through a multi-layer decoder network to obtain an output word vector;
[0010] The multi-layer encoder network and the multi-layer decoder network are trained according to the output word vector and the text classification database to obtain a target text analysis model.
[0011] Optionally, the text classification database includes a scene text sub-database, a category text sub-database and a strategy text sub-database, and the text classification is performed on the original text data according to the text content to obtain the text classification database, including:
[0012] Splitting and preprocessing the original text data to obtain multiple segments of text data;
[0013] Determining the scene text sub-database according to text characters within a preset range in each segment of text data;
[0014] Classify the target question indicated in each piece of text data, generate label data according to the classification result, and determine the category text sub-database according to the classification result and the label data;
[0015] The strategy text sub-database is determined according to the target problem indicated in each piece of text data and the target strategy corresponding to the target problem.
[0016] Optionally, the method further comprises:
[0017] Performing text expansion on the data in the scenario text sub-database, the category text sub-database and the strategy text sub-database, and combining them to obtain the text classification database;
[0018] The scenario text sub-database, the category text sub-database and the strategy text sub-database after text expansion all include the same amount of text data.
[0019] Optionally, encoding the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database includes:
[0020] According to the multi-head attention feature factors of the multi-layer encoder network, channel splicing is performed on the data in the text classification database to obtain a multi-head attention processing result;
[0021] Perform multiple feature extractions on the multi-head attention processing results to obtain the encoding vector corresponding to the text classification database.
[0022] Optionally, performing channel splicing on the data in the text classification database according to the multi-head attention feature factor of the multi-layer encoder network to obtain a multi-head attention processing result includes:
[0023] Encoding the data in the text classification database through a word embedding layer to obtain a word embedding layer result;
[0024] Performing Fourier transform on the word embedding layer result through the Fourier transform layer to obtain a frequency domain word embedding layer vector;
[0025] According to the multi-head attention feature factor of the multi-layer encoder network, channel splicing is performed on the frequency domain word embedding layer vector to obtain the multi-head attention processing result.
[0026] Optionally, decoding the encoded vector through a multi-layer decoder network to obtain an output word vector includes:
[0027] According to the multi-head attention mechanism of the multi-layer decoder network, the encoded vector is decoded to obtain the output word vector.
[0028] Optionally, decoding the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain the output word vector includes:
[0029] Decoding the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain a vector processing result;
[0030] The vector processing result is fully connected and activated through the output layer to obtain the output word vector.
[0031] Optionally, the training of the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the text classification database to obtain a target text analysis model includes:
[0032] According to the output word vector and the scene text sub-database, the multi-layer encoder network and the multi-layer decoder network are trained to obtain a scene text sub-model;
[0033] According to the output word vector and the category text sub-database, a multi-layer encoder network and a multi-layer decoder network in the scene text sub-model are trained to obtain a category text sub-model;
[0034] According to the output word vector and the strategy text sub-database, the multi-layer encoder network and the multi-layer decoder network in the category text sub-model are trained to obtain the target text analysis model.
[0035] Optionally, the training of the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the scene text sub-database to obtain a scene text sub-model includes:
[0036] From the scene text sub-database, obtaining characters within a first character range to obtain a first character set, and obtaining characters within a second character range to obtain a second character set;
[0037] The multi-layer encoder network and the multi-layer decoder network are trained according to the first character set, the second character set and the output word vector to obtain the scene text sub-model.
[0038] Optionally, the step of training a multi-layer encoder network and a multi-layer decoder network in the scene text sub-model according to the output word vector and the category text sub-database to obtain the category text sub-model comprises:
[0039] Obtaining target question texts and label information corresponding to multiple groups of target question categories from the category text sub-database;
[0040] According to the target question text, the label information and the output word vector, the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model are trained to obtain the category text sub-model.
[0041] Optionally, the step of training a multi-layer encoder network and a multi-layer decoder network in the category text sub-model according to the output word vector and the strategy text sub-database to obtain the target text analysis model includes:
[0042] From the strategy text sub-database, obtaining target question texts and target strategy data corresponding to a plurality of groups of target question categories respectively;
[0043] According to the target question text, the target strategy data and the output word vector, the multi-layer encoder network and the multi-layer decoder network in the category text sub-model are trained to obtain the target text analysis model.
[0044] In a second aspect, an embodiment of the present application provides a text analysis model application method, the method comprising: obtaining text data to be tested;
[0045] The text data to be tested is input into a target text analysis model to obtain target strategy information corresponding to the text data to be tested, and the target text analysis model is trained by the text analysis model training method described in the first aspect.
[0046] In a third aspect, an embodiment of the present application provides a text analysis model training device, the device comprising: a first acquisition module, for acquiring original text data;
[0047] A text classification module, used to classify the original text data according to text content to obtain a text classification database, wherein the text content includes text characters, target questions and target strategies corresponding to the original text data;
[0048] A data encoding module, used for encoding the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database;
[0049] A data decoding module, used for decoding the encoded vector through a multi-layer decoder network to obtain an output word vector;
[0050] A model training module is used to train the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the text classification database to obtain a target text analysis model.
[0051] In a fourth aspect, an embodiment of the present application provides a text analysis model application device, the device comprising: a second acquisition module, used to acquire text data to be tested;
[0052] The model application module is used to input the text data to be tested into a target text analysis model to obtain target strategy information corresponding to the text data to be tested, and the target text analysis model is trained by the text analysis model training method described in the first aspect.
[0053] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned text analysis model training method and text analysis model application method when executing the program.
[0054] In a sixth aspect, an embodiment of the present application provides a readable storage medium. When the instructions in the readable storage medium are executed by a processor of an electronic device, the electronic device can execute the above-mentioned text analysis model training method and text analysis model training method.
[0055] In summary, in the embodiment of the present application, the original text data is obtained; the original text data is classified according to the text content to obtain a text classification database, and the text content includes text characters, target problems and target strategies corresponding to the original text data; the data in the text classification database is encoded by a multi-layer encoder network to obtain the encoding vector corresponding to the text classification database; the encoding vector is decoded by a multi-layer decoder network to obtain an output word vector; the multi-layer encoder network and the multi-layer decoder network are trained according to the output word vector and the text classification database to obtain a target text analysis model. The text data to be tested is obtained; the text data to be tested is input into the target text analysis model to obtain the target strategy information corresponding to the text data to be tested. In this scheme, the constructed database can include various types of problems and corresponding solution strategies, so that the trained model can adaptively deal with various problems, that is, the urban management method provided by the model can cover all types of urban problems; at the same time, a multi-layer encoder network and a multi-layer decoder network are added to the model, and the model's feature extraction capability for data is further improved through deep feature extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0057] Figure 1 It is a flowchart of the steps of a text analysis model training method provided in an embodiment of the present application;
[0058] Figure 2 It is a flowchart of the specific steps of a text analysis model training method provided in an embodiment of the present application;
[0059] Figure 3 It is a model schematic diagram of another text analysis model training method provided in an embodiment of the present application;
[0060] Figure 4 It is a model schematic diagram of another text analysis model training method provided in an embodiment of the present application;
[0061] Figure 5 It is a model schematic diagram of another text analysis model training method provided in an embodiment of the present application;
[0062] Figure 6 It is a model schematic diagram of another text analysis model training method provided in an embodiment of the present application;
[0063] Figure 7 It is a flowchart of the steps of a text analysis model application method provided in an embodiment of the present application;
[0064] Figure 8 It is a structural diagram of a text analysis model training device provided in an embodiment of the present application;
[0065] Fig. 9 It is a structural diagram of a text analysis model application device provided in an embodiment of the present application;
[0066] Fig.10 is a structural diagram of an electronic device provided in an embodiment of the present application;
[0067] Fig.11 It is a structural diagram of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of them. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present application.
[0069] With the acceleration of urbanization, the rapid expansion of urban scale has brought greater challenges to urban development and urban life security, ultimately leading to various problems such as traffic congestion, environmental pollution, and resource allocation.
[0070] Smart city management is an effective solution to these problems. With advanced information technology as its core, smart city management can achieve efficient and precise city management. Through data analysis and intelligent decision-making support, it can optimize resource allocation, alleviate traffic congestion, improve environmental quality, and ultimately enhance the efficiency of public services. At the same time, it can strengthen public safety supervision and emergency response capabilities to ensure safe and stable urban operations. These professional means work together in all aspects of urban governance to promote the development of cities in a more intelligent and sustainable direction.
[0071] The common methods currently include the following two:
[0072] Constructing an intelligent system for positioning, planning, design, construction, management and operation of ecological city complexes, that is, a computer application system for digital management of ecological city complexes, which can be digitally connected with the multi-dimensional system of earth resource allocation, urban planning positioning system, urban construction planning and design system, urban comprehensive management system, etc.; and the five systems are digitally connected with the expert database system and the general database system respectively; and the data collector, data classifier, etc. are respectively set in the two-way connection channel with the multi-dimensional system of earth resource allocation, urban planning positioning system, urban construction planning and design system, urban comprehensive management system, expert database system, and general database system, and are digitally connected with each connection system; the expert database system and the general database system are respectively provided with data automatic updaters, and the digital ecological city full support system is provided with multi-dimensional and multi-level feedback devices. This system can implement digitalization of urban positioning, urban planning, urban construction, urban operation, and urban management, and can fully and scientifically realize the comprehensive control and rational use of existing urban resources.
[0073] In addition, an artificial intelligence-based smart city operation and management system can be constructed, which can include a smart parking integrated management platform, a municipal cloud platform control center, a parking service induction system, and a parking space asset management system. The smart parking integrated management platform includes a management subsystem, a data collection subsystem, a data sharing subsystem, a mobile client interface subsystem and a database; through the artificial intelligence big data platform, information islands are connected, and a new parking management model is realized in the operation and management of roadside parking.
[0074] However, the above solutions only solve a certain type of specific urban problem and cannot cover all types of urban problems. At the same time, the results still require active judgment by urban planners, which makes it impossible to achieve efficient, accurate and intelligent operation and management of the entire city.
[0075] The text analysis model training method and text analysis model application method provided in the embodiments of the present application are described in detail below.
[0076] Figure 1 This is a flowchart of a text analysis model training method provided in an embodiment of the present application, see Figure 1 , the text analysis model training method may include:
[0077] Step 101, obtaining original text data.
[0078] In an embodiment of the present application, the original text data may include a variety of text data related to urban issues, specifically including: specific plan documents for urban optimization management, corresponding urban condition information when optimizing specific plans (including urban traffic operation conditions, urban electricity consumption conditions, urban environmental index, etc.), implementation of urban optimization management plans, the final effect of urban optimization plans after implementation, and other comprehensive text information.
[0079] In some embodiments, there may be multiple ways to obtain original text data, such as: obtaining original text data from a network search, extracting original text data from pre-stored data, receiving original text data sent by other devices, etc.
[0080] It should be noted that when obtaining data from a web search, keyword searches can be performed on Wikipedia, Google Scholar, HowNet, and historical data on urban optimization solutions. The keywords may specifically include: smart city, urban optimization management, urban resource optimization, science and technology city, etc. The searched content can be screened and data related to urban issues can be selected to obtain original text data.
[0081] Step 102: classify the original text data according to the text content to obtain a text classification database.
[0082] It should be noted that the text content may include text characters, target problems and target strategies corresponding to the original text data, wherein the text characters may represent specific words in the original text data, the target problem may represent the problem indicated by the text in the original text data, and the target strategy may represent the solution strategy corresponding to the problem indicated by the text in the original text data.
[0083] In an embodiment of the present application, when performing text classification on original text data, each character in the original text data can be analyzed and understood to obtain the problem indicated by the text and the solution strategy corresponding to the problem.
[0084] Step 103: encode the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database.
[0085] In the embodiment of the present application, since the strength of correlation between various urban management issues and between optimization strategies or answers is not completely consistent, for urban issues with shallow correlation, extracting their shallow features can meet the model requirements; but for urban issues with deep correlation, deep features must be extracted to meet the model requirements. Therefore, in order to extract the shallow features and deep features of text interactions respectively, and adaptively fuse the deep features and shallow features through the self-attention mechanism to improve the understanding of various urban issues, the data in the text classification database can be encoded through a multi-layer encoder network, and the hierarchical features of the data can be fully extracted to obtain the encoding vector corresponding to the text classification database.
[0086] It should be noted that the encoding vector can be a feature vector obtained by sequentially processing the multi-head attention mechanism, multi-head attention feature extraction, layer normalization, fully connected layer, random inactivation (Dropout) layer and self-attention mechanism in a multi-layer encoder network.
[0087] In some embodiments, the multi-layer encoder network includes multiple encoders, and the multiple encoders are stacked to connect the input of the next layer of encoder to the output of the previous layer of encoder. The output of the last layer is the output of the entire multi-layer encoder network. The number of layers of the multi-layer encoder network can be set according to the actual needs of the scene or the needs of the user, such as: 5 layers, 8 layers, 10 layers, etc.
[0088] Step 104, decode the encoded vector through a multi-layer decoder network to obtain an output word vector.
[0089] In an embodiment of the present application, the multi-layer decoder network is mainly based on the global feature extraction of the multi-layer encoder network and the structural design of the multi-head attention mechanism. The encoding vector processed by the multi-layer encoder network is processed in the multi-layer decoder network through the multi-head attention mechanism, the fully connected layer, the Dropout layer and the layer normalization to obtain the output word vector, which can be understood as the final output of the model.
[0090] In some embodiments, the multi-layer decoder network includes multiple decoders, and the multiple decoders are stacked, and the input of the next layer of decoders is connected to the output of the previous layer of decoders. The output of the last layer is the output of the entire multi-layer decoder network. The number of layers of the multi-layer decoder network is the same as the number of layers of the multi-layer encoder network, and each layer of decoders in the multi-layer decoder network corresponds to a layer of encoder in the multi-layer encoder network. That is to say, the input of each layer of decoders in the multi-layer decoder network includes the output of the previous layer of decoders and the output of the encoder corresponding to the decoder of this layer.
[0091] Step 105: training the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the text classification database to obtain a target text analysis model.
[0092] In an embodiment of the present application, the output word vector obtained after processing by the multi-layer encoder network and the multi-layer decoder network can be understood as the result of the model output. At this time, the multi-layer encoder network and the multi-layer decoder network can be retrained in combination with the data in the text classification database, so that the output result of the trained model is close to the data in the text classification database, thereby obtaining the final target text analysis model, which can be used to analyze and answer input questions or other texts in actual scenarios.
[0093] In summary, in the embodiment of the present application, the original text data is obtained; the original text data is classified according to the text content to obtain a text classification database, and the text content includes text characters, target problems and target strategies corresponding to the original text data; the data in the text classification database is encoded by a multi-layer encoder network to obtain the encoding vector corresponding to the text classification database; the encoding vector is decoded by a multi-layer decoder network to obtain an output word vector; the multi-layer encoder network and the multi-layer decoder network are trained according to the output word vector and the text classification database to obtain a target text analysis model. The text data to be tested is obtained; the text data to be tested is input into the target text analysis model to obtain the target strategy information corresponding to the text data to be tested. In this scheme, the constructed database can include various types of problems and corresponding solution strategies, so that the trained model can adaptively deal with various problems; at the same time, a multi-layer encoder network and a multi-layer decoder network are added to the model, and the model's feature extraction capability for data is further improved through deep feature extraction.
[0094] Figure 2 This is a flowchart of the specific steps of a text analysis model training method provided by this application, see Figure 2 , the method may include the following steps:
[0095] Step 201, obtaining original text data.
[0096] In the embodiment of the present application, for the description of step 201, please refer to the detailed description of step 101 in the above embodiment, and the embodiment of the present application will not be repeated.
[0097] Step 202, splitting and preprocessing the original text data to obtain multiple segments of text data.
[0098] In an embodiment of the present application, the collected original text data can be split and preprocessed. Specifically, the project descriptions in the original text data that are not related to urban intelligent operations, or the legal terms involved therein, Hypertext Markup Language (HTML) tags, special characters in the original text data, and technical parameters involved in the specific plan can be filtered and processed to reduce invalid data in the initial data and improve the overall quality of the data; in addition, all dimensions appearing in the original text data are unified, all dimensions are converted into international standard dimensions, all English in the original text data are converted into uppercase format, and duplicate data in the original text data are removed using data processing software, and then the cleaned text data is converted into a plain text format using a Uniform Resource Locator (URL) encoding method.
[0099] At the same time, in order to further improve the efficiency of data use, the text data after the unified format can also be split to obtain N segments of text data, which can be expressed as follows:
[0100] T=[text1, text2,..., text N ]
[0101] i∈[1,N]
[0102] Among them, T represents the complete original text data, text i Represents the i-th paragraph of text data, i∈[1,N].
[0103] In an embodiment of the present application, the text classification database may specifically include a scene text sub-database, a category text sub-database, and a strategy text sub-database, which will be described separately below.
[0104] Step 203: determining the scene text sub-database according to the text characters within a preset range in each segment of text data.
[0105] In the embodiment of the present application, a preset range may be pre-set for each segment of text data, and text characters within the preset range in each segment of text data are determined as data of the scene text sub-database.
[0106] It should be noted that, since the text describing the scene usually appears at the beginning, the preset range can be the first a+b consecutive characters in the text, where the first a characters can be used as input text data of a set of scene text sub-databases, represented by the symbol Qw jThen, the continuous b characters after the segment a characters can be used as the predicted output text data of the group of scene text sub-databases, represented by the symbol y j express.
[0107] It should be noted that the input text data and the predicted output text data of the scene text sub-database are combined to obtain a set of scene text data.
[0108] You can use Dataw j =[Qw j ,y j ] indicates that by performing the same processing on each piece of text data, P groups of scene text data can be obtained, and after combining, a scene text sub-database Dw is obtained, where Dw = [Dataw1, Dataw2, ..., Dataw j ], j∈[1,P].
[0109] Step 204 , classify the target question indicated in each segment of text data, generate label data according to the classification result, and determine the category text sub-database according to the classification result and the label data.
[0110] In an embodiment of the present application, various types of target problems indicating problems occurring in a city may be involved in urban management, so the target problems are divided into Z subcategories, and a label feature is assigned to each type of target problem.
[0111] It should be noted that in order to uniquely and accurately identify the classification of specific target problems, each type of target problem has its own exclusive label, which is unique. Therefore, the label feature can be set to a vector of length Z, which is the same as the total number of categories included in the target problem, that is, the Lth digit of the label feature corresponding to the Lth type of target problem is 1, and the remaining digits are 0.
[0112] For example, for the target problem of how to deal with the conflict between the property management and the owners of a community, this type of problem is classified as a civil dispute problem among residents and is defined as a first-type target problem, and its label is [1, 0, 0, 0, 0, 0, 0, ..., 0, 0]; for the target problem of how to distribute shared bicycles in a city, this type of problem is classified as a city shared resource allocation problem and is defined as a second-type target problem, and its label is [0, 1, 0, 0, 0, 0, 0, 0, ..., 0, 0]; for the target problem of what factors should be considered when building a city subway station at a certain location, this type of problem is classified as an urban public transportation facility design problem and is defined as a third-type target problem, and its label is [0, 0, 1, 0, 0, 0, 0, 0, ..., 0].
[0113] Therefore, according to the above description, each target problem is classified in turn. After determining the category of the target problem, it can be labeled according to the category. The target problem belongs to the Lth category of target problem, and the Lth bit of its corresponding label will be set to 1, and the other bits will remain 0.
[0114] In some embodiments, for some target problems that belong to the category of multiple urban problems, the digits corresponding to the problem category to which they belong are set to 1, and the other digits remain 0.
[0115] For example, the target problem is that there are few shared bicycles near a subway station, and the subway station has only one exit. How should the subway station exit be constructed to optimize the configuration of shared bicycles? This type of problem belongs to the problem of urban shared resource configuration and also to the problem of urban public facility design. For this type of problem, the label bits corresponding to the two types of problems are set to 1 in the label, and the other bits remain 0, then the corresponding label can be [01100000…00].
[0116] It should be noted that after each target question is classified, the specific target question classification text is defined as Qf j , and its corresponding label is defined as B j , and combine the two to obtain a set of target problem classification data Dataf j =[Qf j , B j ], and then the obtained N groups of target problem classification data are combined to obtain the category text sub-database Df, where Df = [Dataf1, Dataf2, ..., Dataf j ], j∈[1,P].
[0117] Step 205 , determining the strategy text sub-database according to the target problem indicated in each piece of text data and the target strategy corresponding to the target problem.
[0118] It should be noted that in addition to classifying the target problems, the model can generate a corresponding specific solution strategy for each specific target problem. Specifically, the solution strategy for each specific target problem can be obtained mainly by searching for the solution record documents of past target problems and by asking relevant professional city operators.
[0119] In the embodiment of the present application, the specific target problem description text can be defined as Qm j , and define the corresponding solution strategy or answer as A j , and combine the two data to form a set of target problem solving strategy data Datagj =[Qm j , A j ], and then the obtained N groups of target problem solving strategy data are combined to obtain the strategy text sub-database Dg, where
[0120] Dg=[Datag1, Datag2,…, Datag j ], j∈[1,P].
[0121] Step 206: perform text expansion on the data in the scenario text sub-database, the category text sub-database, and the strategy text sub-database, and combine them to obtain the text classification database.
[0122] In an embodiment of the present application, since the amount of data in the scenario text sub-database, the category text sub-database and the strategy text sub-database obtained above may be different, in order to facilitate subsequent calculations, it is necessary to adjust the amount of data in the scenario text sub-database, the category text sub-database and the strategy text sub-database to the same value. Therefore, text expansion is required, which can improve the diversity of the data set to enhance the generalization ability of the model.
[0123] It should be noted that the data in the scenario text sub-database, the category text sub-database and the strategy text sub-database can be expanded by re-wording, synonym replacement and text structure layout adjustment, so that the scenario text sub-database, the category text sub-database and the strategy text sub-database after text expansion all include the same amount of text data.
[0124] For example, "add traffic lights at intersections" can be replaced with "add red and green lights at intersections" or "add traffic lights" to obtain diversified data with the same semantics but different expressions. Finally, the number of data contained in the scene text sub-database, category text sub-database and strategy text sub-database is expanded to M groups.
[0125] In some embodiments, based on the text expansion operation, an expanded scene text sub-database Dwk, a category text sub-database DTk, and a strategy text sub-database Dgk are obtained, and the three are combined to obtain a complete text classification database D;
[0126] Dwk=[Dataw1, Dataw2,..., Dataw M ]
[0127] Dfk=[Dataf1, Dataf2,..., Dataf M ]
[0128] Dgk=[Datag1, Datag2,..., Datag M ]
[0129] D=[Dwk,Dfk,Dgk]
[0130] Among them, Data k represents the kth group of data in the scene text sub-database, Dataf k represents the kth group of data in the category text sub-database, Datag k Represents the kth group of data in the category text sub-database, k∈[1,M].
[0131] Step 207, according to the multi-head attention feature factor of the multi-layer encoder network, channel splicing is performed on the data in the text classification database to obtain a multi-head attention processing result.
[0132] In an embodiment of the present application, a multi-layer encoder network can perform multi-layer feature extraction on data in a text classification database. Specifically, the feature vectors of each head can be spliced and processed through a multi-head attention feature factor, and global feature extraction can integrate information from multiple perspectives to enhance the diversity and expression capabilities of features.
[0133] In some embodiments, according to the multi-head attention feature factor of the multi-layer encoder network, channel splicing is performed on the data in the text classification database to obtain a multi-head attention processing result, which may specifically include the following steps:
[0134] Sub-step 2071, encodes the data in the text classification database through a word embedding layer to obtain a word embedding layer result.
[0135] In some embodiments, the word embedding layer mainly includes encoding the target problem description text and the corresponding strategy text in the text classification database to obtain their word encoding vectors and position encoding vectors respectively. First, the text is decomposed and encoded based on the Bert word embedding method, and the word encoding vectors Vecw and Vecy corresponding to their respective text data are obtained:
[0136] Vecw=Bert(Txt w )
[0137] Vecy=Bert(Txt y )
[0138] Among them, Txt w ,Txt yThey represent the target problem description text and strategy text to be encoded respectively, Vecw is the word encoding vector obtained after encoding the target problem description text data, Vecy is the word encoding vector obtained after encoding the strategy text data, and Bert(*) represents the Bert word operation function.
[0139] In some embodiments, the position code can be calculated using sine and cosine functions to obtain its position code vector Loc, namely:
[0140]
[0141] Among them, p represents the position of each word in the text sequence, k is the encoding dimension index, d is the dimension of position encoding, and Loc represents the result of position encoding.
[0142] In some embodiments, the word encoding vectors Vecw, Vecy and the position encoding vector Loc with the same data dimension can be added element by element to generate word embedding results Ww, Wy, that is:
[0143] Ww=Vecw+Loc
[0144] Wy=Vecy+Loc
[0145] Sub-step 2072, performing Fourier transform on the word embedding layer result through the Fourier transform layer to obtain a frequency domain word embedding layer vector.
[0146] In some embodiments, in order to further improve the feature expression ability of the word embedding vector, the frequency domain features of the word embedding layer results Ww, Wy can be extracted through the Fourier transform layer, and converted from the time domain word embedding layer vector to the frequency domain word embedding layer vector FWw, FWy;
[0147] FWw=FFT(Ww)
[0148] FWy=FFT(Wy)
[0149] Among them, FFT(*) is the Fourier transform operation function, FWw and FWy represent the target question frequency domain word vector and strategy text vector respectively.
[0150] Sub-step 2073, according to the multi-head attention feature factor of the multi-layer encoder network, channel splicing is performed on the frequency domain word embedding layer vector to obtain the multi-head attention processing result.
[0151] In some embodiments, a multi-layer encoder network can be composed based on a multi-head attention mechanism, a fully connected layer, a Dropout layer, and layer normalization.
[0152] Below, combined with the attached Figure 3A detailed description of the multi-layer encoder network.
[0153] In some embodiments, in a multi-layer encoder network, firstly, feature processing is performed on the word embedding layer result FWw of the frequency domain target problem based on a multi-head attention mechanism, so that this global feature extraction can capture key features from different angles and improve the ability to understand complex information;
[0154] In some embodiments, Q is calculated t , K t and V t matrix:
[0155]
[0156] Among them, f Q (*), f K (*) and f V (*) are query, key and value functions respectively, Q t , K t and V t They represent the query, key and value matrices under the tth attention head respectively. The total number of multi-head attention heads is T, then t∈[1,T].
[0157] In some embodiments, the multi-head attention feature factor AT is calculated t :
[0158]
[0159] Among them, softmax(*) represents the softmax function, d k is the normalization factor.
[0160] In some embodiments, based on the characteristic factor AT t The feature vectors of each head are concatenated and processed. Global feature extraction can integrate information from multiple perspectives and enhance the diversity and expression ability of features. The calculation result F of multi-head attention processing is:
[0161] F t =AT t ·FWw
[0162] F = concat(F1, F2, ..., F T )
[0163] Among them, F t The feature processing vector of the t-th attention head, and t∈[1,T]; concat(*) is the channel concatenation operation; then the multi-head attention processing function is:
[0164] Feaw=Multihead(FWw)
[0165] Among them, Multihead(*) represents the multi-head attention processing function.
[0166] Step 208, perform multiple feature extractions on the multi-head attention processing results to obtain the encoding vector corresponding to the text classification database.
[0167] In an embodiment of the present application, in order to alleviate the gradient vanishing problem of the model and reduce the difficulty of model training, multiple feature extractions can be performed to obtain multiple intermediate features. Skip connections are introduced to directly use the intermediate features as one of the inputs of the subsequent self-attention mechanism. At the same time, in order to further improve the ability of the multi-layer encoder network to extract features, the fully connected layer and the Dropout layer are sent to further feature extraction to obtain the intermediate features.
[0168] In some embodiments, Figure 3 As shown in the figure, the processing result Feaw based on the multi-head attention mechanism is sent to the layer standardization for further feature extraction to obtain the intermediate feature TF1:
[0169] TF1=cbz(Feaw)
[0170] Among them, cbz(*) represents the layer normalization operation function.
[0171] In some embodiments, based on this intermediate feature TF1, in order to alleviate the gradient vanishing problem of the model and reduce the difficulty of model training, a skip connection is introduced to directly use this intermediate feature TF1 as one of the inputs of the subsequent self-attention mechanism. At the same time, in order to further improve the feature extraction capability of the multi-layer encoder network, this feature is sent to the fully connected layer and the Dropout layer for further feature extraction to obtain the intermediate feature TF2:
[0172] TF2=Dropout(full(TF1))
[0173] Among them, Dropout(*) represents the Dropout layer operation function, and full(*) represents the fully connected layer operation function.
[0174] In some embodiments, in order to further obtain the deep features of the data, the intermediate feature TF1 can also be sent to the structure connected by the multi-head attention mechanism and the fully connected layer to obtain the deep feature Fdn:
[0175] Fdn=qlj(Multihead(TF1))
[0176] Among them, Multihead(*) is the multi-head attention mechanism operation function, and full(*) represents the fully connected layer operation function.
[0177] In some embodiments, based on the features TF1, TF2, and Fdn respectively obtained in the above steps, the features TF1, TF2, and Fdn are adaptively fused using a self-attention mechanism, and the fused features are again layer-normalized to obtain the final feature processing result En of the multi-layer encoder network:
[0178] En=cbz(Zyl(TF1, TF2, Fdn))
[0179] Among them, Zyl(*) represents the self-attention mechanism operation function, and cbz(*) represents the layer normalization operation function.
[0180] In some embodiments, the encoders are stacked based on the multi-layer encoder network obtained in the above steps. The number of stacked layers can be set by yourself, for example, 10 layers. The input of the next layer of encoder is connected to the output of the previous layer of encoder. The output of each layer of encoder is defined as En1, En2, ..., En 10 The deep features obtained in each layer of encoder are defined as Fdn1, Fdn2, ..., Fdn 10 Finally, the output En of the last layer encoder 10 As the overall output result of this multi-layer encoder network.
[0181] Step 209: decode the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain the output word vector.
[0182] In an embodiment of the present application, in a multi-layer decoder network, the structure design of the decoder is mainly based on the global feature extraction and multi-head attention mechanism of the multi-layer encoder network.
[0183] In some embodiments, according to the multi-head attention mechanism of the multi-layer decoder network, decoding the encoded vector to obtain the output word vector may specifically include the following steps:
[0184] Sub-step 2091, decode the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain a vector processing result.
[0185] Below, combined with the attached Figure 4 The multi-layer decoder network is described in detail, taking a 10-layer decoder as an example.
[0186] In some embodiments, the decoder has two inputs. For the decoder at layer 10, one of its inputs is the output result En of the multi-layer encoder network. 10, and one of the inputs of the decoder at the upper layer is the output of the decoder at the lower layer; in addition, another input of all decoders is the deep features of the encoder at the same level.
[0187] Based on the multi-head attention mechanism, the multi-head attention mechanism operation used in the decoder is consistent with the multi-head attention mechanism used in the encoder, embedding the word vector En 10 After being sent into this multi-head attention mechanism, the processing result Feay is obtained:
[0188] Feay=Multihead(En 10 )
[0189] In some embodiments, the processing result Feay of the multi-head attention mechanism is combined with the deep-level features Fdn output in each layer of the multi-layer encoder, and the layer correspondence relationship is satisfied during the process (i.e., the deep-level features of the tenth-layer encoder are used as an input of the tenth-layer decoder, the deep-level features of the ninth-layer encoder are used as an input of the ninth-layer decoder, and so on to the first layer, and the deep-level features of the first-layer encoder are used as an input of the first-layer decoder). The combined features are defined as Fi:
[0190] Fj=contact(Feay,Fdn)
[0191] The combined feature Fj is then sent to the multi-head attention mechanism to obtain its corresponding output result Fjm:
[0192] Fjm=Multihead(Fj)
[0193] In some embodiments, the output result of the multi-head attention mechanism is processed by a fully connected layer, a Dropout layer, and a layer normalization to obtain the output De of the multi-layer decoder network:
[0194] De=dqj(Fjm)
[0195] Among them, dqj(*) represents the overall operation function from the fully connected layer, Dropout layer to layer normalization.
[0196] In some embodiments, based on the decoder obtained in the above steps, a decoder stacking operation is performed, and the multi-layer decoder network and the multi-layer encoder network have the same number of layers (a total of 10 layers), and the input vector to be decoded of each subsequent layer of decoders is the output of the previous layer of decoders, and the deep features in the corresponding layer encoder are also used as the input of the same layer decoder. The outputs of each layer of decoders are respectively De1, De2, ..., De 10 , the output of the last layer decoder De 10 is the overall processing result of the multi-layer decoder network.
[0197] Sub-step 2092, performing full connection activation processing on the vector processing result through the output layer to obtain the output word vector.
[0198] In some embodiments, the output layer structure consists of a fully connected layer and a Softmax activation function, and the final processing result De of the multi-layer decoder network is 10 The input of this output layer is the word vector G;
[0199] G=Softmax(Full(De 10 ))
[0200] Among them, G is the final generated word vector output, Softmax(*) represents the Softmax processing function, and Full(*) represents the fully connected layer operation function.
[0201] In some embodiments, Figure 5 The figure shows the overall architecture of the model, which is mainly composed of a multi-layer encoder network and a multi-layer decoder network. It can be seen that after the text is input, it first passes through the word embedding layer and the Fourier transform layer, and is input into the multi-layer encoder network. In addition to outputting features to the encoder of the next layer, each encoder layer will also output deep features to the decoder of the corresponding layer. In addition, the output of the lowest encoder layer and the deep features of this layer are output to the decoder of the corresponding layer together, and after passing through the multi-layer decoder, it is output to the fully connected layer and the Softmax activation function to obtain the final word vector.
[0202] Step 210: training the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the scene text sub-database to obtain a scene text sub-model.
[0203] In an embodiment of the present application, since the text classification database includes a scene text sub-database, a category text sub-database and a strategy text sub-database, when the model is trained through the text classification database, the model is trained in sequence through the above three types of sub-databases. First, training is performed by outputting word vectors and the scene text sub-database to obtain a scene text sub-model.
[0204] In some embodiments, the multi-layer encoder network and the multi-layer decoder network are trained according to the output word vector and the scene text sub-database to obtain a scene text sub-model, which may specifically include the following steps:
[0205] Sub-step 2101: From the scene text sub-database, characters within a first character range are obtained to obtain a first character set, and characters within a second character range are obtained to obtain a second character set.
[0206] In some embodiments, when creating the scene text sub-database, a preset range of characters is selected, Dwk=[dataw1, dataw2, . . . , dataw M ]Used for the model city scene training of the urban smart operation analysis big model, through this round of training, the big model can learn the connection relationship between urban texts and master the corresponding architectural text representation ability. Through training, the big model can have the ability to predict subsequent texts based on existing texts, so that the model can initially become familiar with urban problem scenes and provide a basis for subsequent intelligent urban problem analysis. Therefore, when training the model, the continuous first character range (the first a characters) in the text can be used as the input text data segment, and the first character set is represented by the symbol Qw j Indicates: The second character range after the text (continuous b characters) is used as the predicted output text data, and the second character set is represented by the symbol y j express.
[0207] Sub-step 2102: training the multi-layer encoder network and the multi-layer decoder network according to the first character set, the second character set and the output word vector to obtain the scene text sub-model.
[0208] In some embodiments, based on the collected scene text data data k , and k∈[1,M], the autoregressive language modeling method is used for training, that is, through Qw in each scene text data Dwk k Predict the following y k ; and define the pre-trained autoregressive loss function L AL for:
[0209]
[0210] Among them, Q k is the number of autoregressive predictions corresponding to the k-th paragraph of text, G q represents the current word, G1, G2, ..., G q-1 Indicates that in G q Before the word, θ is the model parameter, which is obtained by random initialization.
[0211] In some embodiments, the loss value is calculated based on the randomly initialized model parameters, and the Adam optimization algorithm is used to optimize the model parameters and update the gradient:
[0212]
[0213] Among them, θ′ represents the updated model parameters, φ is the learning rate; then the parameters are iteratively updated, and when the preset maximum number of Epochs is reached preThe training is then stopped, and the trained model can be defined as the scene text sub-model.
[0214] Step 211, according to the output word vector and the category text sub-database, the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model are trained to obtain the category text sub-model.
[0215] In an embodiment of the present application, the scene text sub-model obtained after training based on the above steps is further trained on the basis of the scene text sub-model using the category text sub-database to obtain the category text sub-model.
[0216] In some embodiments, according to the output word vector and the category text sub-database, the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model are trained to obtain the category text sub-model, which may specifically include the following steps:
[0217] Sub-step 2111, obtaining target question texts and label information corresponding to multiple groups of target question categories from the category text sub-database.
[0218] In some embodiments, when constructing the category text sub-database, Dfk is obtained by using the target text corresponding to each question category and the corresponding label data, where Dfk = [dataf1, dataf2, ..., dataf M ], where dataf k represents the kth group of urban management category data, and dataf k =[Qf k , B k ], k∈[1,M].
[0219] Sub-step 2112, training the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model according to the target question text, the label information and the output word vector to obtain the category text sub-model.
[0220] In some embodiments, the target question text Qf k As model input, and generate corresponding label information B k The target training model is finally used to make the model learn the corresponding target problem types for various target problems. The loss function L used in this round of training is Fine Designed for:
[0221]
[0222] Among them, EB k Respectively represent the text Qf kThe actual corresponding problem category vector, EBy k Represents the problem category vector predicted by the model. |*| represents the vector modulo operation function. During model training, the parameters saved in the scene text sub-model after training are set as the initialization parameters of the category text sub-model. Then, the Adam optimization algorithm is used to optimize the model parameters and perform gradient updates. When the number of training times reaches the maximum preset number of Epochs, fine The training is then stopped, and the trained model is defined as the category text sub-model.
[0223] Step 212: training the multi-layer encoder network and the multi-layer decoder network in the category text sub-model according to the output word vector and the strategy text sub-database to obtain the target text analysis model.
[0224] In an embodiment of the present application, the category text sub-model obtained after training based on the above steps, at this time, the category text sub-model already has the ability to judge the type of problem for the input target problem text. In order to further improve the category text sub-model's ability to solve the target problem and ultimately enable it to have the ability to solve practical problems, the collected target problem solution strategy database can be used to continue training on the basis of the category text sub-model, so that the model has the ability to output corresponding solution strategies based on the specific target problem text input.
[0225] In some embodiments, according to the output word vector and the strategy text sub-database, the multi-layer encoder network and the multi-layer decoder network in the category text sub-model are trained to obtain the target text analysis model, which may specifically include the following steps:
[0226] Sub-step 2121, obtaining, from the strategy text sub-database, a plurality of groups of target question texts and target strategy data corresponding to target question categories.
[0227] In some embodiments, when constructing the strategy text sub-database, Dgk is obtained by using the target text corresponding to each question category and the corresponding strategy data, where Dgk = [datag1, datag2, ..., datag M ], where datag k represents the kth group of urban problem solution data, and datag k =[Qm k , A k ], k∈[1,M].
[0228] Sub-step 2122, according to the target question text, the target strategy data and the output word vector, the multi-layer encoder network and the multi-layer decoder network in the category text sub-model are trained to obtain the target text analysis model.
[0229] In some embodiments, the target question text Qm k As model input, and to generate the corresponding target strategy data A k As the output training model, the model can finally generate corresponding strategies for various target problems. The loss function L used in this round of training is last Designed for:
[0230]
[0231] Among them, EQm k and EA k Represents the text Qm k and A k The corresponding word vector, θ last Represents the parameters saved after training in the category text sub-model, and positions this parameter as the input parameter of the target text analysis model. Then, the Adam optimization algorithm is used to optimize the model parameters and perform gradient updates. When the number of training times reaches the maximum preset number of Epochs last The training is then stopped, and the trained large model is used as the final target text analysis model.
[0232] In some embodiments, Figure 6 The overall process of gradually improving the overall performance of the model through multi-step model training, such as Figure 6 As shown, the scene text sub-model is first trained through the scene text sub-database, then the category text sub-model is trained through the category text sub-database, and then the target text analysis model is trained through the strategy text sub-database, so as to obtain the final target text analysis model.
[0233] To sum up, in the embodiments of the present application, the constructed database may include various types of problems and corresponding solution strategies, so that the trained model can adaptively deal with various problems; at the same time, a multi-layer encoder network and a multi-layer decoder network are added to the model, and the model's feature extraction ability for data is further improved through deep feature extraction; in addition, the multi-step model training strategy allows the model to start learning from familiar problem scenarios during training, and then learn problem categories until it learns how to propose efficient problem-solving strategies. This model training strategy can improve data utilization, enhance training efficiency, and help further improve the model's adaptability to problem scenarios, thereby obtaining a more intelligent model; finally, based on the target text analysis model obtained through the above training, the model is trained through a multi-step training strategy combined with a comprehensive text classification database, which can improve the intelligence and automation of problem text analysis and reduce human resource investment.
[0234] Figure 7 This is a flowchart of a method for applying a text analysis model provided in an embodiment of the present application. Figure 7 , the text analysis model application method may include:
[0235] Step 701, obtaining text data to be tested.
[0236] In the embodiment of the present application, the text data to be tested may be text data of a specific target problem input by a user.
[0237] Step 702: input the text data to be tested into a target text analysis model to obtain target strategy information corresponding to the text data to be tested.
[0238] In the embodiment of the present application, the target text analysis model is trained by the above-mentioned text analysis model training method.
[0239] In an embodiment of the present application, the text data to be tested is input into the target text analysis model in the form of text for the model to extract and analyze data. The target text analysis model can process and analyze the text data to be tested input by the user to obtain corresponding target strategy information.
[0240] In some embodiments, after the training of the target text analysis model is completed, server resources whose computing power, memory resources and the model match can be selected, and the trained target text analysis model can be deployed to the background server cluster.
[0241] In some embodiments, when obtaining the text data to be tested, the specific optimization requirements input by the user can also be obtained, so that the target text analysis model can process and analyze the text data to be tested input by the user, and then generate a corresponding reply text based on the user's specific optimization requirements.
[0242] In some embodiments, the model also needs to be continuously optimized and updated during the application process. Therefore, the target text analysis model can be improved and fine-tuned in real time according to the newly acquired text data to be tested and the corresponding target strategy information, so that the target text analysis model can be synchronously updated and optimized, ultimately ensuring the accuracy and reliability of the analysis and solution of the target problem to meet the problem-solving needs in various scenarios.
[0243] Figure 8 800 is a structural diagram of a text analysis model training device provided in an embodiment of the present application. The text analysis model training device 800 may include:
[0244] The first acquisition module 801 is used to acquire original text data;
[0245] A text classification module 802 is used to classify the original text data according to text content to obtain a text classification database, wherein the text content includes text characters, target questions and target strategies corresponding to the original text data;
[0246] A data encoding module 803 is used to encode the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database;
[0247] A data decoding module 804 is used to decode the encoded vector through a multi-layer decoder network to obtain an output word vector;
[0248] The model training module 805 is used to train the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the text classification database to obtain a target text analysis model.
[0249] Optionally, the text classification database includes a scene text sub-database, a category text sub-database and a strategy text sub-database, and the text classification module 802 includes:
[0250] A text processing submodule, used for splitting and preprocessing the original text data to obtain multiple segments of text data;
[0251] A scene text sub-database generating sub-module, used to determine the scene text sub-database according to text characters within a preset range in each segment of text data;
[0252] A category text sub-database generating sub-module, used for classifying according to the target question indicated in each piece of text data, generating label data according to the classification result, and determining the category text sub-database according to the classification result and the label data;
[0253] The strategy text sub-database generating sub-module is used to determine the strategy text sub-database according to the target problem indicated in each piece of text data and the target strategy corresponding to the target problem.
[0254] Optionally, the text analysis model training device 800 further includes:
[0255] A text expansion module, used to perform text expansion on the data in the scenario text sub-database, the category text sub-database and the strategy text sub-database, and combine them to obtain the text classification database;
[0256] The scenario text sub-database, the category text sub-database and the strategy text sub-database after text expansion all include the same amount of text data.
[0257] Optionally, the data encoding module 803 includes:
[0258] A channel splicing submodule, used to perform channel splicing on the data in the text classification database according to the multi-head attention feature factor of the multi-layer encoder network to obtain a multi-head attention processing result;
[0259] The feature extraction submodule is used to perform multiple feature extractions on the multi-head attention processing results to obtain the encoding vector corresponding to the text classification database.
[0260] Optionally, the channel splicing submodule includes:
[0261] A word embedding unit, used for encoding the data in the text classification database through a word embedding layer to obtain a word embedding layer result;
[0262] A Fourier transform unit, used for performing Fourier transform on the word embedding layer result through a Fourier transform layer to obtain a frequency domain word embedding layer vector;
[0263] The first multi-head attention unit is used to perform channel splicing on the frequency domain word embedding layer vector according to the multi-head attention feature factor of the multi-layer encoder network to obtain the multi-head attention processing result.
[0264] Optionally, the data decoding module 804 includes:
[0265] The vector decoding submodule is used to decode the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain the output word vector.
[0266] Optionally, the vector decoding submodule includes:
[0267] A second multi-head attention unit is used to decode the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain a vector processing result;
[0268] The fully connected unit is used to perform fully connected activation processing on the vector processing result through the output layer to obtain the output word vector.
[0269] Optionally, the model training module 805 includes:
[0270] A scene text sub-model training sub-module, used to train the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the scene text sub-database to obtain a scene text sub-model;
[0271] A category text sub-model sub-module, used to train the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model according to the output word vector and the category text sub-database to obtain a category text sub-model;
[0272] The target text analysis model submodule is used to train the multi-layer encoder network and the multi-layer decoder network in the category text submodel according to the output word vector and the strategy text subdatabase to obtain the target text analysis model.
[0273] Optionally, the scene text sub-model training sub-module includes:
[0274] A character set unit, configured to obtain characters within a first character range from the scene text sub-database to obtain a first character set, and to obtain characters within a second character range to obtain a second character set;
[0275] The scene text sub-model training unit is used to train the multi-layer encoder network and the multi-layer decoder network according to the first character set, the second character set and the output word vector to obtain the scene text sub-model.
[0276] Optionally, the category text sub-model sub-module includes:
[0277] A label acquisition unit, used to acquire target question texts and label information corresponding to multiple groups of target question categories from the category text sub-database;
[0278] The category text sub-model unit is used to train the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model according to the target question text, the label information and the output word vector to obtain the category text sub-model.
[0279] Optionally, the target text analysis model submodule includes:
[0280] A strategy acquisition unit, used to acquire target question texts and target strategy data corresponding to a plurality of groups of target question categories from the strategy text sub-database;
[0281] The target text analysis model unit is used to train the multi-layer encoder network and the multi-layer decoder network in the category text sub-model according to the target question text, the target strategy data and the output word vector to obtain the target text analysis model.
[0282] Fig. 9 9 is a structural diagram of a text analysis model application device provided in an embodiment of the present application. The text analysis model application device 900 may include:
[0283] The second acquisition module 901 is used to acquire the text data to be tested;
[0284] The model application module 902 is used to input the text data to be tested into the target text analysis model to obtain the target strategy information corresponding to the text data to be tested. The target text analysis model is trained by the above-mentioned text analysis model training method.
[0285] See also Fig.10 , the electronic device 1000 may include one or more of the following components: a processing component 1002 , a memory 1004 , a power component 1006 , a multimedia component 1008 , an audio component 1010 , an input / output (I / O) interface 1012 , a sensor component 1014 , and a communication component 1016 .
[0286] The processing component 1002 generally controls the overall operation of the electronic device 1000, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1002 may include one or more processors 1020 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1002 may include one or more modules to facilitate the interaction between the processing component 1002 and other components. For example, the processing component 1002 may include a multimedia module to facilitate the interaction between the multimedia component 1008 and the processing component 1002.
[0287] The memory 1004 is used to store various types of data to support the operation of the electronic device 1000. Examples of such data include instructions for any application or method operating on the electronic device 1000, contact data, phone book data, messages, pictures, multimedia, etc. The memory 1004 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0288] The power supply component 1006 provides power to various components of the electronic device 1000. The power supply component 1006 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1000.
[0289] The multimedia component 1008 includes an interface that provides an output interface between the electronic device 1000 and the user. In some embodiments, the interface may include a liquid crystal display (LCD) and a touch panel (TP). If the interface includes a touch panel, the interface may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1008 includes a front camera and / or a rear camera. When the electronic device 1000 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0290] The audio component 1010 is used to output and / or input audio signals. For example, the audio component 1010 includes a microphone (MIC), and when the electronic device 1000 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 1004 or sent via the communication component 1016. In some embodiments, the audio component 1010 also includes a speaker for outputting audio signals.
[0291] The input / output I / O interface 1012 provides an interface between the processing component 1002 and the peripheral interface module, which may be a keyboard, a click wheel, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0292] The sensor assembly 1014 includes one or more sensors for providing various aspects of status assessment for the electronic device 1000. For example, the sensor assembly 1014 can detect the open / closed state of the electronic device 1000, the relative positioning of components, such as the display and keypad of the electronic device 1000, and the sensor assembly 1014 can also detect the position change of the electronic device 1000 or a component of the electronic device 1000, the presence or absence of user contact with the electronic device 1000, the orientation or acceleration / deceleration of the electronic device 1000, and the temperature change of the electronic device 1000. The sensor assembly 1014 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 1014 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1014 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0293] The communication component 1016 is used to facilitate wired or wireless communication between the electronic device 1000 and other devices. The electronic device 1000 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 1016 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1016 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0294] In an exemplary embodiment, the electronic device 1000 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to implement a method for displaying a vehicle-road collaborative scenario provided in an embodiment of the present application.
[0295] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1004 including instructions, and the instructions can be executed by the processor 1020 of the electronic device 1000 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0296] Fig.11 1 is a block diagram of an electronic device 1100 according to another embodiment of the present invention. For example, the electronic device 1100 may be provided as a server. Fig.11 , the electronic device 1100 includes a processing component 1122, which further includes one or more processors, and a memory resource represented by a memory 1132, for storing instructions that can be executed by the processing component 1122, such as an application. The application stored in the memory 1132 may include one or more modules, each of which corresponds to a set of instructions. In addition, the processing component 1122 is configured to execute instructions to execute a method for displaying a vehicle-road cooperative scenario provided in an embodiment of the present application.
[0297] The electronic device 1100 may also include a power supply component 1126 configured to perform power management of the electronic device 1100, a wired or wireless network interface 1150 configured to connect the electronic device 1100 to a network, and an input / output (I / O) interface 1158. The electronic device 1100 may operate based on an operating system stored in the memory 1132, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM or the like.
[0298] In an embodiment of the present application, the memory 1132 may be used to store software programs and various data. The memory 1132 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instruction required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1132 may include a volatile memory or a non-volatile memory, or the memory 1132 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 1132 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0299] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to the operating system, user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor.
[0300] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image super-resolution reconstruction method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0301] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0302] An embodiment of the present application also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the super-resolution reconstruction method embodiment of the above-mentioned image, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0303] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0304] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A text analysis model training method, characterized in that: The method comprises: Get the original text data; Performing text classification on the original text data according to text content to obtain a text classification database, wherein the text content includes text characters, target questions, and target strategies corresponding to the original text data; Encode the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database; Decoding the encoded vector through a multi-layer decoder network to obtain an output word vector; The multi-layer encoder network and the multi-layer decoder network are trained according to the output word vector and the text classification database to obtain a target text analysis model.
2. The method according to claim 1, characterized in that The text classification database includes a scene text sub-database, a category text sub-database and a strategy text sub-database. The text classification is performed on the original text data according to the text content to obtain the text classification database, including: Splitting and preprocessing the original text data to obtain multiple segments of text data; Determining the scene text sub-database according to text characters within a preset range in each segment of text data; Classify the target question indicated in each piece of text data, generate label data according to the classification result, and determine the category text sub-database according to the classification result and the label data; The strategy text sub-database is determined according to the target problem indicated in each piece of text data and the target strategy corresponding to the target problem.
3. The method according to claim 2, characterized in that The method further comprises: Performing text expansion on the data in the scenario text sub-database, the category text sub-database and the strategy text sub-database, and combining them to obtain the text classification database; The scenario text sub-database, the category text sub-database and the strategy text sub-database after text expansion all include the same amount of text data.
4. The method according to claim 1, characterized in that: The step of encoding the data in the text classification database by a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database includes: According to the multi-head attention feature factor of the multi-layer encoder network, channel splicing is performed on the data in the text classification database to obtain a multi-head attention processing result; Perform multiple feature extractions on the multi-head attention processing results to obtain the encoding vector corresponding to the text classification database.
5. The method according to claim 4, characterized in that The method of performing channel splicing on the data in the text classification database according to the multi-head attention feature factor of the multi-layer encoder network to obtain a multi-head attention processing result includes: Encoding the data in the text classification database through a word embedding layer to obtain a word embedding layer result; Performing Fourier transform on the word embedding layer result through the Fourier transform layer to obtain a frequency domain word embedding layer vector; According to the multi-head attention feature factor of the multi-layer encoder network, channel splicing is performed on the frequency domain word embedding layer vector to obtain the multi-head attention processing result.
6. The method according to claim 1, characterized in that The decoding of the encoded vector by a multi-layer decoder network to obtain an output word vector includes: According to the multi-head attention mechanism of the multi-layer decoder network, the encoded vector is decoded to obtain the output word vector.
7. The method according to claim 6, characterized in that The decoding of the encoding vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain the output word vector includes: Decoding the encoded vector according to the multi-head attention mechanism of the multi-layer decoder network to obtain a vector processing result; The vector processing result is fully connected and activated through the output layer to obtain the output word vector.
8. The method according to claim 2, characterized in that: The step of training the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the text classification database to obtain a target text analysis model includes: According to the output word vector and the scene text sub-database, the multi-layer encoder network and the multi-layer decoder network are trained to obtain a scene text sub-model; According to the output word vector and the category text sub-database, a multi-layer encoder network and a multi-layer decoder network in the scene text sub-model are trained to obtain a category text sub-model; According to the output word vector and the strategy text sub-database, the multi-layer encoder network and the multi-layer decoder network in the category text sub-model are trained to obtain the target text analysis model.
9. The method according to claim 8, characterized in that The step of training the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the scene text sub-database to obtain a scene text sub-model includes: From the scene text sub-database, obtaining characters within a first character range to obtain a first character set, and obtaining characters within a second character range to obtain a second character set; The multi-layer encoder network and the multi-layer decoder network are trained according to the first character set, the second character set and the output word vector to obtain the scene text sub-model.
10. The method according to claim 8, characterized in that The step of training the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model according to the output word vector and the category text sub-database to obtain the category text sub-model includes: Obtaining target question texts and label information corresponding to multiple groups of target question categories from the category text sub-database; According to the target question text, the label information and the output word vector, the multi-layer encoder network and the multi-layer decoder network in the scene text sub-model are trained to obtain the category text sub-model.
11. The method according to claim 8, characterized in that The step of training the multi-layer encoder network and the multi-layer decoder network in the category text sub-model according to the output word vector and the strategy text sub-database to obtain the target text analysis model includes: From the strategy text sub-database, obtaining target question texts and target strategy data corresponding to a plurality of groups of target question categories respectively; According to the target question text, the target strategy data and the output word vector, the multi-layer encoder network and the multi-layer decoder network in the category text sub-model are trained to obtain the target text analysis model.
12. A text analysis model application method, characterized in that: The method comprises: Get the text data to be tested; The text data to be tested is input into a target text analysis model to obtain target strategy information corresponding to the text data to be tested, wherein the target text analysis model is trained by the text analysis model training method described in any one of claims 1 to 11.
13. A text analysis model training device, characterized in that: The device comprises: A first acquisition module, used to acquire original text data; A text classification module, used to classify the original text data according to text content to obtain a text classification database, wherein the text content includes text characters, target questions and target strategies corresponding to the original text data; A data encoding module, used for encoding the data in the text classification database through a multi-layer encoder network to obtain an encoding vector corresponding to the text classification database; A data decoding module, used for decoding the encoded vector through a multi-layer decoder network to obtain an output word vector; A model training module is used to train the multi-layer encoder network and the multi-layer decoder network according to the output word vector and the text classification database to obtain a target text analysis model.
14. A text analysis model application device, characterized in that: The device comprises: The second acquisition module is used to acquire the text data to be tested; A model application module is used to input the text data to be tested into a target text analysis model to obtain target strategy information corresponding to the text data to be tested, wherein the target text analysis model is trained by the text analysis model training method according to any one of claims 1 to 11.
15. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 11 or the method according to claim 12 is implemented.
16. A readable storage medium, characterized in that: When the instructions in the readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method of any one of claims 1 to 11 or the method of claim 12.