Large model self-cognition method and system

Through the combination of self-cognitive classification model and self-cognitive question-and-answer library, Prompt is constructed using vectorized matching and template knowledge, which solves the impact of self-cognitive tasks of large language models on other tasks, and achieves efficient and accurate self-cognitive question-and-answer.

CN120409691APending Publication Date: 2025-08-01SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510528267.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing large language models affect the performance of other tasks in self-cognitive tasks, and heuristic algorithms are difficult to fully enumerate keywords, resulting in erroneous substitution.

Method used

The self-cognitive classification model is used to classify user questions, and the self-cognitive question and answer library and self-cognitive model question and answer module are used to construct Prompt for self-cognitive question and answer through vectorized matching and template knowledge, reducing the impact on the basic large language model.

Benefits of technology

Without affecting the ability of the basic large language model, effectively solve self-cognition problems, improve the accuracy and efficiency of self-cognition tasks, and reduce error replacement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120409691A_ABST
    Figure CN120409691A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of large language models, in particular to a large model self-cognition method and system, and self-cognition of a basic large language model is achieved through a self-cognition classification model and a self-cognition model. The method has the beneficial effects that the self-cognition of the basic large language model is realized by utilizing the self-cognition classification model and the self-cognition model. According to the method, the self-cognition problem of the large language model in different scenes can be solved on the premise that the capacity of the basic large language model is not influenced. Firstly, a self-cognition classification model is used for classifying user questions, and if the user questions are not self-cognition class questions, a basic large language model directly answers the questions; if the question is a self-cognition category question, firstly matching a self-cognition question and answer vector library, if a self-cognition question meeting a similarity threshold value is matched, directly returning an answer corresponding to the self-cognition question, otherwise, retrieving template knowledge corresponding to the corresponding self-cognition category, constructing a self-cognition Prompt, and answering by a self-cognition model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of large language models, and specifically provides a method and system for large model self-awareness. Background Art

[0002] Large language model self-awareness means enabling a large language model to recognize and understand its own role, function, and identity. During the fine-tuning stage of the large language model, datasets related to self-awareness can be integrated and fine-tuned together with other fine-tuning task datasets. However, when applying the large language model to practical application scenarios such as intelligent customer service and intelligent Q&A, customers usually expect the large language model to switch to the customer's identity when answering self-awareness related questions, rather than the large language model's own self-awareness. To achieve this purpose, a self-awareness dataset related to specific customers is usually constructed and then fine-tuned. However, since only self-awareness tasks are fine-tuned at this stage, it often affects the performance of the model on other tasks.

[0003] To reduce the impact of self-awareness fine-tuning on the model's capabilities in other tasks, other task fine-tuning data can usually be integrated at this stage, but it will increase the training time, and it cannot guarantee that the model's capabilities in other tasks are not affected or are less affected. Another method to achieve self-awareness is to use a heuristic algorithm to replace specific keywords in the model output. This method does not require fine-tuning and is simple and convenient to operate. However, it is difficult to enumerate all keywords, and there will also be problems of incorrect replacement when the same keywords exist in some non-self-awareness questions. Summary of the Invention

[0004] The purpose of the present invention is to provide a method and system for large model self-awareness to solve the problems raised in the above background art.

[0005] To achieve the above purpose, the present invention provides the following technical solution: A method for large model self-awareness, which uses a self-awareness classification model and a self-awareness model to achieve the self-awareness of a basic large language model, specifically including:

[0006] Use a self-awareness classification model to classify user questions. The self-awareness classification model is a multi-classification model, which classifies questions into greeting self-awareness questions, introduction self-awareness questions, function self-awareness questions, relationship self-awareness questions, and other questions;

[0007] According to the classification result of the self-awareness classification model, if the classification result is other, directly hand the question over to the basic large language model for answering; if the classification result is "greeting", "introduction", "function", "relationship", then use the question to match the self-awareness Q&A library. If the match is successful, return the corresponding answer. If the match fails, execute the self-awareness model Q&A stage.

[0008] Preferably, the self - awareness classification model is obtained by fine - tuning the "bert - base - chinese" model through a training dataset including "greeting class", "introduction class", "function class", "relationship class", and "other class". The training dataset is adjusted according to the usage scenarios of the basic large - language model to conform to the identity and role of the large - language model in a specific scenario, and specifically uses the transformers library for fine - tuning.

