Model training method and related equipment for artificial intelligence text analysis
Through the parameter optimization and inference technology of the dual dictionary model, the problem of insufficient accuracy of the Chinese text analysis model in specific fields is solved, the syntactic and semantic understanding capabilities of text analysis are improved, and the output accuracy of the model is improved.
Patent Information
- Application Number
- CN202110667894.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-04-30
- Filing Date
- 2021-06-16
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-06-16
AI Technical Summary
Chinese text analysis models in certain fields are difficult to obtain annotated data sets and ignore the syntactic and semantic structure information of text data, resulting in insufficient accuracy of model output.
The dual dictionary model is used to train the artificial intelligence text analysis model. By obtaining the pre-built initial word dictionary, super pattern dictionary and initial parameter system, the parameters are updated and parameter inference is performed. The model is optimized by combining the data enhancement algorithm and the expectation maximization algorithm. Improve the accuracy of text segmentation and semantic understanding.
It improves the output accuracy of the Chinese text analysis model, especially in text analysis in specific fields, enhances the understanding of syntactic and semantic structures, and improves the overall performance of the model.
Smart Images

Figure CN113269272B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text analysis, and in particular to a model training method and related equipment for artificial intelligence text analysis. Background Technology
[0002] Chinese natural language understanding is an important research problem and direction in artificial intelligence. In specific domains of Chinese text analysis, such as classical Chinese, electronic medical records, prose, and poetry, the analysis results often neglect the syntactic and semantic structural information of the text data because labeled datasets are usually difficult to obtain. Furthermore, the input data of text analysis models are mostly prior values, which cannot guarantee the accuracy of the Chinese text analysis results output by the model. Summary of the Invention
[0003] In view of the above, it is necessary to provide a model training method and related equipment for artificial intelligence text analysis, which can assist in optimizing the text analysis model and improve the accuracy of the text analysis results output by the model.
[0004] The model training method for artificial intelligence text analysis includes: acquiring a pre-built dual-dictionary model, wherein the dual-dictionary model includes an initial word dictionary of the target text. Initial supermode dictionary and the initial parameter system (γ, θ) w|c Based on the initial parameter system (γ, θ) w|c ), determine the parameter system η for updating the dual-dictionary model, where η = (γ, θ) w θ c|w ); Perform parameter inference on the updated parameter system η; Based on the results obtained from the parameter inference, perform posterior analysis on the dual-dictionary model.
[0005] Optionally, the method further includes: obtaining the unsegmented text segment T of the target text based on the dual-dictionary model, determining the hidden state H of the unsegmented text segment T; and setting missing data. Among them, set For the B unsegmented text fragments T in the target text b The set of H, where b and B represent positive integers and 1 ≤ b ≤ B; T Representing a collection The hidden state of the unsegmented text segment T is determined; based on the results inferred from the parameters, the text segmentation result of the unsegmented text segment T is obtained, and the text segmentation result includes the optimal hidden state. Based on the text segmentation results, semantic understanding and relation extraction are performed on the unsegmented text fragment T.
[0006] Optionally, the parameter inference of the updated parameter system η includes: using a data augmentation algorithm to sample the posterior distribution of the updated parameter system η to obtain the target posterior distribution of the updated parameter system η, wherein the target posterior distribution is: in, This represents the updated sampling space obtained by expanding the sampling space η; wherein, posterior distribution sampling of the updated parameter system η includes: sampling from the conditional distribution. and conditional distribution Iterative sampling is performed until the target posterior distribution is obtained, wherein... Let H represent the set of all hidden states H of an unsegmented text fragment T.
[0007] Optionally, the dual-dictionary model further includes: a dictionary consisting of all characters 'a' in the target text. l The character set 1≤l≤L; the initial word dictionary in, 1≤n≤N, i, w represents a positive integer. n It is the set Words composed of characters in the text The set of word categories in the target text 1≤k≤K, where c k c0 represents the category of the named entity, where c0 represents the category of the background word that distinguishes it from the named entity. The initial super-pattern dictionary in 1≤m≤M, p m Indicates the use of the radical t j The supermode formed by the symbol j represents a positive integer; e represents a terminator; the initial parameter system (γ, θ) w|c ),in γ represents the sampling probability distribution of the supermodel, where γ p This represents the sampling probability of the supermode p; Let represent a set of sampling probability distributions, where Let θ represent the sampling probability distribution of words given word category c. w|c This represents the conditional sampling probability of word w given word category c; the initial parameter system (γ, θ) is used to represent this probability. w|c Determining the updated parameter system η of the dual-dictionary model includes: setting the updated parameter system η = (γ, θ) wθ c|w The prior distribution of ) and the updated parameter system (γ, θ) w θ c|w The posterior distribution of ), where, This represents the sampling probability distribution of word w. Represents a set of sampling probability distributions. θ represents the conditional distribution of word categories given a word w. c|w This represents the sampling probability of word category c given word w.
[0008] Optionally, the parameter inference of the updated parameter system η includes: maximizing the posterior distribution of the updated parameter system η using the expectation-maximization algorithm, wherein the expectation-maximization algorithm includes E-steps and M-steps, and the expectation-maximization algorithm obtains the point estimation result of the updated parameter system η through iterative convergence in the E-steps and the M-steps.
[0009] Optionally, the method further includes: obtaining the unsegmented text segment T of the target text based on the dual-dictionary model, determining the hidden state H of the unsegmented text segment T; and setting missing data. Among them, set For the B unsegmented text fragments T in the target text b The set of H, where b and B represent positive integers and 1 ≤ b ≤ B; T Representing a collection The hidden state of the unsegmented text fragment T; the E-step includes: calculating the Q function: Wherein, T represents the unsegmented text segment of the target text obtained based on the dual-dictionary model, and the hidden state of the unsegmented text segment T is the hidden state H; Indicates missing data, set For the B unsegmented text fragments T in the target text b The set of H, where b and B represent positive integers, 1 ≤ b ≤ B; T Representing a collection The hidden state of the unsegmented text fragment T in the text; η old This represents the parameters obtained after the previous iteration. This represents the number of times supermode p appears in the hidden state H. Let H represent the set of all hidden states H of an unsegmented text fragment T. The M-step represents the number of occurrences of the category word pair (c, w) in the hidden state H; the M-step includes: setting constraints. θ c (γ) is a fixed value; based on the aforementioned constraints, the expected condition maximization algorithm is used to calculate... The maximum value of .
[0010] Optionally, the posterior analysis of the dual-dictionary model based on the results obtained from the inference of the parameters includes: constructing the saliency scores of the superpattern p, word w, and category word pair (c, w); and constructing the posterior classification distribution of word w.
[0011] Optionally, obtaining the unsegmented text fragment T of the target text and determining the hidden state H of the unsegmented text T includes: from the initial super-pattern dictionary Extract a superpattern p from the superpattern to obtain a superpattern sequence P; extract words w from the superpattern sequence P to obtain a word sequence W. i and the word sequence W i The sequence W, where, Based on the sequence W, an unsegmented text fragment T is obtained, and the hidden state H of the unsegmented text fragment T is determined.
[0012] The computer-readable storage medium stores at least one instruction, which, when executed by a processor, implements the model training method for artificial intelligence text analysis.
[0013] The computer device includes a memory and at least one processor, the memory storing at least one instruction which, when executed by the at least one processor, implements the model training method for artificial intelligence text analysis.
[0014] Compared to existing technologies, the model training method and related equipment for artificial intelligence text analysis described above can optimize the dual-dictionary model and improve the accuracy of the text analysis results output by the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0016] Figure 1 This is a flowchart of a model training method for artificial intelligence text analysis provided in an embodiment of this application.
[0017] Figure 2 This is an architectural diagram of the computer device provided in the embodiments of this application.
[0018] Figure 3A It is an example diagram provided by an embodiment of the present application for segmenting words in a target text.
[0019] Figure 3B It is an example diagram provided by an embodiment of the present application for distinguishing named entities in a target text with different marks.
[0020] Figure 3C It is an example diagram provided by an embodiment of the present application for a superpattern whose length does not exceed the maximum length threshold of the morphemes in the superpattern and its frequency.
[0021] Figure 3D It is an example diagram provided by an embodiment of the present application for a superpattern whose frequency is lower than the lowest frequency threshold of the occurrence of the superpattern.
[0022] Figure 3E It is an example diagram provided by an embodiment of the present application for a superpattern whose frequency is not lower than the lowest frequency threshold of the occurrence of the superpattern.
[0023] Figure 4 It is an example diagram provided by an embodiment of the present application for the generation probability of the hidden state of the unsegmented text fragment "趙普為太師".
[0024] Figure 5 It is an example diagram provided by an embodiment of the present application for the conditional probability of the hidden state of the unsegmented text fragment "趙普為太師".
[0025] Figure 6 It is provided by an embodiment of the present application according to Figure 5 The parameters in are used to calculate n p (T) and n cw (T) example diagrams.
[0026] Main component symbol description
[0027] Computer devices 3 Model training system 30 Memory 31 processor 32
[0028] The following specific embodiments will further illustrate the present application in combination with the above-mentioned drawings. Specific embodiments
[0029] In order to be able to more clearly understand the above-mentioned objects, features and advantages of the present application, the present application will be described in detail below in combination with the drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments may be combined with each other.
[0030] Numerous specific details are set forth in the following description to provide a thorough understanding of this application. The described embodiments are merely some, not all, of the embodiments described herein. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0032] See Figure 1 The diagram shown is a flowchart of a model training method for artificial intelligence text analysis provided in an embodiment of this application.
[0033] In this embodiment, the model training method for artificial intelligence text analysis can be applied to a computer device (e.g., Figure 2 In the computer device 3) shown, text analysis is performed. Specifically, for a computer device that needs to perform text analysis, the text analysis function provided by the method of this application can be directly integrated into the computer device, or it can run on the computer device in the form of a software development kit (SDK).
[0034] like Figure 1 As shown, the model training method for artificial intelligence text analysis specifically includes the following steps. Depending on different needs, the order of the steps in this flowchart can be changed, and some steps can be omitted.
[0035] Step S1: The computer device acquires a pre-built dual-dictionary model, which includes an initial word dictionary of the target text. Initial Meta-pattern dictionary and the initial parameter system (γ, θ) w|c ).
[0036] In one embodiment, the construction of the dual-dictionary model by the computer device includes: acquiring target text; constructing a dual-dictionary model of the target text, the dual-dictionary model including an initial word dictionary. With the initial super-pattern dictionary and the initial parameter system (γ, θ) w|c ).
[0037] In one embodiment, a computer device may receive target text input by a user; the target text may be Chinese text in a specific field, such as classical Chinese, medical electronic records, prose, poetry, etc.
[0038] In one embodiment, the Bayesian logic includes Bayes' theorem and Bayesian statistics and is a probability theory system.
[0039] In one embodiment, the computer device performs text segmentation on the characters in the target text to obtain each character a in the target text l and obtains a character set composed of all characters in the target text where 1 ≤ l ≤ L.
[0040] In one embodiment, the computer device sets a word set according to the prior information of the words in the target text The prior information of the words in the target text may be a known word library pre-stored in the computer device. The known word library contains the words in the target text, and the words include character sequences composed of the characters in For example, Wang Anshi, wei, Canzhi Zhengshi, Zhao Pu, wei, Taishi, etc. It should be noted that the above "Zhao", "wei", and "shi" are traditional Chinese characters, which are used to illustrate the analysis when the target text includes classical Chinese.
[0041] In one embodiment, the computer device obtains the word set according to a preset first rule The preset first rule includes: setting as the maximum length threshold of the characters in a word, as the minimum frequency threshold of the word appearance, using the TopWORDS algorithm to perform text mining on the target text, and extracting the words in the target text whose length does not exceed and whose frequency is not lower than to obtain the word set The TopWORDS algorithm is an unsupervised Chinese text analysis tool. It can achieve efficient word discovery while performing text segmentation, but it has certain limitations: (1) only uses character sequence counting information during the learning process; (2) cannot automatically distinguish word categories; (3) misses low-frequency words. For example, setting then after using the TopWORDS algorithm to extract the words in the target text "AABBABCCABCD", the obtained word set is {B(4), C(3), AB(3), BC(2), ABC(2)}, where the numbers in the brackets represent the appearance frequency of the word.
[0042] In one embodiment, the computer device sets the set of word categories in the target text as follows based on prior information about word categories in the target text. 1≤k≤K, where each word in the target text belongs to a specific word category, which includes the category of named entities and the category of background words that are distinct from the category of named entities, where c k The category of the named entity is represented by c0, where c0 represents the category of the background word that distinguishes it from the named entity. The prior information about the word categories in the target text can be a known word category library pre-stored in a computer device, containing all word categories in the target text. The named entities include personal names, official titles, place names, and all other entities identified by names, such as Zhao Pu, Wang Anshi, Grand Tutor, and Councilor of State Affairs. The background words include all words that distinguish them from the named entities, such as Zhao, Pu, Wei, Tai, Shi, Wei, Wang, An, Shi, Wei, Can, Zhi, Zheng, Shi, etc.
[0043] In one embodiment, the computer device obtains the word set according to a preset second rule. The preset second rule includes: using a pre-trained weak classifier to classify the target text into characters whose length does not exceed a certain threshold. And the frequency is not lower than the stated Extract words; determine the prior classification probability π. c|w Where c represents the word category in the target text, w represents the word extracted by the weak classifier, and π c|w Let π represent the prior classification probability of word category c given word w, where π is the prior classification probability. c|w This represents a conditional probability (e.g., the probability that the word "Zhao Pu" is a "person's name"); and the prior classification probability π among the words extracted by the weak classifier. c|w Words that exceed a preset classification threshold (e.g., 0.5) are used to obtain the word set. The pre-trained weak classifier is a word classifier (or text classifier), which can be obtained by training a model using words from a known vocabulary stored in a computer device. The classification accuracy of the weak classifier is between 60% and 80%.
[0044] In one embodiment, the computer device integrates the character set. Word collection Word collection Word collection Obtain the initial word dictionary The initial word dictionary in, 1≤n≤N, i, represents a positive integer; w n is a word composed of characters in the set above.
[0045] In one embodiment, the initial super-pattern dictionary where e represents the terminator, 1 ≤ m ≤ M, p m represents a super-pattern composed of tokens t j “|” represents the separator, and the tokens where j represents a positive integer. For example, the token t j can be a person's name (Name, N), an official position (Office title, O), a background word (Background, B), etc. characters in the set characters in the set m Then the super-pattern p
[0046] In one embodiment, the computer device sets the super-pattern set according to the prior information of the super-patterns in the target text The prior information of the super-patterns in the target text can be a known super-pattern library pre-stored in the computer device, and the known super-pattern library contains all the super-patterns in the target text.
[0047] In one embodiment, the computer device obtains the super-pattern set according to a preset third rule The preset third rule includes: for example Figures 3A to 3E As shown, based on the initial word dictionary the words in the target text are recognized and segmented, and different tags are used to distinguish the words in the target text whose confidence levels meet the named entities (for example Figure 3B in the set, bold and italic are used to distinguish person's names and official positions: N, O, and different colors can also be used for distinction), where is a preset confidence threshold (for example, 0.85); set as the maximum length threshold of the tokens in the super-pattern (for example, 3), is the lowest frequency threshold for the appearance of the super pattern (e.g., 2), and scans in sequence (e.g., using an optical character recognition algorithm or an image recognition algorithm to sequentially scan and recognize the characters with the same marked features) and extracts the target text with a length not exceeding the and a frequency not lower than the of adjacent marked named entities (e.g., Figure 3D in the super pattern "Wang N Wei" has a frequency of 1, which is lower than the lowest frequency threshold 2 for the appearance of the super pattern, and it is not extracted; for example, Figure 3E in the super pattern "N Wei O" has a frequency of 2, which is not lower than the lowest frequency threshold 2 for the appearance of the super pattern, and it is extracted), and integrates the super patterns extracted in this process to obtain the super pattern set
[0048] In one embodiment, the computer device integrates the terminator e, the set of word categories the super pattern set the super pattern set to obtain the initial super pattern dictionary the initial super pattern dictionary
[0049] In one embodiment, the construction of the initial parameter system (γ, θ w|c ) by the computer device includes: obtaining the count word frequency θ of the words in the initial word dictionary w in the target text; according to the count word frequency θ w and the prior classification probability π c|w , determining the initial value of the sampling probability distribution of the words in the initial word dictionary given the word category c, where represents the sampling probability distribution of the words given the word category c, θ w|c ∝θ w ·π c|w , θ w|c represents the sampling probability of the word w given the word category c (e.g., the sampling probability of the word "Zhao Pu" given the word category "person name"); the sampling probability of the super patterns in in the target text is obtained to obtain the initial value γ of the sampling probability distribution of the super patterns in γ p represents the sampling probability of the super pattern p (e.g., the sampling probability of the super pattern "N Wei O" is 0.01).
[0050] Step S2, the computer device, based on the initial parameter system (γ, θ) w|c ), determine the parameter system η for updating the dual-dictionary model, where η = (γ, θ) w θ c|w ).
[0051] In one embodiment, the computer device is based on the initial parameter system (γ, θ) w|c ) Calculate the updated parameter system (γ, θ) w θ c|w ); Set the updated parameter system (γ, θ) w θ c|w The prior distribution of γ, θ, and the updated parameter system (γ, θ) w θ c|w The posterior distribution of .
[0052] In one embodiment, the initial parameter system (γ, θ) is used. w|c ) Calculate the updated parameter system (γ, θ) w θ c|w This includes: a category of words and a super mode definition Let be the number of times word category c appears in the supermodel p. Then, in the dual-dictionary model, the frequency of word category c is: in, The frequency of the word 'w' is Given word w, the frequency of word category c is make To indicate the distribution of words, let Let represent the sampling probability distribution of a set of word categories, where θ represents the conditional distribution of word categories given a word w. c|w This represents the sampling probability of word category c given word w.
[0053] It should be noted that when the updated parameter system (γ, θ) w θ c|w (Supports the following conditions:) At this time, the two parameter systems can be converted to each other, that is, a one-to-one mapping exists. In one embodiment, the computer device can adjust the parameter system (γ, θ) according to the updated parameter system. w θ c|w ),calculate The initial parameter system (γ, θ) is obtained. w|c ).
[0054] In one embodiment, the setting of the updated parameter system (γ, θ) w θ c|w The prior distribution of ) and the updated parameter system (γ, θ) w θ c|w The posterior distribution includes: the computer device performs Bayesian modeling on the dual-lecture model, and sets the updated parameter system (γ, θ) according to the Dirichlet distribution Dir(α, F). w θ c|w The prior distribution of ), the expression for the Dirichlet distribution is: Where α > 0 represents intensity, F = (F1, ..., F2) d ) represents the base distribution, and F is also the mode of the Dir(α, F) distribution. This represents an indicator function that, when the condition within the curly braces "{}" is satisfied, The value is 1, otherwise The value is 0. In the updated parameter system (γ, θ) w θ c|w Under the given condition, the prior distribution of the parameters is set as γ ~ Dir(α). γ ,π γ ), θ w ~Dir(α) w ,π w ), θ ·|w ~Dir(α) ·|w ,π ·|w According to the definition of Dir(α, F), a computer device utilizes (π) γ ,π w ,π ·|w ) represents the updated parameter system parameters (γ, θ) w θ c|w The prior tendency value of (α) γ α w α ·|w ) represents the strength of prior information. Let π w For a uniform distribution, π ·|w The prior classification distribution of words is given, and this prior classification distribution is predefined in the computer device. The constraints are based on the updated parameter system. set up The intensity hyperparameter is set as (α) γα w α ·|w )=(αN, αN, α), get (γ, θ w θ c|w The prior distribution of ) set up Given B unsegmented text fragments in the target text, then the updated parameter system (γ, θ) w θ c|w The posterior distribution of ) is:
[0055] Step S3: Based on the dual-dictionary model, the computer device obtains the unsegmented text segment T of the target text, determines the hidden state H of the unsegmented text segment T, and sets the missing data.
[0056] In one embodiment, the set For the B unsegmented text fragments T in the target text b The set of integers, where b and B represent positive integers and 1 ≤ b ≤ B; Represents a set Unsegmented text fragment T b The hidden state. It should be noted that when the unsegmented text fragment... At that time, the hidden state H of the unsegmented text fragment T can be represented as the hidden state H. T .
[0057] In one embodiment, the computer device obtains the initial hyperpattern dictionary. Extract a superpattern p from the superpattern to obtain a superpattern sequence P; extract words w from the superpattern sequence P to obtain a word sequence W. i and the word sequence W i The sequence W, where, Based on the sequence W, an unsegmented text fragment T is obtained, and the hidden state H of the unsegmented text fragment T is determined.
[0058] In one embodiment, the initial superpattern dictionary Extracting supermodes to obtain a supermode sequence P includes: a computer device sampling each supermode according to its sampling probability γ. p From the initial superpattern dictionary Randomly select supermode P with replacement i Continue until the terminator e is extracted; set the supermode sequence P = P1|P2|...|P n |e, where supermode
[0059] In one embodiment, the computer device calculates the sampling probability of P. Where γ e This represents the sampling probability of the terminator 'e'.
[0060] In one embodiment, the word sequence W is obtained by extracting word w based on the superpattern sequence P. i and the word sequence W i The sequence W includes: a computer device determining the supermode P i Each symbol t ij Category; when the symbol At that time, let w ij =t ij ; when the radical At that time, based on the sampling probability From the initial word dictionary Extracting words from w ij ; Obtain the sequence and the sequence W = W1|W2|…|W n .
[0061] In one embodiment, the computer device calculates W given the case of P. i Sampling probability in, This represents an indicator function that, when the condition within the curly braces "{}" is satisfied, The value is 1, otherwise The value is 0. And when hour, when hour, express Time ij The sampling probability when w ij =t ij At that time, w ij The sampling probability is 1; when w ij ≠t ij At that time, w ij The sampling probability is 0; Calculate the sampling probability of W given P.
[0062] For example, suppose we are given a dual-dictionary model as shown in Table 1 below.
[0063]
[0064] Table 1
[0065] Then, for example Figure 4 As shown, the extracted super-pattern sequence P3: N is O|e, where the super-pattern "N is O" contains 3 morphemes, namely "N", "is", and "O". The morpheme "N" belongs to the set of word categories According to θ w|(c=N) The corresponding extracted word is "Zhao Pu"; the morpheme "is" belongs to the character set The corresponding extracted word is "is"; the morpheme "O" belongs to the set of word categories According to θ w|(c=O) The corresponding extracted word is "Grand Tutor"; so the word sequence W3 extracted according to the super-pattern sequence P3 is: Zhao Pu|is|Grand Tutor; Similarly, we can obtain Figure 4 in
[0066] In one embodiment, the computer device obtains an unsegmented text fragment T based on the sequence W, determines multiple hidden states H of the unsegmented text fragment T, and calculates the generation probability of each hidden state H
[0067] In one embodiment, the computer device removes the delimiter "|" in the sequence W to obtain an unsegmented text fragment T = T1T2…T n where For example, when the sequence W = word sequence W3: "Zhao Pu|is|Grand Tutor", removing the delimiter therein gives the unsegmented text fragment: Zhao Pu is Grand Tutor.
[0068] In one embodiment, let H = (P, W) be the hidden state of the unsegmented text fragment T, and the generation probability (i.e., sampling probability) of the hidden state H The calculation formula is: where represents the number of times the super-pattern p appears in the hidden state H, represents the number of times the category-word pair (c, w) (e.g., "person name", "Zhao Pu") appears in the hidden state H. For example, Figure 4 As shown, the generation probability of the hidden state H1 = (P1, W1) The generation probability of the hidden state H3 = (P3, W3)
[0069] It should be noted that in practical applications, the hidden state H is not observable and is missing data. Only the unsegmented text fragment T is observable data. Different unsegmented text fragments T can be generated by different hidden states H. Denote as the set of all hidden states that can generate the unsegmented text fragment T. For example Figure 4 As shown, the set of all hidden states of the unsegmented text fragment "Zhao Pu was the Grand Preceptor" Then, under the framework of the double-dictionary model, the generation probability of the unsegmented text fragment T is For example Figure 4 As shown, the generation probability of the unsegmented text fragment "Zhao Pu was the Grand Preceptor" is
[0070] In one embodiment, given the unsegmented text fragment T, the conditional distribution of the hidden state H is where, when the hidden state H belongs to the set then takes the value of 1; when the hidden state H does not belong to the set then takes the value of 0.
[0071] In one embodiment, the hidden state H of each unsegmented text fragment T T is unobservable. The observed data likelihood function includes the summation over the hidden state H T , resulting in no explicitly expressible posterior distribution for the updated parameter system η. Where represents the set of all hidden states H of any unsegmented text fragment T. The missing data analysis framework in statistics can be used to set as the missing data. It should be noted that for the hidden state H of any unsegmented text fragment T in the missing data , its value space is
[0072] Step S4, the computer device performs parameter inference on the updated parameter system η.
[0073] In one embodiment, the parameter inference on the updated parameter system η includes Method 1 and Method 2. It should be noted that Method 1 is more practical in the two methods.
[0074] In one embodiment, Method 1 includes: maximizing the posterior distribution of the updated parameter system η using the Expectation-Maximization (EM) algorithm. The Expectation-Maximization algorithm includes the E-step and the M-step. The Expectation-Maximization algorithm takes the initial value η of the updated parameter system η=(γ, θ w , θ c|w ) (0)As the initial value for the first iteration, the parameter η obtained from the previous iteration is obtained through iterative convergence in the E-step and the M-step. old The parameter η obtained in this iteration is obtained. new In the next iteration, the parameter η will be... new Consider the parameter η obtained after the previous iteration old Repeat this process until the point estimate of the updated parameter system η is obtained. The initial value η... (0) It can be obtained from the prior distribution of the updated parameter system η.
[0075] In one embodiment, the E-step in method one includes: calculating the Q function: Wherein, T represents the unsegmented text segment of the target text obtained based on the dual-dictionary model, and the hidden state of the unsegmented text segment T is the hidden state H; Indicates missing data, set For the B unsegmented text fragments T in the target text b The set of H, where b and B represent positive integers, 1 ≤ b ≤ B; T Represents a set The hidden state of the unsegmented text fragment T in the text; η old This represents the parameters obtained after the previous iteration. This represents the number of times supermode p appears in the hidden state H. Let H represent the set of all hidden states H of an unsegmented text fragment T. This represents the number of times the category word pair (c, w) appears in the hidden state H. For example, according to Figure 4 Parameters in Calculations such as Figure 5 As shown.
[0076] In one embodiment, the computer device sets the unsegmented text fragment T = A1A2…A L , where characters definition T [>r] =A r+1 A r+2 …A L , Let T be a substring of T; Let represent the set of hidden states containing only one supermode, where Len(P) represents the number of supermodes in the supermode sequence P; let Let represent the set of forward recursive hidden states, and let This represents the set of backward recursive hidden states; it should be noted that the length (i.e., the number of characters) of the unsegmented text fragment generated by any supermode does not exceed [a certain value]. in, The maximum length threshold for symbols in the preset superpattern (e.g., 3). If a preset maximum character length threshold (e.g., 4) is set for any unsegmented text segment T, then when any unsegmented text segment T contains more than L characters... P When a character is 1, the unsegmented text segment T has 1 character. It is an empty set. It should be noted that this implies that regardless of how many characters the unsegmented text fragment T contains, and They all contain only a few elements, and and The size of the set will not increase indefinitely proportionally with the length of the unsegmented text fragment T.
[0077] In one embodiment, for n p (T) and n cw The calculation of (T) includes the calculation of (T). The computer device uses the Baum-Welch algorithm framework to sum the n values, employing dynamic programming to solve for the n values. p (T) and n cw (T) is solved, including: in, This means that the terminator 'e' is not considered. The observational likelihood, This means T without considering the terminator e. [>r] The observational likelihood; Recursive computation using the forward-backward algorithm and include: The initial state of the recursion is: Len(H) represents the number of characters in the unsegmented text segment corresponding to the hidden state H. For example, according to Figure 5 n is calculated from the parameters in p (T) and n cw (T) such as Figure 6 As shown.
[0078] In one embodiment, step M in method one includes: setting constraints. θ c(γ) is a fixed value; based on the aforementioned constraints, the Expectation Conditional Maximization (ECM) algorithm is used to calculate... The maxima include: Where, π c|w Let Q(θ) represent the prior classification probability of word category c given word w, where Constant represents an arbitrary constant; maximizing Q(θ) w |η old ) and Q(θ) c|w |η old Calculate θ w extreme values and θ c|w extreme values include: In a given and Under the conditions, by the constraints We can know θ c (γ) is a fixed value, so Q(γ|η) is maximized. old Equivalent to maximization Its maximum point is It should be noted that the point estimation results of the updated parameter system η obtained by using the EM algorithm are... Meet the constraints The stopping criterion for iterative convergence between the E-step and M-step can be: the parameter η obtained in this iteration. new and the parameter η obtained from the previous iteration old The Euclidean distance between them is less than a pre-given convergence threshold (e.g., 10). -6 ).
[0079] In one embodiment, the second method includes: using a data augmentation (DA) algorithm to perform posterior distribution sampling on the updated parameter system η to obtain a target posterior distribution of the updated parameter system η, wherein the target posterior distribution is: in, This represents an expanded (Augmented) and updated sampling space obtained by expanding the sampling space η; wherein, posterior distribution sampling of the updated parameter system η includes: sampling from the conditional distribution. and conditional distribution Iterative sampling is performed until the target posterior distribution is obtained, wherein... The set of all hidden states H of an unsegmented text fragment T.
[0080] Step S5: The computer device performs a posteriori analysis on the dual-dictionary model based on the results obtained from the inference of the parameters.
[0081] In one embodiment, the posterior analysis of the dual-dictionary model based on the results inferred from the parameters includes: constructing the saliency scores of the superpattern p, word w, and category word pair (c, w); and constructing the posterior classification distribution of word w.
[0082] In one embodiment, the saliency score for constructing the hyperpattern p, word w, and category word pair (c, w) includes: Let Let the point estimation result of the updated parameter system η obtained by the parameter inference be... and For a set of updated parameter values; from The parameters γ will be set separately. p θ w and θ w|c Set it to zero, and keep other parameters unchanged; define the significance scores of the superpattern p, word w, and category word pair (c, w) as follows: These are all baseline models. The logarithm of the ratio of the observed likelihood to that of the reduced model. Under the condition that the reduced model holds, the likelihood ratio test shows that 2ψ asymptotically follows a chi-square distribution, which can be used for model selection through hypothesis testing. It should be noted that in practical cases, multiple tests require Bonferroni adjustments to the results or control of the false discovery rate.
[0083] In one embodiment, constructing the posterior classification distribution of word w includes: defining the posterior classification distribution of the word as follows: It utilizes prior word classification information π c|w In addition to textual syntactic and semantic structural information (i.e., hyperpattern information), Bayesian statistical inference methods are used to present optimized results for the prior classification distribution of words. It should be noted that through parameter inference and posterior analysis of the dual-dictionary model, many elements with low significance scores (e.g., less than 10) (e.g., hyperpatterns, words, etc.) are removed, and the remaining elements constitute the optimized dual-word dictionary model.
[0084] Step S6, the computer device obtains the text segmentation result of the unsegmented text segment T based on the result inferred from the parameters, and the text segmentation result includes the optimal hidden state And based on the text segmentation result, semantic understanding and relationship extraction are performed on the unsegmented text segment T
[0085] In one embodiment, obtaining the text segmentation result of the unsegmented text segment T based on the result inferred from the parameters includes: the computer device uses the method of maximum likelihood to give the prediction result of the optimal hidden state of the unsegmented text segment T Since the optimal hidden state cannot be obtained by enumerating all the hidden states in The computer device is based on the idea of dynamic programming and uses the framework of the Viterbi algorithm. From the recurrence formula Solve for the optimal hidden state Where represents the optimal hidden state The number of characters in the unsegmented text segment corresponding to
[0086] In one embodiment, semantic understanding and relationship extraction can be performed on the unsegmented text segment T based on the optimal hidden state of the unsegmented text segment T To help the user with semantic understanding. For example, the optimal hidden state of the unsegmented text segment "趙普為太師" is H3 = (P3, W3) = ("N為O|e", "趙普|為|太師"). Then, through semantic understanding and relationship extraction, it can be known that "趙普" is a personal name, "太師" is an official position, and the meaning expressed is that 趙普's official position is 太師
[0087] The above Figure 1 has introduced in detail the model training method for artificial intelligence text analysis of this application. Next, in combination with Figure 2 The hardware device architecture for implementing the model training method for artificial intelligence text analysis is introduced
[0088] It should be understood that the above embodiments are only for illustration purposes and are not limited by this structure in the scope of the patent application
[0089] Referring to Figure 2 shown, it is a schematic structural diagram of a computer device provided by a preferred embodiment of this application. In a preferred embodiment of this application, the computer device 3 includes a memory 31 and at least one processor 32. Those skilled in the art should understand that Figure 2The structure of the computer device shown does not constitute a limitation of the embodiments of this application. It can be a bus-type structure or a star-type structure. The computer device 3 may also include more or fewer other hardware or software than shown, or different component arrangements.
[0090] In some embodiments, the computer device 3 includes a terminal capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, the hardware of which includes, but is not limited to, microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices.
[0091] It should be noted that the computer device 3 described is merely an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.
[0092] In some embodiments, the memory 31 is used to store program code and various data, such as dual-dictionary models, model training systems 30 installed in the computer device 3, etc., and to achieve high-speed and automatic access to programs or data during the operation of the computer device 3. The memory 31 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable storage medium capable of carrying or storing data.
[0093] In some embodiments, the at least one processor 32 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits packaged with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The at least one processor 32 is the control unit of the computer device 3, connecting various components of the computer device 3 via various interfaces and lines. It executes programs or modules stored in the memory 31 and calls data stored in the memory 31 to perform various functions of the computer device 3 and process data, such as performing model training.
[0094] In some embodiments, the model training system 30 runs on a computer device 3. The model training system 30 may include multiple functional modules composed of program code segments. The program code of each program segment in the model training system 30 may be stored in the memory 31 of the computer device 3 and executed by at least one processor 32 to implement the model training function (see details). Figure 1 describe).
[0095] In this embodiment, the model training system 30 can be divided into multiple functional modules according to the functions it performs. A module, as referred to in this application, is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and is stored in memory.
[0096] Although not shown, the computer device 3 may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 32 via a power management device, thereby enabling functions such as charging, discharging, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The computer device 3 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0097] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0098] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a computer device (which may be a server, personal computer, etc.) or processor to execute portions of the methods described in the various embodiments of this application.
[0099] In a further embodiment, combined with Figure 2 The at least one processor 32 can execute the operating system of the computer device 3 and various installed applications (such as the model training system 30), program code, etc., for example, the various modules mentioned above.
[0100] In one embodiment of this application, the memory 31 stores one or more instructions (i.e., at least one instruction), which are executed by the at least one processor 32 to implement... Figure 1 The purpose of training the model shown.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0102] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0103] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0104] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within this application. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other elements or, and the singular does not exclude the plural. Multiple elements or devices recited in the apparatus claims may also be implemented by a single element or device in software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.
[0105] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the above preferred embodiments, those skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A model training method for artificial intelligence text analysis, characterized in that: The method comprises: Obtain a pre-built dual-dictionary model, which includes an initial word dictionary of the target text Initial HyperSchema Dictionary and the initial parameter system (γ,θ w∣c );in γ represents the sampling probability distribution of the super mode, where γ p represents the sampling probability of super mode p; represents a set of sampling probability distributions, where represents the sampling probability distribution of words given word category c, θ w∣c represents the conditional sampling probability of word w given word category c; Based on the initial parameter system (γ,θ w∣c ), determine the updated parameter system η of the dual dictionary model, where η=(γ,θ w ,θ c∣w );in, represents the sampling probability distribution of word w, represents a set of sampling probability distributions, represents the conditional distribution of word categories given word w, θ c∣w represents the sampling probability of word category c given word w; Performing parameter inference on the updated parameter system η; Based on the results obtained from the parameter inference, a posteriori analysis is performed on the dual dictionary model.
2. The model training method for artificial intelligence text analysis according to claim 1, characterized in that: The method further comprises: Based on the dual dictionary model, obtaining an unsegmented text segment T of the target text, and determining a hidden state H of the unsegmented text segment T; Assuming missing data Among them, the collection is the B unsegmented text segments T in the target text b The set of, b and B represent positive integers and 1≤b≤B; H T Representing a collection The hidden state of the unsegmented text fragment T in ; Based on the result obtained by the parameter inference, the text segmentation result of the unsegmented text segment T is obtained, and the text segmentation result includes the optimal hidden state and Based on the text segmentation result, semantic understanding and relationship extraction are performed on the unsegmented text segment T.
3. The model training method for artificial intelligence text analysis according to claim 2, characterized in that: The performing parameter inference on the updated parameter system η comprises: Using the data enhancement algorithm, the posterior distribution sampling is performed on the updated parameter system η to obtain the target posterior distribution of the updated parameter system η, and the target posterior distribution is: in, represents the updated sampling space obtained by expanding the sampling space η; Wherein, sampling the posterior distribution of the updated parameter system η comprises: From the conditional distribution and conditional distribution Iterative sampling is performed until the target posterior distribution is obtained, where Represents the set of all hidden states H of the unsegmented text segment T.
4. The model training method for artificial intelligence text analysis according to claim 3, characterized in that: The dual dictionary model also includes: All characters a in the target text l The set of characters 1≤l≤L; The initial word dictionary in, 1≤n≤N,i, represents a positive integer, w n is composed of the Words consisting of the characters in The set of word categories in the target text 1≤k≤K, where c k represents the category of the named entity, c0 represents the category of the background word that is different from the named entity, The initial super-schema dictionary in 1≤m≤M,p m Indicated by the pictogram t j The super-pattern composed of the pictogram j represents a positive integer; e represents a terminator; Based on the initial parameter system (γ, θ w∣c ), determining the updated parameter system η of the dual dictionary model includes: Set the updated parameter system η = (γ, θ w ,θ c∣w ), and the updated parameter system (γ,θ w ,θ c∣w )’s posterior distribution.
5. The model training method for artificial intelligence text analysis according to claim 4, characterized in that: The performing parameter inference on the updated parameter system η comprises: The expectation maximization algorithm is used to maximize the posterior distribution of the updated parameter system η. The expectation maximization algorithm includes an E step and an M step. The expectation maximization algorithm obtains a point estimation result of the updated parameter system η through iterative convergence performed in the E step and the M step.
6. The model training method for artificial intelligence text analysis according to claim 5, characterized in that: The method further comprises: Based on the dual dictionary model, obtaining an unsegmented text segment T of the target text, and determining a hidden state H of the unsegmented text segment T; Assuming missing data Among them, the collection is the B unsegmented text segments T in the target text b The set of, b and B represent positive integers and 1≤b≤B; H T Representing a collection The hidden state of the unsegmented text fragment T in ; The E step comprises: Calculate the Q function: Among them, η old represents the parameters obtained after the previous iteration, represents the number of times the super pattern p appears in the hidden state H, represents the set of all hidden states H of the unsegmented text segment T, Indicates the number of times the category word pair (c, w) appears in the hidden state H; The M steps include: Setting Restrictions θ c (γ) is a fixed value; based on the constraints, the expected condition maximization algorithm is used to calculate The maximum value of .
7. The model training method for artificial intelligence text analysis according to claim 4, characterized in that: The performing a posteriori analysis on the dual dictionary model based on the result obtained by the parameter inference comprises: constructing a saliency score for the super-pattern p, word w, and class-word pair (c, w); and Construct the posterior categorical distribution of word w.
8. The model training method for artificial intelligence text analysis according to claim 2 or 3, characterized in that: The step of obtaining an unsegmented text segment T of the target text and determining a hidden state H of the unsegmented text T comprises: From the initial super-schema dictionary Extract the super pattern p from the , and obtain the super pattern sequence P; Extract word w according to the super pattern sequence P to obtain word sequence W i and the word sequence W i A sequence W, where Based on the sequence W, an unsegmented text segment T is obtained, and a hidden state H of the unsegmented text segment T is determined.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by the processor, it implements the model training method for artificial intelligence text analysis as described in any one of claims 1 to 8.
10. A computer device, characterized in that: The computer device includes a memory and at least one processor, wherein the memory stores at least one instruction, and when the at least one instruction is executed by the at least one processor, the model training method for artificial intelligence text analysis as described in any one of claims 1 to 8 is implemented.
