Response text generation method and device, computer equipment and storage medium
By preprocessing and context analysis of the input text, combining industry-specific prompt word templates and keywords, prompt words in large language models are generated, which solves the existing intelligent question-answer system answers inaccurate questions in vertical fields, and improves the accuracy and user satisfaction of the question-and-answer system.
Patent Information
- Application Number
- CN202510395314.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-08-19
AI Technical Summary
The existing intelligent question-and-answer system based on a general large language model is difficult to accurately perceive user needs in vertical fields, resulting in insufficient answer quality and user satisfaction, especially in advertising, film and television fields, and the cost and difficulty of improving system performance is high.
By preprocessing the input text, obtaining context information and industry-specific prompt word templates and keywords, combining large language models to generate reply text, and using multiple rounds of dialogue history and semantic analysis to improve the accuracy and user experience of the system.
It improves the accuracy and user satisfaction of the Q&A system in the vertical field, solves the ambiguity and fuzzy problems of user input in a simplified manner, and enhances the accuracy and reliability of the system.
Smart Images

Figure CN120508609A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of question-answering technology, and in particular to a method, apparatus, computer device, and storage medium for generating a reply text. Background Art
[0002] Amid the rapid development of artificial intelligence (AI) technology, many companies are beginning to adopt intelligent question-answering systems based on general-purpose large language models (LLMs) to meet internal and external business consulting needs and enhance business efficiency. However, these existing systems, often based on a retrieval-augmented generation (RAG) architecture, often suffer from shortcomings in answer quality and user satisfaction, particularly in vertical sectors such as advertising and film.
[0003] The crux of the matter lies in the varying quality of user-entered questions, often containing ambiguous and vague descriptions. This makes it difficult for the system to accurately perceive user needs, leading to inaccurate or even impossible knowledge extraction. Improving the performance of general-purpose large language models in specific industries through pre-training is not only technically difficult but also costly for most companies. Requiring users to improve the quality of their questions not only raises the barrier to entry for system use but also becomes unfeasible, especially when serving external customers.
[0004] Therefore, how to improve the accuracy of the question-and-answer system in vertical fields while ensuring user convenience has become a major challenge in meeting the needs of enterprises for intelligent consulting services. Summary of the Invention
[0005] In view of this, in order to solve the above technical problems or part of the technical problems, an embodiment of the present invention provides a reply text generation method, device, computer equipment and storage medium.
[0006] In a first aspect, an embodiment of the present invention provides a method for generating a reply text, comprising:
[0007] After preprocessing the input text, the target text is obtained;
[0008] Obtaining context information, a first prompt word template, and a first keyword corresponding to the target text;
[0009] Retrieving relevant information corresponding to the input text from a first database according to the input text, the context information, the first prompt word template, and the first keyword to obtain a search result;
[0010] generating prompt words of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result;
[0011] The prompt word is input into the large language model, so as to output a response text corresponding to the input text through the large language model.
[0012] In one possible implementation, the preprocessing of the input text includes:
[0013] generating automatic completion information and prediction information for the input text, so that the user can optimize the input text according to the automatic completion information and the prediction information to obtain an optimized first input text;
[0014] Performing spelling check and synonym replacement processing on the first input text to obtain a processed second input text;
[0015] The second input text is subjected to structural processing to obtain the target text.
[0016] In one possible implementation, generating auto-completion information and prediction information for the input text includes:
[0017] Obtaining a second prompt word template and a second keyword corresponding to the input text from a second database, wherein the second database is used to store universal prompt word templates, prompt word templates for different industries, and keywords;
[0018] The automatic completion information and prediction information are generated according to the second prompt word template and the second keyword for display.
[0019] In one possible implementation, obtaining the context information corresponding to the target text, the first prompt word template, and the first keyword includes:
[0020] Acquire historical conversation information and store it in a third database;
[0021] Acquire context text associated with the target text from the third database;
[0022] Performing vectorized encoding on the context text to obtain a context semantic vector;
[0023] Using the context text and the context semantic vector as the context information;
[0024] The first prompt word template and the first keyword are acquired from a second database according to the context information.
[0025] In a possible implementation, after obtaining the context information corresponding to the target text, the first prompt word template, and the first keyword, the method further includes:
[0026] generating an optimized text corresponding to the input text according to the context information, the first prompt word template, and the first keyword;
[0027] generating a reminder message according to the optimized text;
[0028] The reminder information is sent to the user, so that the user optimizes the input text according to the reminder information.
[0029] In a possible implementation, when there are multiple optimized texts, after sending the reminder information to the user, the method further includes:
[0030] receiving a selection operation or a modification operation of the user on the optimized text;
[0031] Generate target optimization text according to the selection operation or modification operation;
[0032] The input text is updated according to the target optimized text.
[0033] In one possible implementation, retrieving relevant information corresponding to the input text from a first database based on the input text, the context information, the first prompt word template, and the first keyword includes:
[0034] Generating a semantic vector corresponding to the input text, the context information, the first prompt word template, and the first keyword;
[0035] Performing vector similarity retrieval from the first database according to the semantic vector;
[0036] The preset amount of information whose vector similarity is greater than a set threshold is used as the relevant information.
[0037] In a second aspect, an embodiment of the present invention provides a reply text generating device, comprising:
[0038] The preprocessing module is used to preprocess the input text to obtain the target text;
[0039] An acquisition module, configured to acquire context information, a first prompt word template, and a first keyword corresponding to the target text;
[0040] a retrieval module, configured to retrieve relevant information corresponding to the input text from a first database based on the input text, the context information, the first prompt word template, and the first keyword, to obtain a retrieval result;
[0041] a generation module, configured to generate a prompt word of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result;
[0042] An input module is used to input the prompt word into the large language model so as to output a response text corresponding to the input text through the large language model.
[0043] In a third aspect, an embodiment of the present invention provides a computer device comprising: a processor and a memory, wherein the processor is configured to execute a reply text generation program stored in the memory to implement the reply text generation method described in any one of the first aspects above.
[0044] In a fourth aspect, an embodiment of the present invention provides a storage medium storing one or more programs, which can be executed by one or more processors to implement the reply text generation method described in any one of the first aspects above.
[0045] The reply text generation scheme provided by the embodiment of the present invention obtains a target text by preprocessing the input text; obtains context information, a first prompt word template, and a first keyword corresponding to the target text; retrieves relevant information corresponding to the input text from a first database based on the input text, the context information, the first prompt word template, and the first keyword to obtain a search result; generates prompt words of a large language model based on the input text, the context information, the first prompt word template, the first keyword, and the search result; and inputs the prompt words into the large language model to output a reply text corresponding to the input text through the large language model. In this way, after retrieving relevant information based on the input text combined with context information, the industry prompt word template, and keywords, prompt words of the large language model are generated based on the retrieved information to accurately generate a reply text through the large language model, thereby solving the problem of inaccurate knowledge extraction and low reply quality caused by the inability to accurately perceive user needs. By improving the accuracy and reliability of the question-answering system, the accuracy of question-answering and user satisfaction are significantly improved in a simple and efficient manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 A schematic diagram of a process for generating a reply text according to an embodiment of the present invention;
[0047] Figure 2 A schematic flow chart of another method for generating a reply text provided by an embodiment of the present invention;
[0048] Figure 3 A flowchart of another method for generating a reply text provided by an embodiment of the present invention;
[0049] Figure 4 A schematic structural diagram of a reply text generation system provided by an embodiment of the present invention;
[0050] Figure 5 A schematic structural diagram of a reply text generating device provided by an embodiment of the present invention;
[0051] Figure 6 A schematic structural diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0053] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below with reference to the accompanying drawings. The embodiments do not limit the embodiments of the present invention.
[0054] Figure 1 A flowchart of a method for generating a reply text according to an embodiment of the present invention is shown as follows: Figure 1 As shown, the method specifically includes:
[0055] S11. After preprocessing the input text, the target text is obtained.
[0056] The reply text generation method provided by an embodiment of the present invention is applied to a computer device, which may include but is not limited to: a server, a desktop computer, etc. Specifically, after retrieving relevant information based on the input text in combination with contextual information, industry prompt word templates and keywords, prompt words of a large language model are generated based on the retrieved information to accurately generate a reply text through the large language model.
[0057] In this embodiment, the input text is a question input by the user, and the input text after preprocessing is used as the target text. Among them, the preprocessing may include but is not limited to: spell checking processing, synonym replacement processing and structural processing of the input text. During spell checking processing, a writing check tool can be used to detect and correct writing errors. During synonym replacement processing, the keywords in the input are replaced with synonyms and preprocessed. The purpose is to solve the problem of vocabulary diversity in user input and improve the system's ability to understand user intentions. For example, users may use different expressions such as "advertising effect" or "promotion effect", but the actual needs are the same. By replacing with a unified keyword (such as the standardized term "advertising conversion rate"), semantic ambiguity can be reduced and the accuracy of subsequent retrieval and semantic analysis can be enhanced. During structural processing, the input text can be structurally processed, including word segmentation, part-of-speech tagging, etc.
[0058] S12: Obtain context information corresponding to the target text, a first prompt word template, and a first keyword.
[0059] In this embodiment, during historical conversations, multiple rounds of conversation history and context information are stored and managed. The context information cache not only stores conversation history (e.g., historical user questions) but also records logical associations between contexts (e.g., reference relationships in multiple rounds of conversation, such as "it" referring to the "advertising budget" in the previous sentence). Storage can be in the form of key-value pairs (e.g., conversation ID associated with context vector) or graph structures (e.g., knowledge graph association).
[0060] After obtaining the target text, semantic analysis is performed. Natural language processing technology (for example, BERT or LLM) can be used for semantic analysis to capture context associations, and the context associations and context text are used as context information.
[0061] Furthermore, the current question intention and the industry to which the question intention belongs are analyzed in combination with the current context information, input text and target text, and the first prompt word template and the first keyword corresponding to the current target text are obtained from the database. The acquisition method may include: vectorizing all texts and information, and vectorizing the prompt word templates and keywords, calculating the vector similarity to determine the relevance of each prompt word template and keyword, and using the prompt word template and keyword with the highest similarity or the highest relevance as the first prompt word template and the first keyword.
[0062] Semantic vectorization can be performed using the Sentence-BERT model (sentence-transformers / all-mpnet-base-v2). The maximum input text length is 512 tokens, and the output is a 768-dimensional vector. Similarity is calculated using cosine similarity with a threshold of 0.75. Only the top five search results with a similarity above the threshold are retained.
[0063] It can also identify contextual information and the intent of the target text, determine the industry and question intent involved in the user's current question, and determine the most matching first prompt word template and first keyword from the database based on the industry and question intent. For example, the system will identify the intent of the input text (such as "optimize advertising"), match the most relevant prompt word template from the database, and extract field keywords (such as "CPM" and "KPI") from the database. It can also dynamically generate complete prompt words (such as "Do you need to optimize the CPM of the equity advertising of A video playback software?").
[0064] The database is pre-built based on domain knowledge from different industries and is used to store prompt templates and keywords for different industries, as well as general prompt templates. For example, in the advertising industry, a general prompt template might be: "How to improve [metric]?" (metric = click-through rate, conversion rate, etc.). An industry prompt template might be: "What is the best time to run [ad type] on [platform]?" (platform = video player A, ad type = video ads). Keywords can be core terminology within the field (for example, "(Cost Per Click (CPC))" and "target audience" in the advertising industry).
[0065] S13 , searching the first database for relevant information corresponding to the input text according to the input text, the context information, the first prompt word template, and the first keyword to obtain a search result.
[0066] In this embodiment, multiple dimensions of information (input text, context information, first prompt word template, and first keyword) are searched for similarity or keywords with relevant information in the first database belonging to the same industry as the current input text to obtain search results. The first database contains domain knowledge of different industries and answers to common questions in different industries.
[0067] S14, generating prompt words of a large language model according to the input text, context information, the first prompt word template, the first keyword, and the search results;
[0068] S15. Input the prompt word into the large language model to output the response text corresponding to the input text through the large language model.
[0069] In this embodiment, the large language model refers to a pre-trained language model based on the Transformer architecture, including but not limited to GPT-4o and DeepSeek-LLM, which supports the generation of natural language text through prompt words. The input text represents the user's original question or demand, and the context information includes multiple rounds of dialogue history (user questions / responses) and logical associations (such as "it → advertising budget"), which are stored through key-value pairs (dialogue ID → context vector) or knowledge graphs. The first prompt word template is used to guide the large language model to generate a specific format of answer, such as "Please explain in professional language..." The first keyword represents the key information corresponding to the input text, which is used to enhance the query and construct more accurate prompt words. The retrieval results represent the relevant information found from the database to enhance the knowledge of the large language model.
[0070] Specifically, determine the prompt structure, clarify the input format required by the large language model (e.g., question-and-answer, summary, translation, etc.), and select an appropriate tone (formal, informal, technical, etc.). Organize the retrieved knowledge base content or historical conversations into a readable format and combine it with user input. Emphasize keywords so that the large language model can focus on the core information and improve the relevance of the answer. Use clear instructions, such as "Please answer the question based on the following information," to clarify the task objectives of the large language model.
[0071] As an example, the prompt word may be "Based on the following background information: {context information}, combined with the following keywords: {first keyword} and search results, please answer the user's question in detail: {input text}."
[0072] Furthermore, once the prompt word is constructed, it is passed as input to the large language model to generate the response text.
[0073] As an example, consider the input text: "How to improve advertising effectiveness?" Preprocessing: Synonyms are replaced with "How to improve advertising conversion rate?", and the structured word segmentation is ["improve", "advertisement", "conversion rate"]. Context matching: Correlate the historical conversation "Yesterday, a user asked about CPM calculation methods" to generate a contextual semantic vector. Search results: 3 relevant pieces of knowledge (CPM optimization strategy, A / B testing method) are found in the first database. The generated response: "It is recommended to improve conversion rate by optimizing ad creatives and targeted delivery. Specific methods include A / B testing..."
[0074] The reply text generation method provided by an embodiment of the present invention obtains a target text by preprocessing an input text; obtains context information, a first prompt word template, and a first keyword corresponding to the target text; retrieves relevant information corresponding to the input text from a first database based on the input text, the context information, the first prompt word template, and the first keyword to obtain a search result; generates prompt words of a large language model based on the input text, the context information, the first prompt word template, the first keyword, and the search result; and inputs the prompt words into the large language model to output a reply text corresponding to the input text through the large language model. Thus, after retrieving relevant information based on the input text combined with context information, the industry prompt word template, and keywords, prompt words of the large language model are generated based on the retrieved information, so that a reply text is accurately generated through the large language model. This solves the problem of inaccurate knowledge extraction and low reply quality caused by the inability to accurately perceive user needs. By improving the accuracy and reliability of the question-answering system, the accuracy of question-answering and user satisfaction in different industries is significantly improved in a simple and efficient manner.
[0075] Figure 2 A flow chart of another method for generating a reply text according to an embodiment of the present invention is shown as follows: Figure 2 As shown, the method specifically includes:
[0076] S21. Generate auto-completion information and prediction information for the input text, so that the user can optimize the input text according to the auto-completion information and prediction information to obtain an optimized first input text; perform spelling check and synonym replacement on the first input text to obtain a processed second input text; perform structured processing on the second input text to obtain a target text.
[0077] In this embodiment, a large language model (e.g., GPT, BERT, etc.) can be used to predict and complete the input text to improve text coherence. Recommendations can be based on a preset knowledge base: relevant information is extracted from a specific industry knowledge base to enhance the text content. Appropriate optimization suggestions can also be provided to the user.
[0078] Specifically, the method of generating automatic completion information and prediction information for the input text includes: obtaining a second prompt word template and a second keyword corresponding to the input text from a second database, the second database being used to store general prompt word templates, prompt word templates for different industries, and keywords; generating automatic completion information and prediction information based on the second prompt word template and the second keyword for display.
[0079] A second database is pre-built to store general prompt word templates, prompt word templates for different industries, and keywords. This allows for intent recognition based on the current input text. If the input text relates to a specific industry (such as healthcare, law, or finance), the prompt word template for that industry is prioritized. If the industry cannot be determined, a general prompt word template is used. Keyword matching can extract key information from the input text and match it with keywords in the database. For example, methods such as TF-IDF, BERT embedding, and semantic similarity can be used to retrieve the most relevant keyword set. The matching prompt word template and keywords are returned.
[0080] As an example, consider the text: "What is the role of AI in financial risk management?"
[0081] Database search results: Second prompt word template (industry-specific): "In the field of financial risk control, AI is mainly used for {keyword}. Please explain its role in detail." Second keyword (matched from the database): "fraud detection, credit scoring, risk prediction"
[0082] Furthermore, based on the prompt word template and keywords, user-visible completion suggestions are generated as auto-completion information or prediction information. When generating auto-completion information, the prompt word template can be filled in (replacing the placeholder to generate completion suggestions), combined with the input text, and the keywords returned by the database are filled into the template to generate reasonable completion content.
[0083] When generating predictive information, the next step can be predicted (generating possible subsequent content based on LLM), allowing large language models (such as GPT-4 and Claude) to combine templates to predict subsequent questions that users may want to ask, or supplement key background information.
[0084] Furthermore, the generated information is displayed in the form of prompt text, drop-down suggestions, dynamic completion, etc., so that users can adjust the input text by selecting or re-entering, and obtain the optimized first input text. For example, the user is typing: "AI in financial risk control..." The system automatically completes the following completion suggestion (based on the prompt word template + keyword filling): "AI's role in financial risk control includes fraud detection, credit scoring, and risk prediction. It can analyze transaction patterns and detect abnormal behavior through machine learning algorithms, thereby reducing financial risks." Predicted information (to guide users to ask further questions): "Do you want to learn about the algorithmic principles or actual case applications of AI in risk control?"
[0085] For example, predefined industry prompt templates (such as the advertising industry template: "How to optimize [ad type] for [metric] on [target platform]?") are used. Dynamic matching selects the prompt template through keyword matching or intent classification (e.g., using the BERT model). Variable filling extracts keywords from user input (e.g., "ad type = video ad") and fills them into template variables to generate auto-complete information (e.g., "How to optimize the click-through rate of video ads?"), which is then displayed to the user.
[0086] Furthermore, after obtaining the first input text, a spell check is performed to correct spelling errors in the input text and improve the accuracy of the text. Synonym replacement is also performed to optimize the wording to make the text more fluent and in line with specific industry or style requirements. When spell checking, spelling check tools such as Hunspell, SymSpell, and PySpellChecker can be used to identify spelling errors and provide correct suggestions. Combined with NLP language models (such as BERT and GPT), ensure that the spelled words are consistent with the context. When replacing synonyms, replaceable synonyms can be identified based on WordNet, BERT embedding, GPT-4, etc. Ensure that the replaced words do not change the original meaning and comply with industry terminology standards.
[0087] Structured processing is the process of converting unstructured natural language input into a standardized format that can be processed by computers. This can include: Word segmentation: splitting sentences into words (e.g., splitting "advertising effectiveness evaluation" into "advertising," "effectiveness," and "evaluation"). Part-of-speech tagging: marking the grammatical role of words (e.g., noun, verb). Named entity recognition (NER): extracting industry-related entities (e.g., "box office" and "IP adaptation" in the "film and television industry"). Dependency parsing: parsing sentence structure (e.g., subject-verb-object relationships).
[0088] In one possible implementation, the order of the pre-processing steps can be adjusted according to the input text characteristics. If a spelling error rate greater than 10% is detected, spell checking is performed first.
[0089] S22. Obtain historical conversation information and store it in a third database; obtain context text associated with the target text from the third database; perform vectorized encoding on the context text to obtain a context semantic vector; use the context text and the context semantic vector as context information; and obtain a first prompt word template and a first keyword from the second database based on the context information.
[0090] In this embodiment, a third database is pre-built to store historical conversation information. This database can use a relational database (MySQL / PostgreSQL) to store structured conversation data (e.g., user_id, timestamp, message, etc.). Alternatively, a NoSQL database (MongoDB / Elasticsearch) can be used to store unstructured conversation content in JSON format for full-text search. This is combined with vector databases (FAISS, Milvus, Weaviate) to support efficient semantic search.
[0091] Contextual text associated with the target text is retrieved from a third database to retrieve historical conversations related to the target text, providing contextual support. Contextual text can be filtered by time window: the user's most recent N conversations are retrieved to ensure contextual coherence. Keyword searches are used to identify historical conversations that are highly relevant to the target text.
[0092] Convert text into a numerical vector to generate a contextual semantic vector, enabling efficient semantic retrieval. Use cosine similarity to calculate the similarity between the current target text and historical conversations, and select the most relevant contextual semantic vector. The contextual semantic vector and the corresponding context text are used as context information.
[0093] Furthermore, by utilizing context information, the prompt word template and keyword with the highest similarity are obtained from the second database through vector similarity calculation, or the intent in the input text (such as "optimize advertising") is identified based on the context text, and the prompt word template most relevant to the intent is matched from the second database, and the domain keyword with the highest correlation is extracted from the second database.
[0094] S23. Generate optimized text corresponding to the input text according to the context information, the first prompt word template, and the first keyword; generate reminder information according to the optimized text; and send the reminder information to the user, so that the user can optimize the input text according to the reminder information.
[0095] In this embodiment, by analyzing the current input text and context information, it is determined whether the current input text has ambiguity or unclear intention. If so, an optimized text for the input text is generated based on the current first prompt word template and the first keyword, and a reminder message corresponding to the optimized text is generated.
[0096] Specifically, during ambiguity detection, semantic analysis can be used to identify ambiguous points (for example, when the input text is "How is the playback effect of video A?", the ambiguous information is identified as: "effect" may refer to "click-through rate" or "conversion rate"). The first prompt word template (What is the {indicator} of the {target video} in the video playback platform) and the first keyword (click-through rate) are obtained, and the optimized text generated is (What is the click-through rate of video A in the video playback platform?), and a reminder message is generated at the same time (Do you mean click-through rate or conversion rate?). The reminder message and the optimized text are displayed to the user at the same time, and an interactive design is performed. The user can view the current reminder message, re-enter the new input text according to the reminder message, or guide the user to select the optimized text through a button or drop-down menu.
[0097] In one possible embodiment, when there are multiple optimization texts, after sending the reminder message to the user, the process further includes: receiving a user selection or modification operation for the optimization text; generating a target optimization text based on the selection or modification operation; and updating the input text based on the target optimization text. Steps S21-S23 are then repeated until the current input text no longer requires optimization.
[0098] In one possible implementation, after the user selects an optimization suggestion, the system re-processes and searches the updated input text until the user confirms that it is correct. The maximum number of iterations is three, after which the system generates a response based on the most recent input.
[0099] S24. Generate semantic vectors corresponding to the input text, context information, the first prompt word template, and the first keyword; perform vector similarity search from the first database based on the semantic vectors; and use a preset number of pieces of information whose vector similarity is greater than a set threshold as relevant information to obtain search results.
[0100] In this embodiment, the input text, context information, the first prompt word template, and the first keyword are converted into numerical vectors for subsequent similarity calculations. Text vectorization: Sentence-BERT (SBERT) or OpenAI Embedding (text-embedding-ada-002) can be used to generate fixed-dimensional vectors. The semantic information of the text is represented by vectors, and similarity calculations are performed based on the distance between vectors.
[0101] Furthermore, the first database is used to store a large amount of knowledge from different industries and a database of response texts corresponding to different industry questions. It also stores semantic vectors corresponding to the industry knowledge and response texts. Cosine similarity can be used to calculate the similarity between the input text, context information, first prompt word template, and first keyword and the vectors in the database:
[0102] A predefined similarity threshold (e.g., 0.80) and a preset number of results are used to limit the number of results returned (e.g., a maximum of 5 relevant information) to avoid information overload. Results are sorted in descending order of similarity to ensure that the most relevant information is returned first. A preset number of information items with vector similarity greater than the threshold are considered relevant information to obtain the search results.
[0103] S25, generating prompt words of a large language model according to the input text, context information, the first prompt word template, the first keyword, and the search results;
[0104] S26. Input the prompt word into the large language model to output a response text corresponding to the input text through the large language model.
[0105] In this embodiment, steps S25 and S26 are similar to steps S14 and S15, and can be specifically referred to. Figure 1 For the sake of brevity, the relevant content will not be elaborated here.
[0106] The reply text generation method provided by the embodiment of the present invention integrates processing steps such as input preprocessing, automatic completion, context processing, industry prompt word template matching, domain keyword generation, and question clarification interaction, forming a complete processing flow to achieve accurate responses to input questions. The use of industry-specific prompt word templates and domain keyword libraries for completion and prediction improves prediction accuracy and user experience. By eliminating ambiguity and guiding users to provide more information through multiple rounds of dialogue, the accuracy of system responses and user satisfaction are improved. The system can understand user intentions more accurately and provide relevant information. Through industry prompt words and clarification interactions, users can enter query content more conveniently and reduce the trouble caused by ambiguity. The system can adapt to the question and answer needs of different fields and achieve industry adaptation through the expansion of industry prompt word templates and domain keyword libraries.
[0107] Figure 3 A flowchart of another method for generating a reply text according to an embodiment of the present invention is shown as follows: Figure 3 As shown, the method specifically includes:
[0108] 1. User input preprocessing and auto-completion prediction process:
[0109] User input text user_input.
[0110] The user input preprocessing and auto-completion module performs spelling checking, synonym replacement, and structural processing to generate preprocessed text preprocessed_input.
[0111] Generate completion and prediction suggestions completion_suggestions based on matching industry prompt word templates and keywords.
[0112] 2. Semantic and context analysis process:
[0113] The semantic analysis module performs semantic analysis on preprocessed_input and performs context processing in combination with the context cache to generate the context context and its semantic vector contextual_representation.
[0114] 3. Industry prompt word template matching and field keyword generation process
[0115] According to the content of contextual_representation, match the prefabricated industry prompt template and generate possible prompt words user_industry_prompt and domain keywords user_niche_keywords.
[0116] 4. Interactive process of problem clarification:
[0117] When there is ambiguity, a clarification question is dynamically generated and fed back to the user.
[0118] Based on the user's clarified answer, the context information is updated and the process is re-performed.
[0119] 5. Multi-dimensional retrieval fusion process:
[0120] Perform knowledge base vector similarity search or keyword search based on user_input, context, user_industry_prompt, and user_niche_keywords respectively, integrate the search results, sort them by similarity, and select the top N results.
[0121] 6. Construction process of large language model prompt words:
[0122] Based on the user's original input user_input, context fusion information context, user industry prompt word user_industry_prompt, user domain keywords user_niche_keywords and the topN knowledge base search results, a large language model prompt word prompt is constructed. The prompt is input into the LLM, and the reply content is generated and output to the user.
[0123] Figure 4 A schematic diagram of the structure of a reply text generation system provided by an embodiment of the present invention is shown as follows: Figure 4 As shown, the system specifically includes:
[0124] 1. Input preprocessing and auto-completion module: This module is responsible for spelling checking, synonym replacement, and structural processing of user input, and implements input completion and prediction based on industry prompt word templates and field keywords.
[0125] 2. Context processing module: Utilizes the semantic association between previous and subsequent texts to understand and process the context, ensuring that the system can fully understand the user's intent.
[0126] 3. Industry prompt word templates and field keyword modules: Predefine prompt word templates for common industry queries and combine them with keywords in specific fields to dynamically generate suggestions based on user input, thereby improving the accuracy and relevance of input.
[0127] 4. Question clarification interaction module: By dynamically generating question clarification interactions, it guides users to provide more detailed information to eliminate ambiguity and vagueness, ensuring that the system can accurately understand and respond to user needs.
[0128] 5. Multi-dimensional retrieval fusion module: Through the retrieval of information from multiple dimensions, the results are integrated and sorted by relevance to maximize the comprehensiveness and accuracy of knowledge matching.
[0129] 6. Large language model prompt word construction module: By constructing large language model prompt words containing multi-dimensional information, it accurately and clearly expresses user intent and industry knowledge, maximizing the comprehensiveness and accuracy of LLM output.
[0130] Through the collaborative work of the above modules, the response quality and user satisfaction of the question-answering system can be effectively improved, and the ambiguity and vagueness problems in user input can be effectively solved.
[0131] Figure 5 A schematic diagram of the structure of a reply text generating device provided by an embodiment of the present invention is shown as follows: Figure 5 As shown, the device specifically includes:
[0132] A preprocessing module 51 is used to preprocess the input text to obtain the target text;
[0133] An acquisition module 52 is configured to acquire context information, a first prompt word template, and a first keyword corresponding to the target text;
[0134] A retrieval module 53 is configured to retrieve relevant information corresponding to the input text from a first database based on the input text, the context information, the first prompt word template, and the first keyword to obtain a retrieval result;
[0135] A generating module 54, configured to generate prompt words of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result;
[0136] The input module 55 is used to input the prompt word into the large language model so as to output a reply text corresponding to the input text through the large language model.
[0137] In one possible implementation, the preprocessing module is specifically configured to generate auto-completion information and prediction information for the input text, so that the user can optimize the input text according to the auto-completion information and the prediction information to obtain an optimized first input text;
[0138] Performing spelling check and synonym replacement processing on the first input text to obtain a processed second input text;
[0139] The second input text is subjected to structural processing to obtain the target text.
[0140] In one possible implementation, the generating module is specifically configured to obtain a second prompt word template and a second keyword corresponding to the input text from a second database, wherein the second database is configured to store universal prompt word templates, prompt word templates for different industries, and keywords;
[0141] The automatic completion information and prediction information are generated according to the second prompt word template and the second keyword for display.
[0142] In one possible implementation, the acquisition module is specifically configured to acquire historical conversation information and store it in a third database;
[0143] Acquire context text associated with the target text from the third database;
[0144] Performing vectorized encoding on the context text to obtain a context semantic vector;
[0145] Using the context text and the context semantic vector as the context information;
[0146] The first prompt word template and the first keyword are acquired from a second database according to the context information.
[0147] In a possible implementation, the generating module is further configured to generate an optimized text corresponding to the input text based on the context information, the first prompt word template, and the first keyword;
[0148] generating a reminder message according to the optimized text;
[0149] The sending module 56 semantically sends the reminder information to the user, so that the user can optimize the input text according to the reminder information.
[0150] In a possible implementation, the receiving module 57 is configured to receive a selection operation or a modification operation of the user on the optimized text;
[0151] Generate target optimization text according to the selection operation or modification operation;
[0152] The input text is updated according to the target optimized text.
[0153] In one possible implementation, the retrieval module is specifically configured to generate a semantic vector corresponding to the input text, the context information, the first prompt word template, and the first keyword;
[0154] Performing vector similarity retrieval from the first database according to the semantic vector;
[0155] The information of a preset number whose vector similarity is greater than a set threshold is used as the relevant information.
[0156] The device provided in this embodiment can be Figure 5 The device shown in , can perform the following Figure 1-3 All steps of the method are implemented Figure 1-3 For details on the technical effects of the method shown, please refer to Figure 1-3 For the sake of brevity, the relevant description will not be repeated here.
[0157] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is provided. Figure 6 The computer device 600 shown includes: at least one processor 601, memory 602, at least one network interface 604 and other user interfaces 603. The various components in the computer device 600 are coupled together via a bus system 605. It is understood that the bus system 605 is used to achieve connection and communication between these components. In addition to including a data bus, the bus system 605 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the bus system 605 is not described in detail. Figure 6 Various buses are labeled as bus system 605.
[0158] The user interface 603 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touchpad, or a touch screen).
[0159] It is understood that the memory 602 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDRSDRAM), enhanced synchronous DRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 602 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0160] In some embodiments, the memory 602 stores the following elements, executable units, or data structures, or a subset thereof, or an extended set thereof: an operating system 6021 and application programs 6022 .
[0161] The operating system 6021 includes various system programs, such as a framework layer, a core library layer, and a driver layer, for implementing various basic services and handling hardware-based tasks. Application programs 6022 include various application programs, such as a media player and a browser, for implementing various application services. Programs implementing the methods of the embodiments of the present invention may be included in application programs 6022.
[0162] In an embodiment of the present invention, by calling a program or instruction stored in the memory 602, specifically, a program or instruction stored in the application 6022, the processor 601 is configured to execute the method steps provided in each method embodiment, for example, including:
[0163] After preprocessing the input text, the target text is obtained;
[0164] Obtaining context information, a first prompt word template, and a first keyword corresponding to the target text;
[0165] Retrieving relevant information corresponding to the input text from a first database according to the input text, the context information, the first prompt word template, and the first keyword to obtain a search result;
[0166] generating prompt words of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result;
[0167] The prompt word is input into the large language model, so as to output a response text corresponding to the input text through the large language model.
[0168] The methods disclosed in the above embodiments of the present invention can be applied to or implemented by processor 601. Processor 601 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in processor 601 or by software instructions. The above processor 601 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present invention can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software units in the decoding processor. The software units can be located in storage media well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory 602 , and the processor 601 reads the information in the memory 602 and completes the steps of the above method in combination with its hardware.
[0169] It is understood that the embodiments described herein may be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or a combination thereof.
[0170] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0171] The computer device provided in this embodiment may be Figure 6 The computer device shown in , can execute Figure 1-3 All steps of the method are implemented Figure 1-3 For details on the technical effects of the method shown, please refer to Figure 1-3 For the sake of brevity, the relevant description will not be repeated here.
[0172] An embodiment of the present invention further provides a storage medium (computer-readable storage medium). The storage medium stores one or more programs. The storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; and the memory may also include a combination of the aforementioned types of memory.
[0173] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned reply text generation method executed on the device side can be implemented.
[0174] The processor is configured to execute a reply text generation program stored in the memory to implement the following steps of a reply text generation method executed on the device side:
[0175] After preprocessing the input text, the target text is obtained;
[0176] Obtaining context information, a first prompt word template, and a first keyword corresponding to the target text;
[0177] Retrieving relevant information corresponding to the input text from a first database according to the input text, the context information, the first prompt word template, and the first keyword to obtain a search result;
[0178] generating prompt words of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result;
[0179] The prompt word is input into the large language model, so as to output a response text corresponding to the input text through the large language model.
[0180] Professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0181] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0182] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating a reply text, characterized in that: include: After preprocessing the input text, the target text is obtained; Obtaining context information, a first prompt word template, and a first keyword corresponding to the target text; Retrieving relevant information corresponding to the input text from a first database according to the input text, the context information, the first prompt word template, and the first keyword to obtain a search result; generating prompt words of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result; The prompt word is input into the large language model, so as to output a response text corresponding to the input text through the large language model.
2. The method according to claim 1, characterized in that The preprocessing of the input text includes: generating automatic completion information and prediction information for the input text, so that the user can optimize the input text according to the automatic completion information and the prediction information to obtain an optimized first input text; Performing spelling check and synonym replacement processing on the first input text to obtain a processed second input text; The second input text is subjected to structural processing to obtain the target text.
3. The method according to claim 2, characterized in that The generating of automatic completion information and prediction information for the input text includes: Obtaining a second prompt word template and a second keyword corresponding to the input text from a second database, wherein the second database is used to store universal prompt word templates, prompt word templates for different industries, and keywords; The automatic completion information and prediction information are generated according to the second prompt word template and the second keyword for display.
4. The method according to claim 1, wherein The acquiring of the context information corresponding to the target text, the first prompt word template, and the first keyword includes: Acquire historical conversation information and store it in a third database; Acquire context text associated with the target text from the third database; Performing vectorized encoding on the context text to obtain a context semantic vector; Using the context text and the context semantic vector as the context information; The first prompt word template and the first keyword are acquired from a second database according to the context information.
5. The method according to claim 1, wherein After obtaining the context information, the first prompt word template, and the first keyword corresponding to the target text, the method further includes: generating an optimized text corresponding to the input text according to the context information, the first prompt word template, and the first keyword; generating a reminder message according to the optimized text; The reminder information is sent to the user, so that the user optimizes the input text according to the reminder information.
6. The method according to claim 5, characterized in that When there are multiple optimized texts, after sending the reminder information to the user, the method further includes: receiving a selection operation or a modification operation of the user on the optimized text; Generate target optimization text according to the selection operation or modification operation; The input text is updated according to the target optimized text.
7. The method according to claim 1, characterized in that The retrieving relevant information corresponding to the input text from a first database according to the input text, the context information, the first prompt word template, and the first keyword includes: Generating a semantic vector corresponding to the input text, the context information, the first prompt word template, and the first keyword; Performing vector similarity retrieval from the first database according to the semantic vector; The information of a preset number whose vector similarity is greater than a set threshold is used as the relevant information.
8. A reply text generating device, characterized in that: include: The preprocessing module is used to preprocess the input text to obtain the target text; An acquisition module, configured to acquire context information corresponding to the target text, a first prompt word template, and a first keyword; a retrieval module, configured to retrieve relevant information corresponding to the input text from a first database based on the input text, the context information, the first prompt word template, and the first keyword, to obtain a retrieval result; a generation module, configured to generate a prompt word of a large language model according to the input text, the context information, the first prompt word template, the first keyword, and the search result; An input module is used to input the prompt word into the large language model so as to output a response text corresponding to the input text through the large language model.
9. A computer device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a reply text generation program stored in the memory to implement the reply text generation method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the reply text generation method according to any one of claims 1 to 7.
Citation Information
Cited By
Electricity marketing work order reply generation method and system based on generative large model
CN120670562A
Power marketing work order reply generation method and system based on generative large model
CN120670562B
Man-machine conversation implementation method and device, electronic equipment and computer storage medium
CN121256005A
Man-machine conversation implementation method and device, electronic equipment and computer storage medium
CN121256005B
Environmental literature intelligent screening system and method based on large language model
CN121436175A