Intelligent question answering method and system based on large model, terminal and storage medium

By adopting a large-model-based intelligent question-answer method in the intelligent question-answer system, using text classification model and natural language processing technology, the traditional question-answer system is solved in the shortage of timeliness and accuracy in dealing with complex and fast-changing problems, and achieving more efficient, safe and accurate question-and-answer services.

CN120067266APending Publication Date: 2025-05-30SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510205321.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-24
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

When traditional question-and-answer systems deal with complex, diverse and fast-changing questions, they find it difficult to obtain real-time information and have limited understanding capabilities, resulting in insufficient timeliness and accuracy of answers.

Method used

The intelligent question-and-answer method based on big models is adopted to obtain target problems through word segmentation and feature vector transformation, and the text classification model is trained using the security annotation of historical problems to judge the security status of the problems. Determine whether the network is needed based on the security detection results and topic categories, extract keywords and determine topic categories through the TF-IDF and TextCNN models, and design non-networked or networked propts to obtain question and answer results.

Benefits of technology

It improves the security, accuracy and efficiency of the Q&A system, can effectively identify and intercept unsafe issues, and decide whether it is necessary to connect to the Internet to obtain information based on the characteristics of the questions, ensuring the timeliness and comprehensiveness of the answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120067266A_ABST
    Figure CN120067266A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and particularly provides an intelligent question answering method and system based on a large model, a terminal and a storage medium, and the method comprises the steps: obtaining a target question, segmenting words, converting the words into feature vectors, training a text classification model by using historical questions marked with safety conditions, and inputting the feature vectors of the current questions to obtain the safety conditions and probabilities. Judging safety according to the probability and the threshold value, and returning interception information if the judgment is not passed. Through a security detection problem, keywords are extracted by using a TF-IDF algorithm, a TextCNN model is trained by means of historical keywords and topic categories, the topic category of the current problem is obtained, and whether networking is carried out or not is judged. If not, designing a non-networking prompt input large model according to the theme and the intention to obtain an answer; and if networking is needed, calling a search engine after rewriting a write expansion question, and designing a networking prompt input large model to obtain a question and answer result. The safety, accuracy and rationality of questioning and answering are effectively improved, and the quality and efficiency of questioning and answering services are optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of artificial intelligence, and particularly relates to an intelligent question-answering method, system, terminal and storage medium based on a large model. Background Art

[0002] In today's digital age, the demand for intelligent question-answering systems is increasing day by day. Traditional question-answering systems often rely on predefined rules and limited knowledge bases, and show many limitations when facing complex, diverse and constantly changing user questions.

[0003] On the one hand, their knowledge reserves are relatively fixed, and it is difficult to obtain real-time and up-to-date information, resulting in inaccurate answers for time-sensitive questions. For example, when asking about the latest technological trends, real-time financial market conditions or the results of ongoing sports events, traditional systems may give outdated or inaccurate answers due to unupdated data.

[0004] On the other hand, the understanding ability of traditional question-answering systems is limited. For natural language questions with vague semantics and diverse expressions, it is difficult to accurately grasp the user's intention, thus affecting the accuracy and efficiency of question-answering.

[0005] With the continuous development of artificial intelligence technology, it has become a trend to use large models to complete question-answering. However, when current models process user questions, how to effectively integrate external knowledge resources to supplement the deficiencies of the internal knowledge of the model and further improve the comprehensiveness and accuracy of answers is still an urgent problem to be solved. Summary of the Invention

[0006] In view of the above deficiencies of the prior art, the present invention provides an intelligent question-answering method, system, terminal and storage medium based on a large model to solve the above technical problems.

[0007] In a first aspect, the present invention provides an intelligent question-answering method based on a large model, including: S1, obtaining a target question, performing word segmentation on the target question to obtain a plurality of sub-word units and converting them into feature vectors; obtaining historical target questions and annotating the security status for the historical target questions, training a text classification model based on the feature vectors after word segmentation of the historical target questions and the corresponding security status, and inputting the feature vectors after word segmentation of the current target question into the model, and the model outputs the security status and the probability value corresponding to the security status; S2, judging whether the target question passes the security detection based on the probability value corresponding to the security status in combination with a security threshold. If the target question fails to pass the security detection, return an interception message as the answer to the target question; S3. After the target question passes the security check, extract keywords from the target question based on the TF-IDF algorithm, train a TextCNN model based on the keywords of historical target questions and their corresponding topic categories, input the keywords of the current target question into the TextCNN model, and the model outputs the current topic category corresponding to the current target question. Determine whether to connect to the network based on the current topic category; S4. If it is determined that there is no need to connect to the network, design a non-networked prompt based on the topic category and intention of the target question, fill in the specific content of the target question into the non-networked prompt in a specified format, input the non-networked prompt into the large model, and obtain the Q&A result; If it is determined that there is a need to connect to the network, rewrite and / or expand the target question based on natural language processing technology, call an external search engine in real time based on the rewritten and / or expanded target question to obtain search results, design a networked prompt based on the search results, input the search results and the networked prompt into the large model, and obtain the Q&A result.

[0008] In an optional implementation manner, step S1 specifically includes: Segment the target question based on the BERT tokenizer, and convert the sub-word units after segmentation into feature vectors based on the word embedding layer of BERT; Load a pre-trained Transformer model from the pre-trained model library. There is a fully connected layer serving as a classification layer on the Transformer model. The input of the Transformer model is the feature vector, and the output is the security status and the probability value corresponding to the security status; Perform multiple rounds of training on the training set. In each round, divide the training data into small batches, and sequentially input them into the model for forward propagation and backward propagation to update the model parameters; After each round ends, evaluate the performance of the model using the validation set; Use the test set to perform a final evaluation on the trained model.

