Multi-task information extraction method and device based on thinking chain and ranking learning
Through a multi-task information extraction method based on thinking chain and ranking learning, through splicing instructions and thinking chain examples as input data, standard fine-tuning and ranking learning of the target model is solved, and the problems of high dependence on labeled data in the existing technology are solved, achieving efficient and controllable information extraction.
Patent Information
- Application Number
- CN202510707182.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-08-12
AI Technical Summary
Existing information extraction methods rely too much on labeled data, resulting in high cost and low interpretability, and optimization is uncontrollable.
A multi-task information extraction method based on thinking chain and ranking learning is adopted. By determining multiple constraints, the instructions and thinking chain examples are spliced with the target text as input data, the target model is standard fine-tuned, and inference sampling and ranking learning are performed at the preset temperature to generate intermediate data sets and optimize the target model.
Reliance on labeled data is reduced, interpretability of the information extraction process is increased, and controllable optimization is achieved, improving the accuracy and efficiency of information extraction.
Smart Images

Figure CN120471050A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a multi-task information extraction method and device based on thought chaining and ranking learning. Background Art
[0002] Information extraction is a key task in natural language processing, aiming to extract structured information from unstructured text to help computers process and understand human language more efficiently. Its core tasks include named entity recognition, relationship extraction, and event extraction. The goal of these tasks is to transform complex natural language content into computer-friendly data representations to support upper-level applications. Information extraction technology has a wide range of applications in multiple fields: in search engines, information extraction can extract key information from user queries and document content to improve the relevance of search results; in business intelligence, it can extract key information from documents such as contracts and financial reports to assist companies in making efficient decisions; in medical information processing, it can extract information such as diseases, symptoms, and drugs from case histories and medical literature to support clinical diagnosis and drug development; in addition, information extraction can identify sentiment trends and event dynamics in social media, helping companies monitor social hot spots.
[0003] Traditional information extraction methods rely primarily on handcrafted rules and templates, such as regular expressions or domain-specific knowledge, to define extraction patterns. These rules, based on linguistic knowledge and specialized domain expertise, can meet certain requirements to a certain extent, but they lack adaptability and scalability, making them difficult to address the demands of large-scale data processing and cross-domain applications. In recent years, with the development of machine learning, particularly deep learning, information extraction technology has made significant progress. Machine learning-based methods can automatically learn effective feature representations and pattern recognition capabilities from large amounts of annotated data, enabling high-precision extraction of diverse entity and relation types. The introduction of pre-trained language models (such as BERT, GPT, and RoBERTa) has led to unprecedented improvements in information extraction. These models are pre-trained on large-scale general corpora to learn rich semantic representations, and can be adapted to specific tasks with minimal fine-tuning, significantly simplifying the complexity of feature engineering. Although information extraction technology has made significant progress, there are still some problems that are difficult to ignore: the training of deep learning models requires a large amount of high-quality annotated data, but in many professional fields (such as medicine, law, scientific literature, etc.), the cost of obtaining annotated data is extremely high. In addition, the quality of annotated data directly affects the performance of the model; because the generative model (such as GPT or T5) is based on complex neural network calculations, the logic and process of its generation results are difficult to be directly explained. When the information extraction results are wrong, it is difficult to identify the problem; the pre-trained language model has a strong black box nature, and it is difficult to optimize it in a targeted manner when erroneous information extraction results occur.
[0004] Therefore, an information extraction method is urgently needed to solve the problems of over-reliance on labeled data, low interpretability, and uncontrollable optimization in existing information extraction methods. Summary of the Invention
[0005] The present invention provides a multi-task information extraction method and device based on thought chain and ranking learning, which are used to solve the defects of information extraction in the prior art, such as excessive reliance on labeled data, low interpretability, and uncontrollable optimization.
[0006] The present invention provides a multi-task information extraction method based on thought chaining and ranking learning, comprising the following steps: Determine multiple constraints based on the information extraction task requirements; splicing the instruction, the thought chain example and the target text as input data, wherein the thought chain example is an example of a thought chain style information extraction step, and the thought chain style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; Based on the input data, standard fine-tuning is performed on the target model to obtain a fine-tuned target model; Performing inference sampling at a preset temperature on the fine-tuning target model to generate an intermediate data set, and then determining a new training data set based on the intermediate data set; Performing ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; Perform inference sampling using different preset temperatures, iteratively train the optimization target model, and obtain an information extraction model; The information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model.
[0007] According to a multi-task information extraction method based on thought chain and ranking learning provided by the present invention, the constraints include general constraints and specific constraints; the general constraints are universal constraints; the specific constraints are constraints related to the task type or the field to which the task belongs.
[0008] According to a multi-task information extraction method based on thought chain and ranking learning provided by the present invention, the general constraints include at least one of a first constraint condition, a second constraint condition and a third constraint condition, the first constraint condition is that the extracted object comes from a specified text, the second constraint condition is that the object type is within a specified range, and the third constraint condition is that the information extraction result has a specified data structure.
[0009] According to a multi-task information extraction method based on thought chain and ranking learning provided by the present invention, the specificity constraint includes at least one of the fourth constraint condition, the fifth constraint condition, the sixth constraint condition, the seventh constraint condition, the eighth constraint condition and the ninth constraint condition; The fourth constraint condition is that the entity type corresponding to the entity relationship belongs to a specified type; The fifth constraint condition is an exclusion constraint between entity types and entity relationship types; The sixth constraint condition is a constraint on the context corresponding to a specified grammatical structure; The seventh constraint condition is a consistency constraint of time and / or spatial position; The eighth constraint condition is that the entity relationship corresponds to a specified number of entities; The ninth constraint is an order constraint.
[0010] According to the present invention, a multi-task information extraction method based on thought chaining and ranking learning is provided, and the multi-task information extraction method based on thought chaining and ranking learning also includes: For any set of labels for a piece of training data, the constraint evaluator is used to calculate the corresponding constraint score based on the following steps: Obtaining information extraction results of the thought chain style corresponding to the training data; determining a first constraint score based on the plurality of constraints; determining a second constraint score based on the information extraction result of the thought chain style; Based on preset weights, the first constraint score and the second constraint score are weightedly calculated to obtain a constraint score.
[0011] According to a multi-task information extraction method based on thought chaining and ranking learning provided by the present invention, the loss function of the ranking learning is as follows: ; ; ; in, is the fine-tuning loss function, Expressing arrive All time steps are accumulated, Represents a given input and all previous tags , the model predicts the current time step Tags The logarithm of the probability of is the ranking loss function, It's a label The constraint score, It's a label The constraint score, It's a label The probability of generating It's a label The probability of generation; is the weight parameter, is the loss function for ranking learning.
[0012] The present invention also provides a multi-task information extraction device based on thought chain and ranking learning, comprising the following modules: The constraint determination module is used to: determine multiple constraint conditions based on the information extraction task requirements; An input generation module is configured to: concatenate instructions, thought chain examples, and target text as input data, wherein the thought chain examples are examples of a thought chain-style information extraction step, wherein the thought chain-style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; A standard fine-tuning module is used to: perform standard fine-tuning on the target model based on the input data to obtain a fine-tuned target model; An inference sampling module is configured to perform inference sampling at a preset temperature on the fine-tuning target model, generate an intermediate data set, and then determine a new training data set based on the intermediate data set; A ranking learning module is used to: perform ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; An iterative training module is used to perform inference sampling using different preset temperatures and iteratively train the optimization target model to obtain an information extraction model; The information extraction module is used to: input the information to be extracted into the information extraction model to obtain the information extraction result output by the information extraction model.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the multi-task information extraction method based on thought chaining and ranking learning as described above is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the multi-task information extraction methods based on thought chaining and ranking learning as described above.
[0015] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above-described multi-task information extraction methods based on thought chaining and ranking learning.
[0016] The multi-task information extraction method and device based on thought chain and ranking learning provided by the present invention determine multiple constraints based on the information extraction task requirements; splice instructions, thought chain examples and target text as input data, and the thought chain example is an example of an information extraction step with a thought chain style, and the information extraction step with a thought chain style includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition result and the entity relationship recognition result. By splicing instructions, thought chain examples and target files as input data, the information extraction task is targeted, so that the model training process does not require a large amount of labeled data, and there is no need for secondary pre-training on a large corpus. In which, thought chain examples are added to the input data to guide the model generation. The intermediate extraction process is step-by-step to ensure that the information extraction process is visible; based on the input data, the target model is fine-tuned to obtain a fine-tuned target model; on the fine-tuned target model, inference sampling is performed at a preset temperature to generate an intermediate data set, and then a new training data set is determined based on the intermediate data set; on the new training data set, ranking learning is performed based on the multiple constraints to obtain an optimized target model. Through ranking learning, labels can be selected in a targeted manner based on the deficiencies of the extraction results, and the information extraction ability of the model can be gradually optimized; inference sampling is performed using different preset temperatures, and the optimized target model is iteratively trained to obtain an information extraction model; the information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model. In summary, the present invention reduces dependence on labeled data by splicing input data of instructions, thought chain examples and target text, visualizes the intermediate extraction process, increases interpretability, and achieves controllable optimization through ranking learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 This is one of the flow charts of the multi-task information extraction method based on thought chaining and ranking learning provided by the present invention; Figure 2 This is the second flow chart of the multi-task information extraction method based on thought chaining and ranking learning provided by the present invention; Figure 3 Schematic diagram of the structure of the multi-task information extraction device based on thought chain and ranking learning provided by the present invention; Figure 4It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0019] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0020] It should be noted that in the description of the embodiments of the present invention, the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprises a..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element. Terms such as "upper" and "lower" indicate positions or location relationships based on those shown in the accompanying drawings and are intended solely for ease of description and simplification of the present invention. They are not intended to indicate or imply that the device or element referred to must have a specific orientation, be constructed, or operate in a specific orientation, and are therefore not to be construed as limiting the present invention. Unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be broadly construed, for example, to mean a fixed connection, a detachable connection, or an integral connection; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or internal communication between two elements. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0021] The terms "first," "second," and so forth, used herein are used to distinguish similar objects, not to describe a specific order or precedence. It should be understood that such terms are interchangeable where appropriate, allowing embodiments of the present invention to be implemented in an order other than that illustrated or described herein. Furthermore, the terms "first," "second," and so forth generally distinguish objects of a single type, and do not limit the number of objects. For example, the first object may be one or more. Furthermore, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates an "or" relationship between the connected objects.
[0022] Figure 1 This is one of the flow charts of the multi-task information extraction method based on thought chaining and ranking learning provided by the present invention; Figure 2 This is the second flow chart of the multi-task information extraction method based on thought chaining and ranking learning provided by the present invention; like Figure 1-Figure 2 As shown, the method includes the following: S110, determining multiple constraints based on the information extraction task requirements; S120, splicing the instructions, the thought chain examples and the target text as input data; S130, performing standard fine-tuning on the target model based on the input data to obtain a fine-tuned target model; S140, performing inference sampling at a preset temperature on the fine-tuning target model to generate an intermediate data set, and then determining a new training data set based on the intermediate data set; S150, performing ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; S160, performing inference sampling using different preset temperatures, iteratively training the optimization target model, and obtaining an information extraction model; S170: Input the information to be extracted into the information extraction model to obtain the information extraction result output by the information extraction model.
[0023] It should be noted that the execution entity of the multi-task information extraction method based on thought chaining and ranking learning provided in the embodiment of the present invention can be a server or computer device, such as a mobile phone, tablet computer, laptop computer, PDA, ultra-mobile personal computer (UMPC), netbook or personal digital assistant (PDA), etc.
[0024] In the embodiment of the present invention, the information extraction task is formalized as follows: given a long text L, according to the goal of the information extraction task, the following types of sets are extracted respectively: Entity Collection : , where each entity There is a type and a specific entity value , which can be expressed as ; Relationship Set : ,in, and Is a collection of entities The elements in is the type of relationship between these two entities; Event Collection : , where each event Triggered by an event and a set of related arguments composition, represents the value of the argument, Indicates the type of the argument; For each specific task, Belong to a specific set .
[0025] In an embodiment of the present invention, the thought chain example is an example of an information extraction step with a thought chain style, and the information extraction step with a thought chain style includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results.
[0026] Understandably, it's difficult to directly instruct the model to generate the final structured data. However, using thought chain examples can guide the model through step-by-step reasoning to generate the final output. Specifically, the model first locates eligible entities, then analyzes whether there are established relationships between entity pairs. Finally, based on the results of these intermediate steps, the required structured data is constructed, as shown in Table 1 below. This approach breaks down the complex relationship extraction task into multiple, more manageable subtasks, each with clear goals and steps, allowing the model to gradually reason and generate the final output.
[0027] Table 1 Examples of information extraction steps in the thought chain style
[0028] The following is a code example that calls the GPT interface to generate a thought chain: import openai # Set your OpenAI API key openai.api_key = 'api-key' def get_gpt_response(prompt): try: # Call GPT-3.5 API to obtain thinking chain data response = openai.Completion.create( model="gpt-3.5-turbo", prompt=prompt, max_tokens=480, n=1, stop=None, temperature=0.7 ) # Extract the generated results return response.choices[0].text.strip() except Exception as e: return f"Error: {e}" if __name__ == "__main__": #Thought chain example and target text for generating thought chain user_input = input("Thought chain example and target text: ") print(get_gpt_response(user_input)) In S120, the original data is concatenated with the example thought chain extraction steps, and the GPT interface is called to generate thought chain-style information extraction steps for all labeled training data. For the input data, the instructions are concatenated with the example thought chain-style information extraction steps, and then the target text to be extracted is added. This guides the model to generate intermediate extraction steps and structured data for the target text. For ease of understanding, an input data example is given below: What relations of the types [OrgBased In, Work For, Located In, LiveIn, Kill] among the entities [PERSON, LOCATION, ORGANIZATION, OTHER]arepresent in the Target text ?Please provide an answer incloud step-by-step analysis process similar to the examples. #Examples #Text Meanwhile Shi Liming at the Institute of Zoology of Kunming foundthat pandas lack variety in their protein heredity which may serve as one ofthe major reasons for pandas near extinction. #Answer Step one , Identifiedentitiesandtheirtypes: ShiLiming(PERSON) InstituteofZoology(ORGANIZATION) Kunming(LOCATION) pandas(OTHER) Step two, Analyzing relationships: 1.ShiLimingandinstituteofZoology: 1.Relationshiptype:WorkFor 2.Relationshipdescription:ShiLimingworksfortheinstituteofZoology. 2.InstituteofZoologyandKunming: 1.Relationshiptype:OrgBasedIn 2.Relationshipdescription:TheinstituteofZoologyabasedinKunming. Step three , Structuredresults: [[ShiLiming:PERSON;WorkFor,InstituteofZoology:ORGANIATION],[InstituteofZoology:ORGANIATION;OrgBasedin;Kunming:LOCATION]] #Target Text ''If it does not snow, and a lot, within this month we will have no water to submerge 150, 000 hectares (370, 500 acres) of rice, '' said Bruno Pusterla, a top official of the Italian Agricultural Confederation. In the embodiment of the present invention, the output data of the model, i.e., the information extraction result, is composed of information extraction steps and structured data in a thought chain style. For the above input data example, the corresponding output data is: Step one, Identified entities and their types: Bruno Pusterla (PERSON) Italian Agricultural Confederation (ORGANIZATION) Step two, Analyzing relationships: 1.Bruno Pusterla and Italian Agricultural Confederation: 1.Relationship type: Work For 2.Relationship description: Bruno Pusterla is a top official working for the Italian Agricultural Confederation. Step three, Structured results: [[Bruno Pusterla:PERSON;Work For;Italian Agricultural Confederation:ORGANIZATION]] In S130 , the target model is the model to be trained for information extraction. The specific model type used is not limited here. For ease of understanding, the following examples use the FLAN-T5-XL model as the target model to illustrate the information extraction method provided by the present invention. The FLAN-T5-XL model is a version of the T5 (Text-To-Text Transfer Transformer) model series.
[0029] In this embodiment of the present invention, LoRA (Low-Rank Adaptation) is used for standard fine-tuning, thereby reducing the parameters that need to be trained for the model. Part of the fine-tuning code is as follows: define_tune_model(model_id, dataset_path): #Set random seed set_seed(seed) #Load tokenizer and model tokenizer=AutoTokenizer.from_pretrained(model_id) model=AutoModelForSeq2SeqLM.from_pretrained(model_id,load_in_8bit=True,device_map="auto",use_cache=False) #Load the dataset and preprocess it tokenized_dataset=load_and_preprocess_data(dataset_path,tokenizer,max_source_length=1024,max_target_length=256) #Data Collector data_collator=DataCollatorForSeq2Seq(tokenizer,model=model,label_pad_token_id=-100,pad_to_multiple_of=8) #Set training parameters training_args=Seq2SeqTrainingArguments( output_dir="output", per_device_train_batch_size=8, per_device_eval_batch_size=8, num_train_epochs=10, logging_dir="logs", evaluation_strategy="epoch", save_strategy="epoch", load_best_model_at_end=True, report_to="tensorboard", ) #Create a Trainer instance trainer=Seq2SeqTrainer( model=model, args=training_args, train_dataset=tokenized_dataset["train"], eval_dataset=tokenized_dataset["test"], data_collator=data_collator, ) #Start training trainer.train() #Save model model.save_pretrained("output / save") In an embodiment of the present invention, inference sampling is performed on labeled input data at multiple temperatures. Specifically, the target model is fine-tuned using the initial input data to make the model better adapt to the data distribution of the current task, thereby obtaining a fine-tuned target model; on the fine-tuned target model, inference sampling is performed at a specific temperature T1 to generate an intermediate data set; based on the intermediate data set, a new training data set is determined; ranking learning is performed on the new training data set to optimize the model's ranking ability, thereby obtaining an optimized target model; after fine-tuning the model using the new training data set, inference sampling is performed at a new temperature T2 to generate a new intermediate data set; based on the new intermediate data set, a new training data set is determined; ranking learning is performed on the new training data set to further optimize the model's ranking ability; the above steps are repeated, using different temperatures for inference sampling in each iteration, and the data set is continuously updated until the model performance reaches expectations or no longer significantly improves, thereby obtaining the final information extraction model.
[0030] In the embodiment of the present invention, different temperature settings will affect the diversity and certainty of the generated results. In the specific implementation process, the temperature value can be adjusted according to the specific task requirements. Part of the code is as follows: # Initialize the model and tokenizer config = PeftConfig.from_pretrained(peft_model_id) model_flan = AutoModelForSeq2SeqLM.from_pretrained(config.base_model_name_or_path, torch_dtype="auto", device_map="auto", load_in_8bit=True) tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path) model = PeftModel.from_pretrained(model_flan, peft_model_id, device_map={"": 0}) #Input data and temperature are presented in list form data_to_save = [] # Perform inference on each input data for text in input_data: # Encode input data input_ids = tokenizer.encode(text, return_tensors="pt") # Save the current row's data row = [text] # Perform inference on each temperature value for temp in temperatures: # Set sampling parameters (temperature) output = model.generate(input_ids, do_sample=True, temperature=temp,max_length=600) # Decode the generated output generated_text = tokenizer.decode(output[0], skip_special_tokens=True) # Save inference results row.append(generated_text) # Add this row to the data data_to_save.append(row) # Save the data to a DataFrame df = pd.DataFrame(data_to_save, columns=["Original Input"] + [f"Result (Temp {temp})" for temp in temperatures]) # Save as Excel file df.to_excel("t5_inference_results.xlsx", index=False) It is understandable that when using the ranking learning method, since the supervision process of model training does not completely depend on the quality of the labeled data, it is possible to manually label a small amount of data and then call the large language model interface for fast data labeling, thereby reducing the workload of manual data labeling and improving data labeling efficiency.
[0031] The multi-task information extraction method based on thought chain and ranking learning provided by the embodiment of the present invention determines multiple constraints based on the information extraction task requirements; splices instructions, thought chain examples and target text as input data, and the thought chain example is an example of an information extraction step with a thought chain style, and the information extraction step with a thought chain style includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition result and the entity relationship recognition result. By splicing instructions, thought chain examples and target files as input data, the information extraction task is targeted, so that the model training process does not require a large amount of labeled data, and there is no need for secondary pre-training on a large corpus. In which, thought chain examples are added to the input data to guide the model generation. The intermediate extraction process is step-by-step to ensure that the information extraction process is visible; based on the input data, the target model is fine-tuned to obtain a fine-tuned target model; on the fine-tuned target model, inference sampling is performed at a preset temperature to generate an intermediate data set, and then a new training data set is determined based on the intermediate data set; on the new training data set, ranking learning is performed based on the multiple constraints to obtain an optimized target model. Through ranking learning, labels can be selected in a targeted manner based on the deficiencies of the extraction results, and the information extraction ability of the model can be gradually optimized; inference sampling is performed using different preset temperatures, and the optimized target model is iteratively trained to obtain an information extraction model; the information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model. In summary, the present invention reduces dependence on labeled data by splicing input data of instructions, thought chain examples and target text, visualizes the intermediate extraction process, increases interpretability, and achieves controllable optimization through ranking learning.
[0032] In an optional embodiment, the constraints include general constraints and specific constraints; the general constraints are universal constraints; and the specific constraints are constraints related to the task type or the field to which the task belongs.
[0033] In this embodiment of the present invention, common information extraction task requirements are analyzed, broken down, and visualized into general constraints, focusing on the information extraction task itself, without involving specific domains or subtasks. Regarding target extraction task requirements, which involve the task type and domain to which the task belongs, in addition to general task constraints, numerous specific task constraints can also be decomposed. These specific constraints often depend on the target task itself and vary significantly depending on the target task.
[0034] The multi-task information extraction method based on thought chaining and ranking learning provided by the embodiment of the present invention concretizes the information extraction task requirements into general constraints, decomposes specific constraints according to the task type and the field to which the task belongs, thereby effectively constraining the information extraction steps and results, and clarifies and concretizes the task objectives, distinguishes information extraction from general text tasks, and improves the accuracy of information extraction results.
[0035] Furthermore, the general constraint includes at least one of a first constraint, a second constraint and a third constraint, wherein the first constraint is that the extracted object comes from a specified text, the second constraint is that the object type is within a specified range, and the third constraint is that the information extraction result has a specified data structure.
[0036] Here, general constraints usually include: the extracted object must come from a given text, the object type must be within a limited type range, and the final extraction result must have a specific data structure.
[0037] Furthermore, the specificity constraint includes at least one of a fourth constraint condition, a fifth constraint condition, a sixth constraint condition, a seventh constraint condition, an eighth constraint condition, and a ninth constraint condition; The fourth constraint condition is that the entity type corresponding to the entity relationship belongs to a specified type; The fifth constraint condition is an exclusion constraint between entity types and entity relationship types; The sixth constraint condition is a constraint on the context corresponding to a specified grammatical structure; The seventh constraint condition is a consistency constraint of time and / or spatial position; The eighth constraint condition is that the entity relationship corresponds to a specified number of entities; The ninth constraint is an order constraint.
[0038] Specifically, the fourth constraint is a relationship-specific entity constraint. Certain relationships require that participating entities belong to specific categories. For example, an "investment" relationship might require both entities to be of the "company" or "organization" type, while disallowing entities of the "place" or "time" type. A "position held" relationship typically requires one entity to be of the "person" type and the other to be of the "position" or "organization" type.
[0039] The fifth constraint is the exclusion constraint between entity types and relationship types. Some relationships only apply to certain entity types and not others. For example, certain "place"-related relationships, such as "located at," typically only involve "place"-type entities; and certain "time"-related relationships, such as "occurs at," can only involve "time"-type entities and not "person" or "organization" types.
[0040] The sixth constraint is context and grammatical structure. Certain relationships within the context may require entities to play specific roles within the syntactic structure. For example, a "dialogue" relationship may require both the subject and object to represent "people" and typically appear in sentences describing communication events. Similarly, a "belonging" relationship may require entities to appear in specific grammatical roles (such as subject or object) and often be accompanied by certain keywords (such as "belongs").
[0041] The seventh constraint is the temporal and spatial consistency constraint. Some relationships may require that the temporal or spatial locations between entities must be consistent or matching. For example, the "happens at" relationship requires that the time entity must be consistent with the event entity, or the location entity must match the spatial location of the event or person entity.
[0042] The eighth constraint is the quantity consistency constraint. For some relationships, there are strict requirements on the number of entities involved. For example, a "pairing" relationship can only involve two entities, not more than two.
[0043] The ninth constraint is the order constraint. For causal relationships, the order is usually required to be consistent. For example, the "cause" relationship usually requires that the "cause" appear before the "result" in the sentence.
[0044] The multi-task information extraction method based on thought chain and ranking learning provided by the embodiment of the present invention provides a variety of specific constraints for different task types and task fields. These constraints are passed to the model through instructions and ranking learning, thereby increasing the information extraction capability of the model.
[0045] In an optional embodiment, the multi-task information extraction method based on thought chaining and ranking learning further includes: For any set of labels for a piece of training data, the constraint evaluator is used to calculate the corresponding constraint score based on the following steps: Obtaining information extraction results of the thought chain style corresponding to the training data; determining a first constraint score based on the plurality of constraints; determining a second constraint score based on the information extraction result of the thought chain style; Based on preset weights, the first constraint score and the second constraint score are weightedly calculated to obtain a constraint score.
[0046] In the embodiment of the present invention, quality assessment and ranking of a set of labels for a piece of input data is a continuous process, which is achieved by constructing a constraint evaluator.
[0047] It is understandable that in the specific implementation process, the specific implementation of the constraint evaluator is different for different tasks. For example, for the calculation of the first constraint score, if the label meets the corresponding constraint conditions, the first constraint score is increased by the corresponding score; similarly, for the calculation of the second constraint score, if the generated thinking chain meets the constraints for the thinking chain, the second constraint score is increased by the corresponding score. When the information extraction result does not meet a certain type of constraint, the result that violates the constraint can be penalized by deducting points, thereby reducing the probability of the model generating such results. The following is a pseudo code for calculating the constraint score of a label: def get_text_score(input_text,label_text): #Get the target text in the input data input_text=input_text.split("target text tag:")[1] #Get the output thought chain extraction steps label_though_step=label_text.split("Thought chain extraction step label:")[1] pattern_first = r'\[([^\[\]] )\]' matches = re.findall(pattern_first,label_text) pattern_second = r'[^;,:]+:[^,;:]+;[^,;:]+;[^,;:]+:[^,;:]+' #Judge whether there is data of specified structure in label if len(matches)!=0: #With the specified structure, the score plus x1 score+=x1 for out in matches: #Single result structure meets the requirement, score plus x2 if re.match(pattern_second, out): socre+=x2 for con in contrain: #Satisfy a certain constraint, add points x3 if out satisfies con: socre +=x3 #Judge whether the generated thinking chain meets the constraints of the thinking chain for con_t in contrains_t: if label_though_step satisfies con_t: score_through+=x4 #Two score weighted combinations score_all=n score+m score_through return score_all The multi-task information extraction method based on thought chaining and ranking learning provided by the embodiment of the present invention performs quality assessment on a group of labels through a constrained evaluator, thereby realizing automatic evaluation of the information extraction results, which can enable the model to clarify the task objectives, guide and accelerate the model training process.
[0048] Furthermore, the loss function of the ranking learning is as follows: ; ; ; in, is the fine-tuning loss function, Expressing arrive All time steps are accumulated, Represents a given input and all previous tags , the model predicts the current time step Tags The logarithm of the probability of is the ranking loss function, Excellent label The constraint score, is a suboptimal label The constraint score, Excellent label The probability of generating is a suboptimal label The probability of generation; is the weight parameter, is the loss function for ranking learning.
[0049] Here, , is for all time steps Perform the summation, Represents a given input and all previous tags , the model predicts the current time step Tags The logarithm of the probability.
[0050] In this embodiment of the present invention, the constraint score of the constraint evaluator is used as a reward, and the ranking loss function is used to encourage the model to generate a response with the highest score for each input, and the ranking loss of all responses to the same input is optimized according to the relative scores between labels.
[0051] In some embodiments, when using ranking learning to train the model, a coherent training method is used. Specifically, after standard fine-tuning and each ranking learning, a suboptimal label is inferred at a specific temperature. In each stage of ranking learning, the label group inherits the label group of the previous stage, and the results of inference after the previous stage training are combined. For example, on the fine-tuned model, reasoning sampling is performed at a specific temperature T to generate new candidate labels, and these generated suboptimal labels are recorded to form a new label set Lk+1. The new label set Lk+1 is combined with the existing label set Dk to form a new data set Dk+1. Ranking learning is performed on the new data set Dk+1, and the new data set Dk+1 is used as the standard fine-tuning input for the next stage. The above steps are repeated. Each stage will inherit the label group of the previous stage and add the newly generated suboptimal labels to gradually enrich and optimize the training data of the model.
[0052] In other embodiments, when using ranking learning to train the model, a stage-independent training method is used. Specifically, the label group of ranking learning comes from the inference results after the model training of the previous stage. That is to say, the stage-independent training does not transfer labels, but obtains new labels through multi-temperature sampling. For example, on the fine-tuned model, reasoning sampling is performed at a specific temperature T to generate new candidate labels, and these generated suboptimal labels are recorded to form a new label set Lk+1. Using the new label set Lk+1, the new data set Lk+1 is used as the standard fine-tuning input for the next stage, and the above steps are repeated. Each stage directly uses the newly generated suboptimal labels to gradually optimize the training data of the model.
[0053] In summary, if Figure 2As shown, the present invention analyzes and clarifies the task requirements through the task definition module, defines the input data and output data structure, and constructs a small amount of labeled data for the task manually or by calling the language model interface; the thinking chain construction module designs an extraction step with a thinking chain style based on the thinking chain idea, calls the large model interface, and generates extraction steps in the form of thinking chains for all labeled data; the constraint definition module decomposes the requirements of the information extraction task into numerous constraints, and these constraint information is passed to the model through instructions and ranking learning, thereby increasing the information extraction ability of the model; the preliminary training module trains a small number of parameters of the model based on the small amount of labeled data that has been constructed, so that the model is initially adapted to the current task and obtains a relatively stable output; the inference sampling module inputs the input data of the existing labels into the model for forward reasoning, samples the output of the model, selects the appropriate extraction results and constructs a label group in combination with the initial label; the constraint evaluation module uses the constraint evaluator to calculate the constraint score of each label, and sorts the label group within the group according to the constraint score; the ranking learning module uses the generation probability difference between excellent labels and suboptimal labels as one of the optimization goals of model training, guiding the model to generate results that are more in line with the information extraction task.
[0054] The following describes a multi-task information extraction device based on thought chaining and ranking learning provided by an embodiment of the present invention. The multi-task information extraction device based on thought chaining and ranking learning described below and the multi-task information extraction method based on thought chaining and ranking learning described above can be referenced to each other.
[0055] Figure 3 This is a schematic diagram of the structure of the multi-task information extraction device based on thought chain and ranking learning provided by the present invention. Figure 3 As shown, the multi-task information extraction device based on thought chain and ranking learning may include but is not limited to; The constraint determination module 310 is used to: determine multiple constraint conditions based on the information extraction task requirements; An input generation module 320 is configured to: concatenate instructions, thought chain examples, and target text as input data, wherein the thought chain examples are examples of thought chain-style information extraction steps, wherein the thought chain-style information extraction steps include entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; The standard fine-tuning module 330 is configured to perform standard fine-tuning on the target model based on the input data to obtain a fine-tuned target model; An inference sampling module 340 is configured to perform inference sampling on the fine-tuning target model at a preset temperature to generate an intermediate data set, and then determine a new training data set based on the intermediate data set. A ranking learning module 350 is configured to perform ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; Iterative training module 360, configured to perform inference sampling using different preset temperatures, iteratively train the optimization target model, and obtain an information extraction model; The information extraction module 370 is used to input the information to be extracted into the information extraction model to obtain the information extraction result output by the information extraction model.
[0056] It should be noted that the multi-task information extraction device based on thought chain and ranking learning provided in an embodiment of the present invention can execute the multi-task information extraction method based on thought chain and ranking learning described in any of the above embodiments during specific operation, which will not be elaborated in this embodiment.
[0057] Figure 4 An example of a physical structure diagram of an electronic device is shown below. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute a multi-task information extraction method based on thought chaining and ranking learning, the method comprising: determining multiple constraints based on information extraction task requirements; splicing the instruction, the thought chain example and the target text as input data, wherein the thought chain example is an example of a thought chain style information extraction step, and the thought chain style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; Based on the input data, standard fine-tuning is performed on the target model to obtain a fine-tuned target model; Performing inference sampling at a preset temperature on the fine-tuning target model to generate an intermediate data set, and then determining a new training data set based on the intermediate data set; Performing ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; Perform inference sampling using different preset temperatures, iteratively train the optimization target model, and obtain an information extraction model; The information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model.
[0058] Furthermore, the logic instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0059] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being storable on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer is capable of executing the multi-task information extraction method based on thought chaining and ranking learning provided by the above methods, the method including: determining a plurality of constraints based on information extraction task requirements; splicing the instruction, the thought chain example and the target text as input data, wherein the thought chain example is an example of a thought chain style information extraction step, and the thought chain style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; Based on the input data, standard fine-tuning is performed on the target model to obtain a fine-tuned target model; Performing inference sampling at a preset temperature on the fine-tuning target model to generate an intermediate data set, and then determining a new training data set based on the intermediate data set; Performing ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; Perform inference sampling using different preset temperatures, iteratively train the optimization target model, and obtain an information extraction model; The information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model.
[0060] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for performing the multi-task information extraction method based on thought chaining and ranking learning provided by the above methods is implemented, the method comprising: determining a plurality of constraints based on information extraction task requirements; splicing the instruction, the thought chain example and the target text as input data, wherein the thought chain example is an example of a thought chain style information extraction step, and the thought chain style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; Based on the input data, standard fine-tuning is performed on the target model to obtain a fine-tuned target model; Performing inference sampling at a preset temperature on the fine-tuning target model to generate an intermediate data set, and then determining a new training data set based on the intermediate data set; Performing ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; Perform inference sampling using different preset temperatures, iteratively train the optimization target model, and obtain an information extraction model; The information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model.
[0061] The device embodiments described above are merely illustrative. 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, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0062] Through the description of the above embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention 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. However, 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 invention.
Claims
1. A multi-task information extraction method based on thought chain and ranking learning, characterized in that: include: Determine multiple constraints based on the information extraction task requirements; splicing the instruction, the thought chain example and the target text as input data, wherein the thought chain example is an example of a thought chain style information extraction step, and the thought chain style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; Based on the input data, standard fine-tuning is performed on the target model to obtain a fine-tuned target model; Performing inference sampling at a preset temperature on the fine-tuning target model to generate an intermediate data set, and then determining a new training data set based on the intermediate data set; Performing ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; Using different preset temperatures to perform inference sampling, iteratively training the optimization target model to obtain an information extraction model; The information to be extracted is input into the information extraction model to obtain the information extraction result output by the information extraction model.
2. The multi-task information extraction method based on thought chaining and ranking learning according to claim 1 is characterized in that: The constraints include general constraints and specific constraints; the general constraints are universal constraints; the specific constraints are constraints related to the task type or the field to which the task belongs.
3. The multi-task information extraction method based on thought chaining and ranking learning according to claim 2 is characterized in that: The general constraints include at least one of the first constraint, the second constraint and the third constraint. The first constraint is that the extracted object comes from the specified text, the second constraint is that the object type is within the specified range, and the third constraint is that the information extraction result has a specified data structure.
4. The multi-task information extraction method based on thought chaining and ranking learning according to claim 2 is characterized in that: The specificity constraint includes at least one of the fourth constraint, the fifth constraint, the sixth constraint, the seventh constraint, the eighth constraint and the ninth constraint; The fourth constraint condition is that the entity type corresponding to the entity relationship belongs to a specified type; The fifth constraint condition is an exclusion constraint between entity types and entity relationship types; The sixth constraint condition is a constraint on the context corresponding to a specified grammatical structure; The seventh constraint condition is a consistency constraint of time and / or spatial position; The eighth constraint condition is that the entity relationship corresponds to a specified number of entities; The ninth constraint is an order constraint.
5. The multi-task information extraction method based on thought chaining and ranking learning according to claim 1 is characterized in that: The multi-task information extraction method based on thought chain and ranking learning also includes: For any set of labels for a piece of training data, the constraint evaluator is used to calculate the corresponding constraint score based on the following steps: Obtaining information extraction results of the thought chain style corresponding to the training data; determining a first constraint score based on the plurality of constraints; determining a second constraint score based on the information extraction result of the thought chain style; Based on preset weights, the first constraint score and the second constraint score are weightedly calculated to obtain a constraint score.
6. The multi-task information extraction method based on thought chaining and ranking learning according to claim 5 is characterized in that: The loss function of the ranking learning is as follows: ; ; ; in, is the fine-tuning loss function, Expressing arrive All time steps are accumulated, Represents a given input and all previous tags , the model predicts the current time step Tags The logarithm of the probability of is the ranking loss function, It's a label The constraint score, It's a label The constraint score, It's a label The probability of generating It's a label The probability of generation; is the weight parameter, is the loss function for ranking learning.
7. A multi-task information extraction device based on thought chain and ranking learning, characterized in that: include: The constraint determination module is used to: determine multiple constraint conditions based on the information extraction task requirements; An input generation module is configured to: concatenate instructions, thought chain examples, and target text as input data, wherein the thought chain examples are examples of a thought chain-style information extraction step, wherein the thought chain-style information extraction step includes entity recognition, entity relationship recognition, and constructing structured output data based on the entity recognition results and the entity relationship recognition results; A standard fine-tuning module is used to: perform standard fine-tuning on the target model based on the input data to obtain a fine-tuned target model; An inference sampling module is configured to perform inference sampling at a preset temperature on the fine-tuning target model, generate an intermediate data set, and then determine a new training data set based on the intermediate data set; A ranking learning module is used to: perform ranking learning on the new training data set based on the multiple constraints to obtain an optimized target model; An iterative training module is used to perform inference sampling using different preset temperatures and iteratively train the optimization target model to obtain an information extraction model; The information extraction module is used to: input the information to be extracted into the information extraction model to obtain the information extraction result output by the information extraction model.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the multi-task information extraction method based on thought chaining and ranking learning as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the multi-task information extraction method based on thought chaining and ranking learning as described in any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the multi-task information extraction method based on thought chaining and ranking learning as described in any one of claims 1 to 6 is implemented.