LLM information extraction method based on prompt enhancement

Through the LLM information extraction method based on prompt enhancement, the tag and sample algorithm are dynamically generated, which solves the problem of insufficient accuracy of information extraction in small samples and multi-field applications, and realizes efficient text information extraction and multi-task extraction capabilities.

CN120371935APending Publication Date: 2025-07-2510TH RES INST OF CETC
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510459725.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

There is a problem of insufficient accuracy in existing information extraction technologies in small samples and multi-field applications, especially the problem of landing barriers and catastrophic forgetting in resource-constrained scenarios based on judgment and generative models.

Method used

The LLM information extraction method based on prompt enhancement is adopted, and the dynamic generation algorithm of text type detection and information extraction tasks is combined with the label and sample dynamic generation algorithm to improve the accuracy and universality of information extraction and realize the multi-task extraction capability.

Benefits of technology

It improves the accuracy of information extraction and the effect of the model in small sample scenarios, enhances the consistency and semantic distinction of text information extraction, and supports the universality of entity, relationship and event extraction tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371935A_ABST
    Figure CN120371935A_ABST
Patent Text Reader

Abstract

The invention provides an LLM information extraction method based on prompt enhancement, and the method comprises the steps: firstly carrying out the type detection dynamic prompt construction of a text, generating a type detection prompt word, and obtaining a text type detection result based on LLM prompt reasoning; the method comprises the following steps of: firstly, dynamically loading a label definition set contained in a text on the basis of a text type detection result, constructing a text information extraction task cue word on the basis of small sample cue, obtaining an information extraction result through LLM prediction, and finally, forming a text information extraction structured data result through format analysis of the extraction result. According to the method, the text information extraction task is converted into the text generation task, and structured analysis is performed based on the generated text, so that the text information extraction capability is improved, and the extraction precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a LLM information extraction method based on prompt enhancement. Background Art

[0002] Information Extraction (IE) is a core task in Natural Language Processing (NLP). Its main task is to extract structured knowledge information from unstructured text. As a basic capability in NLP, information extraction supports a large number of upstream and downstream natural language processing tasks, including knowledge graph construction, knowledge reasoning, knowledge question and answer, information association, information retrieval, etc. As NLP capabilities are empowered in various industries, the industry's demand for field information extraction is increasing, and the resulting rapid increase in basic work such as data annotation and data governance has largely restricted the implementation of information extraction capabilities in the industry.

[0003] In recent years, large language models (LLMs) have experienced rapid development. Thanks to their strong language intent understanding and language generation capabilities, LLMs have greatly improved the performance of NLP in various upstream and downstream tasks, and information extraction tasks have also made considerable progress. Compared with traditional discriminative extraction models, information extraction based on LLM's generative language model is no longer about extracting structured information from pure text, but about generating the required extraction results based on the contextual reading of the text. This new information extraction mode allows LLM to not only fine-tune learning through information extraction training data to improve information extraction results, but also rely on few-shot learning or prompt design to significantly improve information extraction results in limited training data and even zero-shot learning scenarios.

[0004] Currently, information extraction tasks mainly focus on two main technical approaches: discriminative information extraction and generative information extraction. Discriminative information extraction mainly identifies and extracts information elements based on discriminative deep learning models. However, most discriminative information extraction models are built using heterogeneous neural network models, with significant differences in training data styles and training task methods, poor pre-training semantic feature capture capabilities, and insufficient few-shot learning capabilities, posing significant challenges in multi-domain implementation. Generative information extraction mainly predicts information extraction through generative natural language models. By parsing the predicted information, a structured information prediction result is constructed to achieve information extraction capabilities. From the current mainstream research directions, it can be seen that most current methods are based on the SFT mode. However, training methods such as full-parameter SFT or LoRA bring catastrophic forgetting to the model and also form new implementation barriers in scenarios with limited computing resources and scenarios where rapid iteration of extraction tasks is required.

[0005] In summary, the current main development of information extraction is to explore how to improve the information extraction effect with fewer resources such as data annotation and data governance. This enables information extraction technology to achieve the expected effect through less data learning in the application analysis of different sample data and different domains. The above information extraction methods have their own advantages and disadvantages and still have problems that are difficult to meet the requirements of information extraction accuracy. Summary of the Invention