[0009] In an optional implementation manner, in step S3, the specific process of extracting keywords from the target question based on the TF-IDF algorithm includes: Calculate the word frequency of a word based on the number of times the word appears in the target question; Calculate the inverse document frequency based on the probability of a word appearing in the set of similar questions of the target question; Multiply the word frequency and the inverse document frequency of each word to obtain the TF-IDF value of the word; Sort the TF-IDF values of all words in the target question, and obtain the words with TF-IDF values greater than the key threshold as the keywords of the target question.

[0010] In an alternative embodiment, the training of the TextCNN model specifically includes: Using the keywords of historical target questions and their corresponding topic categories as the dataset; Count all the keywords in the training set, construct a vocabulary, assign a unique index to each keyword, and convert the keywords of each historical target question into the corresponding index sequence according to the vocabulary; The TextCNN model includes: constructing an embedding layer to convert the input keyword index sequence into a word vector representation, constructing a convolutional layer and performing convolution operations on the output of the embedding layer based on multiple convolutional kernels of different sizes, constructing a pooling layer and performing pooling operations on the output of the convolutional layer, connecting the output of the pooling layer to a fully connected layer, and then connecting to an output layer; Training the TextCNN model for multiple rounds based on the training set. In each round, divide the training data into small batches, input them into the model in turn for forward propagation and backward propagation, and update the model parameters; After each round, use the validation set to evaluate the performance of the model; Use the test set to evaluate the trained model.

[0011] In an alternative embodiment, in step S4, the intents of the target questions include factual questions and opinion questions; Factual questions require accurate answers, and the non-networked prompt is designed as "Please accurately answer the following question about [topic category]: [specific content of the target question]"; Opinion questions require providing multiple viewpoints and analyses, and the non-networked prompt is designed as "Please provide multiple viewpoints and analyses on [specific content of the target question] about [topic category]".

[0012] In an alternative embodiment, in step S4, when it is determined that networking is not required, in the multi-round Q&A, in each new round of prompt, the previous user questions and the content of the large model's answers are concatenated in sequence in real time, and then the non-networked prompt corresponding to the target question in the current round is generated in real time.

[0013] In an alternative embodiment, in step S4, the rewriting and / or expansion of the target question based on natural language processing technology includes: replacing the words in the target question with words that are similar in meaning and more in line with the search requirements based on a thesaurus, adding details to the target question based on the topic category and intent of the target question, and expanding the semantics of the target question based on semantic understanding technology to add background, conditions or restrictions; Designing the networked prompt based on the search results includes: Extracting the key information related to the target question from the search results; According to the key information and the type of the target question, determine the structure of the networked prompt, specifically including the basic structure, the comparison structure, the expansion structure, and the case structure.

[0014] In a second aspect, the present invention provides an intelligent question-answering system based on a large model. When the system is implemented, the above-mentioned intelligent question-answering method based on the large model is executed. The system includes: A target question detection module, which obtains the target question, performs word segmentation on the target question to obtain multiple sub-word units and converts them into feature vectors; obtains the historical target question and labels the security status of the historical target question, trains a text classification model based on the feature vectors after word segmentation of the historical target question and the corresponding security status, and inputs the feature vectors after word segmentation of the current target question into the model, and the model outputs the security status and the probability value corresponding to the security status; An insecure question-answering module, which determines whether the target question passes the security detection based on the probability value corresponding to the security status in combination with the security threshold. If the target question fails to pass the security detection, an interception message is returned as the answer to the target question; A network connection judgment module. After the target question passes the security detection, it extracts keywords from the target question based on the TF-IDF algorithm, trains a TextCNN model based on the keywords of the historical target question and the corresponding topic categories, inputs the keywords of the current target question into the TextCNN model, and the model outputs the current topic category corresponding to the current target question, and determines whether to connect to the network based on the current topic category; A question-answering result output module. If it is determined that there is no need to connect to the network, design a non-networked prompt based on the topic category and intention of the target question, fill in the specific content of the target question into the non-networked prompt according to the specified format, input the non-networked prompt into the large model, and obtain the question-answering result; If it is determined that it is necessary to connect to the network, rewrite and / or expand the target question based on natural language processing technology, call an external search engine in real time based on the rewritten and / or expanded target question to obtain search results, design a networked prompt based on the search results, input the search results and the networked prompt into the large model, and obtain the question-answering result.

[0015] In a third aspect, a terminal is provided, including: A processor and a memory, wherein, The memory is used to store a computer program, The processor is used to call and run the computer program from the memory, so that the terminal executes the method of the above-mentioned terminal.

[0016] In a fourth aspect, a computer-readable storage medium is provided. Instructions are stored in the computer-readable storage medium. When it runs on a computer, the computer is made to execute the methods described in the above aspects.

[0017] The beneficial effects of the present invention are as follows. The intelligent question-answering method, system, terminal, and storage medium based on a large model provided by the present invention perform word segmentation on the target question, convert the feature vectors, and use the historical target questions and their security annotations to train a text classification model to judge the security status and probability of the current target question. Then, it judges whether to intercept the question based on the probability value and the security threshold to ensure security. On the premise that the question is safe, keywords are extracted by the TF-IDF algorithm, and the theme category is determined by the TextCNN model and the need for networking is judged. According to whether to connect to the network, non-network or network prompts are designed respectively and input into the large model to obtain the question-answering result, realizing the whole process processing of the target question from security detection to reasonable judgment of the networking need, and then to accurate output of the question-answering result, effectively improving the security, accuracy, and reasonableness of the question-answering, and optimizing the quality and efficiency of the question-answering service.

