A processing method, device and medium for large language model question prompts

By extracting entity and logical relationships in the text for problem reconstruction, and combining adaptive random replacement strategies and multi-source knowledge base verification, accurate candidate prompts are generated, which solves the problem of hallucinatory output of large language models when dealing with fuzzy or error prerequisites, and improves the accuracy and reliability of the model.

CN119537569BActive Publication Date: 2025-05-02SHANDONG INSPUR SCI RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510096446.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-05-02
Estimated Expiration
2045-01-22

AI Technical Summary

Technical Problem

When existing large language models deal with fuzzy or error prerequisites, they are prone to generate illusion outputs that do not match the facts, and the processing process requires a large amount of computing resources and has limited results.

Method used

By obtaining the original text, extracting the entity and extracting the logical relationship based on the entity, refactoring the problem to generate a re-explained problem prompt. Then, an adaptive random replacement strategy is adopted to calculate the semantic similarity and task type of problem prompts and preset vocabulary, dynamically select the replacement mechanism, and generate multiple candidate prompts. Finally, the global entropy value of the candidate prompt is calculated and verified by the multi-source knowledge base to output the smallest candidate prompt.

Benefits of technology

It effectively reduces the occurrence of illusion output, improves the accuracy and reliability of large language models when dealing with error prerequisites or fuzzy problems, and reduces the demand for computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537569B_ABST
    Figure CN119537569B_ABST
Patent Text Reader

Abstract

The present application discloses a processing method, device and medium for question prompts of a large language model, and relates to the technical field of natural language processing. The method includes: obtaining the original text, extracting the entities of the original text, and extracting logical relationships based on the entities, the logical relationships including causal relationships and employment relationships; reconstructing the question according to the entities and logical relationships, and generating restated question prompts; based on the question prompts, using an adaptive random replacement strategy, calculating the semantic similarity and task type between the question prompts and the preset vocabulary, dynamically selecting a replacement mechanism, and generating multiple candidate prompts; calculating the global entropy value of the candidate prompts, and performing multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and outputting the smallest candidate prompt if the verification passes. The present application optimizes the generation process of a large language model when processing wrong premises or fuzzy problems through the above method, thereby effectively reducing the occurrence of hallucination output.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology, and in particular to a method, device and medium for processing large language model question prompts. Background Art

[0002] With the rapid development of natural language processing (NLP) technology, large language models (LLMs) have become the core tools for text understanding and generation. These models can understand and generate fluent and coherent natural language texts by pre-training on large-scale datasets. However, when processing queries based on ambiguous and false premises, LLMs often generate hallucinatory outputs that are inconsistent with the facts, which not only affects the reliability of the model, but also has a negative impact on user trust and the actual application of the model.

[0003] Existing LLMs often generate incorrect information when faced with false prompts, such as fictitious concepts or incorrect statements. This phenomenon is called "hallucination". The generation of hallucination output is partly due to the presence of incorrect information in the data exposed to the model during training, or the model's inability to correctly handle incorrect premises during reasoning. To address this problem, researchers have proposed a variety of strategies, including cleaning of pre-training data, supervised fine-tuning, reinforcement learning with human feedback, and mitigation strategies in the reasoning phase. Although these methods can reduce hallucination output to a certain extent, they usually require a large amount of labeled data, computing resources or model fine-tuning, and have limited effectiveness.

[0004] Through the above analysis, the problems and defects of the prior art are as follows:

[0005] Large language models in the prior art cannot correctly handle queries with ambiguous or false premises, and further generate hallucinatory outputs that are inconsistent with the facts; or they require a large amount of computing resources during the processing and have little effect. Summary of the invention

[0006] The embodiments of the present application provide a method, device and medium for processing large language model question prompts, which can solve the problems in the prior art that large language models cannot correctly process queries with ambiguous or erroneous premises, further generating hallucination outputs that are inconsistent with the facts; or require a large amount of computing resources during the processing and have little effect.

[0007] In a first aspect, an embodiment of the present application provides a method for processing question prompts for a large language model, the method comprising: obtaining an original text, extracting entities of the original text, and extracting logical relationships based on the entities, the logical relationships including causal relationships and employment relationships; reconstructing the question based on the entities and logical relationships, and generating a restated question prompt; based on the question prompt, adopting an adaptive random replacement strategy, calculating the semantic similarity and task type between the question prompt and the preset vocabulary, dynamically selecting a replacement mechanism, and generating multiple candidate prompts; calculating the global entropy value of the candidate prompts, performing multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and outputting the smallest candidate prompt if the verification passes.