[0006] The present invention aims to solve at least one of the above technical problems in the prior art.

[0007] To this end, the present invention provides a method for information extraction based on prompt-enhanced LLM.

[0008] A method for information extraction based on prompt-enhanced LLM provided by the present invention includes:

[0009] Obtain the input text, and perform text type detection on the input text to obtain the text type detection result. The text type detection includes text type detection prompt construction and text type detection prompt reasoning. Among them, text type detection prompt construction includes generating text type detection prompt words; text type detection prompt reasoning includes performing prompt reasoning prediction through LLM according to the text type detection prompt words to obtain text type labels;

[0010] Based on the text type label, perform information extraction on the input text. The information extraction includes information extraction prompt construction and information extraction reasoning. Among them, information extraction prompt construction includes dynamically loading the label definition set included in the input text, and then constructing text information extraction task prompt words based on few-shot prompts; information extraction reasoning includes performing prompt reasoning prediction through LLM according to the information extraction task prompt words to obtain information extraction results;

[0011] Parse the string result generated by information extraction, and generate structured data through parsing to complete the information extraction task;

[0012] Among them, in text type detection, the dynamic generation of text type detection prompt words is realized through the sample dynamic generation algorithm; in information extraction, the dynamic generation of information extraction task prompt words is realized through the label dynamic generation algorithm and the sample dynamic generation algorithm;

[0013] The label dynamic generation algorithm includes dynamically generating task labels for information extraction according to text type labels and label information defined by extraction tasks;

[0014] The sample dynamic generation algorithm includes generating corresponding sample example prompt words by retrieving and recalling similar text information and text annotation information through vector retrieval according to the tasks and semantic information of the text.

[0015] According to the method for LLM information extraction based on prompt enhancement of the above technical solution of the present invention, it may also have the following additional technical features:

[0016] In the above technical solution, the information extraction task includes at least one of entity extraction, relationship extraction, and event extraction;

[0017] Entity extraction includes detecting entity boundaries and identifying their types;

[0018] Relationship extraction includes detecting the boundaries and types of the head entity and the tail entity, and discriminating the relationship type between the head entity and the tail entity;

[0019] Event extraction includes identifying event types and identifying arguments that play corresponding roles in the event from the text based on the event types.

[0020] In the above technical solution, based on the information extraction task, the definition form of the label description is defined:

[0021] The text type label is Tag text 、The entity type label is Tag entity 、The relationship type label is Tag relation 、The relationship entity type label is Tag relation_entity 、The event type label is Tag event 、The event role label is Tag event_role ;

[0022] The text type label set is defined as {Tag text1 ,Tag text2 …}, and each label in the set represents a text category;

[0023] The set of entity type tags is defined as {Tag text1 :{Tag entity1a ,Tag entity1b},Tag text2 :{Tag entity2a ,Tag entity2b ,Tag entity2c}…}, where each type of text type tag Tag text contains different entity type tags Tag entity ;

[0024] The set of relationship type tags is defined as {Tag text1 :[{Tag relation_entity1 ,Tag entity1a ,Tag entity1b},{Ta g relation_entity2 ,Tag entity2a ,Tag entity2b},…]…}, where each type of text type tag Tag text , contains different relationship entity type tags Tag relation_entity and the start and end entity type tags Tag entity ;

[0025] The set of event type tags is defined as {Tag text1 :[{Tag event1 :{Tag event_role 1,Tag event_role2 ,Tag event_role3}},…]…}, where each type of text type tag Tag text , contains different event type tags Tag event and the event role tags Tag event_role corresponding to different event type tags.

[0026] In the above technical solution, the label dynamic generation algorithm includes:

[0027] Input the text type tag output by text type detection, and compare the result with the text type tags in the entity type tag set, relationship type tag set, and event type tag set; if there is a corresponding text type tag in the set, load the corresponding information extraction tag set; if there is no corresponding text type tag in the set, load all the information extraction tag sets defined in the extraction task;