[0018] In addition, the design principle of the present invention is reliable, the structure is simple, and it has a very wide application prospect. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0020] Figure 1 It is a schematic flowchart of an intelligent question-answering method based on a large model according to an embodiment of the present invention.

[0021] Figure 2 It is a schematic block diagram of an intelligent question-answering system based on a large model according to an embodiment of the present invention.

[0022] Figure 3 It is a schematic structural diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0023] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0025] The large-model-based intelligent question-answering method provided in the embodiment of the present invention is executed by a computer device, and accordingly, the large-model-based intelligent question-answering system runs in the computer device.

[0026] Figure 1 is a schematic flow chart of an intelligent question-answering method based on a large model according to an embodiment of the present invention. Figure 1 The execution subject can be an intelligent question-answering system based on a large model. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.

[0027] like Figure 1 As shown, the method includes: S1, obtain the target question, segment the target question, obtain multiple subword units and convert them into feature vectors; obtain historical target questions and mark the safety status of historical target questions, train a text classification model based on the feature vectors of historical target questions after segmentation and the corresponding safety status, input the feature vector of the current target question after segmentation into the model, and the model outputs the safety status and the probability value corresponding to the safety status; Use mature word segmentation tools (such as Transformer-based word segmenters) to segment the target questions obtained and obtain subword units. Then map these subword units to the vector space and convert them into feature vectors. Collect historical target questions from historical data, organize professionals or use existing annotation rules to mark their safety status (such as safety marked as 1 and unsafe marked as 0). Select a suitable deep learning framework (such as PyTorch), build a text classification model architecture (such as a Transformer-based classification model), and use the feature vectors of the historical target questions after word segmentation and the corresponding safety annotations as input for model training. After the training is completed, input the feature vector of the current target question into the model to obtain the safety status and corresponding probability value.

[0028] By performing word segmentation and feature vector conversion on the target question, the text information can be converted into a numerical form that the model can process, which is convenient for model learning. By using historical data to annotate and train the text classification model, the model can be equipped with the ability to judge the security status of the target question, providing a basis for subsequent security testing, effectively identifying problems that may pose risks, and ensuring the security and stability of system operation.

[0029] S2. Based on the probability value corresponding to the security status and in combination with the security threshold, determine whether the target question passes the security detection. If the target question fails the security detection, return the interception information as the answer to the target question. Set a reasonable security threshold (such as 0.6, which can be adjusted according to the actual situation), and compare the probability value corresponding to the security status output by the model with this threshold. If the probability value is lower than the threshold, it is determined that the target question fails the security detection. Prepare the pre-set interception information (such as "Your question has a security risk and cannot be answered"), and return it to the user as the answer to the target question.

[0030] Based on the judgment mechanism of the probability value and the security threshold, it is possible to quickly and accurately screen the target question, intercept in a timely manner the questions with security risks, and avoid potential hazards that may be caused by processing insecure questions.

[0031] S3. After the target question passes the security detection, extract the keywords of the target question based on the TF-IDF algorithm, train the TextCNN model based on the keywords of the historical target questions and their corresponding theme categories, input the keywords of the current target question into the TextCNN model, the model outputs the current theme category corresponding to the current target question, and determine whether to connect to the Internet based on the current theme category. When the target question passes the security detection, use the TF-IDF algorithm to extract its keywords, calculate the term frequency and inverse document frequency of each word, and select the words with higher TF-IDF values as keywords. Collect the keywords of historical target questions and label their corresponding theme categories (such as technology, culture, life, etc.). Use a deep learning framework to build a TextCNN model, and use the historical keywords and theme categories as training data for model training. After training, input the keywords of the current target question into the model to obtain the current theme category output by the model, and then judge whether to connect to the Internet according to the pre-set rules (such as some theme categories correspond to the need to connect to the Internet, and some do not).

[0032] S4. If it is determined that there is no need to connect to the Internet, design a non-internet-connected prompt based on the theme category and intention of the target question, fill in the specific content of the target question into the non-internet-connected prompt according to the specified format, input the non-internet-connected prompt into the large model, and obtain the Q&A result. If it is determined that there is a need to connect to the Internet, rewrite and / or expand the target question based on natural language processing technology, call an external search engine in real time based on the rewritten and / or expanded target question to obtain search results, design an internet-connected prompt based on the search results, input the search results and the internet-connected prompt into the large model, and obtain the Q&A result.

[0033] If it is determined that network connection is not required, analyze the topic category and intention of the target question. According to different topics and intention types (such as factual questions, opinion questions), design a non-networked prompt in a preset format (for example, a factual question is designed as "Please accurately answer the following question about [topic category]: [specific content of the question]"). After filling in the specific content of the target question into the prompt, input it into the existing large model to obtain the Q&A result. If it is determined that network connection is required, use natural language processing techniques (such as synonym replacement, sentence transformation, etc.) to rewrite or expand the target question to make it clearer and more accurate. Use the search engine API or web crawler technology to obtain search results according to the rewritten or expanded question. Extract key information from the search results and design a networked prompt (such as including the question, background information, and answer requirements). Input the search results and the prompt into the large model to get the Q&A result.

[0034] Optionally, as an embodiment of the present invention, Optionally, as an embodiment of the present invention, step S1 specifically includes: Collect a large number of historical target questions and label the security status of each question (for example, "safe" is marked as 1, "unsafe" is marked as 0). These data can be stored in a table, such as a CSV file, where one column is the question text and the other column is the corresponding security annotation.