[0008] In one implementation of the present application, questions are reconstructed based on entities and logical relationships to generate restated question prompts, specifically including: checking the context of the original text and matching the entity entries in a pre-built knowledge base; after matching the entries, using a word vector model to calculate the hypernyms of the entries; in the absence of context in the original text, generating restated question prompts based on the hypernyms and logical relationships.

[0009] In one implementation of the present application, based on the question prompt, an adaptive random replacement strategy is adopted to calculate the semantic similarity and task type between the question prompt and the preset vocabulary, dynamically select a replacement mechanism, and generate multiple candidate prompts, specifically including: segmenting the question prompt to obtain a first vocabulary; mapping the first vocabulary to a high-dimensional vector space through word embedding technology, and obtaining a second vocabulary with similar semantics within a preset distance in the high-dimensional vector space; calculating the vector similarity between the first vocabulary and the second vocabulary, and screening to obtain a third vocabulary with a preset ranking.

[0010] In one implementation of the present application, the task type includes a first task type and a second task type; after calculating the vector similarity between the first vocabulary and the second vocabulary and screening to obtain a third vocabulary with a preset ranking, the method also includes: pre-defining task keywords of different task types in a knowledge base, matching the first vocabulary with the task keywords to perform preliminary classification, and obtaining a first task type, and the task types include question and answer, translation, summary, and generation; according to the third vocabulary and the task type, dynamically selecting a replacement strategy to generate multiple candidate prompts, wherein the replacement strategy includes semantic equivalence transformation, syntactic reorganization, reverse reasoning, task-oriented reconstruction, and heuristic inference.

[0011] In one implementation of the present application, the global entropy value of the candidate prompt is calculated, specifically including: calculating the semantic distance between the candidate prompt and the original text based on the word embedding technology to obtain the semantic entropy; calculating the structural entropy of the candidate prompt; and combining the semantic entropy and the structural entropy to obtain the global entropy of the candidate prompt.

[0012] In one implementation of the present application, after checking the context of the original text and matching the entity entries in the pre-built knowledge base, the method also includes: when the original text has context, querying the intent according to the context, and generating a restated question prompt according to the intent; when the original text has context, reclassifying according to the context information to obtain a second task type; when the original text has context, calculating the context entropy of the candidate prompts; and combining the semantic entropy, structural entropy and context entropy to obtain the global entropy of the candidate prompts.

[0013] In one implementation of the present application, a multi-source knowledge base verification is performed on the candidate prompt with the smallest global entropy value. If the verification is passed, the smallest candidate prompt is output, which specifically includes: introducing an external knowledge base, and if the candidate prompt is inconsistent with the external knowledge base, adding a penalty coefficient to the global entropy of the candidate prompt to increase the entropy value of the global entropy; dynamically updating the content of the knowledge base to form a closed-loop feedback mechanism.

[0014] In one implementation of the present application, the method also includes: extracting time keywords from the original text and candidate prompts; using an event detection algorithm to scan the original text and candidate prompts to identify event types and event arguments; judging whether the event types and event arguments are timely based on the time keywords; and prioritizing the candidate prompts based on timeliness.

[0015] In a second aspect, an embodiment of the present application also provides a processing device for question prompts of a large language model, the device comprising at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: obtain original text, extract entities of the original text, and extract logical relationships based on the entities, wherein the logical relationships include causal relationships and employment relationships; reconstruct questions based on the entities and logical relationships, and generate restated question prompts; based on the question prompts, an adaptive random replacement strategy is adopted to calculate the semantic similarity and task type between the question prompts and preset vocabulary, dynamically select a replacement mechanism, and generate multiple candidate prompts; calculate the global entropy value of the candidate prompts, perform multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and output the smallest candidate prompt if the verification passes.

