Markup language document writing method and device, equipment and storage medium
By fine -tuning the linguistic document data set based on the language model based on the attention mechanism, the generating mode infer the model, solve the problem of the existing technology of the science and the language documentation of the bidding documentation, the problem of high complexity and low efficiency in the process of writing, and achieve more efficient and more efficient and more efficient and more efficient and more efficient and more efficient and efficient Accurate mode inference and documentation.
Patent Information
- Application Number
- CN202411537137.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-01-28
AI Technical Summary
In the process of writing markup language documents, the pattern inference is complex and low efficiency, resulting in low automation analysis and processing efficiency.
Using a language model based on the attention mechanism, fine -tuning the linguistic document dataset data set, generating mode infer the model, and obtaining the characters entered by the user in real time for character prediction.
Improve the efficiency and accuracy of the inference of the labeling language pattern, simplify the writing process, and improve the efficiency of the user experience and markings of the linguistic documentation.
Smart Images

Figure CN119378502A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer formal languages, and in particular to a markup language document writing method, apparatus, device and storage medium. Background Art
[0002] The markup language used in the data transmission process is used to mark electronic documents to make them structured. Due to its flexible structure, good scalability, platform independence and other characteristics, it has been widely used in data exchange, data storage, Web development, database management, configuration document writing, data analysis and processing and other fields. Markup language documents must comply with certain specifications during use. These specifications are defined by the markup language model language. The mainstream markup language model languages include DTD (Document Type Definition) and XSD (Document Structure Description, XML Schema Definition). Through these model languages, the structure of the markup language document, the elements it contains and the corresponding attributes can be strictly defined, thereby ensuring the validity and legality of the markup language document.
[0003] However, there are no fixed tags when writing markup language documents, allowing users to customize their own markup language. Therefore, some markup language documents on the Internet currently do not have corresponding schema definitions, which seriously affects the efficiency of automated analysis and processing of markup language documents.
[0004] In order to solve the above problems, when users write markup language documents, they usually need to infer their patterns, and then predict the next character based on the inferred markup language patterns. The traditional markup language document writing method is based on automata theory, which infers a regular expression from a given markup language document set. The specific process is: first extract strings from the markup language documents as a data set, and then construct SOA (single occurrence order) according to the partial order relationship of the characters in each string. automaton, single occurrence automaton), and then traverse the nodes in the entire SOA graph, calculate its predecessor and successor nodes, and deduce a regular expression according to a certain logic. The pattern of the language space where the regular expression is located is the pattern of the language space where the markup language document is located. By traversing each node of SOA as above and deriving the regular expression corresponding to the markup language pattern according to the rules, the amount of calculation is large and the calculation complexity is high. Especially when inferring the pattern corresponding to the extended regular expression, as the number of nodes in the graph increases, the relationship between the nodes becomes more and more complex, and the complexity of pattern inference becomes higher and higher, which reduces the inference efficiency, and also makes the inference result more complex, making the generalization performance of the pattern worse, thereby limiting the application in actual scenarios and reducing the writing efficiency of markup language documents. Summary of the invention
[0005] In view of this, the purpose of this application is to provide a method, device, equipment and storage medium for writing markup language documents, which can realize the mining of internal logical relationships of markup languages, improve the efficiency and accuracy of markup language pattern inference, and thus improve the efficiency of writing markup language documents. The specific scheme is as follows:
[0006] In a first aspect, the present application discloses a method for writing a markup language document, comprising:
[0007] Get the characters entered by the current user when writing a markup language document, and get the current character;
[0008] Input the current character into a trained pattern inference model, so as to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and output the multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning a language model based on an attention mechanism based on a markup language document dataset;
[0009] When a selection instruction for a target character among the multiple currently predicted characters is obtained, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered until a writing termination instruction is received to complete the writing of the markup language document.
[0010] Optionally, the markup language document writing method further includes:
[0011] Collect different types of historical markup language documents to obtain a markup language document dataset;
[0012] Performing cleaning and deduplication processing on each character in a plurality of character strings in the markup language document data set, so as to abstract a plurality of types of characters appearing in the markup language document data set into a character set, and obtain a preset character set;
[0013] The preset character set is used to perform multiple rounds of fine-tuning on the language model based on the attention mechanism to obtain the pattern inference model.
[0014] Optionally, the language model includes an activation function layer and a fully connected layer, and a gating network is configured before the activation function layer, and the gating network is used to limit the output result of the language model through the preset character set and correct the score of the output result.
[0015] Optionally, the fine-tuning process of the language model further includes:
[0016] Predicting the next character and the probability of occurrence of each character in the preset character set in sequence through the fully connected layer to obtain the next character of each character and the corresponding historical prediction score;
[0017] The gating network is used to determine whether the next character of each character is in the preset character set. If the next character is not in the preset character set, the historical prediction score of the corresponding character is corrected to obtain a corrected score.
[0018] Optionally, predicting the next potentially occurring character after the current character by the pattern inference model to obtain a plurality of current predicted characters, and outputting the plurality of current predicted characters, comprises:
[0019] Predicting the next character that may appear after the current character and the corresponding prediction score, obtaining multiple current predicted characters and the current prediction scores corresponding to the current predicted characters; the current predicted character is in the preset character set;
[0020] The plurality of currently predicted characters are sorted based on the current prediction scores in descending order to obtain sorted characters, and the sorted characters are output.
[0021] Optionally, the step of obtaining the characters input by the current user when writing a markup language document, before obtaining the current characters, further includes:
[0022] Setting a historical prediction data matching switch and controlling the turning on or off of the historical prediction data matching switch;
[0023] Accordingly, the step of taking the target character as a new current character and triggering the step of inputting the current character into the trained pattern inference model until receiving a writing termination instruction includes:
[0024] Obtaining the on state of the historical prediction data matching switch;
[0025] If the on state of the historical prediction data matching switch is off, the target character is used as a new current character, and the step of inputting the current character into the trained pattern inference model is triggered until a writing termination instruction is received;
[0026] If the historical prediction data matching switch is turned on, the current character is concatenated with the target character to obtain a concatenated character;
[0027] The concatenated character is input as a new current character into the trained pattern inference model to predict the next potential character after the current character until a writing termination instruction is received.
[0028] Optionally, the markup language document writing method further includes:
[0029] The pattern inference model is deployed on a preset model deployment platform, and a preset API interface is called using a code development tool to enable the pattern inference function of the pattern inference model.
[0030] In a second aspect, the present application discloses a markup language document writing device, comprising:
[0031] The character acquisition module is used to acquire the characters input by the current user when writing a markup language document, and obtain the current character;
[0032] A character prediction module, configured to input the current character into a trained pattern inference model, to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and to output the multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning a language model based on an attention mechanism based on a markup language document dataset;
[0033] A document writing module is used to, when a selection instruction for a target character among the multiple currently predicted characters is obtained, use the target character as a new current character and trigger the step of inputting the current character into the trained pattern inference model until a writing termination instruction is received to complete the writing of the markup language document.
[0034] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the processor implements the aforementioned markup language document writing method when executing a computer program stored in the memory.
[0035] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned markup language document writing method is implemented.
[0036] It can be seen that the present application first obtains the characters input by the current user when writing a markup language document to obtain the current character; the current character is input into the trained pattern inference model to predict the next character that may appear after the current character to obtain multiple current predicted characters, and outputs multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset; when it is monitored that the user selects the target character from the multiple current predicted characters, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered, until the writing termination instruction is received to complete the writing of the markup language document. In the process of writing a markup language document, the present application obtains the characters input by the user in real time, and inputs the current character into the pattern inference model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset, so as to predict all the characters that may appear next, and after monitoring that the user selects the target character from multiple predicted characters, continue to use the pattern inference model to predict new characters until the writing termination instruction is received, thereby completing the writing of the markup language document. It can be seen that when performing character prediction, the present application uses the language model obtained after training to make predictions. Compared with the traditional markup language document writing method based on automaton theory (ie, SOA), the present application uses the attention mechanism to automatically learn the association relationship between characters in different markup language documents in advance, thereby realizing the mining of the internal logical relationship of the markup language, improving the efficiency and accuracy of the markup language pattern inference, and thus improving the efficiency of markup language document writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] 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 only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0038] Figure 1 A flow chart of a method for writing a markup language document disclosed in this application;
[0039] Figure 2 A flowchart of a specific markup language document writing method disclosed in this application;
[0040] Figure 3 A schematic diagram of the structure of a markup language document writing device disclosed in this application;
[0041] Figure 4 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0042] 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 only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] The present application embodiment discloses a method for writing a markup language document. Figure 1 As shown, the method includes:
[0044] Step S11: Acquire the characters input by the current user when writing a markup language document to obtain the current characters.
[0045] In this embodiment, the characters input by the current user in the process of writing a markup language document are first obtained to obtain the current characters. The markup language document includes but is not limited to XML (Extensible Markup Language, Extensible Markup Language) documents, HTML (Hyper Text Markup Language) documents, JSON (JavaScript Object Notation) (a lightweight data exchange format) documents, etc.
[0046] Step S12: Input the current character into the trained pattern inference model to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and output the multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset.
[0047] In this embodiment, after obtaining the characters input by the current user when writing a markup language document, the current characters are further input into a pattern inference model obtained by fine-tuning a language model based on an attention mechanism (i.e., Large Language Model, LLM) based on a markup language document dataset, so as to predict the next potential (possible) character after the current character through the pattern inference model, obtain multiple prediction results (i.e., the current predicted characters), and then output the predicted multiple current predicted characters. Among them, the language model includes but is not limited to LLaMA (Large Language Model Meta AI, a large-scale language model), Qwen (a pre-trained model based on the Transformer architecture), ChatGLM (a generative language model) and other models.
[0048] Specifically, the acquisition process of the pattern inference model includes: collecting different types of historical markup language documents to obtain a markup language document data set; cleaning and deduplicating each character in multiple character strings in the markup language document data set to abstract multiple types of characters appearing in the markup language document data set into a character set to obtain a preset character set; using the preset character set to perform multiple rounds of fine-tuning on the language model based on the attention mechanism to obtain the pattern inference model. In this embodiment, in order to solve the problems of high complexity and low efficiency encountered by traditional markup language pattern inference methods, a language model based on the attention mechanism is adopted, and the model is fine-tuned to obtain the final model for markup language pattern inference, wherein the attention mechanism is used to automatically learn the association between input characters, and predict the probability information of the next character to appear based on the historical markup language document data. Specifically, different types of historical markup language documents can be collected to obtain a markup language document data set S. In a specific embodiment, the elements in the markup language document dataset S specifically include a1a1a2a3a2a3. It can be understood that any markup language document can be abstracted into a string of finite length composed of finite characters, and these strings all belong to the formal language space defined by the markup language document model, such as regular language or its restricted subclass. Then, all characters in the string corresponding to each markup language document in the collected markup language document dataset S are cleaned and deduplicated, so as to abstract the multiple categories (such as a total of T categories) of characters appearing in the markup language document dataset S into a character set according to the data label, and obtain a preset character set. , that is, construct a character set according to the character categories in the set S. For example, after removing duplicates from a1a1a2a3a2a3 in the markup language document dataset S, a1a2a3 is obtained, and the three types of characters appearing in S after removing duplicates are abstracted into the character set a1a2a3. It should be pointed out that any character x in any string that conforms to the given markup language document pattern definition belongs to the preset character set, that is . Further, using a preset character set Perform multiple rounds of fine-tuning on the language model based on the attention mechanism (such as the LLaMA model) to obtain a model for pattern inference. The number of rounds of fine-tuning (i.e., the number of model iterations) can be selected according to the actual application requirements, such as epochs (number of iterations) = 100. It is understandable that the language model based on the attention mechanism already has basic text learning and understanding capabilities, but in order to apply it to the field of pattern inference, it needs to be fine-tuned, specifically based on a preset character set. Fine-tune the language model to obtain a model M that can be applied to the field of pattern inference I .
[0049] It should be noted that the language model includes an activation function layer and a fully connected layer, and a gated network (GateNet) is configured before the activation function layer. The gated network is specifically used to pass the above preset character set. The output result of the language model is restricted, and the score of the output result is corrected. The activation function layer includes but is not limited to the activation function layer based on softmax.
[0050] In this embodiment, the fine-tuning process of the language model specifically includes: predicting the next character and the probability of occurrence of each character in the preset character set in turn through the fully connected layer to obtain the next character of each character and the corresponding historical prediction score; judging whether the next character of each character is in the preset character set through the gating network, if the next character is not in the preset character set, correcting the historical prediction score of the corresponding character to obtain the corrected score. That is, in the fine-tuning process of the language model, the preset character set is first predicted in turn through the fully connected layer (FC). The next potential character and the probability of the character appearing in each character are predicted to obtain the next character of each character and the corresponding historical prediction score, and then the gated network (GateNet) is used to determine whether the next character of each character is in the above preset character set. If it is not located, the historical prediction score of the corresponding character is corrected. Specifically, before the prediction probability (i.e., prediction score) is output through the activation function layer in the language model, the prediction scores of all characters are output through the fully connected layer of the last layer of the language model, which is recorded as , where the character set length is N, and logits contains T markup language document character sets and other characters used by the language model. Represents the score of the i-th character ti, and then the logits are corrected through the gating network.
[0051] Specifically, the function definition of the gating network is as follows:
[0052] ;
[0053] That is, when When ti belongs to the preset character set When the characters in , the corrected prediction score is ; When ti does not belong to the preset character set When the characters in . After modification, it does not belong to the preset character set The scores of the characters in are all negative infinity, so after passing through the activation function layer, they do not belong to the preset character set. The predicted probabilities of the characters in are all 0.
[0054] Among them, the activation function layer represents the probability value when the predicted value is ti, and the calculation formula of the activation function layer is:
[0055] .
[0056] After the language model has been fine-tuned for multiple rounds on a preset character set, if the loss value and accuracy of the model on the training set and the validation set have converged stably, the training can be stopped and saved as the optimal model M for pattern inference. I .
[0057] It should be pointed out that in the process of fine-tuning the language model, in order to improve the generalization ability of the model, the preset character set can be expanded. In addition, in order to improve the efficiency of the entire fine-tuning training, the model can also be fine-tuned using a distributed training method.
[0058] In a specific implementation, the method of predicting the next character that may appear after the current character through the pattern inference model to obtain multiple current predicted characters and outputting the multiple current predicted characters may specifically include: predicting the next character that may appear after the current character and the corresponding prediction score, obtaining multiple current predicted characters and the current prediction score corresponding to each of the current predicted characters; the current predicted character is in the preset character set; sorting the multiple current predicted characters in descending order based on the current prediction score to obtain sorted characters, and outputting the sorted characters. In this embodiment, in order to improve the efficiency and user experience of users writing markup language documents, the next character that may appear after the current character and the corresponding prediction score may be predicted first, and multiple current predicted characters and the current prediction score corresponding to each of the current predicted characters may be obtained. Then, the multiple current predicted characters may be sorted based on the current prediction score. By placing the predicted characters with higher scores in the front position and outputting them to the user's front-end interface, the characters that are most likely to appear are displayed in the front. In this way, users can select the required characters more quickly, thereby improving the writing efficiency and user experience of markup language documents. In addition, it should be noted that the current predicted character is in the preset character set. That is, when the pattern is inferred in real time, the predicted characters are all in the preset character set obtained in the training phase. In this way, it can be ensured that the prediction space of the pattern inference model belongs to the preset character space (i.e. ), thereby further improving the prediction accuracy.
[0059] In this embodiment, the markup language document writing method may further include: deploying the pattern inference model on a preset model deployment platform, and using a code development tool to call a preset API interface to enable the pattern inference function of the pattern inference model. In this embodiment, before writing a markup language document, the pattern inference model can be deployed on a preset model deployment platform, such as a server, and then a code development tool (such as vscode, Visual Studio Code, a software developer tool) is used to call a preset API interface (Application Programming Interface) in the form of a service plug-in, thereby enabling the pattern inference function of the pattern inference model and enabling the preset model deployment platform to provide a pattern inference service.
[0060] Step S13: When a selection instruction for a target character among the multiple currently predicted characters is obtained, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered until a writing termination instruction is received to complete the writing of the markup language document.
[0061] In this embodiment, after the above-mentioned multiple currently predicted characters are output to the user front-end interface, the user will require a target character according to his or her own needs. When the preset model deployment platform receives the selection instruction after the user selects the target character from the above-mentioned multiple currently predicted characters, the target character can be used as the new current character and input into the trained pattern inference model, so as to perform a new round of character prediction, thereby helping the user to perform subsequent markup language document writing work. When the writing termination instruction sent by the user is received, the pattern inference can be stopped, thereby completing the writing of the entire markup language document.
[0062] It can be seen that the embodiment of the present application first obtains the characters input by the current user when writing a markup language document to obtain the current character; the current character is input into the trained pattern inference model to predict the next character that may appear after the current character to obtain multiple current predicted characters, and outputs multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset; when it is monitored that the user selects a target character from the multiple current predicted characters, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered, until the writing termination instruction is received to complete the writing of the markup language document. In the process of writing a markup language document, the embodiment of the present application obtains the characters input by the user in real time, and inputs the current character into the pattern inference model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document data set, so as to predict all the characters that may appear next, and after monitoring that the user selects the target character from multiple predicted characters, continue to use the pattern inference model to predict new characters until the writing termination instruction is received, thereby completing the writing of the markup language document. It can be seen that when the present application predicts characters, it uses the language model obtained after training to make predictions. Compared with the traditional markup language document writing method based on automaton theory (i.e., SOA), the embodiment of the present application uses the attention mechanism to automatically learn the association relationship between characters in different markup language documents in advance, thereby realizing the mining of the internal logical relationship of the markup language, improving the efficiency and accuracy of the markup language pattern inference, and thus improving the efficiency of the markup language document writing.
[0063] The present application embodiment discloses a specific method for writing a markup language document. Figure 2 As shown, the method includes:
[0064] Step S21: Setting a historical prediction data matching switch, and controlling the turning on or off of the historical prediction data matching switch.
[0065] In this embodiment, a historical prediction data matching switch is first set, and the turning on or off of the historical prediction data matching switch is controlled.
[0066] Step S22: Acquire the characters input by the current user when writing the markup language document to obtain the current characters.
[0067] Step S23: input the current character into the trained pattern inference model to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and output the multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset.
[0068] Step S24: when a selection instruction for a target character among the multiple currently predicted characters is obtained, the on state of the historical prediction data matching switch is obtained.
[0069] In this embodiment, when a selection instruction for a target character among the multiple currently predicted characters is obtained, the current historical prediction data obtained matches the on state of the switch.
[0070] Step S25: If the on state of the historical prediction data matching switch is off, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered until a writing termination instruction is received to complete the writing of the markup language document.
[0071] In this embodiment, if the historical prediction data matching switch is in the off state, the target character selected by the user is used as the new current character, and the current character is input into the trained pattern inference model for a new round of character inference until a writing termination instruction is received, thereby completing the writing of the entire markup language document.
[0072] Step S26: If the on state of the historical prediction data matching switch is on, the current character is concatenated with the target character to obtain a concatenated character.
[0073] In this embodiment, if the historical prediction data matching switch is in an on state, the target character selected by the user is concatenated with the current character to obtain a concatenated character.
[0074] Step S27: input the concatenated character as a new current character into the trained pattern inference model to predict the next potential character after the current character, until a writing termination instruction is received to complete the writing of the markup language document.
[0075] In this embodiment, the above-mentioned concatenated characters are input as new current characters into the trained pattern inference model to predict the next potential character after the new current character, until a writing termination instruction is received, thereby completing the writing of the entire markup language document.
[0076] For more specific processing procedures of the above steps S22 and S23, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.
[0077] It can be seen that the embodiment of the present application sets a historical prediction data matching switch, and controls the opening or closing of the historical prediction data matching switch, and when the selection instruction for the target character in multiple current prediction characters is obtained, the opening state of the historical prediction data matching switch is obtained. If it is in the closed state, the target character is used as the new current character, and a new round of pattern inference is performed until the writing termination instruction is received; if it is in the open state, the initially input character is spliced with the target character, and the spliced character is input as the new current character into the trained pattern inference model to predict the next potential character after the current character, until the writing termination instruction is received. By setting the historical prediction data matching switch, it is possible to provide users with personalized prediction result selection schemes, so that users can choose the desired pattern inference method according to their needs, thereby realizing a more flexible markup language document writing method and improving user experience. At the same time, this solution solves the problems of high complexity and low efficiency of traditional pattern inference methods, and can be well applied in the field of markup language pattern learning, including automatic character matching recommendation, markup language document validity verification, markup language document semantic analysis, and other fields. In addition, this solution also provides a certain reference for the implementation of language models in the field of computer formal languages.
[0078] For example, the characters entered by the current user when writing a markup language document are obtained, and the current character start is obtained, and then it is input into the trained pattern inference model to infer and predict the next character with the highest probability of appearing. The specific process is as follows: the first step is to input the current character start into the pattern inference model M I , and initialize the preset historical string History0 to an empty string; the second step is to infer the model M I Reasoning based on start, predicting the language space where the pattern is located (i.e. the preset character space ), the process can first obtain the scores of each prediction result, then pass through the gating network and the preset character space to obtain the prediction score in the pattern language space, and finally pass through the activation function layer to obtain the final prediction result. The prediction result can be a dictionary, where the key is the predicted character and the value is the predicted probability of the character, recorded as , indicating that it contains k possible prediction results; the third step is to obtain the predi selected by the user from the prediction results according to his own needs, and update the historical string History0 to obtain the updated string History1=History0+predi, where + represents the meaning of string concatenation, such as s1="abc", s2="ef", then s3=s1+s2="abcef"; the fourth step is to obtain the on state of the historical prediction data matching switch, if it is on, update start to History0 string, otherwise update start to predi, and return to the second step to continue to execute the prediction until the writing termination instruction is received, and finally output the complete prediction result History1 to complete the markup language document writing.
[0079] Correspondingly, the present application embodiment also discloses a markup language document writing device, see Figure 3 As shown, the device comprises:
[0080] The character acquisition module 11 is used to acquire the characters input by the current user when writing a markup language document, and obtain the current character;
[0081] The character prediction module 12 is used to input the current character into the trained pattern inference model, so as to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and output the multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset;
[0082] The document writing module 13 is used to, when a selection instruction for a target character among the multiple currently predicted characters is obtained, use the target character as a new current character and trigger the step of inputting the current character into the trained pattern inference model until a writing termination instruction is received to complete the writing of the markup language document.
[0083] Among them, the specific working processes of the above-mentioned modules can refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0084] It can be seen that in the embodiment of the present application, the characters input by the current user when writing a markup language document are first obtained to obtain the current character; the current character is input into the trained pattern inference model to predict the next character that may appear after the current character to obtain multiple current predicted characters, and multiple current predicted characters are output; the pattern inference model is a model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document dataset; when it is monitored that the user selects a target character from the multiple current predicted characters, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered, until the writing termination instruction is received to complete the writing of the markup language document. In the process of writing a markup language document, the embodiment of the present application obtains the characters input by the user in real time, and inputs the current character into the pattern inference model obtained by fine-tuning the language model based on the attention mechanism based on the markup language document data set, so as to predict all the characters that may appear next, and after monitoring that the user selects the target character from multiple predicted characters, continue to use the pattern inference model to predict new characters until the writing termination instruction is received, thereby completing the writing of the markup language document. It can be seen that when the present application predicts characters, it uses the language model obtained after training to make predictions. Compared with the traditional markup language document writing method based on automaton theory (i.e., SOA), the embodiment of the present application uses the attention mechanism to automatically learn the association relationship between characters in different markup language documents in advance, thereby realizing the mining of the internal logical relationship of the markup language, improving the efficiency and accuracy of the markup language pattern inference, and thus improving the efficiency of the markup language document writing.
[0085] In some specific embodiments, the markup language document writing device may further include:
[0086] A document collection unit, used for collecting different types of historical markup language documents to obtain a markup language document data set;
[0087] A data processing unit, configured to perform cleaning and deduplication processing on each character in a plurality of character strings in the markup language document data set, so as to abstract the plurality of types of characters appearing in the markup language document data set into a character set, and obtain a preset character set;
[0088] A model fine-tuning unit is used to perform multiple rounds of fine-tuning on the language model based on the attention mechanism using the preset character set to obtain the pattern inference model.
[0089] In some specific embodiments, the language model includes an activation function layer and a fully connected layer, and a gating network is configured before the activation function layer, and the gating network is used to limit the output result of the language model through the preset character set and correct the score of the output result.
[0090] In some specific embodiments, the markup language document writing device may further include:
[0091] A first prediction unit, configured to predict the next character and the probability of occurrence of each character in the preset character set in sequence through the fully connected layer, to obtain the next character of each character and the corresponding historical prediction score;
[0092] A judging unit, configured to judge, through the gating network, whether the next character of each character is in the preset character set;
[0093] The score correction unit is used to correct the historical prediction score of the corresponding character to obtain a corrected score if the next character is not in the preset character set.
[0094] In some specific embodiments, the character prediction module 12 may specifically include:
[0095] A second prediction unit is used to predict the next character that may appear after the current character and the corresponding prediction score, and obtain multiple current predicted characters and the current prediction scores corresponding to the current predicted characters; the current predicted character is in the preset character set;
[0096] The sorting and outputting unit is used to sort the multiple currently predicted characters in descending order based on the current prediction scores, obtain sorted characters, and output the sorted characters.
[0097] In some specific embodiments, before the character acquisition module 11, the following may also be included:
[0098] A setting and control unit, used to set a historical prediction data matching switch and control the turning on or off of the historical prediction data matching switch;
[0099] Accordingly, the document writing module 13 may specifically include:
[0100] A state acquisition unit, used to acquire the on state of the historical prediction data matching switch;
[0101] a trigger unit, configured to use the target character as a new current character and trigger the step of inputting the current character into the trained pattern inference model if the on state of the historical prediction data matching switch is off, until a writing termination instruction is received;
[0102] A character splicing unit, configured to splice the current character with the target character to obtain a spliced character if the historical prediction data matching switch is turned on;
[0103] The third prediction unit is used to input the concatenated character as a new current character into the trained pattern inference model to predict the next potential character after the current character until a writing termination instruction is received.
[0104] In some specific embodiments, the markup language document writing device may further include:
[0105] A deployment unit, used to deploy the pattern inference model on a preset model deployment platform;
[0106] The interface calling unit is used to call a preset API interface using a code development tool to enable the mode inference function of the mode inference model.
[0107] Furthermore, the present application also discloses an electronic device. Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0108] Figure 4 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the markup language document writing method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0109] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0110] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0111] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the markup language document writing method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0112] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned disclosed method for writing a markup language document. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, and no further description will be given here.
[0113] Furthermore, an embodiment of the present application also discloses a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the markup language document writing method disclosed above.
[0114] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0115] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0116] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0117] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0118] The above is a detailed introduction to a markup language document writing method, device, equipment and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for writing a markup language document, characterized in that: include: Get the characters entered by the current user when writing a markup language document, and get the current character; Inputting the current character into a trained pattern inference model to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and outputting the multiple current predicted characters; The pattern inference model is a model obtained by fine-tuning a language model based on an attention mechanism based on a markup language document dataset; When a selection instruction for a target character among the multiple currently predicted characters is obtained, the target character is used as the new current character, and the step of inputting the current character into the trained pattern inference model is triggered until a writing termination instruction is received to complete the writing of the markup language document.
2. The method for writing a markup language document according to claim 1, characterized in that: Also includes: Collect different types of historical markup language documents to obtain a markup language document dataset; Performing cleaning and deduplication processing on each character in a plurality of character strings in the markup language document data set, so as to abstract a plurality of types of characters appearing in the markup language document data set into a character set, and obtain a preset character set; The preset character set is used to perform multiple rounds of fine-tuning on the language model based on the attention mechanism to obtain the pattern inference model.
3. The method for writing a markup language document according to claim 2, characterized in that: The language model includes an activation function layer and a fully connected layer, and a gating network is configured before the activation function layer. The gating network is used to limit the output result of the language model through the preset character set and correct the score of the output result.
4. The method for writing a markup language document according to claim 3, characterized in that: The fine-tuning process of the language model also includes: Predicting the next character and the probability of occurrence of each character in the preset character set in sequence through the fully connected layer to obtain the next character of each character and the corresponding historical prediction score; The gating network is used to determine whether the next character of each character is in the preset character set. If the next character is not in the preset character set, the historical prediction score of the corresponding character is corrected to obtain a corrected score.
5. The method for writing a markup language document according to claim 4, characterized in that: The method of predicting the next potential character after the current character by the pattern inference model to obtain a plurality of current predicted characters, and outputting the plurality of current predicted characters, comprises: Predicting the next character that may appear after the current character and the corresponding prediction score, obtaining multiple current predicted characters and the current prediction scores corresponding to the current predicted characters; the current predicted character is in the preset character set; The plurality of currently predicted characters are sorted based on the current prediction scores in descending order to obtain sorted characters, and the sorted characters are output.
6. The method for writing a markup language document according to claim 1, characterized in that: The step of obtaining the characters input by the current user when writing a markup language document, before obtaining the current characters, further includes: Setting a historical prediction data matching switch and controlling the turning on or off of the historical prediction data matching switch; Accordingly, the step of taking the target character as a new current character and triggering the step of inputting the current character into the trained pattern inference model until receiving a writing termination instruction includes: Obtaining the on state of the historical prediction data matching switch; If the on state of the historical prediction data matching switch is off, the target character is used as a new current character, and the step of inputting the current character into the trained pattern inference model is triggered until a writing termination instruction is received; If the historical prediction data matching switch is turned on, the current character is concatenated with the target character to obtain a concatenated character; The concatenated character is input as a new current character into the trained pattern inference model to predict the next potential character after the current character until a writing termination instruction is received.
7. The method for writing a markup language document according to any one of claims 1 to 6, characterized in that: Also includes: The pattern inference model is deployed on a preset model deployment platform, and a preset API interface is called using a code development tool to enable the pattern inference function of the pattern inference model.
8. A markup language document writing device, characterized in that: include: The character acquisition module is used to acquire the characters input by the current user when writing a markup language document, and obtain the current character; A character prediction module, configured to input the current character into a trained pattern inference model, to predict the next potential character after the current character through the pattern inference model to obtain multiple current predicted characters, and to output the multiple current predicted characters; the pattern inference model is a model obtained by fine-tuning a language model based on an attention mechanism based on a markup language document dataset; A document writing module is used to, when a selection instruction for a target character among the multiple currently predicted characters is obtained, use the target character as a new current character and trigger the step of inputting the current character into the trained pattern inference model until a writing termination instruction is received to complete the writing of the markup language document.
9. An electronic device, characterized in that: It comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the markup language document writing method as claimed in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the markup language document writing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Text prediction based on multiple language models
CN105229575A
Method and device for generating front-end code generation model
CN111562915A
Markup language model training method and announcement entity recognition method
CN116629263A