[0035] Divide the collected historical target question data into a training set, a validation set, and a test set. Usually, the training set accounts for 70% - 80%, the validation set accounts for 10% - 15%, and the test set accounts for 10% - 15%. The purpose of the division is to evaluate the generalization ability of the model and avoid overfitting.

[0036] Use a suitable tokenization tool to tokenize the target question to obtain multiple sub-word units. For example, a tokenizer based on the Transformer model can be used, such as the BERT tokenizer: load the tokenizer from the pre-trained model, for example, use the transformers library to load the BERT tokenizer; input each question into the tokenizer to obtain the tokenization result; convert the tokenized sub-word units into feature vectors for input into the model.

[0037] Map each sub - word into a vector space of a fixed dimension. Pre - trained word vectors such as the word embedding layer of BERT can be used. To make all input sequences of the same length, the sequences need to be padded. Usually, special padding tokens (such as [PAD]) are used to pad the shorter sequences. In addition to word embeddings, other input features need to be generated, such as attention masks (used to indicate which positions are real words and which are padding) and segment embeddings (if applicable).

[0038] Select a suitable text classification model architecture. For a Transformer - based model, load a pre - trained Transformer model from the pre - trained model library, add a fully - connected layer on top of the pre - trained model as the classification layer with an output dimension of 2 (corresponding to the two categories of safe and unsafe), use the cross - entropy loss function to measure the difference between the model's prediction results and the true labels, and select a suitable optimizer (such as the Adam optimizer) to update the model parameters; Train for multiple epochs on the training set. In each epoch, divide the training data into small batches and input them into the model in turn for forward propagation and backward propagation to update the model parameters.

[0039] After each epoch, evaluate the performance of the model using the validation set. Calculate metrics such as accuracy, precision, recall, etc. of the model on the validation set to monitor the generalization ability of the model. If the performance of the model on the validation set no longer improves, training can be stopped early to avoid overfitting.

[0040] Use the test set to conduct a final evaluation of the trained model. Calculate metrics such as accuracy, precision, recall, F1 - score, etc. of the model on the test set to evaluate the performance of the model.

[0041] After tokenizing and converting the current target problem into feature vectors, input it into the trained model. The model will output the safety status (such as 0 or 1) and the corresponding probability values. The softmax function can be used to convert the output of the model into a probability distribution.

[0042] Optionally, as an embodiment of the present invention, in step S3, the keyword extraction of the target problem based on the TF - IDF algorithm specifically includes: Collect a text collection containing the target problem. This text collection can be a single long text or multiple related short texts (such as a text group composed of multiple questions). Ensure that the text data has been basically pre - processed, such as removing special characters, converting to a unified case form, etc., to improve the accuracy of subsequent processing.

[0043] For each text (if it is a collection of multiple texts), perform word segmentation to split the text into individual words or phrases, and calculate the word frequency of the words based on the number of times they appear in the target question; Count the set of similar questions containing each word, and calculate the inverse document frequency based on the probability of the word appearing in the set of similar questions of the target question; Multiply the word frequency and inverse document frequency of each word to obtain the TF-IDF value of the word; Sort the TF-IDF values of all words in the target question, and obtain the words with TF-IDF values greater than the key threshold as the keywords of the target question.

[0044] Optionally, as an embodiment of the present invention, the training of the TextCNN model specifically includes: Use the keywords of historical target questions and the corresponding topic categories as the data set; Count all keywords in the training set, construct a vocabulary, assign a unique index to each keyword, and convert the keywords of each historical target question into the corresponding index sequence according to the vocabulary; The TextCNN model includes: using an embedding layer to convert the input keyword index sequence into a word vector representation. The role of the embedding layer is to map discrete keyword indexes to a continuous vector space so that the model can learn the semantic relationships between keywords.

[0045] Perform convolution operations on the output of the embedding layer using multiple convolution kernels of different sizes. Each convolution kernel will extract the features of keyword combinations of different lengths. For example, a convolution kernel of size 3 will extract the features of 3 consecutive keywords.

[0046] Perform pooling operations on the output of the convolution layer, usually using max pooling. The role of the pooling layer is to extract the most important features of the output of each convolution kernel and reduce the feature dimension.

[0047] Connect the output of the pooling layer to a fully connected layer, and then connect it to an output layer. The number of neurons in the output layer is equal to the number of topic categories. Use the softmax activation function to convert the output into a probability distribution, indicating the possibility of each topic category.

[0048] Based on the training set, perform multiple rounds of training on the TextCNN model. In each round, divide the training data into small batches, and sequentially input them into the model for forward propagation and backward propagation to update the model parameters; After each round, evaluate the performance of the model using the validation set; Evaluate the trained model using the test set.

[0049] According to the theme category corresponding to the current target question, formulate corresponding rules to determine whether to connect to the network. For example: If the theme category is "Breaking News", "Latest Technological Developments", etc., usually need to connect to the network to obtain the latest information.

[0050] If the theme category is "Basic Knowledge", "Classical Theories", etc., it may not be necessary to connect to the network, and the model's own knowledge reserve can answer the question.

