Water conservancy field rule extraction method based on large language model learning and enhancement
By adopting the water conservancy field rule extraction method based on large language model in the field of flood control scheduling, the problem of incomplete knowledge perception and information sharing in knowledge extraction is solved, and efficient and accurate information extraction and self-growth of knowledge are achieved.
Patent Information
- Application Number
- CN202411702814.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-28
AI Technical Summary
Knowledge extraction in the field of flood control scheduling faces problems such as imperfect knowledge perception and information sharing mechanisms, difficulty in deleting or updating knowledge in traditional language models, lack of interactivity and matching, and the word count limit of large language models, which cannot provide sufficient prompts.
The water conservancy field rule extraction method based on learning and enhancement based on large language model is adopted. By inputting the ontology and labeled documents into the large language model, knowledge prompts in the water conservancy field are generated and offline prompt knowledge trees are constructed. The prompt engineering and thinking tree prompt strategies are used to achieve efficient extraction of scheduling rule data.
It greatly improves the efficiency and accuracy of information retrieval, dynamically constructs extraction templates to adapt input statements, improves the accuracy of extraction, saves manpower and time costs, and has the ability to automatically simulate and generate, achieving self-growth of knowledge.
Smart Images

Figure CN119719382A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information extraction and natural language processing, and in particular to a method for extracting rules in the field of water conservancy based on large language model learning and enhancement. Background Art
[0002] The introduction of the smart water conservancy system has promoted the deep integration of advanced technologies such as big data, cloud computing, and the Internet of Things with the water conservancy field, and accelerated the development of water conservancy digitization and informatization. However, with the increase in water conservancy projects and the improvement of flood control capabilities, the accumulation of engineering scheduling rule texts has also increased, from initially relying on a single data source to today's processing of multi-source heterogeneous data. The continuous growth in the types and scale of data has led to a gradual decline in the efficiency of the flood control scheduling process, which has brought difficulties to the flood control department in responding quickly to flood disasters. Since 2024, Afghanistan, Pakistan, Brazil and other places have been hit by continuous heavy rains, triggering natural disasters such as floods and landslides, causing casualties and national economic losses.
[0003] The occurrence of these disasters further highlights that when carrying out flood control dispatching work, flood control departments need to coordinate multiple water conservancy projects to obtain and process a large amount of hydrological data, water engineering data, expert experience and other data and knowledge contained in the dispatching rules, so as to reasonably dispatch water conservancy projects and achieve accurate decision-making. This not only places increasingly high demands on underlying data support, but also requires a transition from data support to knowledge support. Therefore, there is an urgent need to automatically extract domain knowledge from relevant texts in order to better understand and apply dispatching rules to support flood control dispatching work. However, knowledge extraction in the field of flood control dispatching faces the following challenges, specifically:
[0004] The imperfect knowledge perception and information sharing mechanisms and the fixed extraction templates make it difficult to delete or update knowledge in traditional language models, and they lack interactivity and matching.
[0005] Due to the word limit of the large language model, it is impossible to provide more prompts to assist in the extraction when extracting a large number of documents. Therefore, it is particularly important to obtain and select necessary and effective prompts.
[0006] Therefore, there is still much room for research in the knowledge extraction technology of flood control scheduling rules in the water conservancy field. Therefore, the present invention designs a domain rule extraction method based on large language model learning and enhancement, so as to support the construction and application of knowledge graphs, improve the urgency of water conservancy scheduling efficiency and response speed, and reduce the impact of natural disasters, which is of great significance. Summary of the invention
[0007] Purpose of the invention: In order to achieve the above-mentioned purpose, the present invention proposes a rule extraction method in the water conservancy field based on large language model learning and enhancement. On the basis of the completion of data processing and annotation, the large language model ChatGLM, prompt engineering, thinking tree prompt strategy and other learning technologies are used to realize the efficient extraction of scheduling rule data. The proposed method has good entity relationship joint extraction performance.
[0008] Technical solution: The method for extracting water conservancy rules based on large language model learning and enhancement described in the present invention comprises the following steps:
[0009] (1) Input the ontology and annotated documents into the large language model for parsing to generate water conservancy domain knowledge prompts and construct an offline prompt knowledge tree;
[0010] (2) Construct the part-of-speech sequence of the sentence to be extracted to provide a structural data basis for subsequent keyword retrieval;
[0011] (3) Using the large language model, the water conservancy keywords and special words in the part-of-speech sequence are retrieved in the offline prompt knowledge tree to find the prompt sentences that match them and generate a matching prompt list;
[0012] (4) Introducing tags to simplify the expression of water conservancy rules, making it more intuitive and easy to understand;
[0013] (5) Integrate the prompt list and simplified ontology expression to automatically construct an extraction template suitable for water conservancy field rules and complete the information extraction of field rules.
[0014] Furthermore, the step (1) comprises the following steps:
[0015] (11) Using the large language model and a heuristic strategy, the labels of the annotated documents are learned about the trigger words, the prior condition types in the water conservancy rules, and all candidate labels;
[0016] (12) The annotation content and knowledge in the obtained water conservancy annotation document are learned using a large language model and a context learning strategy to convert instances into prompts, thereby automatically generating structured prompts;
[0017] (13) Integrate the results of (11) and (12), further utilize the generated prompt instructions, summarize knowledge, and improve prompts based on user feedback data;
[0018] (14) According to the predefined ontology structure type, the ontology is expressed as O; at the same time, the collected water conservancy prompt information is organized and stored according to a tree structure to construct an offline prompt knowledge tree suitable for extracting structured information in the water conservancy field:
[0019] O = {R, C, D} (1)
[0020] Among them, C is a concept set including Csub and Cobj, R is the connection edge between C to represent the relationship, and D is the overall text description of each ontology; the D includes a piece of text containing word meaning information and concept relationship structure information.
[0021] Furthermore, the implementation process of step (2) is as follows:
[0022] Using the part-of-speech analysis method, the user input is classified according to the part of speech and the corresponding sequence is constructed; according to the input document sentence, the nouns, verbs, adjectives and prepositions in the water conservancy rule sentence are identified, and then the identified objects are placed in the queue to be processed to form the corresponding sequence.
[0023] Furthermore, the implementation process of step (3) is as follows:
[0024] (31) According to the input keyword sequence corpus and the type of the ontology, the offline prompt knowledge tree is dynamically queried and traversed; under each type, the corresponding knowledge tree branch is traversed in depth first, and the cosine similarity calculation is performed to find the corresponding prompt statement under the tree, and the corresponding prompt is given when extracting:
[0025] P={T1…T n |T i :Prompt} (2)
[0026] Among them, T1…T n Represents the branch of the hint knowledge tree, T i :Prompt represents the prompt statement at the i-th position in the current tree, and P represents the prompt statement that currently meets the conditions after traversal;
[0027] (32) Generate corresponding prompts according to the entity type, and convert each Pc, P R、 P D The prompts are integrated to generate a prompt list for enhanced extraction; Pc∈P refers to the instance prompt in the prompt knowledge tree, corresponding to the branch of the ontology concept set C, P R ∈P is a sentence prompt in the prompt knowledge tree, corresponding to the branch of the ontology relation R, P D It is a global prompt in the prompt knowledge tree, corresponding to D in the ontology, which means the branch of explanation and definition; P R、 Pc 、 P D With the body<R,C,D> The types in complement and support each other:
[0028] Q=∑P (3)
[0029] Among them, Q represents all prompt statements that meet the conditions after traversing this branch.
[0030] Furthermore, the implementation process of step (4) is as follows:
[0031] A formula rich in th, tt tags is introduced to feed the ontology information into the model for processing and simplified expression; formula W is used as a constraint in the extraction process, and the ontology and extraction instance results are structured through triples:
[0032] W={[X]th[Y]tt[Z]r} D (4)
[0033] Among them, [X] and [Y] represent the extracted text entity information, th and tt represent the type information of the head and tail entities, r represents the relationship, [Z] is used to represent the extracted relationship information, and D is the overall text description of each ontology.
[0034] Further, step (5) comprises the following steps:
[0035] (51) Based on the obtained annotated documents, ontology structure and corresponding prompt strategies, a fusion representation is performed, and a prompt extraction template for water conservancy field rules is constructed:
[0036] Template={[P C :Q]th[X]eh[P C :Q]tt[Y]et[P R :Q][Z]} P D (5)
[0037] By adding necessary sentinel marks to the template, the model can better understand and operate the corresponding positions, and complete the extraction by using the cloze method; Pc prompts the instance prompts in the knowledge tree, corresponding to the branches of the ontology concept set C, P R is a sentence prompt in the prompt knowledge tree, corresponding to the branch of the ontology relationship R, P D It is a global prompt in the prompt knowledge tree, corresponding to D in the ontology, which means the branch of explanation and definition; P R , Pc, P D And with the body<R,C,D> The types in complement and support each other; Q means that after traversing this branch, all prompt statements that meet the conditions are returned to the extraction template;
[0038] (52) The constructed prompt extraction template of the water conservancy field rules and the corpus representation are connected to obtain the input sequence IS, that is, the form of <input, template> sentence pairs, which is input into the large language model to extract the field rules:
[0039] IS=[CLS] <inputtext>[SEP] <template>[SEP] (6)
[0040] Among them, [CLS] and [SEP] are special symbols, InputText represents the sentence of text input, and Template represents the template text sentence itself that integrates knowledge prompts and ontology extraction;
[0041] (53) Obtain the extracted triple form:
[0042] y=[X]th[Y]tt[Z]r (7)
[0043] Among them, Y represents the final extracted triple result, [X] represents the head entity object after extraction, and th represents the corresponding ontology and type of the head entity object; similarly, [Y] represents the tail entity object after extraction, and tt represents the corresponding ontology and type of the tail entity object; [Z] represents the extracted or inferred relationship, and r represents the type of its relationship.
[0044] Beneficial effects: Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention automatically learns, organizes and generates domain knowledge and rules by analyzing the content in the annotated data and utilizing methods such as prompt engineering and heuristic strategies; the present invention performs effective information retrieval on the offline prompt knowledge tree by parsing the input sentence and obtains matching sentences, thereby greatly improving the efficiency and accuracy of information retrieval; the present invention provides the ability to dynamically construct extraction templates through the fusion of ontology structure and knowledge, better adapts to input sentences, and at the same time improves the correctness of extraction and saves manpower and time costs; in addition, on the basis of continuous extraction, the present invention has certain automatic simulation and generation capabilities, can continuously self-learn to achieve self-growth of knowledge, has good domain rule extraction performance, and has extremely high practical value and commercial value. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a flow chart of the present invention;
[0046] Figure 2 It is a schematic diagram of a specific process in the implementation scheme of the present invention;
[0047] Figure 3 This is a schematic diagram of the text annotation of the field scheduling rules in the present invention;
[0048] Figure 4 A schematic diagram of an offline prompt knowledge tree of the present invention;
[0049] Figure 5 This is a schematic diagram of the offline prompt knowledge tree retrieval framework in the present invention;
[0050] Figure 6 This is a schematic diagram of the domain rule extraction model framework established in the present invention. DETAILED DESCRIPTION
[0051] The technical solution of the invention is described in detail below with reference to the accompanying drawings.
[0052] like Figure 1 , Figure 2 As shown, the present invention proposes a domain rule extraction method based on large language model learning and enhancement, which specifically includes the following steps:
[0053] S1: Input the ontology and annotated documents into the large language model for parsing to generate water conservancy domain knowledge prompts and construct an offline prompt knowledge tree;
[0054] The obtained labels of the annotated documents are used to learn the trigger words, the prior condition types in the water conservancy rules and all the candidate labels by adopting a heuristic strategy using a large language model;
[0055] For example, if we label the "scheduling object" in a document, we can find all the contents in the document that are labeled as "scheduling object". Through heuristic learning, we can know that the scheduling object refers to the object that needs to be operated in actual scheduling, including reservoirs, gates, dams, pipelines, etc.
[0056] The annotation content and knowledge in the obtained water conservancy annotation documents are learned using a large language model with a contextual learning strategy, and the instances are converted into prompts, thereby automatically generating structured prompts.
[0057] By analyzing the results of multiple annotation statements in the annotated document, some common and common knowledge can be obtained through the prompt statement "find the common content in these annotated documents and summarize them". For example:
[0058] 1) When a rule contains multiple conditions, it is necessary to clarify whether the logical relationship between them is parallel, progressive or inverse.
[0059] 2) For conditions involving numerical values, mark the numerical range and indicate whether it is the upper limit or the lower limit.
[0060] 3) When the water level reaches the warning line, identify the operations that need to be performed, such as opening or closing the gate.
[0061] Specifically: "When the water level of Fuziling Reservoir reaches 129 meters or above, and the water level of Bailianya Reservoir exceeds the flood limit but is lower than the designed maximum flood level of 233.91m, Bailianya will be completely closed for flood discharge, and the flood discharge tunnel will continue to be open for discharge." This rule, such as Figure 3 As shown, the "flood limit water level" in Bailianya Reservoir is marked as the minimum value, and "233.91" is marked as the maximum value. According to the above common knowledge, "for conditions involving numerical values, mark the numerical range and indicate whether it is the upper limit or the lower limit". It can be converted into a prompt like this: "For the provided numerical interval range, one is the maximum value and the other is the minimum value";
[0062] Combining the above results, we further utilize the generated prompt instructions, summarize knowledge, and improve the prompts in combination with human feedback data.
[0063] For example, an example rule such as "When the water level of Fuziling Reservoir reaches 129 meters or more, and the water level of Bailianya Reservoir exceeds the flood limit but is lower than the designed maximum flood level of 233.91m, the middle flood discharge hole of Bailianya will be completely closed, and the flood discharge tunnel will continue to be open." is changed to "For the range of the provided numerical interval, one is the maximum value and the other is the minimum value". According to human feedback, the prompt content is adjusted in time, so that when "reaches" appears, it means that the value following is the "minimum value", and when "below" appears, it means that the value following is the "maximum value".
[0064] According to the predefined ontology structure type, O = {R, C, D}. At the same time, the collected water conservancy prompt information is organized and stored according to the tree structure, so as to construct a structured offline prompt knowledge tree, such as Figure 4 shown.
[0065] S2: Use the part-of-speech analysis method to classify the user input according to the part-of-speech and construct the corresponding sequence. For example, an example rule "When the water level of Fuziling Reservoir reaches 129 meters or more, and the water level of Bailianya Reservoir exceeds the flood limit but is lower than the designed maximum flood level of 233.91m, Bailianya will close the flood discharge hollow and the flood discharge tunnel will continue to be open." is classified according to the part-of-speech to obtain (proper) noun sequences, verb sequences, adjective sequences, etc. For example, the obtained noun sequence is: 'Fuziling Reservoir-water level-129 meters-Bailianya Reservoir-flood limit water level-233.91 meters-highest flood level-flood discharge hollow-flood discharge tunnel'.
[0066] S3: Use the large language model to retrieve the water conservancy keywords and special words in the part-of-speech sequence in the offline prompt knowledge tree to find the matching prompt sentences and generate a matching prompt list to further enhance the extraction method;
[0067] According to the input keyword sequence corpus and the type of the ontology, the system dynamically queries and traverses the offline prompt knowledge tree. Under each type, the system will give priority to deep traversal of the corresponding prompt knowledge tree branches, perform cosine similarity calculations, find the corresponding prompt statements under the tree, and give corresponding prompts when extracting;
[0068] For example, there is such an instance rule: "When the water level of the Foziling Reservoir reaches above 129 meters, and at the same time, although the water level of the Bailianya Reservoir exceeds the flood limit water level but is lower than the designed maximum flood level of 233.91 m, the Bailianya Reservoir is fully closed and emptied during flood discharge, and the flood discharge tunnel continues to discharge freely." As Figure 5 shown, when obtaining hints, it will first traverse the eligible hints stored under the concept set (P C ). The following hints can be traversed from the above statement:
[0069] Hint 1: The Foziling Reservoir is a whole and cannot be split;
[0070] Hint 2: Meter and m represent the same meaning and are both a common measurement unit. They are unified as m during extraction;
[0071] Hint 3: The Bailianya Reservoir is a whole and cannot be split;
[0072] Hint 4: For the number after the word ' reaches ', take it as the minimum value;
[0073] There may be other hints traversed here, which will not be listed one by one.
[0074] To ensure the diversity of hint information and information coverage, corresponding to the ontology type, generate corresponding hints, and integrate the hints of each Pc, P R、 P D to generate a hint list for extraction. Among them, Pc ∈ P refers to the instance hints in the hint knowledge tree, corresponding to the branches of the ontology concept set C, and P R ∈ P is the sentence hint in the hint knowledge tree, corresponding to the branches of the ontology relation R, and P D is the global hint in the hint knowledge tree, corresponding to the branch D in the ontology, which represents the branch of explanation and definition. P R、 Pc 、 P D also complements and supports each other with the types in the ontology <R, C, D>.
[0075] For example, gather the hint sets of the obtained Pc together;
[0076] Q = {The Foziling Reservoir is a whole and cannot be split; The Bailianya Reservoir is a whole and cannot be split;...}.
[0077] S4: Introduce labels such as pseudo - labels to simplify the expression form of the water conservancy rule ontology, making it more intuitive and easy to understand.
[0078] To better send the ontology information into the model for processing and simplify the expression form, introduce tags rich in th, tt, etc. as constraint conditions during the extraction process, and represent the ontology and the extraction instance results through a triple structure.
[0079] W={[X]th[Y]tt[Z]r} D (15)
[0080] Among them, [X] and [Y] represent the extracted text entity information respectively, th and tt represent the type information of the head and tail entities, r represents the relationship, [Z] is used to represent the extracted relationship information, and D is the overall text description of each ontology, including a paragraph of text containing word meaning information and concept relationship structure information, that is, additional information.
[0081] For example, the rule "When the water level of Fuziling Reservoir reaches above 129 meters, and the water level of Bailianya Reservoir exceeds the flood limit but is lower than the designed maximum flood level of 233.91m, Bailianya will be completely closed to discharge flood water, and the discharge tunnel will continue to be open", can extract multiple triple structures. Here, only two triple structures are shown:
[0082] W1 = {[reservoir] trigger object [water level] attribute [relationship] control element} D
[0083] W2 = {[water level] attribute [129m] value [reach] value} D
[0084] D={"" contains the input sentence}
[0085] In the first triple, th and tt refer to the trigger object and attribute respectively, and r refers to the control factor, which can form the ontology contained in "trigger object (Csub)-control factor (R)-attribute (Cobj)". In the second triple, th and tt refer to the attribute and the minimum value, and similarly contain the ontology information "attribute (Csub)-minimum value (R)-minimum value (Cobj)".
[0086] S5: Based on the input document to be extracted, the matching prompt list and simplified ontology expression are integrated to automatically construct an extraction template suitable for water conservancy field rules and complete the information extraction of field rules.
[0087] According to the above-obtained annotated documents, ontology structure and corresponding prompt strategies, a fusion representation is performed, and a prompt extraction template suitable for water conservancy field rules is constructed, such as Figure 6 shown.
[0088] Template={[P C :Q]th[X]eh[P C :Q]tt[Y]et[P R :Q][Z]} P D (16)
[0089] By adding necessary sentinel marks to the template, the model can better understand and operate the corresponding positions, and use the cloze method to fill in [X], [Y], [Z] to complete the extraction. Q represents all the prompt statements that meet the conditions after traversing this branch, and returns them to the extraction template.
[0090] For example, the rule states, "When the water level of the Fuziling Reservoir reaches 129 meters or more, and the water level of the Bailianya Reservoir exceeds the flood limit but is lower than the designed maximum flood level of 233.91 meters, the Bailianya Reservoir will be completely closed for flood discharge, and the flood discharge tunnel will continue to be open for discharge." According to the rule, the template that can be dynamically constructed here is as follows:
[0091] Template = {[Bailianya Reservoir is a whole and cannot be divided] trigger object [Bailianya Reservoir] eh (17) attribute [water level] et [no clear relationship, use the definition in 'R'] [control element]} {已三元组形式输出;‘’中放的是输入的句子}
[0092] The constructed prompt extraction template of water conservancy field rules and the corpus representation are connected to obtain the input sequence IS, that is, the form of <input, template> sentence pairs, which is input into the large language model to extract flood control scheduling rules:
[0093] IS=[CLS] <inputtext>[SEP] <template>[SEP] (18)
[0094] Among them, [CLS] and [SEP] are special symbols, InputText represents the sentence of text input, and Template represents the template text sentence itself that integrates knowledge prompts and ontology extraction.
[0095] Finally, the extracted triple form is obtained.
[0096] y=[X]th[Y]tt[Z]r (19)
[0097] Among them, y represents the final extracted triple result, [X] represents the head entity object after extraction, and th represents the corresponding ontology and type of the head entity object. Similarly, [Y] represents the tail entity object after extraction, and tt represents the corresponding ontology and type of the tail entity object. [Z] represents the extracted or inferred relationship, and r represents the type of its relationship.
[0098] For example, if the rule "When the water level of Fuziling Reservoir reaches above 129 meters, and the water level of Bailianya Reservoir exceeds the flood limit but is lower than the designed maximum flood level of 233.91m, Bailianya will be completely closed to discharge flood water, and the flood discharge tunnel will continue to be open.", multiple triple structures can be extracted in the end. Here, only three triple structures are shown:
[0099] y1 = [Fuziling Reservoir] trigger object [water level] attribute [control element] control element
[0100] y2=[water level] attribute [129m] minimum value [reach] minimum value
[0101] y3 = [Bailianya Reservoir] trigger object [water level] attribute [control element] control element.
[0102] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.< / template> < / inputtext> < / template> < / inputtext>
Claims
1. A water conservancy field rule extraction method based on large language model learning and enhancement, characterized in that: The steps include: (1) Input the ontology and annotated documents into the large language model for parsing to generate water conservancy domain knowledge prompts and construct an offline prompt knowledge tree; (2) Construct the part-of-speech sequence of the sentence to be extracted to provide a structural data basis for subsequent keyword retrieval; (3) Using the large language model, the water conservancy keywords and special words in the part-of-speech sequence are retrieved in the offline prompt knowledge tree to find the prompt sentences that match them and generate a matching prompt list; (4) Introducing tags to simplify the expression of water conservancy rules, making it more intuitive and easy to understand; (5) Integrate the prompt list and simplified ontology expression to automatically construct an extraction template suitable for water conservancy field rules and complete the information extraction of field rules.
2. According to claim 1, a method for extracting rules from the water conservancy field based on large language model learning and enhancement is characterized in that: The step (1) comprises the following steps: (11) Using the large language model and a heuristic strategy, the labels of the annotated documents are learned about the trigger words, the prior condition types in the water conservancy rules, and all candidate labels; (12) The annotation content and knowledge in the obtained water conservancy annotation document are learned using a large language model and a context learning strategy to convert instances into prompts, thereby automatically generating structured prompts; (13) Integrate the results of (11) and (12), further utilize the generated prompt instructions, summarize knowledge, and improve prompts based on user feedback data; (14) According to the predefined ontology structure type, the ontology is expressed as O; at the same time, the collected water conservancy prompt information is organized and stored according to a tree structure to construct an offline prompt knowledge tree suitable for extracting structured information in the water conservancy field: O = {R, C, D} (1) Among them, C is the concept set including Csub and Cobj, R is the connection edge between C to represent the relationship, and D is the overall text description of each ontology.
3. According to claim 1, a method for extracting rules from the water conservancy field based on large language model learning and enhancement is characterized in that: The implementation process of step (2) is as follows: Using the part-of-speech analysis method, the user input is classified according to the part of speech and the corresponding sequence is constructed; according to the input document sentence, the nouns, verbs, adjectives and prepositions in the water conservancy rule sentence are identified, and then the identified objects are placed in the queue to be processed to form the corresponding sequence.
4. According to claim 1, a method for extracting rules from the water conservancy field based on large language model learning and enhancement is characterized in that: The implementation process of step (3) is as follows: (31) According to the input keyword sequence corpus and the type of the ontology, the offline prompt knowledge tree is dynamically queried and traversed; under each type, the corresponding knowledge tree branch is traversed in depth first, and the cosine similarity calculation is performed to find the corresponding prompt statement under the tree, and the corresponding prompt is given when extracting: P={T1…T n |T i :Prompt} (2) Among them, T1…T n Represents the branch of the hint knowledge tree, T i :Prompt represents the prompt statement at the i-th position in the current tree, and P represents the prompt statement that currently meets the conditions after traversal; (32) Generate corresponding prompts according to the entity type, and convert each Pc, P R、 P D The prompts are integrated to generate a prompt list for enhanced extraction; Pc∈P refers to the instance prompt in the prompt knowledge tree, corresponding to the branch of the ontology concept set C, P R ∈P is a sentence prompt in the prompt knowledge tree, corresponding to the branch of the ontology relation R, P D It is a global prompt in the prompt knowledge tree, corresponding to D in the ontology, which means the branch of explanation and definition; P R、 Pc 、 P D With the body<R,C,D> The types in complement and support each other: Q=∑P (3) Among them, Q represents all prompt statements that meet the conditions after traversing this branch.
5. According to claim 1, a method for extracting rules from the water conservancy field based on large language model learning and enhancement is characterized in that: The implementation process of step (4) is as follows: A formula rich in th, tt tags is introduced to feed the ontology information into the model for processing and simplified expression; formula W is used as a constraint in the extraction process, and the ontology and extraction instance results are structured through triples: W={[X]th[Y]tt[Z]r} D (4) Among them, [X] and [Y] represent the extracted text entity information, th and tt represent the type information of the head and tail entities, r represents the relationship, [Z] is used to represent the extracted relationship information, and D is the overall text description of each ontology.
6. According to claim 1, a method for extracting rules in the water conservancy field based on large language model learning and enhancement is characterized in that: Step (5) comprises the following steps: (51) Based on the obtained annotated documents, ontology structure and corresponding prompt strategies, a fusion representation is performed, and a prompt extraction template for water conservancy field rules is constructed: Template={[P C: Q]th[X]eh[P C :Q]tt[Y]et[P R :Q][Z]} P D (5) By adding necessary sentinel marks to the template, the model can better understand and operate the corresponding positions, and complete the extraction by using the cloze method; Pc prompts the instance prompts in the knowledge tree, corresponding to the branches of the ontology concept set C, P R is a sentence prompt in the prompt knowledge tree, corresponding to the branch of the ontology relationship R, P D It is a global prompt in the prompt knowledge tree, corresponding to D in the ontology, which means the branch of explanation and definition; P R、 Pc 、 P D And with the body<R,C,D> The types in complement and support each other; Q means that after traversing this branch, all prompt statements that meet the conditions are returned to the extraction template; (52) The constructed prompt extraction template of water conservancy domain rules and the corpus representation are connected to obtain the input sequence IS, that is, the form of <input, template> sentence pairs, which is input into the large language model to extract domain rules: IS=[CLS] <inputtext>[SEP] <template> [SEP] (6)< / template> < / inputtext> Among them, [CLS] and [SEP] are special symbols, InputText represents the sentence of text input, and Template represents the template text sentence itself that integrates knowledge prompts and ontology extraction; (53) Obtain the extracted triple form: y=[X]th[Y]tt[Z]r (7) Among them, Y represents the final extracted triple result, [X] represents the head entity object after extraction, and th represents the corresponding ontology and type of the head entity object; similarly, [Y] represents the tail entity object after extraction, and tt represents the corresponding ontology and type of the tail entity object; [Z] represents the extracted or inferred relationship, and r represents the type of its relationship.
7. According to claim 2, a method for extracting rules in the water conservancy field based on large language model learning and enhancement is characterized in that: The D includes a text containing word meaning information and concept relationship structure information.
Citation Information
Cited By
Water conservancy data quality inspection rule automatic generation method and system based on large language model
CN120067090A