[0016] In a third aspect, an embodiment of the present application further provides a non-volatile computer storage medium for processing question prompts of a large language model, storing computer executable instructions, wherein the computer executable instructions are configured to: obtain original text, extract entities of the original text, and extract logical relationships based on the entities, wherein the logical relationships include causal relationships and employment relationships; reconstruct the question based on the entities and logical relationships, and generate a restated question prompt; based on the question prompt, adopt an adaptive random replacement strategy, calculate the semantic similarity and task type between the question prompt and the preset vocabulary, dynamically select a replacement mechanism, and generate multiple candidate prompts; calculate the global entropy value of the candidate prompts, perform multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and output the smallest candidate prompt if the verification passes.

[0017] The embodiment of the present application provides a processing method, device and medium for large language model question prompts, which aims to optimize the generation process of large language models (LLM) when processing wrong premises or fuzzy problems, thereby effectively reducing the occurrence of hallucination outputs; firstly, the problem is reconstructed, which has stronger robustness for queries with fuzzy and wrong premises, and can process these queries more accurately to avoid generating outputs that are inconsistent with the facts; multiple candidate prompts are generated through an adaptive random replacement strategy to enhance the diversity of expression while ensuring semantic consistency; the uncertainty of each candidate prompt is quantified through multi-level entropy evaluation, and the prompt with the lowest entropy value is selected as the preferred result; an external knowledge base is introduced to perform multi-knowledge source verification on the factual accuracy of the candidate prompts, and the verification results are combined with the entropy value calculation, and the prompts inconsistent with the knowledge base are adjusted using a penalty mechanism, thereby improving the accuracy and reliability of the generated content. Finally, the method of the present invention can significantly reduce the risk of hallucination output and improve the performance of large language models in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0019] Figure 1 A flow chart of a method for processing large language model question prompts provided in an embodiment of the present application;

[0020] Figure 2 An overall logic diagram of a method for processing large language model question prompts provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram of the internal structure of a processing device for large language model question prompts provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0023] The embodiments of the present application provide a method, device and medium for processing question prompts of a large language model, which solves the problem in the prior art that the large language model cannot correctly process queries with ambiguous or erroneous premises, further generating hallucinatory outputs that are inconsistent with the facts; or requires a large amount of computing resources during the processing and has little effect.

[0024] The technical solution proposed in the embodiments of the present application is described in detail below with reference to the accompanying drawings.

[0025] Figure 1 A flowchart of a method for processing large language model problem prompts provided in an embodiment of the present application. Figure 1 As shown, a method for processing a large language model question prompt provided in an embodiment of the present application specifically includes the following steps:

[0026] Step 10: Get the original text, extract the entities of the original text, and extract the logical relationships based on the entities. The logical relationships include causal relationships and employment relationships.

[0027] In this step, assume that the input question text is The text is analyzed through natural language understanding technology to mark out entities, reasoning logic and other information in the text. For example, the original question: How to improve memory by eating chocolate? There is uncertainty in the causal relationship in the question. Although some studies have shown that certain ingredients in chocolate may be beneficial to brain function, the statement of "improving memory" may be too absolute, so there is a certain logical imprecision; Information extraction: Entity: chocolate, memory; Relationship: indirect causal relationship.

[0028] Step 20: Reconstruct the question based on entities and logical relationships and generate restated question prompts.

[0029] In this step, a more accurate and clear problem description is reconstructed based on this information.

[0030] As an optional embodiment, question reconstruction is performed according to entities and logical relationships to generate restated question prompts, which may specifically include: Step 201: Check the context of the original text and match the entity entries in the pre-built knowledge base.

[0031] In this step, the knowledge base may contain various entities, their attributes, and the relationships between entities; it may be a structured database or a semi-structured document collection, such as Wikipedia. The knowledge base is indexed and matching is performed between chocolate and memory in the database.

[0032] Step 202: After matching an entry, use the word vector model to calculate the hypernym of the entry.

[0033] In this step, for example, the Word2Ve word vector model is used to obtain the word vector representation of the word "memory". According to the set of hypernyms predefined in the knowledge base, such as {"cognitive function", "brain ability", "learning ability", "intelligence", "psychological process"}, for each word in the candidate hypernym set, the cosine similarity between it and the word vector of "memory" is calculated. The cosine similarity between "cognitive function" and "memory" is 0.80, the cosine similarity between "brain ability" and "memory" is 0.85, and the cosine similarities between other candidate hypernyms and "memory" are all lower than 0.80, which means that the hypernym brain ability is matched.