[0028] Generate corresponding task prompt words through the prompt template, and the task prompt words are defined as: the information extraction task includes IEMission; where IEMission represents the type of the set with the corresponding text type tag, and if not, it includes all set types;

[0029] Generate the corresponding label set prompt words through the prompt template. The label set prompt words are defined as follows: The information extraction labels include several types of labels such as IEMission, and the specific labels are defined as IETag. Among them, IETag represents the defined specific entity type labels, relationship type labels, and event type labels; if not present, it includes all defined entity type labels, relationship type labels, and event type labels.

[0030] In the above technical solution, the sample dynamic generation algorithm includes:

[0031] Input the sample generation type. Among them, the sample generation type includes information extraction type and text classification type. Through type detection, load the vector database that fails to pass to complete the construction of the sample vector candidate set. Among them, the index of the vector database is the calculation result of the semantic feature vector of the original sample text, and the value of the vector database is the original text information and the corresponding annotation label result.

[0032] Input the text to be predicted, and perform vector calculation through the loaded vector calculation model to obtain the semantic vector calculation result.

[0033] Through the semantic vector calculation result of the text to be predicted and the loaded vector database, through vector recall calculation, obtain the set of the most similar sample examples Exam N and based on Exam N Construct the sample example prompt words. The sample example prompt words are defined as follows: The examples are as follows ExamN; among them, in the vector recall calculation process, the semantic similarity calculation formula used is as follows:

[0034]

[0035] Among them, vec text represents the text feature vector, that is, the semantic vector calculation result of the text to be predicted; vec exam represents the sample feature vector, that is, the calculation result of the semantic feature vector of the original sample text; Sim represents the semantic similarity calculation result.

[0036] In the above technical solution, the text featureization model adopted by the vector calculation model is the BGE text Embedding model based on the asymmetric encoder-decoder structure RetroMAE model architecture to perform text vectorization modeling.

[0037] In the above technical solution, the text type detection prompt words include the first semantic role, the first task, the first requirement, the first label set, the first sample example, and the first text.

[0038] Among them, the first semantic role is defined as the text classifier.

[0039] The first task is defined as a text classification task;

[0040] The first requirement is defined as outputting a text type label classification according to the original text content based on the label description;

[0041] The first label description set is defined as including the text type label Tag text and for each type of text, a text description Des is defined text The label description set, denoted as tag = {Tag text1 :Des text1 ,Tag text2 :Des text2 …};

[0042] The first sample example is generated by using the sample dynamic generation algorithm, and through the construction of text classification type sample examples, the construction result of the sample example prompt is generated;

[0043] The first text is defined as the text information to be predicted.

[0044] In the above technical solution, the information extraction task prompt words include the second semantic role, the second task, the second requirement, the second label set, the second sample example, and the second text;

[0045] Among them, the second semantic role is defined as an information extraction tool;

[0046] The second task is defined according to the definition and generation of the task prompt words in the label dynamic generation algorithm;

[0047] The second requirement is defined as extracting information in a specified format and outputting the result;

[0048] The second label set is defined according to the definition and generation of the label set prompt words in the label dynamic generation algorithm;

[0049] The second sample example is generated by using the sample dynamic generation algorithm, and through the construction of information extraction type sample examples, the construction result of the sample example prompt is generated;

[0050] The second text is defined as the text information to be predicted.

[0051] In the above technical solution, the LLM adopts the Qwen series model.

[0052] In the above technical solution, the format parsing includes using the JSON format for data parsing.

[0053] In summary, due to the adoption of the above technical features, the beneficial effects of the present invention are:

[0054] A method for extracting information from LLM based on prompt enhancement proposed by the present invention transforms the text information extraction task into a text generation task, and performs structured parsing based on the generated text to improve the text information extraction ability and extraction accuracy. Specifically, in terms of prompt construction, the present invention adopts a dynamic construction scheme that combines the dynamic generation of tags with the recall of semantic feature samples, enabling different texts to dynamically construct information extraction tasks through semantics, enhancing the consistency between the text information extraction tags and the semantic connotations of the text, and improving the extraction accuracy of the model. In terms of general construction, the present invention realizes entity extraction tasks, relationship extraction tasks, and event extraction tasks on the framework through the definition of multi-task tags, reflecting the ability of this technology in multi-task general information extraction. In terms of the alignment of the semantic space, the present invention uses contrastive learning to align semantic features. Through the construction of positive and negative sample contrasts, the distinguishability of the text in semantic features becomes more obvious, improving the effect in the small-sample prompt recall process of this algorithm.

[0055] Additional aspects and advantages of the present invention will become apparent in the following description section or be learned through the practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The above and / or additional aspects and advantages of the present invention will become apparent and be readily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0057] Figure 1 is a flowchart of a method for extracting information from LLM based on prompt enhancement according to an embodiment of the present invention;

[0058] Figure 2 is a flowchart of an algorithm for dynamically generating tags in an embodiment of the present invention;

[0059] Figure 3 is a flowchart of an algorithm for dynamically generating samples in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0060] In order to more clearly understand the above objects, features, and advantages of the present invention, the present invention will be further described in detail below in conjunction with the drawings and specific embodiments. It should be noted that, without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.

[0061] Many specific details are set forth in the following description in order to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited by the specific embodiments disclosed below.

[0062] The following refers to Figures 1 to 3 to describe a method for extracting information from LLM based on prompt enhancement according to some embodiments of the present invention.

[0063] Some embodiments of the present application provide a method for information extraction based on prompt enhancement for large language models (LLMs).

[0064] Before information extraction, it is first necessary to define the tags required for the text. In this disclosure, the information extraction tasks are divided into three tasks: entity extraction, relationship extraction, and event extraction; that is to say, in practical applications, this disclosure can implement any one or more of the above three extraction tasks.

[0065] Specifically, entity extraction includes detecting the boundaries of entities and identifying their types; relationship extraction includes detecting the boundaries and types of the head entity and the tail entity, and discriminating the relationship type between the head entity and the tail entity; event extraction includes identifying the event type and identifying the arguments that play corresponding roles in the event from the text.

[0066] Based on the above three types of tasks, the definition form of the tags is defined as follows:

[0067] The text type tag is Tag text , the entity type tag is Tag entity , the relationship type tag is Tag relation , the relationship entity type tag is Tag relation_entity , the event type tag is Tag event , the event role tag is Tag event_role ;

[0068] The text type tag set is defined as {Tag text1 , Tag text2 …}, and each tag in the set represents a text category;

[0069] The entity type tag set is defined as {Tag text1 : {Tag entity1a , Tag entity1b}, Tag text2 : {Tag entity2a , Tag entity2b , Tag entity2c}…}, where each text type tag Tag text contains different entity type tags Tag entity ;

[0070] The relationship type tag set is defined as {Tag text1 : [{Tag relation_entity1 , Tag entity1a , Tag entity1b}, {Tag relation_entity2 , Tag entity2a , Tag entity2b}, …] …}, where each type of text type label Tag text , includes different relationship entity type labels Tag relation_entity and start and end entity type labels Tag entity ;

[0071] The set of event type labels is defined as {Tag text1 : [{Tag event1 : {Tag event_role 1, Tag event_role2 , Tag event_role3}}, …] …}, where each type of text type label Tag text , includes different event type labels Tag event and event role labels Tag corresponding to different event type labels event_role .

[0072] As Figure 1 shown, the first embodiment of the present invention proposes an LLM information extraction method based on prompt enhancement, including the following steps S1 - S3.

[0073] S1. Obtain the input text, perform text type detection on the input text to obtain the text type detection result, where the text type detection includes text type detection prompt construction and text type detection prompt reasoning; among them, text type detection prompt construction includes generating text type detection prompt words, and dynamically generating text type detection prompt words through a sample dynamic generation algorithm; text type detection prompt reasoning includes performing prompt reasoning prediction through the LLM according to the text type detection prompt words to obtain text type labels.

[0074] In some embodiments, the text type detection prompt words include a first semantic role, a first task, a first requirement, a first label set, a first sample example, and a first text.

