Method for generating Agent by fine-grained knowledge of embedded metadata cue word project
Through the fine-grained knowledge generation Agent method of embedded metadata prompt word engineering, the problem of language models training based on general data sets ignore specific domain knowledge, achieving higher accuracy and quality of research problem generation.
Patent Information
- Application Number
- CN202411804989.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-12-10
AI Technical Summary
In the prior art, model training is carried out based on general data sets, and knowledge elements of specific domains are ignored, resulting in inaccurate language models and poor accuracy in the generation of research questions.
By providing the fine-grained knowledge generation Agent method for embedded metadata prompt word engineering, analyzing the elements of research problem generation, determining the research purpose sentences and research method sentences, constructing a knowledge element training data set, training and fine-tuning the DeBERta model, extracting the fine-grained knowledge data set, building an embedded metadata prompt word engineering, and using LoRA fine-tuning technology to fine-tune and optimize the large language model.
It improves the accuracy and quality of language model training and research problem results generation, ensuring that the model pays more precise attention to professional theories and methods in specific fields.
Smart Images

Figure CN119647578A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field related to data processing, and in particular to an agent method for generating fine-grained knowledge of metadata-embedded prompt word engineering. Background Art
[0002] In the current field of natural language processing (NLP), the application of language models has become an important tool for solving complex knowledge generation problems. Prompt engineering is a technology for designing and optimizing input prompts to guide large language models to generate specific outputs or perform specific tasks. It mainly includes instructions, contexts, and examples, so that large language models can better understand task requirements and produce the required outputs, and generate research questions based on the input text. The generation of research questions mainly utilizes the ability of large language models to summarize and generate scientific and technological literature. The process is as follows: first, the large model analyzes and understands the input scientific and technological literature, and then based on the model knowledge base and the understanding of scientific research paradigms, the large model identifies potential research gaps, contradictions, or expandable directions in the literature. Then, the large model uses this information to construct possible research questions and ensures that the generated questions meet the expression specifications. Finally, the model generates multiple candidate research questions and sorts them according to relevance and quality. However, traditional language models face many challenges in dealing with high-complexity and fine-grained knowledge generation tasks. For example, when constructing prompt words, the fine-grained knowledge required for specific fields or tasks is ignored. That is, the content generation of most large language models is mainly based on the training of general data sets, which means that prompt words that ignore knowledge elements in specific fields may not be able to guide the large models to focus on professional theories, methods and other information in the field; in addition, for specific generation tasks, fine-grained knowledge is not analyzed and screened. A small number of large language models generated for specific tasks try to use text data in related fields for training, but do not screen and refine fine-grained knowledge for specific generation tasks, and are still mixed with a large amount of redundant information, which leads to low accuracy of the language model and reduces the accuracy of the generated research questions.
[0003] At present, relevant technologies have technical problems such as training models based on general data sets, ignoring knowledge elements in specific fields, and failing to analyze and filter fine-grained knowledge, which makes the data redundant, and thus leads to inaccurate language models and poor accuracy of the generated results for research problems. Summary of the invention
[0004] This application solves the technical problems in the prior art of training models based on general data sets, ignoring knowledge elements in specific fields, failing to analyze and screen fine-grained knowledge, resulting in redundant data, and thus leading to inaccurate language models and poor accuracy of generated results for research problems, by providing an agent method for generating fine-grained knowledge embedded in metadata prompt word engineering. This achieves the technical effect of improving the accuracy and quality of language model training and generation of research problem results.
[0005] The present application provides an Agent method for generating fine-grained knowledge of an embedded metadata prompt word project, comprising: analyzing research problem generation elements to determine research problem generation knowledge elements, wherein the research problem generation knowledge elements include a research purpose sentence and a research method sentence; performing data annotation and syntactic structure analysis on the research purpose sentence and the research method sentence to construct a knowledge element training data set; training and fine-tuning a DeBERta model based on the knowledge element training data set, and extracting the research purpose sentence and the research method sentence using the fine-tuned DeBERta model to obtain a fine-grained knowledge data set; constructing an embedded metadata prompt word project based on the fine-grained knowledge data set; obtaining a research problem fine-tuning data set based on the embedded metadata prompt word project, wherein the research problem fine-tuning data set consists of a task description part, an input part, and an output part; fine-tuning and optimizing a large language model based on the research problem fine-tuning data set using the LoRA fine-tuning technology, and generating research problems based on the optimized large language model.
[0006] In a possible implementation, the construction of the knowledge element training data set also performs the following processing: collecting and acquiring a scientific and technological literature data set; annotating the scientific and technological literature data set using a manual annotation method and an iteration-based semi-automatic annotation method to construct a research purpose sentence data set and a research method sentence data set; performing syntactic structure analysis on the research purpose sentence data set and the research method sentence data set to extract a purpose sentence feature word set and a method sentence feature word set; performing feature sentence pattern analysis on the research purpose sentence data set and the research method sentence data set to obtain a purpose sentence feature sentence pattern set and a method sentence feature sentence pattern set; constructing the knowledge element training data set based on the purpose sentence feature word set and the method sentence feature word set, as well as the purpose sentence feature sentence pattern set and the method sentence feature sentence pattern set.
[0007] In a possible implementation, the construction of the research purpose sentence dataset and the research method sentence dataset also performs the following processing: annotating a preset proportion of the scientific and technological literature dataset using a manual annotation method to obtain a manually annotated dataset; training the manually annotated dataset using an iteration-based semi-automatic annotation method to obtain a basic annotation model; performing iterative annotation training based on the basic annotation model to obtain an automatic annotation model; and annotating the scientific and technological literature dataset using the automatic annotation model to construct the research purpose sentence dataset and the research method sentence dataset.
[0008] In a possible implementation, the LoRA fine-tuning technology is used to fine-tune the large language model based on the research problem fine-tuning dataset, and the following processing is also performed: selecting and obtaining a pre-trained large language model and setting fine-tuning hyperparameters; defining a LoRA module, the LoRA module is composed of a first low-rank projection matrix A i and the second low-rank projection matrix B i Composition, where i is the i-th layer of the large language model; introduce the first low-rank projection matrix A i and the second low-rank projection matrix B i , based on the research problem fine-tuning dataset and the fine-tuning hyperparameters, the large language model is trained, fine-tuned and optimized.
[0009] In a possible implementation, the fine-grained knowledge generation agent method for embedding metadata prompt word engineering further performs the following processing: introducing the first low-rank projection matrix A on each layer i of the large language model i and the second low-rank projection matrix B i ; Based on the research problem fine-tuning dataset and the fine-tuning hyperparameters, the large language model is trained through forward propagation to obtain the original forward calculation result h of the i-th layer of the large language model i =f i (x i ), where x i is the input of the i-th layer, f i is the forward calculation function of the i-th layer; based on the first low-rank projection matrix A i and the second low-rank projection matrix B i The original forward calculation result is corrected to obtain a forward corrected calculation result; a model loss function is constructed, with minimizing the model loss function as an optimization goal; and the large language model is fine-tuned and optimized based on the forward corrected calculation result according to the optimization goal.
[0010] In a possible implementation, the step of obtaining the forward correction calculation result further includes performing the following processing: i and the second low-rank projection matrix Bi , construct the forward correction calculation formula: h i ′=f i (x i )+A i B i f i (x i ) = f i (x i )+Δ i , where Δ i =A i B i f i (x i ) represents the correction term introduced by the LoRA module; based on the forward correction calculation formula, the original forward calculation result is corrected to obtain the forward correction calculation result.
[0011] In a possible implementation, the fine-grained knowledge generation agent method for embedding metadata prompt word engineering further performs the following processing: the model loss function is specifically:
[0012]
[0013] Among them, θ represents the fixed parameters of the original model, Represents all projection matrices introduced by the LoRA module, is the training dataset for the new task, is the task-related loss function.
[0014] In a possible implementation, the fine-grained knowledge generation agent method for embedding metadata prompt word engineering further performs the following processing: according to the first low-rank projection matrix A i and the second low-rank projection matrix B i , determine the first matrix dimension (d, r) and the second matrix dimension (r, d), where d is the model hidden layer dimension, r is the projection dimension, and r< <d。
[0015] Through the fine-grained knowledge generation agent method of the embedded metadata prompt word project proposed in this application, the research question generation elements are analyzed to determine the knowledge elements for the research question generation; data annotation and syntactic structure analysis are performed to construct a knowledge element training data set; the DeBERta model is trained and fine-tuned, and the research purpose sentence and research method sentence are extracted to obtain a fine-grained knowledge data set; the embedded metadata prompt word project is constructed; the research question fine-tuning data set is obtained; the large language model is fine-tuned and optimized using the LoRA fine-tuning technology, and research questions are generated. The technical problems existing in the prior art of model training based on general data sets, ignoring knowledge elements in specific fields, and not analyzing and screening fine-grained knowledge, which makes the data redundant, and thus leads to inaccurate language models and poor accuracy of research question generation results, are solved, and the accuracy and quality of language model training and research question result generation are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the accompanying drawings of the embodiment of the present invention will be briefly introduced below. A flow chart is used in the present application to illustrate the operations performed by the system according to the embodiment of the present application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, various steps can be processed in reverse order or simultaneously as needed. At the same time, other operations can also be added to these processes, or one or more operations can be removed from these processes.
[0017] Figure 1 A flowchart of a fine-grained knowledge generation agent method for embedding metadata prompt word engineering provided in an embodiment of the present application;
[0018] Figure 2 A schematic diagram of the process of constructing a dataset of research purpose sentences and research method sentences in the fine-grained knowledge generation agent method of the metadata prompt word embedded engineering provided in an embodiment of the present application. DETAILED DESCRIPTION
[0019] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below.
[0020] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0021] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict, and the terms "first\second" involved are merely to distinguish similar objects and do not represent a specific ordering of objects. The terms "including" and "having" and any variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products, or devices. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field of this application. The terms used herein are for the purpose of describing the embodiments of the present application only.
[0022] The present application embodiment provides a method for generating an agent based on fine-grained knowledge embedded in metadata prompt word engineering, such as Figure 1 As shown, the method includes:
[0023] Step S100, analyzing the research question generation elements to determine the research question generation knowledge elements, wherein the research question generation knowledge elements include a research purpose sentence and a research method sentence.
[0024] Preferably, the research question generation method based on fine-grained knowledge prompt mainly analyzes the knowledge elements required for the large model to generate research questions, then extracts fine-grained knowledge from scientific and technological literature and constructs prompts. The format of the research question prompt that integrates fine-grained knowledge is as follows: Given the title: the title of the paper, the research objective: the research objective sentence, the research methods: the research method sentence, can we distill a concise questionsummarizing the research issue addressed in this article? (Can we extract a concise question to summarize the research problem involved in the article) Please use appropriate question words! (Please use appropriate question words) Question: the summarized research question, and then fine-tune the large model to finally achieve the accurate generation of research questions in scientific and technological literature. Specifically, research questions can be divided into two categories: theoretical questions and methodological questions. Among them, theoretical questions focus on exploring the nature, laws and mechanisms of things, aiming to establish or develop scientific theories; in scientific and technological literature, this question is usually reflected in the research objective part, and the researcher will clearly point out what the theoretical problem to be explored is. Methodological problems arise from the challenges of technical routes or methods encountered in the scientific research process, and aim to explore effective solutions. In scientific and technological literature, methodological problems are usually reflected in the research methods, and researchers will focus on introducing the specific technical solutions and implementation steps taken to solve the problems.
[0025] Preferably, analyzing the elements of research problem generation means systematically disassembling the research problem and identifying the core information closely related to the research task, so as to provide an accurate and fine-grained basis for the knowledge generation process, including the research purpose sentence and the research method sentence, and then forming the knowledge elements of research problem generation. Specifically, the research purpose sentence is a sentence used to clearly state the main goal or intention of the research work, usually answering the core question of "What problem does the research want to solve?" or "What results do the research hope to achieve?" The research purpose sentence can directly reflect the motivation and direction of the research and is the core driving force of the research problem. The research method sentence is a description of the specific methods, techniques or paths to achieve the research objectives, usually answering the question of "How is the research conducted?" or "What means and tools are used?" The research method sentence provides technical support for the realization of the research objectives and reflects the operability and logic of the research.
[0026] Step S200, performing data annotation and syntactic structure analysis on the research purpose sentence and the research method sentence to construct a knowledge element training data set.
[0027] Preferably, data annotation and syntactic structure analysis of the research purpose sentences and research method sentences refers to the refinement and structuring of the text data in the research question, that is, the construction of the research purpose sentence and method sentence data set by manual annotation and iterative semi-automatic annotation method, a total of 15,000 high-quality corpora are obtained, and the knowledge element training data set is constructed. Specifically, data annotation refers to the semi-automatic annotation of the content related to the research purpose sentences and research method sentences in the text data, clarifying their semantic boundaries and category attributes, including, through predefined rules or preliminary models, the research question text that may belong to the research purpose sentences and research method sentences. The research method sentence is extracted, and the corresponding labels are assigned to the extracted sentences. The keywords, phrases, and syntactic components in the sentences are accurately annotated to ensure the consistency of the annotations between different samples; syntactic structure analysis refers to parsing the grammatical structure of the research purpose sentence and the research method sentence, extracting syntactic relations, such as subject, predicate, object, and modifying components. Specifically, the sentences are segmented and each word is assigned a part of speech (such as noun, verb, etc.). Natural language processing tools (such as spaCy, Stanza, etc.) are used to build a sentence dependency tree, clarify the grammatical dependencies in the sentences, extract syntactic patterns, and simplify complex sentences into patterned structures. Collect research question texts in multiple fields to ensure that the data sources are wide and cover different types of research purposes and methods. Organize the text data and annotation results into training samples, store them in a structured manner, and build a knowledge element training data set, including annotated research purpose sentences and research method sentences.
[0028] Furthermore, step S200 also includes step S210, collecting and acquiring a scientific and technological literature dataset; step S220, annotating the scientific and technological literature dataset using a manual annotation method and an iteration-based semi-automatic annotation method, and constructing a research purpose sentence dataset and a research method sentence dataset; step S230, performing a syntactic structure analysis on the research purpose sentence dataset and the research method sentence dataset, and extracting a purpose sentence feature word set and a method sentence feature word set; step S240, performing a feature sentence pattern analysis on the research purpose sentence dataset and the research method sentence dataset, and obtaining a purpose sentence feature sentence pattern set and a method sentence feature sentence pattern set; step S250, constructing the knowledge element training dataset based on the purpose sentence feature word set and the method sentence feature word set, as well as the purpose sentence feature sentence pattern set and the method sentence feature sentence pattern set.
[0029] Preferably, scientific and technological literature in related fields is collected from open access databases (such as PubMed, IEEE Xplore), institutional document resource databases, etc., including journal articles, conference papers, technical reports, etc., covering research problems, research purposes, research methods and results. As the scientific and technological literature data set, the scientific and technological literature data set is annotated using manual annotation methods and semi-automatic annotation methods that combine manual annotation with automation tools (such as NLP models) to obtain a research purpose sentence data set and a research method sentence data set; then the annotated research purpose sentences and research method sentences are grammatically parsed to extract feature words therein, that is, the sentences are decomposed into words and the parts of speech (such as nouns, verbs, adjectives, etc.) are marked, the syntactic structure is parsed through a dependency tree, the core components and modifying components are extracted, and a feature word set of the purpose sentence and a feature word set of the method sentence are obtained.
[0030] Preferably, based on the annotated sentences, common sentence templates of the research purpose sentences and research method sentences are analyzed, sentence features are extracted, and common sentence patterns are extracted. The characteristic sentence examples of the purpose sentences are: this study aims at + verb + goal (such as "this study aims to improve efficiency") or the goal is + noun phrase (such as "the goal is to explore the impact of X"); the characteristic sentence examples of the method sentences are: use + noun phrase + verb (such as "verify by experimental analysis method") or through + noun phrase + achieve (such as "optimize through big data analysis"); then generate the characteristic sentence set of the purpose sentences and the characteristic sentence set of the method sentences, and finally, based on the characteristic word set of the purpose sentences and the characteristic word set of the method sentences, as well as the characteristic sentence pattern set of the purpose sentences and the characteristic sentence pattern set of the method sentences, the sentences in the annotated data are matched with the characteristic words and the characteristic sentence patterns to obtain the knowledge element training data set.
[0031] Further, such as Figure 2 As shown, step S220 also includes step S221, annotating a preset proportion of the scientific and technological literature data set by manual annotation to obtain a manually annotated data set; step S222, training the manually annotated data set by an iteration-based semi-automatic annotation method to obtain a basic annotation model; step S223, performing iterative annotation training based on the basic annotation model to obtain an automatic annotation model; step S224, annotating the scientific and technological literature data set using the automatic annotation model to construct the research purpose sentence data set and the research method sentence data set.
[0032] Preferably, a certain proportion of documents (such as 10%-20%) is selected from the scientific literature dataset, and sentences are accurately annotated manually using an annotation platform (such as Label Studio, Prodigy) to clarify the research purpose sentences and research method sentences, as a manually annotated dataset, in which each sentence is labeled with a category (purpose sentence or method sentence), and a model suitable for sequence labeling or classification tasks (such as BERT, RoBERTa, etc.) is selected and trained using the manually annotated dataset to obtain a basic annotation model, which can preliminarily identify the research purpose sentences and research method sentences, but may have limitations in boundary recognition and complex sentence processing.
[0033] Preferably, the basic annotation model is used to perform multiple rounds of iterative optimization, and the annotation ability of the model is gradually improved through a cycle of manual correction and retraining. Specifically, the basic annotation model is used to predict unannotated documents, the model prediction results are manually reviewed, and incorrect annotations are corrected. The corrected prediction results are added to the training data set, and the basic annotation model is retrained using the expanded training data. The above cycle is continued to gradually reduce the proportion of manual intervention, and a high-precision automatic annotation model is obtained, which can accurately annotate unannotated data; finally, the automatic annotation model is used to fully annotate the remaining unannotated scientific and technological literature data sets to obtain a research purpose sentence data set (including all sentences marked as purpose sentences) and a research method sentence data set (including all sentences marked as method sentences).
[0034] Step S300, training and fine-tuning the DeBERta model based on the knowledge element training data set, and using the fine-tuned DeBERta model to extract research purpose sentences and research method sentences to obtain a fine-grained knowledge data set.
[0035] Preferably, the DeBERta model is trained and fine-tuned according to the knowledge element training data set, wherein DeBERta (Decoding-enhanced BERT with disentangled attention) is an advanced language model that can capture rich contextual information and perform fine-grained semantic analysis on sentences. Specifically, a pre-trained DeBERta model is used as the basic model, its existing language knowledge is inherited, a classification or sequence labeling task is defined, and sentences are divided into "research purpose sentences", "research method sentences" or "non-target sentences". The research question text in the training data is input into the model in the form of word segmentation, and annotation information for specific tasks is added. Through training, the model can assign a probability value to each sentence or text fragment, indicating the possibility that it belongs to the "research purpose sentence" or "research method sentence". The cross-entropy loss function is used to optimize the error between the model prediction result and the annotation label, and the model is trained iteratively for multiple times until its performance on the validation set reaches the expected level. The fine-tuned DeBERta model is then used to process new research question texts and automatically extract the research purpose sentences and research method sentences. That is, the new research question text is input into the fine-tuned DeBERta model, and the model classifies each sentence or fragment and outputs its category probability. Based on the classification results, the research purpose sentences and research method sentences in the text are extracted to form a fine-grained knowledge dataset, which is high-quality structured data extracted by the model from the research question text, and can accurately describe the core information of the research problem.
[0036] Step S400: constructing an embedded metadata prompt word project according to the fine-grained knowledge dataset.
[0037] Preferably, the extracted fine-grained knowledge such as the research purpose sentence and the research method sentence is converted into a prompt word design method, and a structured task description is generated by embedding metadata to guide the language model to more accurately generate research questions that meet specific goals. Specifically, embedding metadata is to integrate the research purpose sentence and the research method sentence extracted from the fine-grained knowledge data set into the prompt word according to structured rules, as auxiliary information when the language model generates research questions, such as research purpose, research method and task background; prompt word engineering is an input structure designed for language models (such as large language models), which aims to guide the model to generate required content through clear task descriptions, input conditions and target outputs. Finally, the prompt word engineering constructed by the fine-grained knowledge data set is optimized to ensure its guiding role on the language model and significantly improve the efficiency and quality of the research question generation task.
[0038] Step S500, based on the embedded metadata prompt word project, obtain a research question fine-tuning dataset, and the research question fine-tuning dataset consists of a task description part, an input part and an output part.
[0039] Preferably, obtaining a research question fine-tuning dataset based on the metadata embedded prompt word engineering refers to parsing the task description, input and output from the metadata embedded prompt word engineering and converting them into samples of the fine-tuning dataset, that is, obtaining a research question fine-tuning dataset, which consists of a task description part, an input part and an output part. The task description clearly states what the goal of the generated task is, what kind of task the model needs to complete, what specific requirements and restrictions are, etc., to provide clear guidance for subsequent input and output. Specifically, the task description part clarifies the goal of the task or the task that the language model needs to complete, helping the model understand the type of task to be performed or the content target to be generated; the input part provides the model with the contextual information or reference data required to complete the task, which comes from the fine-grained knowledge dataset, including the research purpose sentence and the research method sentence, and provides specific information input for the model to generate research questions; the output part is to clearly define the output content that the model is expected to generate, usually a complete answer or extended description of the input part, guiding the form and content of the model generation result. For example, examples of actual datasets are shown in the table below:
[0040]
[0041]
[0042] Step S600, using LoRA fine-tuning technology to fine-tune the data set based on the research question, fine-tune and optimize the large language model, and generate a research question based on the optimized large language model.
[0043] Preferably, the LoRA (Low-Rank Adaptation) fine-tuning technology is used to fine-tune and optimize the large language model based on the research problem fine-tuning dataset, and generate research problems based on the optimized model. This means that the pre-trained large language model is lightweight adapted to reduce computing and storage costs so that it can more accurately perform the research problem generation task. LoRA is a lightweight fine-tuning technology that aims to adjust the weights of the large model by introducing a low-rank matrix without changing the weights of the original model, thereby significantly reducing the parameter overhead and computing requirements during fine-tuning. LoRA is very suitable for tasks that require frequent fine-tuning, such as research problem generation, which requires optimization for domain data.
[0044] Preferably, the constructed research question fine-tuning dataset is used, each sample consists of a task description, an input part, and an output part. The specific layers that need to be adjusted are selected in the large language model (such as DeBERTa) (usually the weight matrix part in the attention mechanism). The fine-tuning of LoRA will only affect the low-rank representation part of these layers, and will not modify the entire model. Low-rank adjustment refers to adding low-rank matrix adjustment items to the weight moment of the attention layer. Specifically, the low-rank matrix is initialized to a random value or zero, and the task description, input part, and output part in the research question fine-tuning dataset are converted into training samples of the model. The low-rank matrix is optimized using the gradient descent method so that the output generated by the model is closer to the reference answer provided in the fine-tuning dataset. The rest of the model remains frozen to avoid waste of resources. Finally, the new research objectives and methods and other information are used as input, and the model is guided to generate research questions through prompt words. The optimized model can generate research questions with clear content, reasonable logic, and semantic expectations based on the input. By optimizing the large language model through the LoRA fine-tuning technology and combining it with the research question fine-tuning dataset, the accuracy of the model-generated research questions, the efficiency and adaptability of the model training, and the efficiency of task generation can be significantly improved.
[0045] Further, step S600 also includes step S610, selecting to obtain a pre-trained large language model and setting fine-tuning hyperparameters; step S620, defining a LoRA module, the LoRA module is composed of a first low-rank projection matrix A i and the second low-rank projection matrix B i , wherein i is the i-th layer of the large language model; Step S630, introducing the first low-rank projection matrix A i and the second low-rank projection matrix B i , based on the research problem fine-tuning dataset and the fine-tuning hyperparameters, the large language model is trained, fine-tuned and optimized.
[0046] Preferably, choose to obtain a pre-trained large language model and set fine-tuning hyperparameters, batch_size: int = 10 (batch size: integer 10), micro_batch_size: int = 2 (micro-batch size: integer 2), num_epochs: int = 2 (number of training rounds: integer 2), learning_rate: float = 1e-5 (learning rate: floating point number 1e-5 = 0.00001), lora_r: int = 8 (LoRA parameter rank: integer 8), lora_alpha: int = 16 (LoRA parameter alpha value: integer 16), lora_dropout: float = 0.05 (LoRA parameter dropout probability: floating point number 0.05); define the LoRA module, which is used to significantly reduce the amount of parameter updates and video memory usage during fine-tuning, and limit the weight update of the original model to a low-rank subspace instead of updating the weight of the entire model. Ai and Bi are two trainable low-dimensional matrices, which are responsible for projecting the input into the low-rank space and then restoring it from the low-rank space. Finally, based on the research problem, fine-tuning the dataset and fine-tuning the hyperparameters, the large language model is trained, fine-tuned and optimized. Specifically, the original weights of the large language model are frozen (the main parameters of the model remain unchanged), and Ai and Bi are trained by gradient descent. The effect of the fine-tuned model is close to that of full parameter fine-tuning, but the computational cost is greatly reduced, allowing the model to perform better on the target task dataset.
[0047] Furthermore, step S600 further includes introducing the first low-rank projection matrix A on each layer i of the large language model i and the second low-rank projection matrix B i ; Step S640, based on the research problem fine-tuning dataset and the fine-tuning hyperparameters, forward propagation training is performed on the large language model to obtain the original forward calculation result h of the i-th layer of the large language model i =f i (x i ), where x i is the input of the i-th layer, f i is the forward calculation function of the i-th layer; Step S650, based on the first low-rank projection matrix A i and the second low-rank projection matrix B i The original forward calculation result is corrected to obtain a forward corrected calculation result; step S660, constructing a model loss function, with minimizing the model loss function as an optimization goal; step S670, fine-tuning and optimizing the large language model based on the forward corrected calculation result according to the optimization goal.
[0048] Step S650 further includes step S651, according to the first low-rank projection matrix Ai and the second low-rank projection matrix B i , construct the forward correction calculation formula: h i ′=f i (x i )+A i B i f i (x i ) = f i (x i )+Δ i , where Δ i =A i B i f i (x i ) represents the correction term introduced by the LoRA module; step S652, correcting the original forward calculation result based on the forward correction calculation formula to obtain the forward correction calculation result.
[0049] Step S660 further includes that the model loss function is specifically:
[0050]
[0051] Among them, θ represents the fixed parameters of the original model, Represents all projection matrices introduced by the LoRA module, is the training dataset for the new task, is the task-related loss function.
[0052] Step S620 further includes, according to the first low-rank projection matrix A i and the second low-rank projection matrix B i , determine the first matrix dimension (d, r) and the second matrix dimension (r, d), where d is the model hidden layer dimension, r is the projection dimension, and r< <d。
[0053] Preferably, the core idea of LoRA is to introduce a set of low-rank projection matrices on each layer of the large model, and to adapt the original model by optimizing these matrices. Specifically, for the i-th layer of the model, LoRA defines two projection matrices A i and B i , the dimensions are (d, r) and (r, d), respectively, where d is the model hidden layer dimension, r is the projection dimension, and r<<d. During forward propagation, LoRA adds a correction term based on the projection matrix to the original layer calculation result. Assume that the original forward calculation of the i-th layer can be expressed as:
[0054] h i =f i (x i );
[0055] Among them, x i is the input of the i-th layer, f i is the forward calculation function of the i-th layer (such as self-attention, feedforward network, etc.). In LoRA, the modified forward calculation formula is:
[0056] h i ′=f i (x i )+A i B i f i (x i )=f i (x i )+Δ i ;
[0057] Among them, Δ i =A i B i f i (x i ) represents the correction term introduced by LoRA, which can be regarded as the output f of the original layer i (x i ), a low-rank perturbation is added.
[0058] The optimization goal of LoRA is to minimize the loss function of the modified model on the new task:
[0059]
[0060] Among them, θ represents the fixed parameters of the original model, Represents all projection matrices introduced by LoRA, is the training dataset for the new task, is the task-related loss function (such as cross entropy loss). During the optimization process, we only update Keeping θ unchanged, the training cost of LoRA is much less than the traditional full parameter fine-tuning. At the same time, since the rank r of the projection matrix is much smaller than the dimension d of the original model, the amount of additional parameters introduced by LoRA is also much smaller than the original model. By screening and refining fine-grained knowledge for specific generation tasks, the key knowledge types and elements required for research question generation are analyzed. Two types of sentences, research purpose sentences and research method sentences, are first extracted from scientific and technological literature. Then, the extracted fine-grained knowledge is used to construct prompts for generating research questions. The large language model is fine-tuned using the research question prompt that is manually constructed to integrate fine-grained knowledge, providing more accurate and targeted input for the research question generation model, and improving the quality and accuracy of the generated results.
[0061] The above specific implementation manner does not constitute a limitation to the protection scope of the present application. It should be understood by those skilled in the art that various modifications, combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application. In some cases, the actions or steps recorded in the present application can be performed in an order different from that in the embodiment and can still achieve the desired results. In addition, the process depicted in the accompanying drawings does not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Claims
1. The fine-grained knowledge generation agent method for metadata-embedded prompt word engineering is characterized by: The method comprises: Analyze the research question generation elements to determine the research question generation knowledge elements, wherein the research question generation knowledge elements include a research purpose sentence and a research method sentence; Performing data annotation and syntactic structure analysis on the research purpose sentence and the research method sentence to construct a knowledge element training data set; The DeBERta model is trained and fine-tuned based on the knowledge element training data set, and the research purpose sentence and the research method sentence are extracted using the fine-tuned DeBERta model to obtain a fine-grained knowledge data set; According to the fine-grained knowledge dataset, construct an embedded metadata prompt word project; Based on the metadata embedding project, a research question fine-tuning dataset is obtained, wherein the research question fine-tuning dataset consists of a task description part, an input part, and an output part; The LoRA fine-tuning technology is used to fine-tune the dataset based on the research question, and the large language model is fine-tuned and optimized, and the research question is generated based on the optimized large language model.
2. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 1 is characterized in that: The constructing of the knowledge element training data set includes: Collect and obtain scientific and technological literature data sets; Annotating the scientific literature dataset using a manual annotation method and an iteration-based semi-automatic annotation method to construct a research purpose sentence dataset and a research method sentence dataset; Performing syntactic structure analysis on the research purpose sentence data set and the research method sentence data set to extract characteristic word sets of purpose sentences and characteristic word sets of method sentences; Performing characteristic sentence pattern analysis on the research purpose sentence data set and the research method sentence data set to obtain a characteristic sentence pattern set of purpose sentences and a characteristic sentence pattern set of method sentences; The knowledge element training data set is constructed based on the target sentence feature word set and the method sentence feature word set, as well as the target sentence feature sentence pattern set and the method sentence feature sentence pattern set.
3. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 2 is characterized in that: The construction of the research purpose sentence dataset and the research method sentence dataset includes: Annotating a preset proportion of the scientific and technological literature data set by manual annotation to obtain a manually annotated data set; Using an iteration-based semi-automatic annotation method to train the manually annotated data set to obtain a basic annotation model; Perform iterative annotation training based on the basic annotation model to obtain an automatic annotation model; The automatic annotation model is used to annotate the scientific literature dataset, and the research purpose sentence dataset and the research method sentence dataset are constructed.
4. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 1 is characterized in that: The LoRA fine-tuning technology is used to fine-tune the large language model based on the research problem fine-tuning dataset, including: Choose to obtain a pre-trained large language model and set fine-tuning hyperparameters; Define a LoRA module, which consists of a first low-rank projection matrix A i and the second low-rank projection matrix B i , wherein i is the i-th layer of the large language model; Introducing the first low-rank projection matrix A i and the second low-rank projection matrix B i , based on the research problem fine-tuning dataset and the fine-tuning hyperparameters, the large language model is trained, fine-tuned and optimized.
5. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 4 is characterized in that: The method comprises: Introduce the first low-rank projection matrix A on each layer i of the large language model i and the second low-rank projection matrix B i ; Perform forward propagation training on the large language model based on the research problem fine-tuning dataset and the fine-tuning hyperparameters, and obtain the original forward calculation result h of the i-th layer of the large language model. i =f i (x i ), where x i is the input of the i-th layer, f i is the forward calculation function of the i-th layer; Based on the first low-rank projection matrix A i and the second low-rank projection matrix B i Correcting the original forward calculation result to obtain a forward corrected calculation result; Constructing a model loss function, with minimizing the model loss function as an optimization goal; The large language model is fine-tuned and optimized based on the forward correction calculation result according to the optimization target.
6. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 5 is characterized in that: The obtaining of the forward correction calculation result comprises: According to the first low-rank projection matrix A i and the second low-rank projection matrix B i , construct the forward correction calculation formula: h i ′=f i (x i )+A i B i f i (x i ) = f i (x i )+Δ i , where Δ i =A i B i f i (x i ) represents the correction item introduced by the LoRA module; The original forward calculation result is corrected based on the forward correction calculation formula to obtain the forward correction calculation result.
7. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 6 is characterized in that: The model loss function is specifically: Among them, θ represents the fixed parameters of the original model, Represents all projection matrices introduced by the LoRA module, is the training data set for the new task, and l is the task-related loss function.
8. The fine-grained knowledge generation agent method for embedding metadata prompt word engineering as claimed in claim 4 is characterized in that: The method comprises: According to the first low-rank projection matrix A i and the second low-rank projection matrix B i , determine the first matrix dimension (d, r) and the second matrix dimension (r, d), where d is the model hidden layer dimension and r is the projection dimension, and r<<d。
Citation Information
Patent Citations
Language large model-based scientific research literature interpretation method and device
CN116822521A
Method, device and equipment for extracting phrases of research questions and medium
CN118052225A
Text generation method and system based on prompt project and fine tuning technology
CN118095292A
Domain review generation method and system based on large language model
CN118152557A
Large language model reliable legal question and answer generation method based on knowledge fine tuning
CN118210891A
Cited By
Power distribution network planning scheme generation method and device based on large model, terminal and medium
CN120258485A
Distribution network planning scheme generation method, device, terminal and medium based on large model
CN120258485B