[0051] Optionally, as an embodiment of the present invention, in step S4, the theme category of the target question includes "Historical Knowledge", "Scientific Theories", "Literary Appreciation", etc., and the intents include factual questions (such as asking about the time, place, people, etc. of a certain event) and opinion questions (such as asking about the evaluation of a certain work, the view on a certain phenomenon, etc.); Factual questions require accurate answers, and the non-networked prompt is designed as "Please accurately answer the following question about [theme category]: [specific content of the target question]"; Example: If the target question is "In which year did Emperor Qin Shi Huang unify the six states", and the theme category is "Historical Knowledge", then the designed prompt is "Please accurately answer the following question about historical knowledge: In which year did Emperor Qin Shi Huang unify the six states"; Opinion questions require providing multiple viewpoints and analyses, and the non-networked prompt is designed as "Please provide multiple viewpoints and analyses on [specific content of the target question] about [theme category]".

[0052] If the target question is "How to evaluate the artistic value of 'Dream of the Red Chamber'", and the theme category is "Literary Appreciation", then the prompt is "Please provide multiple viewpoints and analyses on how to evaluate the artistic value of 'Dream of the Red Chamber' about literary appreciation.

[0053] Optionally, as an embodiment of the present invention, in step S4, when it is determined that there is no need to connect to the network, in the multi-round Q&A, in each new round of prompt, the previous user questions and the content of the large model's answers are concatenated in sequence in real time, and then added with the non-networked prompt corresponding to the target question of the current round to be generated in real time.

[0054] If this is a round in a multi-round conversation, it is necessary to concatenate the previous user questions and the content of the large model's answers in sequence, and then add the currently generated prompt.

[0055] Concatenation format: List the previous conversation content sentence by sentence, separated by line breaks, and finally append the current prompt.

[0056] Example: First-round user question: "What stories are mainly written in *Dream of the Red Chamber*?" Answer from the large model: "*Dream of the Red Chamber* takes the rise and fall of the four major families of Jia, Shi, Wang, and Xue as the background, and the love and marriage tragedies of Jia Baoyu, Lin Daiyu, and Xue Baochai as the main line, depicting all aspects of life in Chinese feudal society in the first half of the 18th century from multiple perspectives." Second-round user question (i.e., the current target question): "How to evaluate the artistic value of *Dream of the Red Chamber*?" Then the new prompt is: plaintext What stories are mainly written in *Dream of the Red Chamber* *Dream of the Red Chamber* takes the rise and fall of the four major families of Jia, Shi, Wang, and Xue as the background, and the love and marriage tragedies of Jia Baoyu, Lin Daiyu, and Xue Baochai as the main line, depicting all aspects of life in Chinese feudal society in the first half of the 18th century from multiple perspectives.

[0057] Please provide various views and analyses on how to evaluate the artistic value of *Dream of the Red Chamber* regarding literary appreciation.

[0058] Optionally, as an embodiment of the present invention, in step S4, the rewriting and / or expansion of the target question based on natural language processing technology includes: replacing the words in the target question with words that are similar in meaning and more in line with the search requirements based on a synonym dictionary, adding details to the target question based on the theme category and intention of the target question, and expanding the semantics of the target question based on semantic understanding technology to add background, conditions, or restrictions; Designing an Internet-connected prompt based on search results includes: Extracting key information related to the target question from the search results; According to the key information and the type of the target question, determining the structure of the Internet-connected prompt, which generally can adopt the structure of "question + background information + requirements", specifically including basic structure, contrast structure, expansion structure, and case structure; Basic structure Question introduction: Directly put forward the core question, clearly expressing the content that needs to be answered by the large model. For example, "What are the latest technologies of artificial intelligence in medical image diagnosis?".

[0059] Background information: Provide background knowledge, preconditions, or supplementary details related to the question to help the large model better understand the context and context of the question. For example, "With the continuous development of artificial intelligence technology, its application in the medical field is becoming more and more extensive, especially in medical image diagnosis."

[0060] Guiding instruction: Tell the large model how to answer the question, such as "Please introduce in detail the principles and application advantages of these technologies."

[0061] Comparative structure Raising comparative questions: Raise questions involving comparison, such as "What are the differences between artificial intelligence diagnosis and traditional medical diagnosis in terms of accuracy and efficiency?".

[0062] Introducing the backgrounds of both sides: Elaborate on the background information of both sides in the comparison. "Artificial intelligence diagnosis can quickly process a large amount of imaging data with the help of technologies such as deep learning; traditional medical diagnosis mainly relies on doctors' experience and professional knowledge to analyze images."

[0063] Requirements for comparative analysis: Require the large model to conduct comparative analysis from specific perspectives. "Please conduct a detailed comparative analysis from aspects such as misdiagnosis rate and diagnosis time, and explain their respective applicable scenarios."

[0064] Expansion structure Elaborating on the basic question: First raise a basic question, such as "What is gene editing technology?".

[0065] Expanding relevant information: Provide some expansion directions or backgrounds related to the basic question. "Gene editing technology has important applications in fields such as agriculture and medicine, and has triggered a series of ethical and legal issues."

[0066] Guiding expansion questions: Guide the large model to expand and answer based on the basic question. "Please introduce specific application cases of gene editing technology in the above fields and analyze the ethical and legal challenges it faces."

[0067] Case structure Case description: Provide a specific case. "A certain hospital adopted a new artificial intelligence medical diagnosis system and conducted imaging diagnoses on 1000 patients within three months."

[0068] Relating the case to the target question: Relate the case to the target question, such as "What technical and ethical issues may the artificial intelligence medical diagnosis system in this case encounter in actual applications?".

[0069] Analysis requirements: Require the large model to conduct in-depth analysis and answers based on the case. "Please conduct in-depth analysis of these issues in combination with the characteristics of artificial intelligence technology and the norms of the medical industry, and propose possible solutions."