[0075] Among them, the first semantic role is defined as a text classifier; the first task is defined as a text classification task; the first requirement is defined as classifying and outputting text type labels according to the original content based on the label description; the first label description set is defined as including the text type label Tag text and a label description set that defines text descriptions Des text for each type of text, expressed as tag = {Tag text1 : Des text1 , Tag text2 : Des text2 …}; the first sample example is generated by using the sample dynamic generation algorithm, and through the construction of text classification type sample examples, the generation result of the sample example prompt is generated; the first text is defined as the text information to be predicted.

[0076] Based on the text type prompt construction, through the LLM for prompt inference prediction, the text type detection result is obtained, that is, the text type label; in a specific embodiment, the LLM adopts the Qwen series model with a model parameter quantity of 72B.

[0077] S2. Based on the text type label, perform information extraction on the input text; the information extraction includes information extraction prompt construction and information extraction inference; among them, the information extraction prompt construction includes dynamically loading the label definition set contained in the input text, and then constructing the prompt words for the text information extraction task based on few-shot prompts; the dynamic generation of the prompt words for the information extraction task is realized through the label dynamic generation algorithm and the sample dynamic generation algorithm; the information extraction inference includes performing prompt inference prediction through the LLM according to the prompt words for the information extraction task to obtain the information extraction result.

[0078] In some embodiments, the prompt words for the information extraction task include the second semantic role, the second task, the second requirement, the second label set, the second sample example, and the second text.

[0079] Among them, the second semantic role is defined as the information extraction tool; the second task is defined according to the definition and generation of the prompt words in the label dynamic generation algorithm; the second requirement is defined as extracting information and outputting the result in a specified format; the second label set is defined according to the definition and generation of the label set prompt words in the label dynamic generation algorithm; the second sample example is generated by using the sample dynamic generation algorithm, and the result of the sample example prompt construction is generated through the construction of the information extraction type sample example; the second text is defined as the text information to be predicted.

[0080] Based on the information extraction prompt construction, through the LLM for prompt inference prediction, the information extraction result is obtained. In a specific embodiment, the LLM adopts the Qwen series model with a model parameter quantity of 72B.

[0081] S3. Parse the string result generated by the information extraction to generate structured data, and complete the information extraction task. In a specific embodiment, the format parsing includes using the JSON format for data parsing.

[0082] In any of the above embodiments, the label dynamic generation algorithm includes dynamically generating the task label for information extraction according to the text type label and the label information defined by the extraction task.

[0083] In some embodiments, as Figure 2 shown, the label dynamic generation algorithm includes:

[0084] Input the text type label detected from the input text type, and compare the result with the text type labels in the entity type label set, relationship type label set, and event type label set; if there is a corresponding text type label in the set, load the corresponding information extraction label set; if there is no corresponding text type label in the set, load all the information extraction label sets defined in the extraction task.

[0085] Generate the corresponding task prompt word through the prompt template. The task prompt word is defined as: The information extraction task includes IEMission; where IEMission represents the type of the set with the corresponding text type label, and if not, it includes all set types, that is, it includes entity extraction tasks, relationship extraction tasks, and event extraction tasks.

[0086] Generate the corresponding label set prompt word through the prompt template. The label set prompt word is defined as: The information extraction label includes several types of labels of IEMission, and the specific labels are defined as IETag; where IETag represents the defined specific entity type labels, relationship type labels, and event type labels; if not, it includes all the defined entity type labels, relationship type labels, and event type labels.

[0087] In any of the above embodiments, the sample dynamic generation algorithm includes, according to the task and semantic information of the text, recalling similar text information and text annotation information through vector retrieval to generate the corresponding sample example prompt word.

[0088] In some embodiments, as Figure 3 shown, the sample dynamic generation algorithm includes:

[0089] Input the example generation type, where the example generation type includes information extraction type and text classification type. Through type detection, load the vector database that fails to pass to complete the construction of the sample vector candidate set; where the index of the vector database is the calculation result of the semantic feature vector of the original text of the example, and the value of the vector database is the original text information and the corresponding annotation label result.