[0009] Preferably, the self - awareness Q&A library is a vector library, which is obtained by vectorizing pre - constructed self - awareness Q&A pairs. The vector library uses Milvus, Chroma, etc., and the vectorization model uses bge. The question matching process is as follows: vectorize the user's question using the vectorization model, retrieve in the self - awareness Q&A vector library, retrieve the Top1 similar question vector. If the similarity between the Top1 similar vector and the question vector is greater than or equal to the specified threshold, directly return the answer corresponding to the Top1 question vector. If the similarity is less than the specified threshold, execute the self - awareness model Q&A stage.

[0010] Preferably, the self - awareness model Q&A stage includes question extraction, and the question extraction is realized through Prompt engineering using the basic large - language model.

[0011] Preferably, query the template knowledge corresponding to the self - awareness question classification obtained in the first step, construct a self - awareness Q&A Prompt using this template knowledge, and give the self - awareness Q&A Prompt to the self - awareness model for answering.

[0012] A large - model self - awareness system for a large - model self - awareness method, including a self - awareness classification module, a self - awareness Q&A library matching module, and a self - awareness model Q&A module;

[0013] The self - awareness classification module is used to classify the user's question using the self - awareness classification model. The self - awareness classification model is a multi - classification model, which classifies the question into a greeting - type self - awareness question, an introduction - type self - awareness question, a function - type self - awareness question, a relationship - type self - awareness question, and other questions;

[0014] The self - awareness Q&A library matching module is used to, according to the classification result of the self - awareness classification module, if the classification result is other class, directly hand the question to the basic large - language model for answering; if the classification result is "greeting class", "introduction class", "function class", "relationship class", then use the question to match the self - awareness Q&A library. If the match is successful, return the corresponding answer. If the match fails, trigger the self - awareness model Q&A module;

[0015] The self - awareness model Q&A module is used to, when the match fails, perform question extraction and construct a Prompt using the extracted question combined with template knowledge to give to the self - awareness model for answering.

[0016] Preferably, the self - awareness classification model is obtained by fine - tuning the "bert - base - chinese" model with a training data set including "greeting class", "introduction class", "function class", "relationship class", "other class". The training data set is adjusted according to the usage scenarios of the basic large - language model to conform to the identity and role of the large - language model in a specific scenario, and specifically, the transformers library is used for fine - tuning.

[0017] Preferably, the self - awareness Q&A library is a vector library, which is obtained by vectorizing pre - constructed self - awareness Q&A pairs. The vector library uses Milvus and Chroma, and the vectorization model uses bge.

[0018] The question matching process of the self - awareness Q&A library matching module is as follows: Vectorize the user's question using the vectorization model, retrieve it in the self - awareness Q&A vector library, and retrieve the top 1 similar question vector. If the similarity between the top 1 similar vector and the question vector is greater than or equal to the specified threshold, directly return the answer corresponding to the top 1 question vector. If the similarity is less than the specified threshold, trigger the self - awareness model Q&A module.

[0019] Preferably, the question extraction of the self - awareness model Q&A module is realized through Prompt engineering using the basic large - language model.

[0020] Preferably, the number of parameters of the self - awareness model is less than that of the basic large - language model. Select a large - language model of about 1B, such as Qwen2 - 0.5B - Instruct; construct a self - awareness data set matching the usage scenario of the basic large - language model, and use the LLaMAFactory fine - tuning tool to fine - tune the self - awareness model. The fine - tuning method selects full - parameter fine - tuning or LoRA fine - tuning. Priority is given to using full - parameter fine - tuning to achieve better fine - tuning effects, and the Q&A effect of the user's non - self - awareness questions is not affected during this fine - tuning stage.

[0021] Compared with the prior art, the beneficial effects of the present invention are:

[0022] The self-awareness method and system for large models proposed by the present invention utilize a self-awareness classification model and a self-awareness model to achieve the self-awareness of a basic large language model. This method can solve the self-awareness problem of large language models in different scenarios without affecting the capabilities of the basic large language model. First, the self-awareness classification model is used to classify user questions. If it is not a self-awareness category question, the basic large language model directly answers; if it is a self-awareness category question, the self-awareness Q&A vector library is first matched. If a self-awareness question that meets the similarity threshold is matched, the corresponding answer to the self-awareness question is directly returned. Otherwise, the template knowledge corresponding to the self-awareness classification is retrieved to construct a self-awareness Prompt, and the self-awareness model answers. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 is the flowchart of problem extraction for the present invention;