[0070] Optionally, as an embodiment of the present invention, when the user inputs a question, first, the security detection module is used to identify the security risk of the question. Judgments are made regarding aspects such as national security risks, public security risks, and ethical security risks. If the user's question violates the security red line, the question is intercepted, and fixed return terms are set, such as "It is detected that your question may violate the security and privacy policies, and I cannot provide relevant answers. Please ensure that your question does not contain such information."

[0071] The questions that pass the security detection are processed further. The questions are sent to the large model to determine whether to search for answers online. The basis for the judgment is based on keyword and topic recognition. Some specific keyword phrases are set. When the question input by the user contains these words, it triggers an online search. The keywords set here include time-related phrases such as "latest", "recent", "real-time", "current", etc. When the input question is similar to "latest technology news", "real-time stock market quotes", the model will determine that it is necessary to obtain the latest information online; topic recognition classifies the question through natural language processing technology. If the question belongs to those topic areas where information is updated frequently and real-time data is required, such as news current affairs, financial markets, sports events, etc. For example, if the question is about the score of a certain ongoing sports game or the impact of the latest financial policies on the market, the model will determine that it is necessary to search online.

[0072] For questions that do not require online search, the prompt design module designs differently according to the type and intention of the question. For factual questions, the prompt is designed as "Please accurately answer the following question: [question content]"; for opinion questions, the prompt is designed as "Please provide various opinions and analyses on [question content]". At the same time, the prompt should support the form of multi-round conversations. In each new prompt, the previous user question and the content of the large model's answer are concatenated in order, and then the question or instruction of the current round is added as the new prompt input to the large model, allowing the large model to reason and generate answers based on the prompt and its own knowledge.

[0073] For questions that require online search, first, the question needs to be rewritten / expanded. The question rewriting / expansion module uses natural language processing technology to rewrite the question through methods such as synonym replacement and sentence pattern conversion to make its expression clearer and more accurate, facilitating the understanding of the search engine. For example, rewrite "What is artificial intelligence" as "What is artificial intelligence". At the same time, expand the question according to the topic and context of the question, adding relevant keywords and information to improve the comprehensiveness of the search.

[0074] The online search module conducts searches based on the rewritten / expanded questions by invoking the API of an external search engine (purchasing an API key) or using web crawler technology (subject to relevant regulations and laws). It retrieves information such as the text content, links, and summaries of the search result pages and passes this information to the data cleaning module.

[0075] The data cleaning module processes the data obtained from the online search: a) Remove duplicate search results by calculating text similarity and other methods to determine the repeatability of the results.

[0076] b) Filter out content irrelevant to the question, such as advertisements, navigation bars, and other non-body information. This can be achieved by analyzing indicators such as the topical relevance and keyword matching degree of the text.

[0077] c) Standardize the text format, unify character encoding, line break format, etc., for subsequent processing.

[0078] d) Assign a unified numerical number to the search results for subsequent large model annotation of the source.

[0079] The prompt combination module combines the cleaned web content with the new prompt to guide the large model to use this data to generate answers. Finally, the combined prompt content is input into the large model for inference and answer generation. The following is the prompt for online search: You are an AI assistant good at web search and answering users' questions.

[0080] Based on the provided context, generate a rich and relevant response to the user's question. You must utilize this context to answer the user's query in the best possible way. The response should be in an objective and news-reporting style.

[0081] Your response should be moderately long. Do not include duplicate content. You can use markdown format to arrange the response content. Use bullet point lists to enumerate information, ensuring that the answer content is substantial and informative.

[0082] You must use the [number] annotation method to indicate the source of the answer. You must annotate the sentences according to the relevant context numbers, and you must annotate each part of the answer so that users can know where the information comes from. Place these annotations at the end of the corresponding sentences. If a sentence is related to multiple documents, you can annotate it multiple times, such as [number1][number2]. The numbers refer to the search result numbers (passed in the context) used to generate the corresponding parts of the answer.

[0083] Any content within the following context code block is information returned by the search engine. You must answer questions based on this and quote relevant information from it.

[0084] <context> {Cleaned web content 1} {Cleaned web content 2} … < / context> If you think there is no relevant information in the search results, you can say, "Sorry, I couldn't find any relevant information about this question. Do you want me to search again or ask something else?"

[0085] Today's date is {date}.

[0086] The user's question is: {question}.

[0087] In some embodiments, the large model-based intelligent question-answering system may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the large model-based intelligent question-answering system can be stored in the memory of the computer device and executed by at least one processor to perform the functions of large model-based intelligent question-answering (see details in Figure 1 description).

[0088] In this embodiment, the large model-based intelligent question-answering system can be divided into multiple functional modules according to the functions it performs, as Figure 2 shown. The functional modules of the system may include: a target question detection module, an insecure question-answering module, a network connection judgment module, and a question-answering result output module. The module referred to in the present invention means a series of computer program segments that can be executed by at least one processor and can complete fixed functions, and are stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments. The system includes: The target question detection module, which obtains the target question, performs word segmentation on the target question to obtain multiple sub-word units and converts them into feature vectors; obtains the historical target question and labels the security status of the historical target question, trains a text classification model based on the feature vectors after word segmentation of the historical target question and the corresponding security status, and inputs the feature vectors after word segmentation of the current target question into the model, and the model outputs the security status and the probability value corresponding to the security status; The insecure question-answering module, which judges whether the target question passes the security detection based on the probability value corresponding to the security status in combination with the security threshold. If the target question fails to pass the security detection, it returns an interception message as the answer to the target question; Network connection judgment module: After the target question passes the security detection, keywords of the target question are extracted based on the TF-IDF algorithm, a TextCNN model is trained based on the keywords and corresponding topic categories of historical target questions, the keywords of the current target question are input into the TextCNN model, and the model outputs the current topic category corresponding to the current target question. Whether to connect to the network is judged based on the current topic category; Question and answer result output module: If it is determined that there is no need to connect to the network, a non-networked prompt is designed based on the topic category and intention of the target question, the specific content of the target question is filled into the non-networked prompt according to the specified format, and the non-networked prompt is input into the large model to obtain the question and answer result; If it is determined that it is necessary to connect to the network, the target question is rewritten and / or expanded based on natural language processing technology, an external search engine is called in real time based on the rewritten and / or expanded target question to obtain search results, a networked prompt is designed based on the search results, and the search results and the networked prompt are input into the large model to obtain the question and answer result.