[0090] Input the text to be predicted, perform vector calculation through the loaded vector calculation model to obtain the semantic vector calculation result; in a specific embodiment, the text featureization model adopted by the vector calculation model is the BGE text Embedding model based on the asymmetric encoder-decoder structure RetroMAE model architecture for text vectorization modeling.

[0091] Through the semantic vector calculation result of the text to be predicted and the loaded vector database, perform vector recall calculation to obtain the most similar sample example set Exam N and based on ExamN Construct a sample prompt, where the sample prompt is defined as follows: The example is ExamN; among them, during the vector recall calculation process, the semantic similarity calculation formula used is as follows:

[0092]

[0093] Among them, vec text represents the text feature vector, that is, the calculation result of the semantic vector of the text to be predicted; vec exam represents the sample feature vector, that is, the calculation result of the semantic feature vector of the original text of the example; Sim represents the calculation result of the semantic similarity.

[0094] In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiments or examples. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0095] Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for extracting information from an LLM based on prompt enhancement, characterized in that, Including: Obtain the input text, and perform text type detection on the input text to obtain the text type detection result. The text type detection includes text type detection prompt construction and text type detection prompt reasoning. Among them, text type detection prompt construction includes generating text type detection prompt words. Text type detection prompt reasoning includes performing prompt reasoning prediction through an LLM according to the text type detection prompt words to obtain text type labels. Based on the text type labels, perform information extraction on the input text. The information extraction includes information extraction prompt construction and information extraction reasoning. Among them, information extraction prompt construction includes dynamically loading the label definition set included in the input text, and then constructing text information extraction task prompt words based on few-shot prompts. Information extraction reasoning includes performing prompt reasoning prediction through an LLM according to the information extraction task prompt words to obtain information extraction results. Parse the string result generated by information extraction to generate structured data and complete the information extraction task. Among them, in text type detection, the dynamic generation of text type detection prompt words is realized through a sample dynamic generation algorithm. In information extraction, the dynamic generation of information extraction task prompt words is realized through a label dynamic generation algorithm and a sample dynamic generation algorithm. The label dynamic generation algorithm includes dynamically generating task labels for information extraction according to the text type labels and the label information defined in the extraction task. The sample dynamic generation algorithm includes retrieving similar text information and text annotation information through vector retrieval according to the task and semantic information of the text, and generating corresponding sample example prompt words.

2. The method for extracting LLM information based on prompt enhancement according to claim 1, wherein The information extraction task includes at least one of entity extraction, relation extraction, and event extraction. Entity extraction includes detecting the entity boundary and identifying its type. Relation extraction includes detecting the boundaries and types of the head entity and the tail entity, and discriminating the relation type between the head entity and the tail entity. Event extraction includes identifying the event type and identifying the arguments that play corresponding roles in the event from the text based on the event type.

3. The method for extracting LLM information based on prompt enhancement according to claim 2, wherein Based on the information extraction task, define the label description form: The text type label is Tag text , the entity type label is Tag entity , the relationship type label is Tag relation , the relationship entity type label is Tag relation_entity , the event type label is Tag event , the event role label is Tag event_role ; The set of text type tags is defined as {Tag text1 , Tag text2 …}, and each tag in the set represents a text category; The set of entity type tags is defined as {Tag text1 :{Tag entity1a ,Tag entity1b},Tag text2 :{Tag entity2a ,Tag entity2b ,Tag entity2c}…}, where each text type tag Tag text contains different entity type tags Tag entity ; The set of relationship type tags is defined as {Tag text1 : [{Tag relation_entity1 , Tag entity1a , Tag entity1b}, {Tag relation_entity2 , Tag entity2a , Tag entity2b}, …]…}, where each type of text type tag Tag text contains different relationship entity type tags Tag relation_entity and the start and end entity type tags Tag entity ; The set of event type tags is defined as {Tag text1 :[{Tag event1 :{Tag event_role 1,Tag event_role2 ,Tag event_role3}},…]…}, where each text type tag Tag text contains different event type tags Tag event and the event role tags Tag event_role corresponding to different event type tags.

