Text processing method and device, electronic equipment and medium
By combining prompt learning and pre-training models, the event extraction task is decomposed into event detection and argument extraction. The event type and trigger word are identified using a large language model, and the argument is extracted through the second prompt word. This solves the problems of high labeling cost and low extraction accuracy in the existing technology, and achieves efficient and low-cost event extraction.
Patent Information
- Application Number
- CN202510424434.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-09-23
AI Technical Summary
Existing technologies require a large amount of annotated text for model fine-tuning in event extraction, resulting in high annotation costs and long time. In addition, when the language description is unclear or the event is difficult to extract, the extraction accuracy is low.
The method combines prompt learning with a pre-trained natural language processing model, generates prompt words to guide the model for event extraction, decomposes the event extraction task into two steps: event detection and argument extraction, uses a large language model to identify event types and trigger words, and extracts arguments through the second prompt word.
Without fine-tuning the model, the accuracy of event extraction is improved, resource consumption and annotation costs are reduced, the complexity of model processing is simplified, and the accuracy of event detection and argument extraction is improved.
Smart Images

Figure CN120688606A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and specifically to a text processing method, device, electronic device, and medium. Background Art
[0002] Event extraction (EE) is a classic information extraction task in natural language processing (NLP). Event extraction refers to extracting structured event knowledge from structured text.
[0003] Currently, humans can annotate massive amounts of text with reference to the events to be extracted to obtain annotated text, and then use the annotated text to fine-tune the pre-trained natural language processing model to improve the event extraction accuracy of the natural language processing model. Summary of the Invention
[0004] In view of the above, it is necessary to provide a text processing method, device, electronic device and medium that can improve the accuracy of event extraction.
[0005] In a first aspect, an embodiment of the present application provides a text processing method, including: determining a first prompt word based on an event description text; inputting the first prompt word and the event description text into a first model for processing to obtain a first event type described by the event description text and a first trigger word of the first event type; determining a second prompt word based on the first event type, the first trigger word and the event description text; inputting the second prompt word and the event description text into a second model for argument extraction to obtain a first argument of the event description text.
[0006] In a second aspect, an embodiment of the present application also provides a file processing device, comprising: a determination module for determining a first prompt word based on an event description text; a processing module for inputting the first prompt word and the event description text into a first model for processing to obtain a first event type described by the event description text and a first trigger word of the first event type; the determination module is also used to determine a second prompt word based on the first event type, the first trigger word and the event description text; the processing module is also used to input the second prompt word and the event description text into a second model for argument extraction to obtain the first argument of the event description text.
[0007] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call the instructions in the memory so that the electronic device executes the above-mentioned text processing method.
[0008] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned text processing method.
[0009] The text processing method provided in the embodiment of the present application determines a first prompt word based on an event description text. The first prompt word can guide the first model to process the event description text to obtain the first event type described by the text and the first trigger word of the type. Then, a second prompt word is determined based on the information obtained by processing the first model and the event description text. The second prompt word can guide the second model to extract arguments from the event description text. This realizes the extraction of text arguments without fine-tuning the model, thereby reducing resource consumption caused by model fine-tuning. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 A schematic diagram of an application environment of a text processing method provided according to an embodiment of the present application.
[0011] Figure 2 The flowchart of the text processing method provided according to one embodiment of the present application is shown.
[0012] Figure 3 The present invention provides a flowchart of a text processing method according to another embodiment of the present application.
[0013] Figure 4 A schematic diagram of a scenario of a text processing method provided according to an embodiment of the present application.
[0014] Figure 5 A flowchart of a method for obtaining a first text example is provided according to an embodiment of the present application.
[0015] Figure 6 A schematic diagram of the configuration of example event extraction data provided according to an embodiment of the present application.
[0016] Figure 7 The present invention provides a flowchart of a text processing method according to another embodiment of the present application.
[0017] Figure 8 A schematic diagram of a scenario of a text processing method provided according to another embodiment of the present application.
[0018] Figure 9 Schematic diagram of the structure of a text processing device provided according to an embodiment of the present application.
[0019] Figure 10 The figure is a schematic structural diagram of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features therein can be combined with each other without conflict.
[0021] In the following description, many specific details are set forth to facilitate a full understanding of the present application. The described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0022] 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 pertains. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0023] It should be further noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0024] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A alone, A and B together, and B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," and so on (if any) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or precedence.
[0025] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0026] Large Language Model (LLM): A natural language processing model with a large number of parameters. Examples include OpenAI's GPT3, GPT4, ChatGLM, and Qwen-14B models. Large language models typically require extensive computing resources and training data to train, enabling them to handle a variety of complex natural language tasks, including language understanding, generation, and translation.
[0027] Prompt learning: Prompt learning is a machine learning technique that uses human-generated prompts to guide model learning. Prompts can include text, images, audio, and other forms. Prompts can help the model understand user needs and generate corresponding output text.
[0028] Chain-of-thought (CoT) simulates the way humans think by breaking down a problem into a series of sub-problems to find the best way to solve the problem.
[0029] Few-Shot COT: Combines few-shot learning with COT, using a small number of labeled samples and reasoning chains to guide model learning, thereby enhancing the model's reasoning ability.
[0030] Trigger words: The core words that trigger an event, mostly verbs and nouns.
[0031] Event detection refers to identifying the type of event described by the text and the trigger words of the event, such as "delayed delivery" and "overdue payment".
[0032] An argument refers to a participant in an event. In a text, an argument is generally an entity or concept closely related to a predicate or verb. The argument plays a specific role in the event and participates in the action expressed by the predicate or verb.
[0033] Argument role: The role played by the argument in the event.
[0034] Argument extraction refers to detecting the arguments of an event and determining their argument roles.
[0035] Currently, pre-trained natural language processing models, such as pre-trained language models, can be used to achieve event extraction. For example, manually annotating event types, trigger words, arguments, and argument roles in text to generate massive amounts of annotated text can then be used to fine-tune the pre-trained large language model, thereby improving its accuracy in event extraction tasks.
[0036] However, the above-mentioned annotated text needs to include complex annotation information such as event type and trigger words, which leads to high annotation cost and long annotation time.
[0037] Therefore, an embodiment of the present application provides a text processing method that can combine prompt learning with a pre-trained natural language processing model, and use prompt words to guide the natural language processing model to perform event extraction.
[0038] The following first describes the application environment applicable to the embodiment of this application. Figure 1 , Figure 1 A schematic diagram of an application environment of a text processing method provided in an embodiment of the present application is shown.
[0039] The text processing method provided in the embodiment of the present application is applied to an electronic device 10 and a terminal device 20, wherein the electronic device 10 can be connected to the terminal device 20 via a network. The network is used to provide a communication link between the electronic device 10 and the terminal device 20. The network can include various connection types, such as wired communication links, wireless communication links, etc., which are not limited in the embodiment of the present application.
[0040] It should be understood that Figure 1 The electronic device 10, network and terminal device 20 are merely illustrative. In the embodiment of the present application, the number of the electronic device 10 and terminal device 20 is not limited.
[0041] In the embodiments of the present application, the electronic device 10 may be a server, which may be a physical server or a server cluster composed of multiple servers. The terminal device 20 may be a mobile phone, tablet, desktop computer, laptop computer, etc. It is understood that the embodiments of the present application may also allow multiple terminal devices 20 to access the electronic device 10 simultaneously.
[0042] For example, the terminal device 20 may provide a front-end interface and receive event description text, such as a breach of contract liability text, from the front-end interface. Furthermore, the terminal device 20 sends the event description text to the electronic device 10 via the network. After the electronic device 10 receives the text, it may extract events from the event description text using the text processing method described in the embodiments of the present application.
[0043] In other embodiments, the electronic device may also be Figure 1 The terminal device 20 shown in FIG. 20 can provide a front-end interface, receive the text to be extracted from the front-end interface, or obtain the event description text from the server. Then, the text processing method provided in the embodiment of the present application is used to extract the event from the event description text.
[0044] The above application environment is only an example and the embodiments of the present application are not limited to this.
[0045] Figure 2 This is a flowchart of the text processing method provided by the embodiment of the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted. Figure 2 As shown, the text processing method may include the following steps.
[0046] S201, obtaining event description text.
[0047] In the embodiment of the present application, the event description text is the text to be extracted. For example, the event description text can be a contract text, a news report, a current affairs commentary, an academic paper, a technical report, a forum post, and a diagnostic report. S202: Obtain a first prompt word based on a prompt word template and an event description text.
[0048] In an embodiment of the present application, the preset prompt word template corresponding to the event extraction and the event description text are combined to obtain the first prompt word corresponding to the event extraction. Among them, the prompt word template is an instruction framework that guides the model to perform event extraction, which usually includes task definition, input description, output format and example reference. Among them, the task definition is used to clarify the specific tasks that the model needs to complete (such as event type identification, feature extraction). The input description is used to describe the input text type and content range. The output format is used to specify the structured data format returned by the model (such as JSON, key-value pairs). The example reference can provide a small number of examples (Few-shot Learning) to assist the model in understanding the requirements.
[0049] In an embodiment of the present application, the prompt word template may include descriptive information of the event extraction task, the event type of the event to be extracted, the situation in which the event of this type occurs, the trigger word of the situation, the argument type to be extracted, etc. The prompt word template may also include at least one event extraction example, which may include an event extraction text example and the event extraction result of the event extraction text example. By adding event extraction examples to the prompt word template, the large language model can be further guided to perform event extraction, thereby improving the accuracy of event extraction.
[0050] S203: Input the first prompt word and the event description text into the first model for processing to obtain an event extraction result.
[0051] In this embodiment of the present application, the first model can be a pre-trained large language model used to perform event extraction. The event extraction results include various types of events described by the event description text, as well as the arguments of each event. The first prompt word and the event description text are input into the first model for processing to obtain the event extraction results.
[0052] The following uses the event description text as a contract breach liability text as an example to illustrate the process of extracting contract breach events from the contract breach liability text, as well as the prompt word template used in the process.
[0053] In some embodiments of the present application, prompt word templates can be defined by the electronic device for the contract breach events to be extracted. Specifically, the breach circumstances and trigger words in the contract breach events can be defined. For example, if the breach is delayed delivery, the corresponding trigger words may include failure to deliver on time, late completion, and overdue delivery; if the breach is overdue payment, the corresponding trigger words may include delayed payment, failure to pay fees on time as agreed, and overdue payment.
[0054] In some embodiments of the present application, the arguments in the contract breach event can also be defined by the electronic device. For the extraction of the contract breach event, the arguments can include the breach situation, the breaching party, and the breach liability.
[0055] In some embodiments of the present application, several event extraction examples of contract breach events may be selected by the electronic device and added to the prompt word template.
[0056] For example, the prompt word template may be as follows: "Task Description: You are currently a contract review expert. Your task is to extract all breach of contract events, along with the corresponding breach circumstances, breaching parties, and punitive measures, from the contract breach liability text.
[0057] Definition of contract breach event: Delayed delivery: refers to the delay in delivering goods and failure to complete tasks on time.
[0058] Late payment: refers to failure to pay on the agreed time.
[0059] … An example of event extraction for a contract breach event is as follows: Event extraction example 1: Event extraction example 2: Please output the results in the following format: - Event of Default 1-: <Breach of Contract, Breaching Party, Penalty Measures> - Event of Default 2-: <Breach of Contract, Breaching Party, Penalty Measures> … Event description text: {Contract breach liability text}." In some embodiments of the present application, the electronic device can store the above-mentioned prompt word template. When event extraction is required, the electronic device can obtain the contract breach liability text, combine the contract breach liability text and the prompt word template to obtain the event extraction prompt word; input the prompt word into the first model to obtain the event extraction result of the contract breach event.
[0060] The text processing method provided in the embodiment of the present application can improve the accuracy of event extraction by adopting the first prompt word corresponding to event extraction to guide the pre-trained first model to perform event extraction. There is no need to rely on massive annotated text to fine-tune the first model, and low-cost, high-precision event extraction can be achieved.
[0061] However, when the language description of the text for event extraction is unclear, or when the first model encounters events that are difficult to extract, it is difficult for the first model to accurately extract various types of events and the arguments corresponding to various types of events from the text at one time, which leads to incorrect or incomplete event extraction results.
[0062] For example, when the description of the contractual liability for breach of contract is not clear enough, the first model may not be able to extract the breach circumstances, breaching party, penalty measures, etc. of the breach event at one time.
[0063] In view of the above, the embodiments of the present application also provide a text processing method, device, electronic device and medium for solving the above problems. Figure 3 FIG. 1 is a flowchart of another text processing method provided by an embodiment of the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.
[0064] S301: Determine a first prompt word based on an event description text.
[0065] In an embodiment of the present application, to address the low accuracy of event extraction from event description text using a large model, event detection can be performed on the event description text to obtain event detection results; then, argument extraction can be performed based on the event detection results to obtain event extraction results. For example, when performing event extraction on a contract breach liability document, the breach event extraction problem can be broken down into two steps: first, breach event detection can be performed; then, argument extraction can be performed based on the breach event detection results to obtain the final event extraction results.
[0066] In an embodiment of the present application, before performing event detection on an event description text, it is necessary to determine a first prompt word based on the event description text. Specifically, determining the first prompt word based on the event description text includes: obtaining a first text example, wherein the first text example includes a second event type described by the text example, a second trigger word of the second event type, and a second argument; and generating the first prompt word based on the first text example, the second event type, the second trigger word, the event description text, and a preset first prompt word template.
[0067] In an embodiment of the present application, a first prompt word is generated based on a first text example, a second event type, a second trigger word, an event description text, and a preset first prompt word template, including: determining first association information between the first text example and the second event type and the second trigger word; based on the first association information and the first prompt word template, determining the first prompt word from the event description text.
[0068] In an embodiment of the present application, the first prompt word is used to describe the second event type that the first model needs to identify and the second trigger word of the second event type. The first model is a pre-trained event detection model, such as a large language model.
[0069] In some embodiments, the first association information and a preset first prompt word template may be combined to obtain the first prompt word.
[0070] The first prompt word template may include: description information of the event detection task, definition of the event type to be detected, output format of the event detection result, etc., but is not limited thereto. In actual application, it can be set according to needs.
[0071] For example, the first prompt word template may further include a text example. The text example may further include the first text example and an event detection result of the first text example. The event detection result includes a second event type, a second trigger word of the second event type, and a second argument. The format of the event detection result of the first text example may be consistent with the format of the event detection result set in the first prompt word template.
[0072] For example, assuming that the event description text is a contract breach liability text, the first model needs to detect the second event type of contract breach and its corresponding second trigger word from the contract breach liability text. The first prompt word template can be as follows: Task Description: You are a contract intelligence review expert and need to extract a list of breach of contract event types and their trigger words from the input text.
[0073] Definitions of each type of Event of Default: Delayed delivery: refers to the delay in delivering goods and failure to complete tasks on time.
[0074] Late payment: refers to failure to pay on the agreed time.
[0075] … The following is an example text: {Text Example 1} {Text Example 2} End of example.
[0076] Please output the results in the following format: {event type, trigger word} Event description text: {Breach of contract liability text}".
[0077] In an embodiment of the present application, the first prompt word template is further defined with a text example, so that the first model can be guided more carefully to perform event detection according to the text example, thereby further improving the accuracy of event detection.
[0078] In some embodiments, the above text example may be a fixed example set in the first prompt word template.
[0079] In other embodiments, reference Figure 4 As shown, the electronic device may also determine a first text example according to the event description text, and then fill the first text example and the event description text into a first prompt word template to obtain a first prompt word.
[0080] In an embodiment of the present application, there are multiple methods for obtaining a first text example. The first text example can be obtained by a clustering algorithm, for example, by a K-means clustering algorithm. Specifically, obtaining the first text example includes: determining the similarity between the event description text and N pre-stored text examples to obtain N similarities, where N is an integer greater than 1; selecting M second text examples from the N text examples, where the similarity between the second text example and the event description text is greater than or equal to a preset threshold, where M is an integer greater than 1 and less than or equal to N; dividing the M similarities corresponding to the M second text examples into P clusters, where P is an integer greater than 1 and less than or equal to M; and selecting at least one second text example corresponding to a similarity in each cluster as the first text example.
[0081] In some embodiments of the present application, the first text example can also be determined based on the event description text. For specific methods, please refer to the following: Figure 5 S302: Input the first prompt word and the event description text into the first model for processing to obtain the first event type described by the event description text and the first trigger word of the first event type.
[0082] In an embodiment of the present application, the first prompt word and the event description text are input into the first model to obtain an event detection result of the event description text, wherein the event detection result includes a first event type and a first trigger word of the first event type.
[0083] In an embodiment of the present application, the first model is a pre-trained large language model, which is used to perform event detection on event description files. The training method of the first model is an existing training method and will not be repeated here. In an embodiment of the present application, the first model includes multiple, and the first prompt word and the event description text can be input into multiple first models for processing to obtain the first event type described by the event description text and the first trigger word of the first event type. Specifically, the first prompt word and the event description text are input into multiple first models to obtain multiple first output results; the first target output result in the multiple first output results is determined as the first event type. The first number of the first target output results in the multiple first output results is greater than or equal to the first preset threshold. The second target output result in the multiple first output results is determined as the first trigger word. The second number of the second target output results in the multiple first output results is greater than or equal to the second preset threshold.
[0084] S303: Determine a second prompt word based on the first event type, the first trigger word, and the event description text.
[0085] In this embodiment of the present application, after performing event detection on the event description text and obtaining the event detection results, argument extraction is performed based on the event detection results. Specifically, a second prompt word is determined based on the first event type, the first trigger word, and the event description text, and argument extraction is then performed based on the second prompt word.
[0086] In this embodiment of the present application, determining the second prompt word based on the first event type, the first trigger word, and the event description text includes: generating the second prompt word based on the first text example, the second argument, the event description text, the first event type, the first trigger word, and a preset second prompt word template. Specifically, determining second association information between the first text example and the second argument; and determining the second prompt word from the event description text based on the second association information, the first event type, the first trigger word, and the second prompt word template.
[0087] S304: Input the second prompt word and the event description text into the second model to extract arguments, and obtain the first argument of the event description text.
[0088] In an embodiment of the present application, the second prompt word and the event description text may be input into a pre-trained second model to obtain an argument detection result for the event description text, the argument detection result including the first argument. The argument detection result includes arguments for various types of events.
[0089] The argument extraction results and event detection results can reflect the event extraction results. The event extraction results of the event description text can include: various types of events described in the event description text, and the arguments of each event.
[0090] For example, the event extraction results can be described as follows: {Event type 1, breach of contract 1, breaching party 1, penalty measure 1}; {Event type 2, breach of contract 2, breaching party 2, penalty measures 2}.
[0091] The embodiment of the present application generates corresponding event detection prompt words and argument extraction prompt words based on the event description text, so as to guide the pre-trained event detection model and argument extraction model to perform event extraction on the event description text. Even without fine-tuning the pre-trained event detection model and argument extraction model, the accuracy of the event detection model and argument extraction can be improved, and the time consumption caused by model fine-tuning and the manpower consumption caused by data labeling can be reduced.
[0092] In an embodiment of the present application, the text processing method determines a first prompt word based on the event description text, and the first prompt word can be used to guide the first model to process the event description text to obtain the first event type and the first trigger word of the type described by the text. Then, based on the information obtained by the first model processing and the event description text, a second prompt word is determined, and the second prompt word can be used to guide the second model to extract arguments from the event description text. It is achieved that the argument extraction of the text can be achieved without fine-tuning the model, reducing the resource consumption caused by model fine-tuning. In addition, the embodiment of the present application splits the complex event extraction task into two simple tasks, event detection and argument extraction, which simplifies the complexity of the tasks processed by the model and is conducive to improving the accuracy of the model on the two simple tasks.
[0093] In an embodiment of the present application, the event description text can also be split into Q subtexts first, and then the Q subtexts are subjected to file processing to obtain the first argument. The event description text is a complete text. Specifically, the event description text is split into Q subtexts based on a preset model, where Q is an integer greater than 1; based on the Q subtexts, Q first prompt words are determined, where one subtext corresponds to one first prompt word; based on each subtext and the first prompt word corresponding to the subtext, the first model is input for processing to obtain the first event type described by each subtext and the first trigger word of the first event type; based on the first event type and the first trigger word corresponding to each subtext, and each subtext, a second prompt word is determined; the second prompt word and each corresponding subtext are input into the second model for argument extraction to obtain the first argument of the subtext.
[0094] In this embodiment of the present application, by splitting the complete event description text, content describing the same event type is grouped into the same event description text, which helps reduce the complexity of the data processed by the first and second models at one time. Furthermore, it helps to adaptively determine the corresponding first prompt word for each subtext, further improving the accuracy of event extraction.
[0095] In some embodiments of this application, reference Figure 5 As shown, determining the first text example according to the event description text may further include: Step S501: Acquire multiple candidate first text examples, wherein each candidate first text example includes a candidate text example, a second event type corresponding to the candidate text example, and a second trigger word of the second event type.
[0096] In some embodiments, the electronic device may obtain a plurality of candidate first text examples from a database.
[0097] Among them, reference Figure 6 As shown, the database stores a plurality of candidate first text examples and a plurality of candidate second text examples. The candidate second text examples include the candidate text examples and the first arguments corresponding to the candidate text examples.
[0098] In an embodiment of the present application, the configuration method for storing data in the database may include: determining the event type corresponding to the event to be extracted. For example, assuming that a contract breach liability text is to be extracted, the extracted event types may include M types. For each event type, candidate first text examples corresponding to the candidate text examples, event detection results for the candidate text examples, and argument extraction results for the candidate first text examples are collected. The candidate first text examples may be contextual description text for the event type.
[0099] For example, for event type 1, K candidate first text examples, target detection results and argument extraction results of K candidate first text examples 1 are collected, and the K candidate first text examples 1 are all used to describe events belonging to event type 1; for event type 2, K candidate first text examples, target detection results and argument extraction results of K candidate first text examples 2 are collected, and the K candidate first text examples 2 are all used to describe events belonging to event type 2.
[0100] The value of K can be set according to actual application requirements. For example, for event types that are more difficult to extract, K can be set to a larger value, such as K=15. For event types that are easier to extract, the value of K can be set to a smaller value, such as K=5.
[0101] In some embodiments, continue to refer to Figure 6As shown, after collecting the candidate first text example and the candidate second text example, these data can also be input into the text representation model to obtain vector representations of the candidate first text example and the candidate second text example respectively, and the vector representations are stored in the database to facilitate text similarity calculation.
[0102] The text representation model may be a GTE model, a Word2Vec model, a GloVe model, etc., but is not limited thereto.
[0103] Step S502 : calculating similarities between the event description text and multiple candidate first text examples respectively to obtain multiple similarities.
[0104] For example, the electronic device may obtain a first vector representation and a second vector representation, where the first vector representation is a vector representation of the event description text, and the second vector representation is a vector representation of the candidate first text example. For example, the electronic device may input the event description text into a text representation model to obtain the first vector representation; then retrieve the second vector representation from a database. The electronic device then calculates the similarity between the first vector representation and the second vector representation to obtain the similarity between the event description text and the candidate first text example.
[0105] In some embodiments of the present application, the cosine similarity or Euclidean distance between the first vector representation and the second vector representation may be used as the similarity between the event description text and the candidate text example.
[0106] Step S503 : selecting at least one candidate first text example from the plurality of candidate first text examples as the first text example based on the plurality of similarities.
[0107] In some embodiments of the present application, multiple similarities are arranged in descending order, and multiple candidate first text examples are sorted according to the order of the similarities. The first i candidate first text examples are selected as the first text examples in this order. Where i is a positive integer greater than 1 and can be set according to actual application requirements, for example, to 5.
[0108] In some embodiments of the present application, i candidate first text examples that are most similar to the event description text may be searched in a database as the first text examples.
[0109] The embodiment of the present application searches for an event description text example that is highly similar to the event description text as the first text example, which can increase the context understanding capability of the first model and further improve the accuracy of argument extraction.
[0110] refer to Figure 7As shown, the embodiment of the present application also provides a text processing method. In this embodiment, the electronic device can obtain the original text, split the original text into several text segments, and extract events based on each text segment, thereby obtaining the event extraction result of the original text. Specifically, combined with Figure 7 and Figure 8 As shown, the text processing method includes: Step S701: Obtain original text.
[0111] Step S702: split the original text into multiple text segments.
[0112] In some embodiments, the electronic device may obtain a title level corresponding to each title in the original text, and segment the original text based on the title level to obtain multiple text segments. For example, the original text may be segmented based on level three titles to obtain multiple text segments.
[0113] For example, the electronic device can use a text segmentation model to determine the title hierarchy corresponding to each title in the original text, and then segment the original text. The text segmentation model can use a large language model, and the number of text segments generated can be set based on actual application requirements such as the length of the original text. For example, the total number of text segments can be set to no more than 10.
[0114] Step S703: Select one of the multiple text segments as the event description text.
[0115] Step S704: Determine a first prompt word based on the event description text.
[0116] Step S705: Input the first prompt word and the event description text into the first model for processing to obtain the first event type described by the event description text and the first trigger word of the first event type.
[0117] Step S706: Determine a second prompt word based on the first event type, the first trigger word, and the event description text.
[0118] Step S707: Input the second prompt word and the event description text into the second model to extract arguments, and obtain the first argument of the event description text.
[0119] The specific implementation of steps S704-S707 can refer to Figure 3 The implementation methods of S301-S304 are not described here in detail.
[0120] Step S708: Determine whether all of the multiple text segments serve as event description texts.
[0121] In the embodiment of the present application, if it is determined that there are fragments in the multiple text fragments that have not been extracted as event description texts, the process returns to S703; if the multiple text fragments have all been extracted as event description texts, step S709 is executed.
[0122] Step S709: taking the first arguments of the multiple text segments as the argument extraction results of the original text. The embodiment of the present application splits the original text into several segments, which is beneficial to reducing the complexity of the data processed by the event detection model and the argument extraction model at one time. Moreover, it can also adaptively determine the corresponding prompt words for each text segment, further increasing the accuracy of event extraction.
[0123] Furthermore, the embodiment of the present application divides the event description text according to the title level. Generally speaking, the event types described by the texts belonging to the same title level are the same or similar, and the event types described by the texts belonging to different title levels are different. Therefore, this division method is conducive to realizing text division according to event type, so that the first prompt word and the second prompt word can be adaptively determined for the text corresponding to different event types, making the prompt word more accurate, thereby further improving the accuracy of event extraction.
[0124] Based on the same concept as the text processing method in the above embodiment, the present application also provides a file processing device that can be used to execute the above text processing method. For ease of explanation, the structural diagram of the file processing device embodiment only shows the parts related to the embodiment of the present application. Those skilled in the art will understand that the illustrated structure does not constitute a limitation of the device, and it may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0125] Figure 9 is a structural diagram of a text processing device provided in an embodiment of the present application. The text processing device 900 may include multiple functional modules composed of computer program segments. The computer program of each program segment in the text processing device 900 may be stored in a memory of a computer device and executed by at least one processor to perform (see Figure 3 Description) text processing functions.
[0126] In this embodiment, the text processing device 900 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a determination module 901 and a processing module 902. The module referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in the memory. In this embodiment, the text processing device 900 can be used to implement the following Figure 2 and Figure 3 and Figure 7The text processing method shown in Figure 9 As shown, the text processing device 900 is applied to an electronic device (such as Figure 1 In the electronic device shown in FIG. 1 , the text processing device 900 includes: The determining module 901 is used to determine a first prompt word based on the event description text; The processing module 902 is configured to input the first prompt word and the event description text into a first model for processing to obtain a first event type described by the event description text and a first trigger word of the first event type; The determining module 901 is further configured to determine a second prompt word based on the first event type, the first trigger word, and the event description text; The processing module 902 is further configured to input the second prompt word and the event description text into a second model to perform argument extraction, thereby obtaining a first argument of the event description text.
[0127] The determination module 901 is also used to obtain a first text example, wherein the first text example includes a second event type described by the text example, a second trigger word of the second event type, and a second argument; and generate the first prompt word based on the first text example, the second event type, the second trigger word, the event description text, and a preset first prompt word template.
[0128] The processing module 902 is further configured to determine first association information between the first text example, the second event type, and the second trigger word; and determine the first prompt word from the event description text based on the first association information and the first prompt word template.
[0129] The determination module 901 is further configured to generate the second prompt word based on the first text example, the second argument, the event description text, the first event type, the first trigger word, and a preset second prompt word template.
[0130] The processing module 902 is also used to determine second association information between the first text example and the second argument; based on the second association information, the first event type, the first trigger word and the second prompt word template, determine the second prompt word from the event description text.
[0131] The processing module 902 is also used to determine the similarity between the event description text and N pre-stored text examples, obtaining N similarities, where N is an integer greater than 1; selecting M second text examples from the N text examples, where the similarity between the second text examples and the event description text is greater than or equal to a preset threshold, where M is an integer greater than 1 and less than or equal to N; dividing the M similarities corresponding to the M second text examples into P clusters, where P is an integer greater than 1 and less than or equal to M; and selecting at least one second text example corresponding to a similarity in each cluster as a first text example.
[0132] The processing module 902 is also used to input the first prompt word and the event description text into the first model for processing to obtain the first event type described by the event description text and the first trigger word, including: inputting the first prompt word and the event description text into multiple first models to obtain multiple first output results; determining the first target output result among the multiple first output results as the first event type, and the first number of the first target output results in the multiple first output results is greater than or equal to a first preset threshold; determining the second target output result among the multiple first output results as the first trigger word, and the second number of the second target output result in the multiple first output results is greater than or equal to a second preset threshold.
[0133] Figure 10 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. As shown in the figure, the electronic device 10 can be a server. For example, the electronic device 10 can be a central server, an edge server, or a local server in a local data center. Each electronic device 10 may include a communication module 101, a memory 102, a processor 103, an input / output (I / O) interface 104 and a bus 105. The processor 103 is coupled to the communication interface 101, the memory 102, and the I / O interface 104 respectively through the bus 105.
[0134] The communication module 101 may include a wired communication module and / or a wireless communication module. The wired communication module may provide one or more wired communication solutions such as universal serial bus (USB) and controller area network (CAN). The wireless communication module may provide one or more wireless communication solutions such as wireless fidelity (Wi-Fi), Bluetooth (BT), mobile communication network, frequency modulation (FM), near field communication (NFC), infrared (IR), etc.
[0135] Memory 102 may include one or more random access memories (RAMs) and one or more non-volatile memories (NVMs). The RAM can be directly read and written by the processor 103 and can be used to store executable programs (e.g., machine instructions) for the operating system or other running programs, as well as user and application data. RAM may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), etc.
[0136] The non-volatile memory can also store executable programs and user and application data, etc., and can be pre-loaded into the random access memory for direct reading and writing by the processor 103. The non-volatile memory can include disk storage devices and flash memory.
[0137] The memory 102 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 103. The one or more computer programs include multiple instructions. When the multiple instructions are executed by the processor 103, the text processing method executed on the electronic device 10 can be implemented.
[0138] In other embodiments, the electronic device 10 further includes an external memory interface for connecting to an external memory to expand the storage capacity of the electronic device 10 .
[0139] The processor 103 may include one or more processing units. For example, the processor 103 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0140] The processor 103 provides computing and control capabilities. For example, the processor 103 is used to execute computer programs stored in the memory 102 .
[0141] The I / O interface 104 is used to provide a channel for user input or output. For example, the I / O interface 104 can be used to connect various input and output devices, such as a mouse, keyboard, touch device, display screen, etc., so that the user can enter information or visualize information.
[0142] The bus 105 is at least used to provide a channel for mutual communication among the communication module 101 , the memory 102 , the processor 103 , and the I / O interface 104 in the electronic device 10 .
[0143] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 10. In other embodiments of the present application, the electronic device 10 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0144] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the methods in the above-mentioned embodiments of the present application.
[0145] The computer-readable storage medium may be an internal memory of the electronic device described in the above embodiment, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, etc. equipped on the electronic device.
[0146] In some embodiments, the computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system, applications required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc.
[0147] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0148] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0149] In the embodiments provided in this application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that 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.
[0150] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0151] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. A text processing method, characterized in that: include: Determining a first prompt word based on the event description text; Inputting the first prompt word and the event description text into a first model for processing to obtain a first event type described by the event description text and a first trigger word of the first event type; Determining a second prompt word based on the first event type, the first trigger word, and the event description text; The second prompt word and the event description text are input into a second model for argument extraction to obtain a first argument of the event description text.
2. The text processing method according to claim 1, wherein: The determining of the first prompt word based on the event description text includes: Obtaining a first text example, wherein the first text example includes a second event type described by the text example, a second trigger word of the second event type, and a second argument; The first prompt word is generated based on the first text example, the second event type, the second trigger word, the event description text, and a preset first prompt word template.
3. The text processing method according to claim 2, wherein: The generating the first prompt word based on the first text example, the second event type, the second trigger word, the event description text, and a preset first prompt word template includes: Determining first association information between the first text example, the second event type, and the second trigger word; The first prompt word is determined from the event description text based on the first association information and the first prompt word template.
4. The text processing method according to claim 2, wherein: The determining of the second prompt word based on the first event type, the first trigger word, and the event description text includes: The second prompt word is generated based on the first text example, the second argument, the event description text, the first event type, the first trigger word and a preset second prompt word template.
5. The text processing method according to claim 4, wherein: The generating of the second prompt word based on the first text example, the second argument, the event description text, the first event type, the first trigger word, and a preset second prompt word template includes: determining second association information between the first text example and the second argument; The second prompt word is determined from the event description text based on the second association information, the first event type, the first trigger word, and the second prompt word template.
6. The text processing method according to claim 2, wherein: The obtaining of the first text example includes: Determine the similarity between the event description text and N pre-stored text examples to obtain N similarities, where N is an integer greater than 1; Selecting M second text examples from the N text examples, wherein the similarity between the second text examples and the event description text is greater than or equal to a preset threshold, where M is an integer greater than 1 and less than or equal to N; Dividing the M similarities corresponding to the M second text examples into P clusters, where P is an integer greater than 1 and less than or equal to M; In each of the clusters, at least one second text example corresponding to the similarity is selected as the first text example.
7. The text processing method according to any one of claims 1 to 6, characterized in that: The first model includes multiple items; the first prompt word and the event description text are input into the first model for processing to obtain the first event type described by the event description text and the first trigger word, including: Inputting the first prompt word and the event description text into a plurality of first models to obtain a plurality of first output results; determining a first target output result among the plurality of first output results as the first event type, wherein a first number of the first target output results among the plurality of first output results is greater than or equal to a first preset threshold; A second target output result among the multiple first output results is determined as the first trigger word, and a second number of the second target output results among the multiple first output results is greater than or equal to a second preset threshold.
8. A text processing device, characterized in that: include: A determination module, configured to determine a first prompt word based on the event description text; a processing module, configured to input the first prompt word and the event description text into a first model for processing, to obtain a first event type described by the event description text and a first trigger word of the first event type; The determining module is further configured to determine a second prompt word based on the first event type, the first trigger word, and the event description text; The processing module is further configured to input the second prompt word and the event description text into a second model to perform argument extraction to obtain a first argument of the event description text.
9. An electronic device comprising a processor and a memory, characterized in that: The memory is used to store instructions, and the processor is used to call the instructions in the memory, so that the electronic device executes the text processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the text processing method according to any one of claims 1 to 7.
Citation Information
Cited By
Power grid operation event extraction and disposal method and system based on large language model
CN121210629A