Method, device, computer device and storage medium for generating prompt words
Patent Information
- Application Number
- CN202610998823.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-06
- Publication Date
- 2026-10-23
AI Technical Summary
[0004]目前基于问题文本与文档块所记载内容的相似度,对提示词进行丰富的方式相对单一,导致RAG知识库中文档的利用率不高
在本申请提供的技术方案中,可以为RAG知识库中包括的文档块设置特例标签,用于指示对应的文档块所记载内容的不适用情况。在针对用户的问题文本进行检索时,一方面根据文档块所记载内容与问题文本的匹配度,为问题文本匹配在内容上接近的正面信息。另一方面根据文本块对应的特例标签与问题文本的匹配度,为问题文本匹配将问题文本相关的内容作为特例情况对待的反面信息。这样,可以提高在RAG知识库中的检索维度,提高RAG知识库中文档的利用率,进而提高提示词的信息丰富度。
Smart Images

Figure CN122964212A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer device, and storage medium for generating prompt words. Background Technology
[0002] Retrieval-Augmented Generation (RAG) is a technique that combines information retrieval with Large Language Model (LLM).
[0003] In RAG technology, a large number of documents related to the application domain of the large language model can be stored in the RAG knowledge base. When a user sends a question text to the large language model, document blocks with high similarity to the question text can first be retrieved from the RAG knowledge base. These retrieved document blocks are then merged with the question text to form prompts input to the large language model. This enriches the information input to the large language model, improving its reasoning performance.
[0004] Currently, the methods for enriching prompts based on the similarity between the question text and the content recorded in the document block are relatively limited, resulting in low utilization of documents in the RAG knowledge base. Summary of the Invention
[0005] This application provides a method, apparatus, computer device, and storage medium for generating prompt words, which can increase the dimensions of information retrieval in the RAG knowledge base and improve the information richness of generated prompt words. The corresponding technical solution is as follows: Firstly, a method for generating prompt words is provided, the method comprising: Receive the user's question text; In the retrieval enhancement generation of the RAG knowledge base, among multiple document blocks, at least one first document block is matched for the question text. Each of the multiple document blocks is provided with a special case label, which is used to indicate situations outside the scope of application of the content recorded in the document block. The at least one first document block is determined based on the first matching degree between the question text and the special case label provided for each document block. In the plurality of document blocks, at least one second document block is matched for the question text, wherein the second document block is determined based on a second matching degree between the question text and the content recorded in each document block; Based on the question text, the at least one first document block, and the at least one second document block, a prompt word is generated for input to the large language model.
[0006] Optionally, the plurality of document blocks are divided into multiple categories, and the category to which each document block belongs is determined according to the content recorded in each document block. The categories include operation category, concept category, or cause category.
[0007] Optionally, among the plurality of document blocks, at least one first document block is matched for the question text, including: In the document block corresponding to each category, at least one first document block is matched for the question text.
[0008] Optionally, among the plurality of document blocks, at least one second document block is matched for the question text, including: In the document block corresponding to each category, at least one second document block is matched for the question text.
[0009] Optionally, among the plurality of document blocks, at least one first document block is matched for the question text, including: Extract at least one keyword from the question text; The at least one first document block is determined based on the first degree of matching between the at least one keyword and the special tag set for each document block.
[0010] Optionally, each document block corresponds to a summary content, and among the plurality of document blocks, at least one second document block is matched for the question text, including: Based on the large language model, hypothetical text content corresponding to the question text and hypothetical summary content corresponding to the hypothetical text content are generated. The hypothetical text content is the content recorded in the document block that the question text matches. Among the plurality of document blocks, the first number of document blocks are determined based on the third matching degree between the hypothetical summary content and the summary content corresponding to each document block; In the first number of document blocks, at least one second document block is determined based on the second degree of matching between the hypothetical text content and the content recorded in each document block.
[0011] Optionally, the special case label includes product categories, user types, or time periods for which the content recorded in the corresponding document block is not applicable.
[0012] Secondly, an apparatus for generating prompt words is provided, the apparatus comprising: The receiving module is used to receive the user's question text; A matching module is configured to match at least one first document block for the question text among multiple document blocks included in the retrieved and enhanced RAG knowledge base, wherein each document block is provided with a special case label, the special case label being used to indicate situations outside the scope of application of the content recorded in the document block, and the at least one first document block being determined based on a first matching degree between the question text and the special case label provided in each document block; and to match at least one second document block for the question text among the multiple document blocks, wherein the second document block is determined based on a second matching degree between the question text and the content recorded in each document block; The generation module is used to generate prompt words for input to the large language model based on the question text, the at least one first document block, and the at least one second document block.
[0013] Optionally, the plurality of document blocks are divided into multiple categories, and the category to which each document block belongs is determined according to the content recorded in each document block. The categories include operation category, concept category, or cause category.
[0014] Optionally, the matching module is used to match at least one first document block for the question text in the document block corresponding to each category.
[0015] Optionally, the matching module is used to match at least one second document block for the question text in the document block corresponding to each category.
[0016] Optionally, the matching module is used to extract at least one keyword included in the question text; and to determine the at least one first document block based on the first matching degree between the at least one keyword and the special tag set for each document block.
[0017] Optionally, each document block corresponds to a summary content. The matching module is used to generate hypothetical text content corresponding to the question text and hypothetical summary content corresponding to the hypothetical text content based on the large language model. The hypothetical text content is the content recorded in the document block that the predicted question text matches. Among the plurality of document blocks, a first number of document blocks are determined based on the third matching degree between the hypothetical summary content and the summary content corresponding to each document block. Among the first number of document blocks, at least one second document block is determined based on the second matching degree between the hypothetical text content and the content recorded in each document block.
[0018] Optionally, the special case label includes product categories, user types, or time periods for which the content recorded in the corresponding document block is not applicable.
[0019] Thirdly, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, the instruction being loaded and executed by the processor to perform the operations performed by the method for generating prompt words as described in the first aspect above.
[0020] Fourthly, a computer-readable storage medium is provided, the storage medium storing at least one instruction, the instruction being loaded and executed by a processor to perform the operations performed by the method for generating prompt words as described in the first aspect above.
[0021] Fifthly, a computer program product is provided, the computer program product including at least one piece of program code, the program code being loaded and executed by a processor to perform the operations performed by the method for generating prompt words as described in the first aspect above.
[0022] The beneficial effects of the technical solution provided in this application are: The technical solution provided in this application allows for setting special case tags for document blocks included in the RAG knowledge base, used to indicate the inapplicability of the content recorded in the corresponding document block. When searching for a user's question text, on the one hand, based on the matching degree between the content recorded in the document block and the question text, positive information that is similar in content is matched to the question text. On the other hand, based on the matching degree between the special case tags corresponding to the text block and the question text, negative information that treats the content related to the question text as a special case is matched to the question text. In this way, the retrieval dimensions in the RAG knowledge base can be improved, the utilization rate of documents in the RAG knowledge base can be increased, and the information richness of the prompt words can be improved. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a flowchart illustrating a method for constructing a RAG knowledge base, as provided in an embodiment of this application. Figure 2 This is a schematic diagram illustrating the establishment of a RAG knowledge base provided in an embodiment of this application; Figure 3 This is a flowchart of a method for generating prompt words provided in an embodiment of this application; Figure 4 This is a flowchart of a retrieval method for a RAG knowledge base provided in an embodiment of this application; Figure 5This is a schematic diagram of a method for generating prompt words provided in an embodiment of this application; Figure 6 This is a schematic diagram of a device for generating prompt words provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0026] Retrieval-Augmented Generation (RAG) is a technique that combines information retrieval with Large Language Model (LLM).
[0027] In RAG technology, a large number of documents related to the application domain of the large language model can be stored in the RAG knowledge base. When a user sends a question text to the large language model, document blocks with high similarity to the question text can first be retrieved from the RAG knowledge base. These retrieved document blocks are then merged with the question text to form prompts input to the large language model. This enriches the information input to the large language model, improving its reasoning performance.
[0028] However, the current methods for enriching prompts based on the similarity between the question text and the content recorded in the document block are relatively limited. Therefore, this application's embodiments address at least the following problems with RAG technology: (1) Similarity-based information retrieval can only retrieve supporting information from the question text, often ignoring opposing information (special cases). For example, in the e-commerce field, a user's question text is "Can I return the salmon I bought?". In the RAG knowledge base, the document block related to "Seafood Purchase Instructions" has a higher similarity to the user's question text than the document block related to "7-Day No-Reason Return Policy." For instance, the document related to "7-Day No-Reason Return Policy" only states that daily necessities, clothing, and shoes can be returned without reason within 7 days, and the text content is unrelated to "salmon." Thus, the document related to "7-Day No-Reason Return Policy" may be ignored. If the document block related to "Seafood Purchase Instructions" does not explicitly state the return conditions for "salmon," the relevant document block may mislead the large language model, leading to an incorrect answer.
[0029] (2) Failure to differentiate between the intent type of documents and user questions. For example, user questions can be categorized into three different types of demands at the cognitive level: "how to do it", "what it is", and "why". The document types required for each type of demand are essentially different, and a uniform and undifferentiated search is unlikely to "prescribe the right medicine".
[0030] (3) There is a significant discrepancy between the language style of the user's question text and the language style of the document storage. The user's colloquial, incomplete, and technically deficient expressions are difficult to directly match with the written, structured, and standardized document expressions. Therefore, the current method of matching question text with document based on similarity may have a large error, which in turn affects the inference accuracy of the large language model.
[0031] This application provides a method for generating prompts, which involves generating special tags for document blocks in the RAG knowledge base, classifying document blocks, preprocessing user question text, and retrieving information from the RAG knowledge base based on the preprocessing results. The method provided in this application can be applied to any business scenario implementing large language model question answering based on RAG technology, such as AI customer question answering services provided by e-commerce platforms, ticketing software, and enterprise platforms.
[0032] To facilitate understanding of the embodiments of this application, the process of constructing the RAG knowledge base in this application will be introduced below. Figure 1 This is a flowchart illustrating a method for constructing a RAG knowledge base, as provided in an embodiment of this application. For example, this method can be executed by a server or a terminal, such as... Figure 1 As shown, the method includes: Step 101: Document preprocessing and segmentation.
[0033] In this context, "documents" refers to the documents stored in the RAG knowledge base. The specific content of these documents varies depending on the business domain targeted by the large language model. For example, in the e-commerce domain, the RAG knowledge base might store documents related to e-commerce operation rules, after-sales service terms, and discount / reduction rules. Similarly, in the autonomous driving domain, the RAG knowledge base might store documents related to road traffic rules and regional traffic restrictions.
[0034] Document preprocessing can include noise reduction, deduplication, and text formatting. Document segmentation can include semantic segmentation based on natural paragraphs, ensuring that each document segment is a complete semantic unit. When the number of document segments exceeds a preset length threshold, a sliding window overlap strategy can be used for secondary segmentation to reduce the breakage of cross-segment information. After preprocessing and segmenting each document to be stored in the RAG knowledge base, a large number of document segments can be obtained.
[0035] Step 102: Document block intent classification and summary generation.
[0036] To improve the efficiency and comprehensiveness of subsequent matching in the RAG knowledge base based on user question text, intent classification and summary generation can be performed on document blocks. Both intent classification and summary generation for document blocks can be achieved using artificial intelligence models.
[0037] The intent of a document block can be categorized based on the user's intended question. In one example, the user's intent can be divided into "how to do it," "what it is," and "why it is." Correspondingly, based on the problem the document block can solve, the intent can be categorized into "operational" (corresponding to "how to do it"), "conceptual" (corresponding to "what it is"), and "causal" (corresponding to "why it is"). It is understood that the intent category for each document block is not unique; for example, a document block can be classified as either "conceptual" or "causal." In this embodiment, the intent categorization for document blocks is merely an example. In actual business scenarios, other categories can be used to classify the intent of document blocks, which will not be listed here. The document block summary can be a brief overview of the document block's content in one or a few short sentences (one or more keywords).
[0038] In one example, a classification model for intent classification and a summary generation model for extracting summaries can be trained separately. The classification model and the summary generation model can be implemented using specialized models such as Bidirectional Encoder Representations from Transformers (BERT) or Bidirectional and Auto-Regressive Transformer (BART).
[0039] In another example, intent classification and summary generation of document blocks can be achieved based on set prompts and a large language model. For example, prompts may include "Please read the content of this document block. Based on the user problem that this document block can solve, classify the document block into one or more of the three categories: operation, concept, and cause." Alternatively, prompts may include "Generate a concise summary of the document block, extract the core theme, key fields, and main conclusions of the block, and form a medium-granularity semantic representation between complete content and simple keywords." It is understood that the large language model used for intent classification and summary generation of document blocks here can be the same large language model or a different large language model than the large language model used to solve user problems in the embodiments of this application.
[0040] Step 103: Extracting special tags from document blocks.
[0041] Exception tags are used to indicate situations outside the scope of application of the content described in a document block. These exception tags can also be called exclusion tags or restriction tags. In real-world scenarios, each document block has a corresponding scope of application when addressing the "why," "what," or "how" related to a user's problem. Exception tags are keywords or text segments that summarize situations outside that scope. For example, a document block describing a 7-day no-questions-asked refund policy might have an application scope that includes clothing, household goods, and toys; the corresponding exception tags could be fresh produce, digital products, etc.
[0042] It is understandable that exception tags may or may not be included in document blocks. These tags can be manually set or implemented using artificial intelligence models. In one example, exception tags for each document block can be extracted based on set prompts and a large language model. For example, the prompt might include, "Read the following document block and list the entities or scenarios corresponding to the explicitly mentioned inapplicable situations, exceptions, and restrictions, outputting a structured tag set." For instance, in the e-commerce field, exception tags could include inapplicable product categories, inapplicable scenarios, and invalidation conditions for the document block. For example, in an e-commerce platform, the exception tags for a document block might include inapplicable product categories, inapplicable user types, inapplicable time periods, inapplicable scenarios, and invalidation conditions, where user types could include user level, whether the user is a consumer or a merchant, etc.
[0043] Step 104: Vectorization and bucketing of document blocks.
[0044] After obtaining the category, summary, and special case tags corresponding to the intent classification of each document block, a semantic vector model can be used to vectorize the summary, content, and special case tags of each document block, resulting in vectorized representations of these elements. Furthermore, based on the intent classification category of each document block, content vector indices corresponding to the content of each document block and summary vector indices corresponding to the summary of each document block can be created in buckets. For example, content vector indices and summary vector indices can be created for "operation class," "concept class," and "cause class" document blocks.
[0045] It is understandable that each document block may correspond to a category that is not limited to one. If a document block is classified into multiple categories, then the document block may exist in the content vector index and summary vector index corresponding to each category.
[0046] Figure 2 This is a schematic diagram illustrating the establishment of a RAG knowledge base provided in an embodiment of this application, such as... Figure 2 As shown, for each document in the document set, document segmentation can be performed first. After obtaining multiple document segments, the document segments can be categorized based on the intent of the user's question, generating summaries and special case tags for each document segment. Finally, indexes for operation categories, concept categories, and cause categories can be built according to the corresponding categories.
[0047] After the RAG knowledge base is built on the server, the method for generating prompt words provided in the embodiments of this application can be implemented based on the RAG knowledge base. Figure 3 This is a flowchart of a method for generating prompt words provided in an embodiment of this application, such as... Figure 3 As shown, the method includes: Step 301: The server receives the user's question text.
[0048] In one example, the server can receive text questions sent by users through their terminals. For instance, a user can enter their question, such as "What after-sales service is available for the products I recently purchased?", into the client interface provided by the e-commerce platform, and then send the question to the e-commerce platform's server through their terminal.
[0049] After receiving the question text, the server can vectorize it. For example, the semantic vector model can vectorize the user's question text to obtain the vectorized question text.
[0050] Step 302: In the multiple document blocks included in the RAG knowledge base, match at least one first document block for the question text. Each document block in the multiple document blocks is set with a special case label. The special case label is used to indicate situations outside the scope of application of the content recorded in the document block. At least one first document block is determined based on the first matching degree between the question text and the special case label set in each document block.
[0051] In one example, after obtaining the vectorized representation of the question text (which can be referred to as the question text hereafter for ease of description), the server can calculate the similarity between the question text and the special case label corresponding to each document block. The higher the similarity, the higher the first match degree between the corresponding question text and the special case label of the document block. Where there are multiple special case labels corresponding to a document block, the highest similarity among these multiple special case labels can be determined as the first match degree.
[0052] In another example, the server can also extract keywords from the question text and determine the first match between these keywords and specific tags. For example, in e-commerce, the extracted keywords from the question text could relate to product categories, order times, and so on.
[0053] In one example, the initial match between keywords and special case tags can be divided into three cases: Case 1: The keyword matches a special case tag, meaning that at least one special case tag is included among the keywords in the question text. Case 2: The keyword's parent or child tag matches a special case tag. This means that at least one special case tag is included among the child tags of the parent tags of the keyword in the question text. Here, the parent tag of the keyword can be the parent category tag corresponding to the keyword, and the child tag of the keyword can be the child category tag corresponding to the keyword. For example, "salmon" is a child tag of "seafood," and "seafood" is a parent tag of "salmon." Case 3: The keyword and special case tag perform a fuzzy match. This means that the similarity between the keyword and the special case tag is greater than the set similarity threshold. For example, the match scores for Case 1, Case 2, and Case 3 can be decreased sequentially.
[0054] In practice, after calculating the first match degree between the user's question text and the special tag corresponding to each document block in the RAG knowledge base, the server can select the n document blocks with the highest first match degree as the first document block.
[0055] In this embodiment, the RAG knowledge base includes multiple document blocks corresponding to multiple categories. Document blocks of different categories can meet the needs of users with different intent questions. To improve the utilization rate of document blocks in the RAG instruction base, the server can calculate the first matching degree between the special case tags of the document blocks corresponding to each category and the question text, and then select at least one document block from the document blocks corresponding to each category as the first document block. Optionally, the server can perform parallel execution of matching the first document block for the question text based on the special case tags in the document blocks corresponding to multiple categories, thereby improving the efficiency of matching the first document block.
[0056] Step 303: In a plurality of document blocks, match at least one second document block for the question text, wherein the second document block is determined based on a second degree of matching between the question text and the content recorded in each document block.
[0057] In one feasible approach, a second matching degree can be determined by calculating the similarity between the question text and each document block. Then, the m document blocks with the highest corresponding second matching degrees can be selected as the second document blocks.
[0058] It is understandable that steps 302 and 303 are two steps divided for the convenience of scheme description. Steps 302 and 303 do not represent the execution order in terms of timing. In one example, steps 302 and 303 can also be executed in parallel.
[0059] In this embodiment, to address the issue of a low deviation between the language style of the user's question text and the language style of the stored documents, which affects retrieval performance in the RAG knowledge base, a large language model can be used to predict hypothetical text content and corresponding hypothetical summary content that are similar in language style to the document blocks based on the user's question text. It is understood that this hypothetical text content and hypothetical summary content are predictions from the large language model of the content and corresponding summary of the document blocks that can be matched with the question text. The purpose of the generated hypothetical text content and hypothetical summary content is to retrieve document blocks included in the RAG knowledge base, and it is not used to generate prompts for the question text. Its main purpose is to address the issues of users' colloquial, incomplete, and technically deficient expressions. Therefore, the hypothetical text content and hypothetical summary content do not need to be perfectly accurate in content description; as long as the content includes keywords and other information similar to the actual document blocks, it is sufficient.
[0060] Figure 4 This application provides a flowchart of a method for retrieving information from the RAG knowledge base based on hypothetical text content and hypothetical summary content, as illustrated in the embodiments of this application. Figure 4 As shown, the method includes: Step 401: Based on the large language model, generate hypothetical text content corresponding to the question text and hypothetical summary content corresponding to the hypothetical text content.
[0061] In implementation, based on constructed prompts and a large language model, hypothetical text content aligned with the language style of document blocks in the RAG knowledge base can be generated for the user's question text, along with corresponding hypothetical summary content. For example, prompts could be "simulating a fragment of the main text of a relevant document block, providing a written and complete possible answer" or "simulating a summary of a relevant document block, extracting the core conclusions and key fields corresponding to the user's question text."
[0062] After obtaining the hypothetical text content and hypothetical summary content output by the large language model, the hypothetical text content and hypothetical summary content can be vectorized using the semantic vector model to obtain the vectorized hypothetical summary vector and hypothetical content vector.
[0063] To improve matching efficiency, in this embodiment of the application, multiple document blocks included in the RAG knowledge base can be initially filtered based on the hypothetical summary content, and then further filtered based on the hypothetical text content. The corresponding processing can be seen in steps 402 and 403.
[0064] Step 402: Among multiple document blocks, determine the first number of document blocks based on the third degree of matching between the hypothetical summary content and the summary content of each document block.
[0065] In implementation, the similarity between the hypothetical summary content and the summary content corresponding to the content recorded in each document block can be calculated, and this similarity can be determined as the third matching degree between the hypothetical summary content and the summary content of the document block. After obtaining the third matching degree, a first number of document blocks with the highest third matching degree can be determined. This first number can be preset by technical personnel.
[0066] Step 403: In the first number of document blocks, determine at least one second document block based on the second matching degree between the hypothetical text content and the content recorded in each document block.
[0067] After obtaining a first number of document blocks, the similarity between the hypothetical text content and the content recorded in the first number of document blocks can be further calculated, thereby obtaining a second matching degree between the hypothetical text content and the content recorded in each document block. After obtaining the second matching degree, a second number of document blocks with the highest second matching degree can be determined, and these second number of document blocks are at least one matched second document block. In one example, the second number can be preset by a technician.
[0068] In this embodiment, the RAG knowledge base includes multiple document blocks corresponding to multiple categories. Document blocks of different categories can meet the needs of users with different intent questions. To improve the utilization rate of document blocks in the RAG indicator library, the server can calculate the second matching degree between the special case tags of the document blocks corresponding to each category and the question text, and then filter out at least one document block from the document blocks corresponding to each category as the first document block. Optionally, the server can perform parallel execution of matching second document blocks for the question text based on the special case tags in the document blocks corresponding to multiple categories, thereby improving the efficiency of matching second document blocks.
[0069] Step 304: Generate prompt words based on the question text, at least one first document block, and at least one second document block.
[0070] After obtaining at least one first document block and at least one second document block, the at least one first document block and at least one second document block can be combined with the user's question text to form a corresponding prompt word. In one example, the prompt word also includes descriptive information for each document block, such as category information for the first and second document blocks, or information indicating that the second document block is the opposite of the question text. For example, the structure of the prompt word may include "[Question Text], [Operation Class - Supporting Evidence], [Operation Class - Exception / Restriction], [Concept Class - Supporting Evidence], [Concept Class - Exception / Restriction], [Cause Class - Supporting Evidence], [Cause Class - Exception / Restriction]".
[0071] Figure 5 This is a schematic diagram illustrating a method for generating prompt words provided in an embodiment of this application. For example... Figure 5 As shown, the system obtains the user's input question text and generates a hypothetical summary text, hypothetical content text, and keywords based on the large language model. Then, based on the generated hypothetical summary text, hypothetical content text, and keywords, it filters the Top-K candidate document blocks from the document blocks corresponding to the operation, concept, and cause categories, respectively. Then, from the Top-K candidate document blocks in each category, it selects the Top-N1 second document blocks based on the second matching degree to achieve refined ranking of positive example paths. From the Top-K candidate document blocks in each category, it selects the Top-N2 first document blocks based on the first matching degree to achieve refined ranking of negative example paths. Alternatively, it selects the Top-N2 first document blocks from the document blocks corresponding to the operation, concept, and cause categories based on the first matching degree. Finally, it structurally concatenates the document blocks corresponding to the positive examples and rebates for the three categories to obtain prompts for the user's question text. In this way, the large language model is guided to proactively consider evidence from three dimensions of intent when generating answers and proactively informs the user of corresponding exceptions / limitations based on negative example evidence. In this way, the answers generated by the large language model have the completeness of three intention dimensions: operation guidance, concept definition, and causal explanation. At the same time, the use of counterexample information effectively avoids absolute erroneous answers and improves the reasoning accuracy of the large language model.
[0072] Based on the same inventive concept, this application also provides an apparatus for generating prompt words, which can be configured on the server or terminal in the above embodiments. Figure 6 This is a schematic diagram of a device for generating prompt words provided in an embodiment of this application, such as... Figure 6 As shown, the device includes: The receiving module 610 is used to receive the user's question text; The matching module 620 is configured to match at least one first document block for the question text among multiple document blocks included in the retrieved and enhanced RAG knowledge base, wherein each document block is provided with a special case label, the special case label being used to indicate situations outside the scope of application of the content recorded in the document block, and the at least one first document block being determined based on a first matching degree between the question text and the special case label set for each document block; and to match at least one second document block for the question text among the multiple document blocks, wherein the second document block is determined based on a second matching degree between the question text and the content recorded in each document block; The generation module 630 is used to generate prompt words for input to the large language model based on the question text, the at least one first document block, and the at least one second document block.
[0073] Optionally, the plurality of document blocks are divided into multiple categories, and the category to which each document block belongs is determined according to the content recorded in each document block. The categories include operation category, concept category, or cause category.
[0074] Optionally, the matching module 620 is used to match at least one first document block for the question text in the document block corresponding to each category.
[0075] Optionally, the matching module 620 is used to match at least one second document block for the question text in the document block corresponding to each category.
[0076] Optionally, the matching module 620 is used to extract at least one keyword included in the question text; and to determine the at least one first document block based on the first matching degree between the at least one keyword and the special tag set for each document block.
[0077] Optionally, each document block corresponds to a summary content, and the matching module 620 is used to generate hypothetical text content corresponding to the question text and hypothetical summary content corresponding to the hypothetical text content based on the large language model; among the plurality of document blocks, the first number of document blocks are determined based on the third matching degree between the hypothetical summary content and the summary content corresponding to each document block; among the first number of document blocks, at least one second document block is determined based on the second matching degree between the hypothetical text content and the content recorded in each document block.
[0078] Optionally, the special case label includes product categories, user types, or time periods for which the content recorded in the corresponding document block is not applicable.
[0079] It should be noted that the device for generating prompt words provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the server can be divided into different functional modules to complete all or part of the functions described above. In addition, the device for generating prompt words and the method for generating prompt words provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0080] Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device 700 can be a server as described in the above embodiments. The computer device 700 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 701 and one or more memories 702. The memory 702 stores at least one instruction, which is loaded and executed by the processor 701 to implement the methods provided in the various method embodiments described above. Of course, the server may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be elaborated upon here.
[0081] Figure 8 This illustration shows a structural block diagram of a computer device 800 provided in an exemplary embodiment of this application. The computer device 800 can be a portable mobile terminal, such as the terminal shown in the above embodiments, including smartphones, tablets, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, or desktop computers. The computer device 800 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.
[0082] Typically, computer device 800 includes a processor 801 and a memory 802.
[0083] Processor 801 may include one or more processing cores, such as a quad-core processor, a seven-core processor, etc. Processor 801 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 801 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 801 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 801 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0084] The memory 802 may include one or more computer-readable storage media, which may be non-transitory. The memory 802 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 802 are used to store at least one instruction, which is executed by the processor 801 to implement the method for generating prompt words provided in the embodiments of this application.
[0085] In some embodiments, the computer device 800 may also optionally include a peripheral device interface 803 and at least one peripheral device. The processor 801, memory 802, and peripheral device interface 803 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 803 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807, a positioning assembly 807, and a power supply 809.
[0086] Peripheral device interface 803 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 801 and memory 802. In some embodiments, processor 801, memory 802 and peripheral device interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 801, memory 802 and peripheral device interface 803 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0087] The radio frequency (RF) circuit 804 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 804 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 804 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), and wireless local area networks. In some embodiments, the RF circuit 804 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0088] Display screen 805 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 805 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 801 for processing. In this case, display screen 805 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 805, disposed on the front panel of computer device 800; in other embodiments, there may be at least two display screens, disposed on different surfaces of computer device 800 or in a folded design; in still other embodiments, display screen 805 may be a flexible display screen, disposed on a curved or folded surface of computer device 800. Furthermore, display screen 805 may be configured as a non-rectangular irregular shape, i.e., a non-rectangular screen. Display screen 805 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0089] The camera assembly 806 is used to acquire images or videos. Optionally, the camera assembly 806 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 806 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0090] The audio circuit 807 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 801 for processing, or input to the radio frequency circuit 804 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located in a different part of the computer device 800. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from the processor 801 or the radio frequency circuit 804 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 807 may also include a headphone jack.
[0091] The positioning component 808 is used to locate the current geographical location of the computer device 800 in order to enable navigation or LBS (Location Based Service).
[0092] Power supply 809 is used to supply power to various components in computer device 800. Power supply 809 can be alternating current, direct current, a disposable battery, or a rechargeable battery. When power supply 809 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0093] Those skilled in the art will understand that Figure 8 The structure shown does not constitute a limitation on the computer device 800, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0094] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including instructions that can be executed by a processor in a terminal to complete the method for generating prompt words in the above embodiments. The computer-readable storage medium may be non-transitory. For example, the computer-readable storage medium may be ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, and optical data storage devices, etc.
[0095] In an exemplary embodiment, a computer program product is also provided, which includes program code that can be executed by a processor in a computer device to perform the method for generating prompt words in the above embodiments.
[0096] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals (including but not limited to signals transmitted between user terminals and other devices) involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the page information involved in this application was obtained with full authorization.
[0097] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0098] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.
[0099] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for generating prompt words, characterized in that, The method includes: Receive the user's question text; In the retrieval enhancement generation of the RAG knowledge base, among multiple document blocks, at least one first document block is matched for the question text. Each of the multiple document blocks is provided with a special case label, which is used to indicate situations outside the scope of application of the content recorded in the document block. The at least one first document block is determined based on the first matching degree between the question text and the special case label provided for each document block. In the plurality of document blocks, at least one second document block is matched for the question text, wherein the second document block is determined based on a second matching degree between the question text and the content recorded in each document block; Based on the question text, the at least one first document block, and the at least one second document block, a prompt word is generated.
2. The method according to claim 1, characterized in that, The multiple document blocks are divided into multiple categories. The category to which each document block belongs is determined based on the content recorded in each document block. The categories include operation category, concept category, or cause category.
3. The method according to claim 2, characterized in that, Among the plurality of document blocks, at least one first document block is matched for the question text, including: In the document block corresponding to each category, at least one first document block is matched for the question text.
4. The method according to claim 2, characterized in that, Among the plurality of document blocks, matching at least one second document block for the question text includes: In the document block corresponding to each category, at least one second document block is matched for the question text.
5. The method according to any one of claims 1 to 4, characterized in that, Among the plurality of document blocks, at least one first document block is matched for the question text, including: Extract at least one keyword from the question text; The at least one first document block is determined based on the first degree of matching between the at least one keyword and the special tag set for each document block.
6. The method according to any one of claims 1 to 4, characterized in that, Each document block corresponds to a summary content. Among the plurality of document blocks, at least one second document block is matched for the question text, including: Based on the large language model, hypothetical text content corresponding to the question text and hypothetical summary content corresponding to the hypothetical text content are generated. The hypothetical text content is the content recorded in the document block that the question text matches. Among the plurality of document blocks, the first number of document blocks are determined based on the third matching degree between the hypothetical summary content and the summary content corresponding to each document block; In the first number of document blocks, at least one second document block is determined based on the second degree of matching between the hypothetical text content and the content recorded in each document block.
7. The method according to any one of claims 1 to 4, characterized in that, The special case tags include product categories, user types, or time periods where the content recorded in the corresponding document block is not applicable.
8. An apparatus for generating prompt words, characterized in that, The device includes: The receiving module is used to receive the user's question text; A matching module is configured to match at least one first document block for the question text among multiple document blocks included in the retrieved and enhanced RAG knowledge base, wherein each document block is provided with a special case label, the special case label being used to indicate situations outside the scope of application of the content recorded in the document block, and the at least one first document block being determined based on a first matching degree between the question text and the special case label provided in each document block; and to match at least one second document block for the question text among the multiple document blocks, wherein the second document block is determined based on a second matching degree between the question text and the content recorded in each document block; The generation module is used to generate prompt words based on the question text, the at least one first document block, and the at least one second document block.
9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one instruction that is loaded and executed by the processor to perform the operation performed by the method for generating prompt words as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction, which is loaded and executed by a processor to perform the operation of the method for generating prompt words as described in any one of claims 1 to 7.