[0034] Step 203: In the case where the original text has no context, a restated question prompt is generated based on hypernyms and logical relationships.

[0035] For example, based on brain capacity and non-causal relationships, the question is reconstructed as follows: "Does eating chocolate help brain function?" This question more accurately expresses the potential relationship between chocolate and brain function, avoiding the absolute statement of "improving memory" in the original question.

[0036] Step 30: Based on the question prompt, an adaptive random replacement strategy is used to calculate the semantic similarity and task type between the question prompt and the preset vocabulary, dynamically select a replacement mechanism, and generate multiple candidate prompts.

[0037] As an optional embodiment, based on the question prompt, an adaptive random replacement strategy is adopted to calculate the semantic similarity and task type between the question prompt and the preset vocabulary, dynamically select a replacement mechanism, and generate multiple candidate prompts, which may specifically include: Step 301: segment the question prompt to obtain the first vocabulary.

[0038] In this step, the calculation is performed with the first word being chocolate.

[0039] Step 302: Map the first vocabulary to a high-dimensional vector space by word embedding technology, and obtain a second vocabulary with similar semantics within a preset distance in the high-dimensional vector space.

[0040] In this step, for example, the chocolate input word is embedded into the model to obtain a vector representation: [0.1, 0.3, -0.2,..., 0.5], a 300-dimensional vector. Only some dimensions are shown here. To determine which words are semantically similar to the first word, a preset distance or similarity threshold needs to be defined. For example, a cosine similarity threshold can be set, and only words with a similarity higher than this threshold will be considered similar. Suppose the second words within the preset distance include "candy", "dessert", "cocoa products". For each second word, calculate the vector similarity between it and the first word "chocolate", which is similar to step 202.

[0041] Step 303: Calculate the vector similarity between the first word and the second words, and filter to obtain the third words ranked by the preset ranking.

[0042] In this step, suppose the preset range is the top 2, then the third words are "candy" and "cocoa products".

[0043] As an alternative embodiment, based on the task types including the first task type and the second task type; after calculating the vector similarity between the first word and the second words and filtering to obtain the third words ranked by the preset ranking, the method may further include:

[0044] Step 304: Define task keywords for different task types in the knowledge base in advance, match the first word with the task keywords for preliminary classification to obtain the first task type, and the task types include question answering, translation, summarization, generation.

[0045] In this step, for example, for the question answering task, keywords such as "question", "answer", "Q&A" and ending words such as "ma", "嘛" can be defined; for the translation task, keywords such as "translation", "English to Chinese", "Chinese to English" can be defined; for the summarization task, keywords such as "summary", "summarize", "overview" can be defined; for the generation task, broader keywords such as "generate", "create", "write" can be defined and further refined according to the specific task; if the matching fails, that is, the first word does not match any task keywords, more complex natural language processing analysis can be considered, or the input text or input can be marked as an unknown type for further processing.

[0046] Step 305: Dynamically select replacement strategies according to the third words and the task type to generate multiple candidate prompts, where the replacement strategies include semantic equivalent transformation, syntactic restructuring, backward reasoning, task-oriented reconstruction, and heuristic speculation.

[0047] In this step, semantic equivalence transformation: by finding synonyms or phrases with similar semantics to the original words, replace the core entities or verbs in the original question, so that the sentence can be expressed in different ways without changing the original meaning. For example: "Do cocoa products have a positive effect on brain function?" Syntactic reorganization: adjust the grammatical structure of the sentence, change the order of the components or sentence pattern of the sentence, such as from active voice to passive voice, or reverse the word order. For example: "Can brain function be improved by eating candy?" Reverse reasoning: convert the reasoning from "cause" to "effect" to reasoning from "effect" to "cause", or change the assumptions, and try to re-express the problem through different causal relationships. Through reverse reasoning, different logical orders or argumentation methods are given to generate candidate prompts. For example: "Does eating cocoa products have any effect on brain function?" Task-oriented reconstruction: According to the actual needs of the task, adjust the way the question is asked, add specific goal orientation, such as the answer form (yes / no, quantitative, qualitative) or the task type (question and answer, reasoning, induction); Heuristic inference: Use heuristic methods to generate candidate prompts, infer the relevant results of the problem based on existing knowledge or common sense, and thus propose hypothetical questions related to the original question. For example: "Do the antioxidants contained in cocoa products help slow down brain decline?"

