Text information extraction method and device, electronic equipment and storage medium
By constructing object extraction prompts and target training text, the model is trained to improve the accuracy of text information extraction, and the problem of low accuracy when the extraction objects is not standard in the prior art is solved, achieving more efficient text information extraction.
Patent Information
- Application Number
- CN202411207349.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-06
AI Technical Summary
The existing text information extraction methods are based on specific vocabulary lists or rules, and cannot effectively extract information when the extraction object is not standard, resulting in low accuracy.
通过获取初始训练文本,构建目标抽取对象的对象抽取提示语,并基于该提示语及初始训练文本构建目标训练文本,对预设模型进行训练,生成目标对象抽取模型以提高抽取准确率。
It improves the accuracy of text information extraction and the accuracy of the target object extraction model, and can extract specific information from the text more effectively.
Smart Images

Figure CN119088897A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information extraction and artificial intelligence technology, and in particular to a text information extraction method and device, an electronic device and a storage medium. Background Art
[0002] Text information extraction refers to the extraction of specific information from a text. By extracting specific information from a text, it can help text readers quickly obtain the information they need. For example, in the medical field, extracting the names of drugs from a patient's medication description text can help doctors quickly obtain the patient's medication history.
[0003] At present, common text information extraction is implemented based on specific vocabularies or rules. However, when the extraction object is not standard enough, the extraction object does not exist in the specific vocabulary or rules. At this time, it is often impossible to extract the extraction object from the text information based on the specific vocabulary or rules, resulting in low accuracy of text information extraction. Therefore, how to improve the accuracy of text information extraction has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a text information extraction method and device, an electronic device and a storage medium, aiming to improve the accuracy of text information extraction.
[0005] To achieve the above object, a first aspect of an embodiment of the present application proposes a text information extraction method, the method comprising:
[0006] Acquire initial training text, wherein the initial training text refers to text that marks the target extraction object;
[0007] Based on the initial training text, construct an object extraction prompt for the target extraction object, wherein the extraction prompt is used to prompt the model for the object to be extracted;
[0008] Constructing a target training text based on the target extraction object, the object extraction prompt and the initial training text;
[0009] Based on the target training text, a preset initial object extraction model is trained to obtain a target object extraction model;
[0010] A target text containing the target extraction object is obtained, and information is extracted from the target text based on the object extraction prompt and the target object extraction model.
[0011] In some embodiments, constructing a target training text based on the target extraction object, the object extraction prompt and the initial training text includes:
[0012] Based on the target extraction object, target positioning is performed on the initial training text to obtain object position information;
[0013] Based on the object position information and the initial training text, generating an object position index;
[0014] The initial training text, the object position index and the object extraction prompt are concatenated to obtain the target training text.
[0015] In some embodiments, generating an object position index based on the object position information and the initial training text includes:
[0016] Based on the object position information, query the initial training text for a starting position to obtain an object starting index;
[0017] Based on the object position information, query the end position of the initial training text to obtain the object end index;
[0018] The object start index and the object end index are index-merged to obtain the object position index.
[0019] In some embodiments, constructing the object extraction prompt of the target extraction object based on the initial training text includes:
[0020] Extracting attribute features of the target extraction object in the initial training text;
[0021] The object extraction prompt is generated based on a preset prompt template and the attribute feature, wherein the prompt template is used to prompt the model for the task to be performed.
[0022] In some embodiments, obtaining the initial training text includes:
[0023] Acquire an initial text, wherein the initial text refers to a text containing the target extraction object;
[0024] Performing target extraction on the initial text to obtain the target extraction object;
[0025] Based on a preset extraction task environment, text generation is performed on the target extraction object to obtain the initial training text, wherein the extraction task environment is used to characterize context information of the initial training text.
[0026] In some embodiments, the step of performing target extraction on the initial text to obtain the target extraction object includes:
[0027] Get the extracted object features;
[0028] Performing text cleaning on the initial text to obtain a cleaned text;
[0029] Based on the extracted object features, keyword extraction is performed on the cleaned text to obtain text keywords;
[0030] The text keywords are targeted and screened to obtain the target extraction objects.
[0031] In some embodiments, the training of a preset initial object extraction model based on the target training text to obtain a target object extraction model includes:
[0032] Encoding the target training text based on the initial object extraction model to obtain a text encoding vector, wherein the text encoding vector includes a text word vector;
[0033] Based on the initial object extraction model, the attention weight of the text word vector is calculated to obtain the word vector weight;
[0034] Based on the word vector weight, an activation function is calculated on the text word vector to obtain a predicted extraction object;
[0035] Based on the target extraction object and the predicted extraction object, the initial object extraction model is back-propagated to obtain the target object extraction model.
[0036] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a text information extraction device, the device comprising:
[0037] An initial text generation module, used to obtain initial training text, wherein the initial training text refers to the text that marks the target extraction object;
[0038] A prompt construction module, used to construct an object extraction prompt of the target extraction object based on the initial training text, wherein the extraction prompt is used to prompt the model to extract the object;
[0039] A target text generation module, used to construct a target training text based on the target extraction object, the object extraction prompt and the initial training text;
[0040] An extraction model training module is used to train a preset initial object extraction model based on the target training text to obtain a target object extraction model;
[0041] The text information extraction module is used to obtain a target text containing the target extraction object, and extract information from the target text based on the object extraction prompt and the target object extraction model.
[0042] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0043] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0044] The text information extraction method and device, electronic device and storage medium proposed in the present application construct an object extraction prompt for the target extraction object based on the acquired initial training text for marking the target extraction object, which is used to prompt that the object to be extracted in the initial training text is the target extraction object, thereby improving the accuracy of object extraction in the text information. Furthermore, according to the target extraction object, the object extraction prompt and the initial training text, a target training text is constructed, and according to the target training text, a preset initial object extraction model is trained to obtain a target object extraction model, which can improve the accuracy of the target object extraction model, thereby improving the accuracy of text information extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a flowchart of a text information extraction method provided in an embodiment of the present application;
[0046] Figure 2 yes Figure 1 Flow chart of step S101 in FIG.
[0047] Figure 3 yes Figure 2 Flow chart of step S202 in FIG.
[0048] Figure 4 yes Figure 1 Flow chart of step S102 in FIG.
[0049] Figure 5 yes Figure 1 Flow chart of step S103 in FIG.
[0050] Figure 6 yes Figure 5 Flow chart of step S502 in FIG.
[0051] Figure 7 yes Figure 1 Flow chart of step S104 in FIG.
[0052] Figure 8 is a structural schematic diagram of a text information extraction device provided in an embodiment of the present application;
[0053] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0055] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0057] First, some nouns involved in this application are analyzed:
[0058] Prompts: Prompts play a guiding role in the model, helping the model to better understand and generate context-related content. By providing specific contextual information or instructions, prompts can improve the accuracy and consistency of the model and ensure that the generated results are more in line with user expectations. In addition, effective prompts can reduce ambiguity and make the model more efficient in performing tasks, thereby optimizing interaction effects and user experience.
[0059] Text information extraction refers to the extraction of specific information from a text. By extracting specific information from a text, it can help text readers quickly obtain the information they need. For example, in the medical field, extracting the names of drugs from a patient's medication description text can help doctors quickly obtain the patient's medication history.
[0060] At present, common text information extraction is implemented based on specific vocabularies or rules. However, when the extraction object is not standard enough, the extraction object does not exist in the specific vocabulary or rules. At this time, it is often impossible to extract the extraction object from the text information based on the specific vocabulary or rules, resulting in low accuracy of text information extraction. Therefore, how to improve the accuracy of text information extraction has become a technical problem that needs to be solved urgently.
[0061] Based on this, the embodiments of the present application provide a text information extraction method and device, an electronic device and a storage medium, aiming to improve the accuracy of text information extraction.
[0062] The text information extraction method and device, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the text information extraction method in the embodiments of the present application is described.
[0063] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0064] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0065] The text information extraction method provided in the embodiment of the present application relates to the field of information extraction and artificial intelligence technology. The text information extraction method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the text information extraction method, etc., but is not limited to the above forms.
[0066] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0067] Figure 1 is an optional flow chart of a text information extraction method provided in an embodiment of the present application, the method is applied to a server, Figure 1 The method may include but is not limited to steps S101 to S105.
[0068] Step S101, obtaining an initial training text, wherein the initial training text refers to a text for marking a target extraction object;
[0069] Step S102, constructing an object extraction prompt for a target extraction object based on the initial training text, wherein the extraction prompt is used to prompt the object to be extracted from the initial training text;
[0070] Step S103, constructing a target training text based on the target extraction object, the object extraction prompt and the initial training text;
[0071] Step S104, training a preset initial object extraction model based on the target training text to obtain a target object extraction model;
[0072] Step S105, obtaining a target text containing a target extraction object, and extracting information from the target text based on the object extraction prompt and the target object extraction model.
[0073] Steps S101 to S105 shown in the embodiment of the present application are to obtain an initial training text by acquiring text that marks a target extraction object, and then construct a prompt for the object to be extracted in the initial training text based on the initial training text to obtain an object extraction prompt. Secondly, a target training text is constructed based on the target extraction object, the object extraction prompt and the initial training text, and a preset initial object extraction model is trained based on the target training text to obtain a target object extraction model. Finally, a target text containing the target extraction object is obtained, and information is extracted from the target text based on the object extraction prompt and the target object extraction model. Therefore, the present application constructs an object extraction prompt for the target extraction object based on the acquired initial training text that marks the target extraction object, so as to prompt that the object to be extracted in the initial training text is the target extraction object, thereby improving the accuracy of object extraction in the text information. Furthermore, according to the target extraction object, the object extraction prompt and the initial training text, a target training text is constructed, and according to the target training text, a preset initial object extraction model is trained to obtain a target object extraction model, which can improve the accuracy of the target object extraction model and thus improve the accuracy of text information extraction.
[0074] In step S101 of some embodiments, the target extraction object can be obtained by obtaining an initial text containing the target extraction object, then extracting the target extraction object from the obtained initial text, and finally, generating an initial training text suitable for model training based on the target extraction object.
[0075] For details, see Figure 2 In some embodiments, step S102 may include but is not limited to steps S201 to S203:
[0076] Step S201, obtaining an initial text, wherein the initial text refers to a text containing a target extraction object;
[0077] Step S202, performing target extraction on the initial text to obtain a target extraction object;
[0078] Step S203, based on a preset extraction task environment, text generation is performed on the target extraction object to obtain an initial training text, wherein the extraction task environment is used to characterize context information of the initial training text.
[0079] In step S201 of some embodiments, the initial text containing the target extraction object can be obtained by searching the Internet or performing information search in a specific database. It should be noted that in order to facilitate the extraction of the target extraction object in the initial text, when obtaining the initial text, it is necessary to select texts that are easy to extract from the target extraction object. For example, when the target extraction object is a drug name, the initial text can be a drug instruction manual, the Pharmacopoeia of the People's Republic of China, and other texts that are easy to extract the drug name.
[0080] In step S202 of some embodiments, by extracting keywords from the initial text without problems such as repetition and unclearness, text keywords can be obtained, and then target extraction objects can be screened out from the text keywords.
[0081] For details, see Figure 3 In some embodiments, step S202 may include but is not limited to steps S301 to S304:
[0082] Step S301, obtaining the extracted object features;
[0083] Step S302, performing text cleaning on the initial text to obtain a cleaned text;
[0084] Step S303, based on the extracted object features, keyword extraction is performed on the cleaned text to obtain text keywords;
[0085] Step S304, target screening is performed on the text keywords to obtain target extraction objects.
[0086] In step S301 of some embodiments, the extracted object features refer to the common features of multiple target extracted objects. For example, when the extracted object is a company name, the extracted object features may be phrases such as Limited Company, Technology, and Group.
[0087] The present application can determine the extraction object features of the target extraction object by analyzing the common features of multiple target extraction objects.
[0088] In step S302 of some embodiments, the cleaned text can be obtained by removing non-standard text in the initial text or unifying the characters in the initial text, for example, removing the initial text containing special symbols or unifying the English in the initial text into lowercase.
[0089] In step S303 of some embodiments, text keywords containing the extraction object features are extracted from the cleaned text according to the extraction object features obtained above.
[0090] In step S304 of some embodiments, the required target extraction object can be obtained by further screening the text keywords. For example, when the cleaned text is "Doctor, I have had stomach pain recently, and it hasn't gotten better after taking Metoclopramide", and the extraction object feature is "stomach", the extracted text keywords include "stomach pain" and "Metoclopramide", and then "stomach pain" and "Metoclopramide" are screened by part of speech, and the target extraction object can be obtained as "Metoclopramide".
[0091] In steps S301 to S304 shown in this embodiment, the initial text is cleaned to obtain a cleaned text, thereby improving the accuracy of the training text. Furthermore, keywords are extracted from the cleaned text based on the acquired extraction object features to obtain text keywords to avoid missing target extraction objects. Finally, the text keywords are targeted and screened to obtain target extraction objects, thereby improving the accuracy of the screened target extraction objects.
[0092] In step S203 of some embodiments, a training text template can be constructed according to a pre-set extraction task environment of a target extraction object, and then an initial training text for marking the target extraction object can be generated according to the target extraction object extracted from the initial text and the training text template. For example, when the extraction task is to extract the name of a drug in a patient's symptom description, training text templates such as "Doctor, I have a stomachache recently, and I haven't gotten better after taking Metoclopramide" and "Doctor, I seem to have a fever, and I took some amoxicillin capsules not long ago" can be constructed. Based on the above-constructed training sample templates and the pre-extracted target extraction objects such as "Ganmao Ling", initial training texts such as "Doctor, I have a cold recently, and I haven't gotten better after taking Ganmao Ling" and "Doctor, I seem to have a cold, and I took some Ganmao Ling not long ago" can be generated.
[0093] In steps S201 to S203 shown in this embodiment, the target extraction object is extracted from the initial text, and then text is generated for the extracted target extraction object according to a pre-set extraction task environment to obtain the initial training text. This can improve the efficiency of obtaining the initial training text and reduce the demand for training text.
[0094] In one application scenario, when the target extraction object is the name of a drug, by searching the Internet or searching for information in a specific database, texts such as drug instructions and the Pharmacopoeia of the People's Republic of China, which are easy to extract drug names, can be obtained. The common features of multiple drug names in the texts such as the drug instructions and the Pharmacopoeia of the People's Republic of China are then analyzed to determine the extraction object features of the drug names. Secondly, the texts such as the drug instructions and the Pharmacopoeia of the People's Republic of China are cleaned to ensure the accuracy of the initial texts. Based on the extraction object features of the drug names, the cleaned texts such as the drug instructions and the Pharmacopoeia of the People's Republic of China are keyed. Word extraction is performed to obtain text keywords containing the characteristics of the extraction object, and then the target extraction objects that match the drug name are screened out from the text keywords. Finally, according to the pre-set drug name extraction task environment, training text templates such as "Doctor, I have a stomachache recently, and I haven't gotten better after taking Metoclopramide", "Doctor, I seem to have a fever, and I took some amoxicillin capsules not long ago" can be constructed. According to the above-constructed training sample templates and the target extraction objects such as "Ganmao Ling" extracted in advance, initial training texts such as "Doctor, I have a cold recently, and I haven't gotten better after taking Ganmao Ling", "Doctor, I seem to have a cold, and I took some Ganmao Ling not long ago" can be generated.
[0095] In step S102 of some embodiments, an object extraction prompt is constructed to prompt the model to extract the object according to the attribute characteristics of the target extraction object in the acquired initial training text.
[0096] For details, see Figure 4 In some embodiments, step S102 may include but is not limited to steps S401 to S402:
[0097] Step S401, extracting attribute features of the target extraction object in the initial training text;
[0098] Step S402, generating an object extraction prompt based on a preset prompt template and attribute features, wherein the prompt template is used to prompt the model for the task to be performed.
[0099] In step S401 of some embodiments, the attribute features may be features such as part of speech, meaning, and class of speech of the target extraction object. For example, when the target extraction object is a drug name, the attribute features of the target extraction object may be features such as a noun and a drug name.
[0100] The present application can determine the attribute characteristics of the target extraction object by performing phrase parsing on the target extraction object in the initial training text and then combining the context information of the target extraction object in the initial training text.
[0101] In step S402 of some embodiments, a prompt template is generated according to a pre-set task goal, and then the description information of the target extraction object to be extracted is determined according to the attribute characteristics of the target extraction object extracted above. Finally, the description information of the target extraction object is substituted into the prompt template to obtain an object extraction prompt of the target extraction object. For example, the pre-set task goal may be to extract phrases from text information, and prompt templates such as "identify XXX in the text" or "extract XXX in the text" may be generated at this time. Furthermore, when the attribute characteristics of the target extraction object are nouns, drug names, etc., it can be determined that the description information of the target extraction object is a drug name. Therefore, by substituting the drug name into the prompt templates such as "identify XXX in the text" or "extract XXX in the text", object extraction prompts such as "identify the drug name in the text" or "extract the drug name in the text" may be obtained.
[0102] In steps S401 to S402 shown in the present embodiment, the attribute features are obtained by extracting the features of the target extraction object in the initial training text, and then the object extraction prompt is generated according to the pre-set prompt template and the attribute features, which can assist the model in extracting the target extraction object and improve the model's extraction accuracy for the target extraction object.
[0103] In step S103 of some embodiments, after the target extraction object is determined and the object extraction prompt and the initial training text are obtained, the target training text is constructed by marking the position of the target extraction object in the initial training text.
[0104] For details, see Figure 5 In some embodiments, step S103 may include but is not limited to steps S501 to S503:
[0105] Step S501, based on the target extraction object, the initial training text is positioned to obtain the object position information;
[0106] Step S502, generating an object position index based on the object position information and the initial training text;
[0107] Step S503, performing text concatenation on the initial training text, the object position index and the object extraction prompt to obtain the target training text.
[0108] In step S501 of some embodiments, a position query is performed on the target extraction object in the initial training text, so that the starting position and the ending position of the target extraction object in the initial training text can be determined, and the starting position and the ending position are combined to determine the object position information of the target extraction object in the initial training text.
[0109] In step S502 of some embodiments, based on the object position information of the target extraction object in the initial training text and the number of characters in the initial training text, the order of the starting characters of the target extraction object in the initial training text and the order of the ending characters of the target extraction object in the initial training text can be determined, thereby obtaining the object position index of the target extraction object in the initial training text.
[0110] For details, see Figure 6 In some embodiments, step S502 may include but is not limited to steps S601 to S603:
[0111] Step S601, based on the object position information, perform a start position query on the initial training text to obtain the object start index;
[0112] Step S602, based on the object position information, query the end position of the initial training text to obtain the object end index;
[0113] Step S603: merge the object start index and the object end index to obtain the object position index.
[0114] In step S601 and step S602 of some embodiments, based on the obtained object position information, the starting position of the target extracted object in the initial training text is queried to obtain the object starting index of the target extracted object, and the ending position of the target extracted object in the initial training text is queried to obtain the object ending index of the target extracted object.
[0115] In step S603 of some embodiments, the object start index of the target extraction object and the object end index of the target extraction object are concatenated to determine the overall index of the target extraction object in the initial training text, that is, the object position index.
[0116] In steps S601 to S603 shown in the present embodiment, the starting position and the ending position of the target extraction object in the initial training text are queried to determine the object starting index and the object ending index of the target extraction object, and then the object starting index and the object ending index are merged to obtain the object position index, which can improve the index accuracy of the target extraction object and facilitate the model to quickly identify the target extraction object in the initial training text, thereby improving the model's recognition speed and recognition accuracy of the target extraction object.
[0117] In step S503 of some embodiments, the object position index is spliced with the initial training text and the object extraction prompt in a preset splicing order to obtain a target training text. For example, when the object position index is "object starting index: 11, object ending index: 13", the initial training text is "Doctor, I have a stomachache recently, and I haven't gotten better after taking Metoclopramide", and the object extraction prompt is "Identify the name of the drug in the text", and the preset splicing order is initial training text, object position index, and object extraction prompt, the object position index, initial training text, and object extraction prompt can be spliced into a target training text in the style of {text: Doctor, I have a stomachache recently, and I haven't gotten better after taking Metoclopramide, object starting index: 11, object ending index: 13, identify the name of the drug in the text}.
[0118] In steps S501 to S503 shown in the present embodiment, by locating the target extraction object in the initial training text, determining the object position information, and then generating the object position index of the target extraction object based on the object position information and the initial training text, the model can be helped to quickly confirm the position of the target extraction object in the initial training text, thereby improving the efficiency of model training. Furthermore, the initial training text, the object position index and the object extraction prompt are concatenated to obtain the target training text, thereby assisting the model in training and improving the model training speed.
[0119] In step S104 of some embodiments, a preset initial object extraction model is trained based on the constructed target training text to obtain a target object extraction model for text information extraction.
[0120] It should be noted that the initial object extraction model can be an open source Chinese pre-trained model, which generally includes an encoding layer, an attention weight layer and a fully connected layer, such as the Bert model, the GPT model, etc.
[0121] For details, see Figure 7 In some embodiments, step S104 may include but is not limited to steps S701 to S704:
[0122] Step S701, encoding the target training text based on the initial object extraction model to obtain a text encoding vector, wherein the text encoding vector includes a text word vector;
[0123] Step S702, based on the initial object extraction model, the attention weight of the text word vector is calculated to obtain the word vector weight;
[0124] Step S703, based on the word vector weight, the activation function is calculated for the text word vector to obtain a predicted extraction object;
[0125] Step S704, based on the target extraction object and the predicted extraction object, back-propagation is performed on the initial object extraction model to obtain the target object extraction model.
[0126] In step S701 of some embodiments, the encoding layer in the initial object extraction model is used to encode the characters in the target training text word by word to obtain a text encoding vector containing multiple text word vectors.
[0127] In step S702 of some embodiments, the attention weight layer in the initial object extraction model is used to calculate the attention weight of each text word vector to obtain the word vector weight.
[0128] In step S703 of some embodiments, the probability of each text word vector being the target extraction object is calculated based on the word vector weight of each text word vector and a pre-set activation function, and based on the probability of each text word vector being the target extraction object, the text word vector with the highest probability is selected as the predicted extraction object.
[0129] In step S704 of some embodiments, the initial object extraction model is back-propagated based on the target extraction object marked in the target training text and the predicted extraction object predicted by the initial object extraction model, and some parameters of the initial object extraction model are adjusted to ensure that the predicted extraction object is consistent with the target extraction object, thereby completing the training of the initial object extraction model and obtaining the target object extraction model.
[0130] In steps S701 to S704 shown in this embodiment, the initial object extraction model is used to encode each phrase in the target training text to obtain multiple text word vectors, and the predicted extraction object is determined based on the word vector weights of the multiple text word vectors. Then, based on the target extraction object and the predicted extraction object, the parameters in the initial object extraction model are fine-tuned to obtain the target object extraction model, which reduces the duration of model training and improves the efficiency of model training.
[0131] In step S105 of some embodiments, the target text refers to text that contains the target extraction object but does not mark the target extraction object.
[0132] After obtaining the target text containing the target extraction object, the present application can input the target text and the above-generated object extraction prompt into the target object extraction model to obtain the target extraction object in the target text.
[0133] The present application constructs an object extraction prompt for the target extraction object based on the acquired initial training text for marking the target extraction object, which is used to prompt that the object to be extracted in the initial training text is the target extraction object, thereby improving the accuracy of object extraction in text information. Furthermore, according to the target extraction object, the object extraction prompt and the initial training text, a target training text is constructed, and according to the target training text, a preset initial object extraction model is trained to obtain a target object extraction model, which can improve the accuracy of the target object extraction model and thus improve the accuracy of text information extraction.
[0134] See also Figure 8 The embodiment of the present application also provides a text information extraction device, which can implement the above-mentioned text information extraction method, and the device includes:
[0135] An initial text generation module 801 is used to obtain an initial training text, wherein the initial training text refers to a text that marks a target extraction object;
[0136] A prompt construction module 802 is used to construct an object extraction prompt of a target extraction object based on the initial training text, wherein the extraction prompt is used to prompt the model of the object to be extracted;
[0137] A target text generation module 803 is used to construct a target training text based on the target extraction object, the object extraction prompt and the initial training text;
[0138] The extraction model training module 804 is used to train the preset initial object extraction model based on the target training text to obtain the target object extraction model;
[0139] The text information extraction module 805 is used to obtain a target text containing a target extraction object, and extract information from the target text based on the object extraction prompt and the target object extraction model.
[0140] The specific implementation of the text information extraction device is basically the same as the specific implementation of the above-mentioned text information extraction method, and will not be repeated here.
[0141] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above text information extraction method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0142] See also Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0143] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0144] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the text information extraction method of the embodiment of this application;
[0145] Input / output interface 903, used to implement information input and output;
[0146] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0147] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0148] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0149] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned text information extraction method is implemented.
[0150] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0151] The text information extraction method, text information extraction device, electronic device and storage medium provided in the embodiments of the present application obtain an initial training text by acquiring text with a target extraction object marked thereon, and then constructing a prompt for prompting the object to be extracted in the initial training text based on the initial training text to obtain an object extraction prompt. Secondly, a target training text is constructed based on the target extraction object, the object extraction prompt and the initial training text, and a preset initial object extraction model is trained based on the target training text to obtain a target object extraction model. Finally, a target text containing the target extraction object is acquired, and information is extracted from the target text based on the object extraction prompt and the target object extraction model.
[0152] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0153] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0154] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0155] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0156] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0157] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0158] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0159] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0161] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0162] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A text information extraction method, It is characterized in that The method comprises: Acquire initial training text, wherein the initial training text refers to text that marks the target extraction object; Based on the initial training text, construct an object extraction prompt for the target extraction object, wherein the extraction prompt is used to prompt the model for the object to be extracted; Constructing a target training text based on the target extraction object, the object extraction prompt and the initial training text; Based on the target training text, a preset initial object extraction model is trained to obtain a target object extraction model; A target text containing the target extraction object is obtained, and information is extracted from the target text based on the object extraction prompt and the target object extraction model.
2. The method according to claim 1, It is characterized in that The step of constructing a target training text based on the target extraction object, the object extraction prompt and the initial training text includes: Based on the target extraction object, target positioning is performed on the initial training text to obtain object position information; Based on the object position information and the initial training text, generating an object position index; The initial training text, the object position index and the object extraction prompt are concatenated to obtain the target training text.
3. The method according to claim 2, It is characterized in that The generating an object position index based on the object position information and the initial training text includes: Based on the object position information, query the initial training text for a starting position to obtain an object starting index; Based on the object position information, query the end position of the initial training text to obtain the object end index; The object start index and the object end index are index-merged to obtain the object position index.
4. The method according to claim 1, It is characterized in that The step of constructing the object extraction prompt of the target extraction object based on the initial training text includes: Extracting attribute features of the target extraction object in the initial training text; The object extraction prompt is generated based on a preset prompt template and the attribute feature, wherein the prompt template is used to prompt the model for the task to be performed.
5. The method according to claim 1, It is characterized in that The obtaining of the initial training text comprises: Acquire an initial text, wherein the initial text refers to a text containing the target extraction object; Performing target extraction on the initial text to obtain the target extraction object; Based on a preset extraction task environment, text generation is performed on the target extraction object to obtain the initial training text, wherein the extraction task environment is used to characterize context information of the initial training text.
6. The method according to claim 5, It is characterized in that The target extraction of the initial text to obtain the target extraction object includes: Get the extracted object features; Performing text cleaning on the initial text to obtain a cleaned text; Based on the extracted object features, keyword extraction is performed on the cleaned text to obtain text keywords; The text keywords are targeted and screened to obtain the target extraction objects.
7. The method according to any one of claims 1 to 6, It is characterized in that The step of training a preset initial object extraction model based on the target training text to obtain a target object extraction model includes: Encoding the target training text based on the initial object extraction model to obtain a text encoding vector, wherein the text encoding vector includes a text word vector; Based on the initial object extraction model, the attention weight of the text word vector is calculated to obtain the word vector weight; Based on the word vector weight, an activation function is calculated on the text word vector to obtain a predicted extraction object; Based on the target extraction object and the predicted extraction object, the initial object extraction model is back-propagated to obtain the target object extraction model.
8. A text information extraction device, It is characterized in that The device comprises: An initial text generation module, used to obtain initial training text, wherein the initial training text refers to the text that marks the target extraction object; A prompt construction module, used to construct an object extraction prompt of the target extraction object based on the initial training text, wherein the extraction prompt is used to prompt the model to extract the object; A target text generation module, used to construct a target training text based on the target extraction object, the object extraction prompt and the initial training text; An extraction model training module is used to train a preset initial object extraction model based on the target training text to obtain a target object extraction model; The text information extraction module is used to obtain a target text containing the target extraction object, and extract information from the target text based on the object extraction prompt and the target object extraction model.
9. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the text information extraction method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the text information extraction method according to any one of claims 1 to 7 is implemented.