[0024] Figure 2 is the flowchart of problem matching for the present invention;

[0025] Figure 3 is the flowchart of large model Q&A for the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0026] In order to clearly and completely describe the objectives, technical solutions of the present invention, and make the advantages more clearly understood, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are part of the embodiments of the present invention, rather than all of the embodiments, and are only used to explain the embodiments of the present invention, not to limit the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.

[0027] Example 1, please refer to Figures 1 to 3 , the present invention provides a technical solution: a self-awareness method for large models, specifically including:

[0028] The first step: Classify user questions using the self-awareness classification model

[0029] The self-awareness classification model is a multi-classification model that divides questions into greeting self-awareness questions, introduction self-awareness questions, function self-awareness questions, relationship self-awareness questions, and other questions. Among them, greeting self-awareness questions include greetings such as "Hello", "Hey", "Hi", etc.; introduction self-awareness questions include "Who are you?", "Introduce yourself?", "Who developed you?", etc.; function self-awareness questions include "What capabilities do you have?", "Do you have the ability to recognize named entities?", etc.; relationship self-awareness includes "What's your relationship with OpenAI?", "What's your relationship with Spark Model?", "What's your relationship with Baidu?", etc.; other questions are questions other than the above-mentioned self-awareness questions. The self-awareness multi-classification model can be obtained by fine-tuning the "bert-base-chinese" model with a training dataset containing "greeting class", "introduction class", "function class", "relationship class", "other class". The bert-base-chinese model is very suitable for classification tasks and can be specifically fine-tuned using the transformers library. This training dataset needs to be adjusted according to the usage scenarios of the basic large language model to conform to the identity and role of the large language model in a specific scenario, etc.

[0030] Step 2: Use the question to match the self-awareness Q&A library

[0031] If the result of the question classification by the self-awareness classification model in the first step is other class, the question is directly handed over to the basic large language model for answering. If the question classification result is "greeting class", "introduction class", "function class", "relationship class", etc., the self-awareness Q&A library is used. This self-awareness Q&A library is a vector library obtained by vectorizing pre-constructed self-awareness Q&A pairs. Among them, the vector library can use Milvus, Chroma, etc., and the vectorization model can use bge, etc. The specific matching process is as follows: Vectorize the user question using the vectorization model, and then retrieve it in the self-awareness Q&A vector library to retrieve the Top1 similar question vector. If the similarity between the Top1 similar vector and the question vector is greater than or equal to the specified threshold, directly return the answer corresponding to the Top1 question vector. If the similarity is less than the specified threshold, the self-awareness model Q&A stage is executed.

[0032] Step 3: Self-awareness model Q&A

[0033] Before using the self-awareness model for Q&A, question extraction needs to be carried out first. The purpose of question extraction is mainly to eliminate other background knowledge contained in the user input and only retain the user's true Q&A intention. Question extraction is implemented using the basic large language model through Prompt engineering. The following is an example of the Prompt for question extraction:

[0034] prompt=f"""

[0035] Extract the question asked by the user according to the user input, without giving the analysis process

[0036]

User Input

[0037] {user_input}

[0038] """

[0039] During the use process, replace user_input with the actual user input. For example, if the user input is "You are an AI assistant developed by Inspur Cloud. What's your relationship with Inspur?", the output question should be "What's your relationship with Inspur?". Then query the template knowledge corresponding to the self-awareness question classification obtained in the first step, and then use this template knowledge to construct a self-awareness Q&A Prompt and give the self-awareness Q&A Prompt to the self-awareness model for answering. The following is an example of the self-awareness Q&A Prompt:

[0040] prompt=f"""

[0041] Please answer the question according to the background knowledge, without giving the analysis process

[0042]

Background Knowledge

[0043] {background_knowledge}

[0044]

Question

[0045] {user_question}

[0046] """