[0048] Step 40: Calculate the global entropy value of the candidate prompts, perform multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and output the smallest candidate prompt if the verification passes.

[0049] As an optional embodiment, calculating the global entropy value of the candidate prompt may specifically include: Step 401: calculating the semantic distance between the candidate prompt and the original text based on the word embedding technology to obtain the semantic entropy.

[0050] In this step, the Multi-Level Entropy Assessment (MLEA) method is used to gradually quantify multiple dimensions of candidate prompts to increase comprehensive consideration of prompt uncertainty. Semantic Entropy (SE) measures the semantic uncertainty of candidate prompts, taking into account the semantic fluctuations caused by changes in word selection and syntactic structure. Specifically, the semantic distance between each candidate prompt and the original prompt is calculated based on the similarity of semantic embedding to obtain SE, which represents the possible semantic deviation of the candidate prompt.

[0051]

[0052] Where n is the candidate hint Length, is the probability of the i-th word appearing given the previous i-1 words, and the semantic uncertainty of the entire sequence is measured by averaging the negative log-likelihood of each word.

[0053] Step 402: Calculate the structural entropy of the candidate prompts.

[0054] In this step, Structural Entropy (SEn) evaluates whether the grammar and structure of the candidate prompt are stable and checks for logical or fluency problems that may be caused by structural changes. Specifically, using component syntax, the uncertainty of sentence structure is calculated to generate SE. Structural entropy measures the impact of changes in syntactic and grammatical structures on language production.

[0055]

[0056] in, S E ( sj ′) indicates candidate hint The structural entropy of n is the total number of sentence structures. Before given i -1 structure, i The probability of a structure appearing.

[0057] Step 403: Combine the semantic entropy and the structural entropy to obtain the global entropy of the candidate prompt.

[0058] As an optional embodiment, multi-source knowledge base verification is performed on the candidate prompt with the smallest global entropy value, and when the verification passes, the smallest candidate prompt is output, which may specifically include:

[0059] Step 404: introduce an external knowledge base. If the candidate prompt is inconsistent with the external knowledge base, add a penalty coefficient to the global entropy of the candidate prompt to increase the entropy value of the global entropy.

[0060] In this step, after the candidate prompt is generated, the facts in the prompt content are first verified by querying the external knowledge base, and by comparing with the standard facts in the external knowledge base, it is checked whether the generated content is inconsistent with the known facts or erroneous. If it is found that the information in the candidate prompt is inconsistent with the external knowledge base, it can be corrected or a prompt that is more in line with the facts can be regenerated to ensure the accuracy of the output.

[0061] Specifically, a multi-knowledge source verification mechanism can be introduced, which is not limited to Wikipedia or a specific database, but can be combined with multiple authoritative sources (such as domain-specific databases, expert systems, etc.) for cross-verification to enhance the accuracy and authority of the verification results. For outdated or incomplete content in the knowledge base, the knowledge base is dynamically updated and the automatic error correction mechanism is used to further improve the quality of candidate prompts. The verification results of the external knowledge base are used as an important factor in the calculation of the entropy value. If the candidate prompt is inconsistent with the facts in the knowledge base, a penalty coefficient is added to the entropy value of the prompt. This penalty coefficient is adjusted according to the severity of the inconsistency, thereby affecting the entropy value of the prompt.

[0062] For example, if a fact in the prompt is highly wrong or inconsistent, a higher penalty will be given to the prompt, causing its entropy value to increase, thereby reducing its likelihood of being the final choice. Among all candidate prompts, a prompt that has both a low entropy value and is highly consistent with the external knowledge base is selected as the final output.

[0063] Step 405: Dynamically update the content of the knowledge base to form a closed-loop feedback mechanism.

[0064] As an optional embodiment, after checking the context of the original text and matching the entity entries in the pre-built knowledge base, the method may also include: when the original text has context, querying the intent according to the context, and generating a restated question prompt according to the intent; when the original text has context, re-classifying according to the context information to obtain a second task type; when the original text has context, calculating the context entropy of the candidate prompts.