[0089] The target question is tokenized and converted into a feature vector by the target question detection module, and a text classification model is trained using historical target questions and annotations to output the security status and probability value of the current target question; the insecure question and answer module judges whether to intercept the question based on the probability value and the security threshold; after the question passes the security detection, the network connection judgment module determines the topic category and judges whether to connect to the network through keyword extraction and the TextCNN model; the question and answer result output module designs a non-networked or networked prompt according to whether to connect to the network and inputs it into the large model to obtain the question and answer result, realizing the security detection of the target question, reasonably judging the network connection requirement and outputting an accurate question and answer result, effectively ensuring the security and accuracy of the question and answer, and improving the quality of the question and answer service.

[0090] Figure 3 The figure is a schematic structural diagram of a terminal provided by an embodiment of the present invention, and the terminal can be used to execute the method for intelligent question and answer based on a large model provided by an embodiment of the present invention.

[0091] Among them, the terminal may include: a processor, a memory, and a communication unit. These components communicate through one or more buses. Those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation to the present invention. It can be a bus structure, a star structure, and may also include more or fewer components than shown in the figure, or combine some components, or have different component arrangements.

[0092] Among them, the memory can be used to store the execution instructions of the processor. The memory can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disc. When the execution instructions in the memory are executed by the processor, the terminal can execute some or all of the steps in the above method embodiments.

[0093] The processor is the control center of the storage terminal, connecting various parts of the entire electronic terminal through various interfaces and lines. By running or executing the software programs and / or modules stored in the memory, and calling the data stored in the memory, it can execute various functions of the electronic terminal and / or process data. The processor can be composed of an integrated circuit (IC). For example, it can be composed of a single packaged IC, or composed of multiple packaged ICs with the same or different functions connected together. For example, the processor can only include a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single operation core or include multiple operation cores.

[0094] The communication unit is used to establish a communication channel, so that the storage terminal can communicate with other terminals. It receives user data sent by other terminals or sends user data to other terminals.

[0095] The present invention also provides a computer storage medium. Among them, the computer storage medium can store a program, and when the program is executed, it can include some or all of the steps in the embodiments provided by the present invention. The storage medium can be a magnetic disk, an optical disc, a read-only memory (ROM), a random access memory (RAM), etc.

[0096] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solutions in the embodiments of the present invention, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disc, etc., various media that can store program codes, including several instructions for causing a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0097] For the same or similar parts among the various embodiments in this specification, reference can be made to each other. In particular, for the terminal embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the descriptions in the method embodiments.

[0098] In several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there can be other division methods. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the systems or modules can be in electrical, mechanical or other forms.

[0099] The modules described as separate components may or may not be physically separated. The components shown as modules may or may not be physical modules, that is, they can be located in one place, or they can be distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0100] In addition, in each embodiment of the present invention, the various functional modules can be integrated in a processing module, or each module can exist physically alone, or two or more modules can be integrated in one module.

[0101] Although the present invention has been described in detail by referring to the accompanying drawings and in conjunction with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, those of ordinary skill in the art can make various equivalent modifications or substitutions to the embodiments of the present invention, and all such modifications or substitutions should be within the scope of the present invention. / Any person skilled in the art within the technical scope disclosed by the present invention can easily conceive of changes or substitutions, and all of them should be covered by the protection scope of the present invention.

Claims

1. An intelligent question answering method based on a large model, characterized in that: The following steps are involved: S1, obtain the target question, segment the target question, obtain multiple subword units and convert them into feature vectors; obtain historical target questions and mark the safety status of historical target questions, train a text classification model based on the feature vectors of historical target questions after segmentation and the corresponding safety status, input the feature vector of the current target question after segmentation into the model, and the model outputs the safety status and the probability value corresponding to the safety status; S2, based on the probability value corresponding to the security status and the security threshold, determines whether the target question passes the security test. If the target question fails the security test, returns the interception information as the answer to the target question; S3: After the target question passes the security test, keywords are extracted based on the TF-IDF algorithm. The TextCNN model is trained based on the keywords of the historical target questions and the corresponding topic categories. The keywords of the current target question are input into the TextCNN model. The model outputs the current topic category corresponding to the current target question. Based on the current topic category, it is determined whether networking is required. S4, if it is determined that networking is not necessary, a non-networked prompt is designed based on the subject category and intention of the target question, and the specific content of the target question is filled into the non-networked prompt according to the prescribed format, and the non-networked prompt is input into the large model to obtain the question-answering result; If it is determined that networking is needed, the target question is rewritten and / or expanded based on natural language processing technology, and an external search engine is called in real time based on the rewritten and / or expanded target question to obtain search results. A networking prompt is designed based on the search results, and the search results and networking prompt are input into the large model to obtain the question and answer results.