[0047] During the usage process, replace background_knowledge with the template knowledge queried according to self-awareness questions, and replace user_question with the user question extracted in the question extraction stage. The self-awareness model is also a large model, and its number of parameters is less than that of the basic large language model. Generally, a large language model with about 1B parameters is selected, such as Qwen2-0.5B-Instruct, etc. Fine-tuning a model with this parameter scale requires less computing resources and shorter training time, and can be quickly fine-tuned according to the usage scenarios of the basic large language model. In a specific usage scenario, first construct a self-awareness dataset that matches the usage scenario of the basic large language model, and then fine-tune the self-awareness model to enhance the self-awareness Q&A effect of the self-awareness model in this scenario. Since questions not related to self-awareness Q&A are still answered by the basic large language model, this fine-tuning stage will not affect the Q&A effect of user questions that are not self-awareness questions. Specifically, during the usage process, the LLaMA Factory fine-tuning tool can be used for fine-tuning, and the fine-tuning method can be selected as full-parameter fine-tuning or LoRA fine-tuning. LoRA fine-tuning is a widely used efficient fine-tuning method for large language models. It can save memory and maintain the performance of the basic model on tasks outside the target domain as much as possible. However, the effect is usually lower than that of full-parameter fine-tuning. Since the self-awareness model is only used to answer self-awareness questions, full-parameter fine-tuning is preferred to achieve a better fine-tuning effect.

[0048] Example 2. On the basis of Example 1, a large model self-awareness system for a large model self-awareness method is proposed, including a self-awareness classification module, a self-awareness Q&A library matching module, and a self-awareness model Q&A module;

[0049] The self-awareness classification module is used to classify user questions using the self-awareness classification model. The self-awareness classification model is a multi-classification model that classifies questions into greeting self-awareness questions, introduction self-awareness questions, function self-awareness questions, relationship self-awareness questions, and other questions. The self-awareness classification model is obtained by fine-tuning the "bert-base-chinese" model with a training dataset containing "greeting class", "introduction class", "function class", "relationship class", and "other class". The training dataset is adjusted according to the usage scenario of the basic large language model to conform to the identity and role of the large language model in a specific scenario, and specifically uses the transformers library for fine-tuning.

[0050] The self - awareness Q&A library matching module is used to, according to the classification result of the self - awareness classification module, if the classification result is "other", directly hand the question to the basic large - language model for answering; if the classification result is "greeting", "introduction", "function", or "relationship", then use the question to match the self - awareness Q&A library. If the match is successful, the corresponding answer is returned; if the match fails, the self - awareness model Q&A module is triggered. The self - awareness Q&A library is a vector library, which is obtained by vectorizing the pre - constructed self - awareness Q&A pairs. The vector library uses Milvus and Chroma, and the vectorization model uses bge.

[0051] The question matching process of the self - awareness Q&A library matching module is as follows: Vectorize the user question using the vectorization model, retrieve in the self - awareness Q&A vector library, and retrieve the Top1 similar question vector. If the similarity between the Top1 similar vector and the question vector is greater than or equal to the specified threshold, directly return the answer corresponding to the Top1 question vector; if the similarity is less than the specified threshold, trigger the self - awareness model Q&A module.

[0052] The self - awareness model Q&A module is used to, when the match fails, extract the question and use the extracted question combined with template knowledge to construct a Prompt for the self - awareness model to answer. The question extraction of the self - awareness model Q&A module is implemented through Prompt engineering using the basic large - language model. The number of parameters of the self - awareness model is less than that of the basic large - language model. Select a large - language model of about 1B, such as Qwen2 - 0.5B - Instruct. Construct a self - awareness data set that matches the usage scenario of the basic large - language model, and use the LLaMAFactory fine - tuning tool to fine - tune the self - awareness model. The fine - tuning method selects full - parameter fine - tuning or LoRA fine - tuning. It is preferred to use full - parameter fine - tuning to achieve a better fine - tuning effect, and this fine - tuning stage does not affect the Q&A effect of the user's non - self - awareness questions.

[0053] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A large model self - awareness method, characterized in that: Implementing self-awareness of a basic large language model using a self-awareness classification model and a self-awareness model, specifically including: Classifying user questions using a self-awareness classification model. The self-awareness classification model is a multi-classification model that divides questions into greeting self-awareness questions, introduction self-awareness questions, function self-awareness questions, relationship self-awareness questions, and other questions; According to the classification result of the self-awareness classification model, if the classification result is other, directly hand the question to the basic large language model for answering; if the classification result is "greeting", "introduction", "function", "relationship", then use the question to match the self-awareness Q&A library. If the match is successful, return the corresponding answer. If the match fails, execute the self-awareness model Q&A stage.