[0065] In this step, contextual entropy (CE) considers the adaptability of the candidate prompt in the current conversation or situation and checks whether it is consistent with the context information. Specifically, through the context analysis algorithm, the adaptability of the candidate prompt to the conversation history or question background is calculated to obtain C, which is an entropy value that measures the adaptability and consistency of the prompt in a specific context.

[0066]

[0067] in, Indicates candidate hints The context entropy of n is n, where n is the total number of contexts. is the probability of the i-th structure appearing given the previous i-1 structures.

[0068] Furthermore, semantic entropy, structural entropy and contextual entropy are combined to obtain the global entropy of the candidate prompt.

[0069] refer to Figure 2,Global Entropy (GE) combines semantic entropy, structural entropy and contextual entropy to obtain the ,global entropy of each candidate cue to comprehensively evaluate its uncertainty.,The semantic entropy, structural entropy and contextual entropy are weighted ,combined to obtain GE, which takes into account multiple factors, ,ensuring a comprehensive evaluation of the uncertainty of the candidate cue.

[0070]

[0071] Among them, α, β, and γ are weight coefficients, which are dynamically adjusted according to specific tasks or situations.

[0072] As an optional embodiment, the method may also include: extracting time keywords from the original text and candidate prompts; using an event detection algorithm to scan the original text and candidate prompts to identify event types and event arguments; judging whether the event types and event arguments are timely based on the time keywords; and prioritizing the candidate prompts based on timeliness.

[0073] In this step, a keyword list containing common time expressions is predefined in the knowledge base, such as "today", "tomorrow", "yesterday", "last week", "next month", "last year", etc. Simply put, events "today" are usually more timely, while events "last year" may be less timely.

[0074] Specific examples:

[0075] Dialogue history: User: I’ve been learning programming lately, and it feels a bit strenuous, but also very fulfilling. Model: “Great! Programming is indeed challenging and rewarding, and the process of learning new skills is a kind of growth in itself.” Candidate prompt: “You’ve done very well, keep going, the process of learning programming will help you open up more doors of opportunity, and the future will be even more exciting!”

[0076] First, calculate the semantic entropy (SE). Suppose the following conditional probabilities are calculated: for "learning programming", the probability of the candidate word "doing very well" is 0.8; for "difficult, but fulfilling", the probability of the candidate word "keep going" is 0.7; for "the process of programming", the probability of the candidate word "helps you open more doors of opportunity" is 0.6; for "the future is more exciting", the probability of the candidate word "more fulfilling" is 0.75. Calculate the negative log-likelihood (i.e., semantic entropy) of each word: for "done very well", -logP(done very well | learning programming) = -log(0.8) = 0.0969; for "keep on", -logP(keep on | hard work, but a sense of accomplishment) = -log(0.7) = 0.1554; for "help you open more doors of opportunity", -logP(help you open more doors of opportunity | the process of programming) = -log(0.6) = 0.2218; for "more fulfilling", -logP(more fulfilling | a more exciting future) = -log(0.75) = 0.125.

[0077] Semantic entropy calculation:

[0078]

[0079] Therefore, the semantic entropy SE = 0.1498.

[0080] Calculate the structural entropy (SEn): "Learning programming", the probability of the structure "doing very well" is 0.85; "Difficult, but a sense of accomplishment", the probability of the structure "keep on" is 0.8; "Programming process", the probability of the structure "helping you open more doors of opportunity" is 0.7; "The future is more exciting", the probability of the structure "more fulfilling" is 0.9. Calculate the negative log-likelihood (i.e. structural entropy) of each structure: for "doing very well", -logP(doing very well | learning programming) = -log(0.85) = 0.162; for "keep on", -logP(keep on | difficult, but a sense of accomplishment) = -log(0.8) = 0.0969; for "helping you open more doors of opportunity", -logP(helping you open more doors of opportunity | programming process) = -log(0.7) = 0.1554; for "more fulfilling", -logP(more fulfilling | more exciting future) = -log(0.9) = 0.0458.

[0081] Structural entropy calculation:

[0082]

[0083] Therefore, the structural entropy SEn = 0.1151.