4. The method for extracting LLM information enhanced by prompts according to claim 3, wherein The label dynamic generation algorithm includes: Input the text type labels output by text type detection, and compare the results with the text type labels in the entity type label set, relation type label set, and event type label set. If there is a corresponding text type label in the set, load the corresponding information extraction label set. If there is no corresponding text type label in the set, load all the information extraction label sets defined in the extraction task. Generate corresponding task prompt words through a prompt template. The task prompt words are defined as: The information extraction task includes IEMission; where IEMission represents the type of the set with the corresponding text type label, and if not, it includes all set types. Generate the corresponding tag set prompt through the prompt template. The tag set prompt is defined as follows: The information extraction tags include several types of tags such as IEMission, and the specific tags are defined as IETag. Among them, IETag represents the defined specific entity type tags, relationship type tags, and event type tags. If not present, it includes all defined entity type tags, relationship type tags, and event type tags.

5. The method for LLM information extraction based on prompt enhancement according to claim 3, wherein The sample dynamic generation algorithm includes: Input the sample generation type. Among them, the sample generation type includes information extraction type and text classification type. Through type detection, load the vector database that fails to pass, and complete the construction of the sample vector candidate set. Among them, the index of the vector database is the calculation result of the semantic feature vector of the original sample text, and the value of the vector database is the original text information and the corresponding labeled tag result. Input the text to be predicted, and perform vector calculation by loading the vector calculation model to obtain the semantic vector calculation result. Based on the calculation result of the semantic vector of the text to be predicted and the loaded vector database, the most similar set of sample examples Exam is obtained through vector recall calculation N , and based on Exam N a sample example prompt is constructed. The sample example prompt is defined as: The examples are as follows ExamN; Among them, in the vector recall calculation process, the semantic similarity calculation formula used is as follows: Among them, vec text represents the text feature vector, that is, the calculation result of the semantic vector of the text to be predicted; vec exam represents the sample feature vector, that is, the calculation result of the semantic feature vector of the original text of the sample; Sim represents the calculation result of the semantic similarity.

6. The method for extracting LLM information enhanced by prompts according to claim 5, wherein The text feature extraction model adopted by the vector calculation model is the BGE text Embedding model based on the asymmetric encoder-decoder structure RetroMAE model architecture to perform text vectorization modeling.

7. The method for extracting LLM information enhanced by prompts according to claim 1, wherein The text type detection prompt words include the first semantic role, the first task, the first requirement, the first tag set, the first sample example, and the first text. Among them, the first semantic role is defined as the text classifier. The first task is defined as the text classification task. The first requirement is defined as outputting the text type label classification according to the label description based on the original text content. The first set of tag descriptions is defined to include text type tags Tag text and for each type of text, a text description Des is defined text The set of tag descriptions, denoted as tag = {Tag text1 : Des text1 , Tag text2 : Des text2 …}; The first sample example is generated by using the sample dynamic generation algorithm. Through the construction of the text classification type sample example, the sample example prompt construction result is generated. The first text is defined as the text information to be predicted.

8. The method for extracting LLM information based on prompt enhancement according to claim 4, wherein The information extraction task prompt words include the second semantic role, the second task, the second requirement, the second tag set, the second sample example, and the second text. Among them, the second semantic role is defined as the information extraction tool. The second task is defined according to the definition and generation of the task prompt words in the tag dynamic generation algorithm. The second requirement is defined as extracting information in the specified format and outputting the result. The second tag set is defined according to the definition and generation of the tag set prompt words in the tag dynamic generation algorithm. The second sample example is generated by using the sample dynamic generation algorithm. Through the construction of the information extraction type sample example, the sample example prompt construction result is generated. The second text is defined as the text information to be predicted.

9. The method for LLM information extraction based on prompt enhancement according to claim 1, wherein The LLM adopts the Qwen series models.

10. The method for extracting LLM information enhanced by prompts according to claim 1, wherein The format parsing includes data parsing in JSON format.

Citation Information

Cited By

  • Cross-disaster-type dynamic prompt-driven disaster knowledge element extraction method and related device

    CN121328538A