2. The intelligent question-answering method based on a large model according to claim 1, characterized in that: Step S1 specifically includes: The target question is segmented based on the BERT tokenizer, and the sub-word units after segmentation are converted into feature vectors based on the BERT word embedding layer; Load the pre-trained Transformer model from the pre-trained model library. The Transformer model has a fully connected layer as a classification layer. The input of the Transformer model is a feature vector, and the output is the safety status and the probability value corresponding to the safety status; Perform multiple rounds of training on the training set. In each round, divide the training data into small batches and input them into the model in turn for forward propagation and back propagation to update the model parameters. After each round, the validation set is used to evaluate the performance of the model; Use the test set to perform a final evaluation of the trained model.

3. The intelligent question-answering method based on a large model according to claim 1, characterized in that: In step S3, keyword extraction for the target question based on the TF-IDF algorithm specifically includes: Calculate the frequency of a word based on the number of times it appears in the target question; Calculate the inverse document frequency based on the probability of a word appearing in a set of similar questions to the target question; Multiply the term frequency and inverse document frequency of each word to get the TF-IDF value of the word; Sort the TF-IDF values ​​of all words in the target question, and obtain words with TF-IDF values ​​greater than the key threshold as keywords of the target question.

4. The intelligent question-answering method based on a large model according to claim 1, characterized in that: The training of the TextCNN model specifically includes: The keywords of historical target questions and the corresponding subject categories are used as data sets; Count all the keywords in the training set, build a vocabulary, assign a unique index to each keyword, and convert the keywords of each historical target question into a corresponding index sequence according to the vocabulary; The TextCNN model includes: constructing an embedding layer to convert the input keyword index sequence into a word vector representation, constructing a convolutional layer and performing convolution operations on the output of the embedding layer based on multiple convolution kernels of different sizes, constructing a pooling layer and performing pooling operations on the output of the convolutional layer, connecting the output of the pooling layer to a fully connected layer, and then to an output layer; The TextCNN model is trained for multiple rounds based on the training set. In each round, the training data is divided into small batches and input into the model in turn for forward propagation and back propagation to update the model parameters. After each round, the validation set is used to evaluate the performance of the model; Use the test set to evaluate the trained model.

5. The intelligent question-answering method based on a large model according to claim 1, characterized in that: In step S4, the intention of the target question includes factual questions and opinion questions; Factual questions require accurate answers, and the non-networked prompt is designed as "Please accurately answer the following questions about [topic category]: [specific content of the target question]"; Opinion questions require multiple viewpoints and analyses. The non-online prompt is designed as "Please provide multiple viewpoints and analyses on [specific content of the target question] on [topic category]." 6. The intelligent question answering method based on a large model according to claim 1, characterized in that: In step S4, when it is determined that networking is not required, in multiple rounds of questions and answers, each new prompt in real time stitches together the previous user questions and the content of the large model's answers in order, and then generates a non-networked prompt corresponding to the target question of the current round in real time.

7. The intelligent question answering method based on a large model according to claim 1, characterized in that: In step S4, rewriting and / or expanding the target question based on natural language processing technology includes: replacing words in the target question with words with similar meanings and more in line with search requirements based on a synonym dictionary, adding details to the target question based on the subject category and intent of the target question, and expanding the semantics of the target question based on semantic understanding technology to add background, conditions or restrictions; Designing online prompts based on search results includes: Extract key information related to the target question from the search results; Determine the structure of the online prompt based on the type of key information and target questions, including basic structure, comparative structure, expanded structure and case structure.

8. An intelligent question-answering system based on a large model, characterized in that: When the system is implemented, the intelligent question-answering method based on a large model as described in any one of claims 1 to 7 is executed, and the system includes: The target problem detection module obtains the target problem, performs word segmentation on the target problem, obtains multiple subword units and converts them into feature vectors; obtains historical target problems and marks the safety status of historical target problems, trains a text classification model based on the feature vectors of historical target problems after word segmentation and the corresponding safety status, inputs the feature vector of the current target problem after word segmentation into the model, and the model outputs the safety status and the probability value corresponding to the safety status; The unsafe question-answering module determines whether the target question has passed the security test based on the probability value corresponding to the security status and the security threshold. If the target question fails the security test, the interception information is returned as the answer to the target question. Networking judgment module: After the target question passes the security test, the target question is keyword extracted based on the TF-IDF algorithm. The TextCNN model is trained based on the keywords of the historical target questions and the corresponding topic categories. The keywords of the current target question are input into the TextCNN model. The model outputs the current topic category corresponding to the current target question and determines whether networking is required based on the current topic category. The question-answering result output module, if it is determined that networking is not required, designs a non-networked prompt based on the subject category and intent of the target question, fills the specific content of the target question into the non-networked prompt according to the prescribed format, and inputs the non-networked prompt into the large model to obtain the question-answering result; If it is determined that networking is needed, the target question is rewritten and / or expanded based on natural language processing technology, and an external search engine is called in real time based on the rewritten and / or expanded target question to obtain search results. A networking prompt is designed based on the search results, and the search results and networking prompt are input into the large model to obtain the question and answer results.

9. A terminal, characterized in that: include: A memory for storing an intelligent question-answering program based on a large model; A processor, used to implement the steps of the large model-based intelligent question-answering method as described in any one of claims 1 to 7 when executing the large model-based intelligent question-answering program.

10. A computer-readable storage medium, characterized in that: The readable storage medium stores a large-model-based intelligent question-answering program, which, when executed by a processor, implements the steps of the large-model-based intelligent question-answering method as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Intelligent question and answer method and system, electronic equipment and storage medium

    CN121434348A