[0084] Calculate the context entropy (CE): "Learning programming", the probability of the candidate prompt "doing very well" is 0.9; "Difficult, but a sense of accomplishment", the probability of the candidate prompt "keep on" is 0.85; "Programming process", the probability of the candidate prompt "help you open more doors of opportunity" is 0.8; "The future is more exciting", the probability of the candidate prompt "more fulfilling" is 0.85; calculate the negative log-likelihood (i.e., context entropy) of each structure: for "doing very well", -logP(doing very well | learning programming) = -log(0.9) = 0.0458; for "keep on", -logP(keep on | difficult, but a sense of accomplishment) = -log(0.85) = 0.1625; for "helping you open more doors of opportunity", -logP(helping you open more doors of opportunity | programming process) = -log(0.8) = 0.0969; for "more fulfilling", -logP(more fulfilling | more exciting future) = -log(0.85)=0.1625.

[0085] Context entropy calculation:

[0086]

[0087] Therefore, the context entropy CE = 0.1169.

[0088] Calculate global entropy (GE): Global entropy is the weighted sum of semantic entropy, structural entropy and contextual entropy, which is used to comprehensively evaluate the overall uncertainty of candidate prompts. Assume that we set the weight coefficients according to the specific task: semantic entropy weight α = 0.4; structural entropy weight β = 0.3; contextual entropy weight γ = 0.3;

[0089] The global entropy is calculated as:

[0090]

[0091] So, substituting the values:

[0092] Therefore, the global entropy of the candidate hint is GE = 0.1295.

[0093] Introducing external knowledge base for verification: To further ensure the validity of candidate prompts, we introduced an external knowledge base for verification. Here, our external knowledge base contains some knowledge about programming learning and mood management. For example: "Learning programming can help improve personal sense of accomplishment and self-confidence." "Many studies have shown that maintaining a positive attitude can effectively reduce stress when facing difficulties."

[0094] Verification results: Through the external knowledge base, we found that the candidate prompt "The process of learning programming will help you open more doors of opportunity, and the future will be more exciting" is completely consistent and there is no conflict; the external knowledge base supports the two views of "The programming process enhances the sense of accomplishment" and "A positive attitude brings more opportunities."

[0095] In this example, since the candidate prompt is highly consistent with the conversation history and has a clear grammatical structure, the semantic entropy, structural entropy, and contextual entropy are relatively small, and the global entropy is small, indicating that the candidate prompt fits the context very well and is a positive and appropriate response.

[0096] The above is an embodiment of the method proposed in this application. Based on the same inventive concept, the embodiment of this application also provides a processing device for large language model question prompts, and its structure is as follows: Figure 3 shown.

[0097] Figure 3 A schematic diagram of the internal structure of a processing device for large language model question prompts provided in an embodiment of the present application. Figure 3 As shown, the device includes:

[0098] at least one processor 301;

[0099] and, a memory 302 communicatively connected to at least one processor;

[0100] Among them, the memory 302 stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor 301 so that the at least one processor 301 can: obtain the original text, extract the entities of the original text, and extract the logical relationship based on the entities, and the logical relationship includes causal relationship and employment relationship; reconstruct the question according to the entities and logical relationship, and generate a restated question prompt; based on the question prompt, adopt an adaptive random replacement strategy, calculate the semantic similarity and task type between the question prompt and the preset vocabulary, dynamically select the replacement mechanism, and generate multiple candidate prompts; calculate the global entropy value of the candidate prompt, perform multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and output the smallest candidate prompt if the verification passes.

[0101] Some embodiments of the present application provide corresponding Figure 1A non-volatile computer storage medium for processing question prompts of a large language model, storing computer executable instructions, wherein the computer executable instructions are configured to: obtain original text, extract entities of the original text, and extract logical relationships based on the entities, wherein the logical relationships include causal relationships and employment relationships; reconstruct the question based on the entities and logical relationships, and generate restated question prompts; based on the question prompts, adopt an adaptive random replacement strategy, calculate the semantic similarity and task type between the question prompt and preset vocabulary, dynamically select a replacement mechanism, and generate multiple candidate prompts; calculate the global entropy value of the candidate prompts, perform multi-source knowledge base verification on the candidate prompt with the smallest global entropy value, and output the smallest candidate prompt if the verification passes.

[0102] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the IoT device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0103] The system and medium provided in the embodiments of the present application correspond one-to-one to the method. Therefore, the system and medium also have similar beneficial technical effects to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the system and medium will not be repeated here.