2. The self - awareness method of a large model according to claim 1, characterized in that: The self-awareness classification model is obtained by fine-tuning the "bert-base-chinese" model using a training dataset containing "greeting", "introduction", "function", "relationship", "other". The training dataset is adjusted according to the usage scenario of the basic large language model to conform to the identity and role of the large language model in a specific scenario. Specifically, it is fine-tuned using the transformers library.

3. The self - awareness method of a large model according to claim 2, characterized in that: The self-awareness Q&A library is a vector library obtained by vectorizing pre-constructed self-awareness Q&A pairs. The vector library uses Milvus, Chroma, etc., and the vectorization model uses bge; the question matching process is: vectorize the user question using the vectorization model, retrieve in the self-awareness Q&A vector library, retrieve the Top1 similar question vector. If the similarity between the Top1 similar vector and the question vector is greater than or equal to the specified threshold, directly return the answer corresponding to the Top1 question vector. If the similarity is less than the specified threshold, execute the self-awareness model Q&A stage.

4. The self - awareness method of a large model according to claim 3, characterized in that: The self-awareness model Q&A stage includes question extraction, which is realized by using the basic large language model through Prompt engineering.

5. A large model self-awareness method according to claim 4, characterized in that: Query the template knowledge corresponding to the self-awareness question classification obtained in the first step, construct a self-awareness Q&A Prompt using this template knowledge, and give the self-awareness Q&A Prompt to the self-awareness model for answering.

6. A large model self - awareness system for the large model self - awareness method according to claim 5, characterized in that: Including a self-awareness classification module, a self-awareness Q&A library matching module, and a self-awareness model Q&A module; The self-awareness classification module is used to classify user questions using a self-awareness classification model. The self-awareness classification model is a multi-classification model that divides questions into greeting self-awareness questions, introduction self-awareness questions, function self-awareness questions, relationship self-awareness questions, and other questions; The self-awareness Q&A library matching module is used to, according to the classification result of the self-awareness classification module, if the classification result is other, directly hand the question to the basic large language model for answering; if the classification result is "greeting", "introduction", "function", "relationship", then use the question to match the self-awareness Q&A library. If the match is successful, return the corresponding answer. If the match fails, trigger the self-awareness model Q&A module; The self-awareness model Q&A module is used to extract questions when the matching fails and construct a Prompt for the self-awareness model to answer by combining the extracted questions with template knowledge.

7. A large model self-awareness system according to claim 6, characterized in that: The self-awareness classification model is obtained by fine-tuning the "bert-base-chinese" model with a training dataset containing "greeting", "introduction", "function", "relationship", and "other" categories. The training dataset is adjusted according to the usage scenarios of the basic large language model to conform to the identity and role of the large language model in a specific scenario, and specifically uses the transformers library for fine-tuning.

8. A large model self-awareness system according to claim 7, characterized in that: The self-awareness Q&A library is a vector library obtained by vectorizing pre-constructed self-awareness Q&A pairs. The vector library uses Milvus and Chroma, and the vectorization model uses bge. The question matching process of the self-awareness Q&A library matching module is as follows: Vectorize the user's question using the vectorization model, retrieve it in the self-awareness Q&A vector library, and retrieve the Top1 similar question vector. If the similarity between the Top1 similar vector and the question vector is greater than or equal to the specified threshold, directly return the answer corresponding to the Top1 question vector. If the similarity is less than the specified threshold, trigger the self-awareness model Q&A module.

9. The self-awareness system of a large model according to claim 8, characterized in that: The question extraction of the self-awareness model Q&A module is realized through Prompt engineering using the basic large language model.

10. A large model self-awareness system according to claim 9, characterized in that: The number of parameters of the self-awareness model is less than that of the basic large language model. Select a large language model of about 1B, such as Qwen2-0.5B-Instruct; construct a self-awareness dataset that matches the usage scenario of the basic large language model, and use the LLaMAFactory fine-tuning tool to fine-tune the self-awareness model. The fine-tuning method selects full-parameter fine-tuning or LoRA fine-tuning, and full-parameter fine-tuning is preferred to achieve better fine-tuning effects, and this fine-tuning stage does not affect the Q&A effect of the user's non-self-awareness questions.