[0104] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0105] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0106] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0107] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0108] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0109] Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0110] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0111] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0112] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method for processing question prompts for a large language model, characterized in that: The method comprises: Acquire original text, extract entities of the original text, and extract logical relationships based on the entities, wherein the logical relationships include causal relationships and employment relationships; Reconstruct the question according to the entities and logical relationships, and generate restated question prompts; Based on the question prompt, an adaptive random replacement strategy is adopted to calculate the semantic similarity and task type between the question prompt and the preset vocabulary, and a replacement mechanism is dynamically selected to generate multiple candidate prompts, specifically including: Segmenting the question prompt to obtain a first vocabulary; Mapping the first vocabulary to a high-dimensional vector space by word embedding technology, and obtaining a second vocabulary with similar semantics within a preset distance in the high-dimensional vector space; Calculating the vector similarity between the first vocabulary and the second vocabulary, and selecting and obtaining a third vocabulary with a preset ranking; Based on the fact that the task types include a first task type and a second task type, task keywords of different task types are predefined in a knowledge base, and the first vocabulary is matched with the task keywords to perform preliminary classification to obtain a first task type, wherein the task types include question answering, translation, summary, and generation; According to the third vocabulary and the task type, dynamically selecting the replacement strategy to generate a plurality of candidate prompts, wherein the replacement strategy includes semantic equivalence transformation, syntactic reorganization, reverse reasoning, task-oriented reconstruction and heuristic inference; The global entropy value of the candidate prompt is calculated, and the candidate prompt with the smallest global entropy value is verified by a multi-source knowledge base. If the verification passes, the candidate prompt with the smallest global entropy value is output.

2. A method for processing large language model question prompts according to claim 1, characterized in that: Reconstruct the question based on the entities and logical relationships to generate restated question prompts, including: Reviewing the context of the original text and matching entries of the entity in a pre-built knowledge base; After matching the entry, use the word vector model to calculate the hypernym of the entry; In the case that the original text has no context, a restated question prompt is generated according to the hypernyms and logical relationships.

3. A method for processing large language model question prompts according to claim 1, characterized in that: Calculating the global entropy value of the candidate prompt includes: Calculate the semantic distance between the candidate prompt and the original text based on word embedding technology to obtain semantic entropy; calculating the structural entropy of the candidate prompt; The semantic entropy and the structural entropy are combined to obtain the global entropy of the candidate prompt.

4. A method for processing large language model question prompts according to claim 3, characterized in that: After reviewing the context of the original text and matching the entry of the entity in the pre-built knowledge base, the method further includes: In the case where the original text has a context, querying the intent according to the context, and generating a restated question prompt according to the intent; In the case where the original text has a context, reclassifying according to the context information to obtain a second task type; In the case where the original text has a context, calculating the context entropy of the candidate prompt; The semantic entropy, structural entropy and context entropy are combined to obtain the global entropy of the candidate prompt.

5. A method for processing large language model question prompts according to claim 1, characterized in that: The candidate hint with the smallest global entropy value is verified by a multi-source knowledge base, and if the verification passes, the smallest candidate hint is output, which specifically includes: An external knowledge base is introduced, and if the candidate prompt is inconsistent with the external knowledge base, a penalty coefficient is added to the global entropy of the candidate prompt to increase the entropy value of the global entropy; The content of the knowledge base is dynamically updated to form a closed-loop feedback mechanism.

6. A method for processing large language model question prompts according to claim 1, characterized in that: The method further comprises: Extracting time keywords from the original text and candidate prompts; Scanning the original text and candidate prompts using an event detection algorithm to identify event types and event arguments; Determining whether the event type and event argument are time-sensitive according to the time keyword; The candidate prompts are prioritized according to timeliness.

7. A processing device for large language model question prompts, characterized in that: The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least a processor to execute so that the at least one processor is capable of: Execute the steps of a method for processing a large language model question prompt as described in any one of claims 1-6.

8. A non-volatile computer storage medium for processing large language model question prompts, storing computer An executable instruction, characterized in that The computer executable instructions are configured to: Execute the steps of a method for processing a large language model question prompt as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Internet information object positioning method based on webpage structure semantic meaning

    CN102662969A

  • Question and answer matching method, training method of text matching model and related equipment

    CN113342958A