Question classification-based knowledge question-answering method and system, electronic equipment and medium
By dividing the historical knowledge base file into multiple sub-files according to roles and matching the target knowledge base sub-file according to the user's role, the problems of poor flexibility and waste of computing resources in knowledge question answering of large natural language models are solved, and more efficient knowledge question answering is achieved.
Patent Information
- Application Number
- CN202510964205.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-11-21
AI Technical Summary
Existing large-scale natural language models lack flexibility and accuracy in knowledge-based question answering, and consume excessive computational resources.
By dividing the historical knowledge base file into multiple knowledge base sub-files according to roles, matching the target knowledge base sub-file according to the user's role, and retrieving the target historical question with the highest similarity, the relevant target information is obtained to obtain the answer.
It improves the flexibility and accuracy of knowledge-based question answering, saves computing resources, and reduces reliance on computing power.
Smart Images

Figure CN120994815A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of knowledge question answering, in particular to a knowledge question answering method and system based on question classification, an electronic device and a medium. BACKGROUND
[0002] When constructing an intelligent agent application in a complex scenario, the intelligent agent application needs to receive a user question and convert the user question into a specific interface or SQL statement to obtain relevant data and then feed back to the user.
[0003] The current commonly used solution is to pass the user question to a natural language large model (such as DeepSeek / ChatGPT, etc.), understand the user question by configuring a complex prompt, and then convert it into a corresponding interface or SQL statement to obtain data. However, whenever a new function needs to be added, the natural language large model needs to be adjusted and adapted to the prompt, so the flexibility is poor. Moreover, when there are multiple questions with similar semantics, the large model often cannot accurately distinguish them, and the recognition accuracy is not high. In addition, the natural language large model relies heavily on computing power, and when the computing power is not enough, the large model output is very slow. The natural language large model also needs to use a large number of prompts to ensure recognition accuracy, which consumes a lot of computing power.
[0004] Therefore, based on the natural language large model for knowledge question answering, the flexibility is poor, the question recognition is not accurate, and a lot of computing resources are wasted. SUMMARY
[0005] The present application aims to provide a knowledge question answering method and system based on question classification, which can improve the flexibility and accuracy of knowledge question answering and save computing resources.
[0006] In a first aspect, an embodiment of the present application provides a knowledge question answering method based on question classification, which comprises:
[0007] obtaining a user input question to be answered and a user role;
[0008] constructing a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions, and dividing the historical knowledge base file into a plurality of knowledge base sub-files according to the role, wherein the target information includes an interface address for obtaining an answer;
[0009] selecting a target knowledge base sub-file matched with the user role, and retrieving a target historical question with the highest similarity to the question to be answered in the target knowledge base sub-file;
[0010] According to the target historical question, the target information associated with the target historical question is obtained from the target knowledge base sub-file.
[0011] obtaining the answer matching the question to be answered according to the interface address in the target information associated with the target historical question.
[0012] Compared with the prior art, the first aspect of the application has the following beneficial effects:
[0013] The method obtains the question to be answered and the user role input by the user, constructs a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions, divides the historical knowledge base file into a plurality of knowledge base sub-files according to the role, and the target information contains an interface address for obtaining an answer, selects a target knowledge base sub-file matching the user role, and retrieves a target historical question with the greatest similarity to the question to be answered in the target knowledge base sub-file, obtains target information associated with the target historical question from the target knowledge base sub-file according to the target historical question, and obtains an answer matching the question to be answered according to the interface address in the target information associated with the target historical question. In this way, by dividing the plurality of historical questions and the target information associated with the historical questions into a plurality of knowledge base sub-files according to the role, the target knowledge base sub-file is matched according to the user role in the later stage, and then the target historical question is matched, and finally the answer matching the question to be answered is obtained, without the need to adjust the prompt word, only the historical knowledge base file needs to be updated and maintained, and without the need to search for a historical knowledge base file, only the matching target knowledge base sub-file needs to be found, the flexibility and accuracy of knowledge Q&A are improved, and the computing resources are saved.
[0014] In some embodiments, the dividing the historical knowledge base file into a plurality of knowledge base sub-files according to the role comprises:
[0015] constructing a role library containing all roles in the target scene;
[0016] extracting all roles in the historical knowledge base file according to the roles in the role library to obtain a plurality of different roles;
[0017] constructing a knowledge base sub-file for the historical question and the target information associated with each role in the plurality of different roles to obtain a plurality of knowledge base sub-files.
[0018] In some embodiments, the extracting all roles in the historical knowledge base file according to the roles in the role library to obtain a plurality of different roles comprises:
[0019] vectorizing the roles in the role library into role vectors;
[0020] performing word segmentation processing on the historical knowledge base file to obtain a plurality of first segmented words;
[0021] vectorize each first segmented word to obtain a plurality of word vectors;
[0022] calculate the similarity between the word vectors and the role vectors;
[0023] take the word vectors with a similarity greater than a preset value as roles until all word vectors are compared, to extract all roles in the historical knowledge base file, and obtain a plurality of different roles.
[0024] In some embodiments, the historical knowledge base file is segmented to obtain a plurality of first segmented words, including:
[0025] calculate the correlation between characters:
[0026]
[0027]
[0028] wherein P represents the correlation between characters, P(xy) represents the probability of characters x and y appearing simultaneously, P(x) represents the probability of character x appearing, P(y) represents the probability of character y appearing, z represents a string, H r (z) represents the right adjacency entropy of string z, H l (z) represents the left adjacency entropy of string z, ∈ represents a constant parameter, P(a) represents the probability of character a appearing in the left or right adjacency of string z, and m represents the number of characters in the total string formed by string z and character a.
[0029] segment the historical knowledge base file according to the correlation to obtain a plurality of first segmented words.
[0030] In some embodiments, the target historical question with the greatest similarity to the question to be answered is retrieved from the target knowledge base sub-file, including:
[0031] extract keywords in the question to be answered to obtain a plurality of keywords;
[0032] combine the plurality of keywords and vectorize the combined keywords to obtain a keyword vector;
[0033] vectorize each historical question in the target knowledge base sub-file to obtain a plurality of historical question vectors;
[0034] calculate the similarity between the keyword vector and each historical question vector to obtain a plurality of similarity results;
[0035] sort the plurality of similarity results, and determine the target historical question with the greatest similarity to the question to be answered according to the sorting result.
[0036] In some embodiments, the extracting the keywords in the question to be answered, obtaining a plurality of keywords, comprises:
[0037] performing word segmentation on the question to be answered, obtaining a plurality of second segmented words;
[0038] calculating the importance of each second segmented word;
[0039] extracting the keywords in the question to be answered according to the importance, obtaining a plurality of keywords.
[0040] In some embodiments, the calculating the importance of each second segmented word, comprises:
[0041]
[0042] wherein, W represents the importance, P(xy) represents the probability of the simultaneous occurrence of character x and character y, P(x) represents the probability of the occurrence of character x, P(y) represents the probability of the occurrence of character y, and a represents the attention weight.
[0043] In a second aspect, the embodiments of the present application further provide a knowledge question answering system based on question classification, comprising:
[0044] a data acquisition unit configured to acquire a question to be answered input by a user and a user role;
[0045] a file division unit configured to construct a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions, and divide the historical knowledge base file into a plurality of knowledge base sub-files according to roles, wherein the target information comprises an interface address for obtaining an answer;
[0046] a data retrieval unit configured to select a target knowledge base sub-file matched with the user role, and retrieve a target historical question with the greatest similarity to the question to be answered in the target knowledge base sub-file;
[0047] an information acquisition unit configured to acquire target information associated with the target historical question from the target knowledge base sub-file according to the target historical question;
[0048] an answer acquisition unit configured to obtain an answer matched with the question to be answered according to the interface address in the target information associated with the target historical question.
[0049] In a third aspect, the embodiments of the present application further provide an electronic device, comprising at least one control processor and a memory connected with the at least one control processor for communication; the memory stores instructions executable by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to perform the knowledge question and answer method based on question classification as described above.
[0050] In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores computer executable instructions for enabling a computer to perform the knowledge question and answer method based on question classification as described above.
[0051] It can be understood that the beneficial effects of the above-mentioned second aspect to fourth aspect compared with the related art are the same as the beneficial effects of the above-mentioned first aspect compared with the related art, which can be referred to the related description in the first aspect and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0052] The above and / or additional aspects and advantages of the present application will become apparent and be readily appreciated from the following description, including the appended drawings, wherein:
[0053] Figure 1 is a flowchart of an embodiment of the knowledge question and answer method based on question classification provided by the present application;
[0054] Figure 2 is a format diagram of splitting a historical knowledge base file into a knowledge base sub-file in the best embodiment of the knowledge question and answer method based on question classification provided by the present application;
[0055] Figure 3 is a question retrieval diagram in the best embodiment of the knowledge question and answer method based on question classification provided by the present application;
[0056] Figure 4 is a structure diagram of an embodiment of the knowledge question and answer system based on question classification provided by the present application;
[0057] Figure 5 is a structure diagram of an embodiment of the electronic device provided by the present application. DETAILED DESCRIPTION
[0058] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the drawings, wherein the same or similar notations represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and are only used to explain the present application, and cannot be understood as a limitation of the present application.
[0059] In the description of the present application, if the first, second, etc. are described, it is only for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features or the sequence of indicated technical features.
[0060] In the description of the present application, it should be understood that the orientation description, such as the orientation or position relationship indicated by up, down, etc. is based on the orientation or position relationship shown in the drawings, only for the purpose of facilitating the description of the present application and simplifying the description, and is not intended to indicate or imply that the device or element indicated must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation of the present application.
[0061] In the description of the present application, it should be noted that, unless otherwise explicitly limited, the words such as setting, installing, connecting, etc. should be broadly understood, and those skilled in the art can reasonably determine the specific meaning of the above words in the present application in combination with the specific content of the technical solution.
[0062] The current commonly used solution is to pass the user question to a natural language large model (such as DeepSeek / ChatGPT, etc.), understand the user question by configuring complex prompts, and then convert it into a corresponding interface or SQL statement to obtain data. However, each time a new function needs to be added, the natural language large model needs to be adjusted and adapted to the prompt (Prompt), so the flexibility is relatively poor, and when there are multiple similar semantic questions, the large model often cannot accurately distinguish them, the recognition accuracy is not high, and the natural language large model is heavily dependent on computing power. When the computing power is not enough, the large model output is very slow, and the natural language large model also needs to use a large number of prompts to ensure the recognition accuracy, which consumes a lot of computing power.
[0063] In order to solve the problems of poor flexibility and inaccurate question recognition in the prior art, and waste a lot of computing resources, the present application provides a knowledge question answering method, system, electronic device and medium based on question classification.
[0064] Reference Figure 1 The present application provides a flowchart of a knowledge question answering method based on question classification. The knowledge question answering method based on question classification is applied to an electronic device, which can be a server or a mobile terminal, etc. As shown in Figure 1 The knowledge question answering method based on question classification can include the following steps:
[0065] Step S101, obtaining a user input question to be answered and a user role;
[0066] In step S102, a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions is constructed, and the historical knowledge base file is divided into a plurality of knowledge base sub-files according to roles, and the target information contains an interface address used to obtain an answer.
[0067] In step S103, a target knowledge base sub-file matched with the user role is selected, and a target historical question with the greatest similarity to the question to be answered is searched in the target knowledge base sub-file.
[0068] In step S104, target information associated with the target historical question is obtained from the target knowledge base sub-file according to the target historical question.
[0069] In step S105, an answer matched with the question to be answered is obtained according to the interface address in the target information associated with the target historical question.
[0070] In the embodiment, the question to be answered input by the user and the user role are obtained, a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions is constructed, and the historical knowledge base file is divided into a plurality of knowledge base sub-files according to roles, and the target information contains an interface address used to obtain an answer. A target knowledge base sub-file matched with the user role is selected, and a target historical question with the greatest similarity to the question to be answered is searched in the target knowledge base sub-file. Target information associated with the target historical question is obtained from the target knowledge base sub-file according to the target historical question. An answer matched with the question to be answered is obtained according to the interface address in the target information associated with the target historical question. In this way, the plurality of historical questions and the target information associated with the historical questions are divided into a plurality of knowledge base sub-files according to roles, the target knowledge base sub-file is matched according to the user role in the later stage, the target historical question is matched, and finally the answer matched with the question to be answered is obtained. No prompt word needs to be adjusted, and only the historical knowledge base file needs to be updated and maintained. No historical knowledge base file needs to be searched, and only the matched target knowledge base sub-file needs to be found. The flexibility and accuracy of the knowledge question and answer are improved, and the computing resources are saved.
[0071] In some embodiments, dividing the historical knowledge base file into a plurality of knowledge base sub-files according to roles includes:
[0072] A role library containing all roles in a target scene is constructed.
[0073] All roles in the historical knowledge base file are extracted according to the roles in the role library, and a plurality of different roles are obtained.
[0074] The historical questions and target information associated with each role in the plurality of different roles are constructed into a knowledge base sub-file, and a plurality of knowledge base sub-files are obtained.
[0075] In the embodiment, the historical question and target information associated with each role in the plurality of different roles are constructed into a knowledge base sub-file, a plurality of knowledge base sub-files are obtained, the knowledge question and answer in the later stage can be facilitated, and only the matching target knowledge base sub-file can be found according to the user input role, the flexibility and accuracy of the knowledge question and answer are improved, and the computing resources are saved.
[0076] In some embodiments, all roles in the historical knowledge base file are extracted according to the roles in the role library, and a plurality of different roles are obtained, including:
[0077] The roles in the role library are vectorized into role vectors;
[0078] The historical knowledge base file is subjected to word segmentation processing, and a plurality of first segmented words are obtained;
[0079] Each first segmented word is vectorized to obtain a plurality of word vectors;
[0080] The similarity between the word vectors and the role vectors is calculated;
[0081] The word vectors with a similarity greater than a preset value are taken as roles until all the word vectors are compared, so as to extract all the roles in the historical knowledge base file, and a plurality of different roles are obtained.
[0082] In the embodiment, the word vectors with a similarity greater than a preset value are taken as roles until all the word vectors are compared, so as to extract all the roles in the historical knowledge base file, and a plurality of different roles are obtained, the all roles in the historical knowledge base file can be automatically extracted, the accuracy of the extracted roles is high, and a good data foundation is laid for the division of the historical knowledge base file into a plurality of knowledge base sub-files according to the roles in the later stage.
[0083] The above preset value can be changed according to actual conditions, and the embodiment is not limited specifically.
[0084] In some embodiments, the historical knowledge base file is subjected to word segmentation processing, and a plurality of first segmented words are obtained, including:
[0085] The correlation between characters and characters is calculated:
[0086]
[0087] wherein P represents the correlation between characters and characters, P(xy) represents the probability of the simultaneous appearance of characters x and y, P(x) represents the probability of the appearance of character x, P(y) represents the probability of the appearance of character y, z represents a string, H r (z) represents the right adjacent entropy of the string z, and H l(z) represents the left-adjacent entropy of a string z, represents a constant parameter, P(a) represents the probability of occurrence of a character a that is left-adjacent or right-adjacent to the string z, and m represents the number of characters in a total string composed of the string z and the character a.
[0088] The historical knowledge base files are segmented according to the correlation degrees, to obtain a plurality of first segmented words.
[0089] In this embodiment, the greater the correlation degree between characters, the greater the probability of forming a word, so maximizing the correlation degree can obtain more accurate words.
[0090] In some embodiments, the target historical question with the greatest similarity to the question to be answered is searched in the target knowledge base sub-file, including:
[0091] The keywords in the question to be answered are extracted, to obtain a plurality of keywords;
[0092] The plurality of keywords are combined, and the combined keywords are vectorized, to obtain a keyword vector;
[0093] Each historical question in the target knowledge base sub-file is vectorized, to obtain a plurality of historical question vectors;
[0094] The similarity between the keyword vector and each historical question vector is calculated, to obtain a plurality of similarity results;
[0095] The plurality of similarity results are sorted, and the target historical question with the greatest similarity to the question to be answered is determined according to the sorting result.
[0096] In this embodiment, the similarity between the keyword vector and each historical question vector is calculated, to obtain a plurality of similarity results; the plurality of similarity results are sorted, and the target historical question with the greatest similarity to the question to be answered is determined according to the sorting result, so that the target historical question most similar to the question to be answered can be found, and the answer matching the question to be answered can be quickly obtained.
[0097] In some embodiments, the keywords in the question to be answered are extracted, to obtain a plurality of keywords, including:
[0098] The question to be answered is segmented, to obtain a plurality of second segmented words;
[0099] The importance of each second segmented word is calculated;
[0100] The keywords in the question to be answered are extracted according to the importance, to obtain a plurality of keywords.
[0101] In the embodiment, the keyword screening can remove the influence of irrelevant words on problem identification, thereby improving the accuracy of retrieving the target historical problem with the greatest similarity to the to-be-answered problem in the target knowledge base sub-file.
[0102] In some embodiments, the importance of each second segmented word is calculated, including:
[0103]
[0104] Wherein, W represents the importance, P(xy) represents the probability of the simultaneous occurrence of character x and character y, P(x) represents the probability of the occurrence of character x, P(y) represents the probability of the occurrence of character y, and a represents the attention weight.
[0105] In the embodiment, by calculating the importance of each second segmented word, more accurate keywords can be extracted, laying a good data foundation for later retrieval of the target historical problem with the greatest similarity to the to-be-answered problem in the target knowledge base sub-file.
[0106] To facilitate the understanding of those skilled in the art, a set of preferred embodiments is provided below:
[0107] When building an intelligent agent application in a complex scenario, the intelligent agent application needs to receive a user question and convert the user question into a specific interface or SQL statement to obtain relevant data and then feed back to the user.
[0108] The current common solution is to pass the user question to a natural language large model (such as DeepSeek / ChatGPT, etc.), understand the user question by configuring complex prompts, and then convert it into a corresponding interface or SQL statement to obtain data. However, whenever new functions need to be added, the natural language large model needs to be adjusted and adapted to the prompt (Prompt), so the flexibility is relatively poor. Moreover, when there are multiple semantically similar questions, the large model often cannot accurately distinguish them, resulting in low recognition accuracy. In addition, the natural language large model relies heavily on computing power, and when the computing power is insufficient, the large model output is very slow. The natural language large model also needs a large number of prompts to ensure recognition accuracy, which consumes a lot of computing resources.
[0109] Therefore, to solve the problems of poor flexibility, inaccuracy, and waste of a large amount of computing resources when using the existing natural language large model for knowledge question and answer, the embodiment proposes a knowledge question and answer method based on problem classification. The method of the embodiment includes the following contents:
[0110] Step 1: Collect multiple historical questions and target information (including segmented titles and segmented contents) associated with each historical question from historical knowledge base files, organize the historical knowledge base files, and import them into a knowledge base retrieval system. Refer to Figure 2The knowledge base sub-file can be split into multiple knowledge base sub-files according to different roles, one knowledge base sub-file corresponds to one role, and the sub-file content mainly includes a segmented title, segmented content (role, interface address and function name, etc.), and associated problems. The roles include students and teachers, and the interface address is associated with the answers of historical problems (that is, clicking the interface address corresponding to the historical problem can obtain the answer corresponding to the historical problem). The answers of related problems can be obtained through the interface address, the function name and the segmented title can be the same, and the function name is mainly used to represent the same purpose of multiple problems, that is, multiple similar problems correspond to one function name.
[0111] In the knowledge base retrieval system, a classification method is provided, which mainly includes the following contents:
[0112] Since the main roles (for example, students, teachers, principals and counselors, etc.) in a scene are limited, all roles are constructed as a role library.
[0113] According to the role in the role library, all roles in the historical knowledge base file are extracted, and the historical problems associated with the same role and the target information associated with the historical problems are combined into one knowledge base sub-file to obtain multiple knowledge base sub-files. The multiple knowledge base sub-files include the knowledge base sub-file of each role in the historical knowledge base file.
[0114] The role extraction method adopts a vector similarity method, each role in the role library is constructed as a role vector, the historical knowledge base file is subjected to word segmentation processing to obtain multiple segmented words (i.e. first segmented words), and each segmented word is vectorized to obtain a word vector. The similarity between the role vector A and the word vector B is calculated, and the words with a similarity greater than or equal to a preset value (for example, the preset value is set to 100%) are extracted and recorded as the roles in the historical knowledge base file. Each segmented word can be vectorized by using the TF-IDF vectorization method, the Word2Vec method and the FastText method, etc. The prior art known to those skilled in the art, which is not specifically limited and described in this embodiment. The word segmentation processing adopts the following method:
[0115] The correlation between characters and characters is calculated:
[0116]
[0117] wherein P represents the correlation between characters and characters, P(xy) represents the probability that character x and character y appear at the same time, P(x) represents the probability that character x appears, P(y) represents the probability that character y appears, z represents a string, which can include character x and character y, H r (z) represents the right adjacent entropy of string z, H l(z) represents the left-adjacent entropy of the string z, represents a constant parameter, which is a small positive number, P(a) represents the probability of the occurrence of the character a left-adjacent or right-adjacent to the string z, and m represents the number of characters in the total string composed of the string z and the character a.
[0118] According to the calculated correlation degree P, the historical knowledge base file is processed for word segmentation, and a plurality of segmented words are obtained.
[0119] The greater the correlation degree between characters, the greater the probability of forming a word. Therefore, maximizing the correlation degree p can obtain more accurate words. The historical knowledge base file is processed for word segmentation in the above manner, and the word segmentation accuracy can be improved.
[0120] The similarity calculation formula is:
[0121]
[0122] Wherein, S represents the similarity between the role vector and the word vector, A represents the role vector, and B represents the word vector.
[0123] Second step: configuring an input node to obtain a user input question to be answered and a user role.
[0124] Third step: configuring a knowledge base node, selecting a knowledge base sub-file (i.e., a target knowledge base sub-file) matching the user role from a plurality of knowledge base sub-files according to the user role, and then performing historical question retrieval in the knowledge base sub-file matching the user role according to the user input question to be answered, to obtain a plurality of retrieval results (i.e., a plurality of historical questions similar to the question to be answered). And output the record with the highest matching degree in the retrieval result through the configuration of the knowledge base node.
[0125] Specifically, the keywords in the user input question to be answered are extracted to obtain a plurality of keywords. The user input question to be answered can be segmented, and the importance of each segmented word (i.e., the second segmented word) is calculated, and a plurality of keywords with relatively high importance are selected. The calculation method is as follows:
[0126]
[0127] Wherein, P(xy) represents the probability of the simultaneous occurrence of characters x and y, P(x) represents the probability of the occurrence of character x, P(y) represents the probability of the occurrence of character y, and a represents the attention weight, which is calculated by the attention mechanism in BERT (Bidirectional Encoder Representations from Transformers) to calculate the attention weight of each word in the sentence.
[0128] The plurality of keywords are combined and the combined keywords are vectorized to obtain keyword vectors.
[0129] The historical questions in the knowledge base sub-file matched with the user role are vectorized to obtain historical question vectors.
[0130] The cosine similarity is used to calculate the similarity between the keyword vectors and the historical question vectors to obtain a plurality of similarity results (i.e., retrieval results).
[0131] The plurality of similarity results are sorted, and the record with the highest similarity (i.e., the highest matching degree) in the retrieval results is output by configuring the knowledge base node.
[0132] Step 4: Determine whether the knowledge base node has a retrieval result output. If no relevant function is retrieved, directly output the user question that cannot be understood. If the knowledge base node has a retrieval result output, perform the fifth step logic.
[0133] Step 5: Configure a data acquisition node. Only one data acquisition node needs to be configured. According to the output retrieval result of the knowledge base node, the interface address corresponding to the retrieval result is acquired, and then the interface is called to acquire the answer data matched with the user input question and output. Refer to Figure 3 .
[0134] Step 6: If the user input question is different from the historical question in the historical knowledge base file, the answered user input question is taken as the historical question, and the historical knowledge base file is updated.
[0135] Refer to Figure 4 , the embodiment of the application also provides a knowledge question and answer system based on question classification, which comprises a data acquisition unit 401, a file division unit 402, a data retrieval unit 403, an information acquisition unit 404 and an answer acquisition unit 405, wherein:
[0136] The data acquisition unit 401 is used for acquiring a user input question and a user role.
[0137] The file division unit 402 is used for constructing a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions, and dividing the historical knowledge base file into a plurality of knowledge base sub-files according to the role. The target information comprises an interface address used for acquiring an answer.
[0138] The data retrieval unit 403 is used for selecting a target knowledge base sub-file matched with the user role, and retrieving a target historical question with the maximum similarity to the question to be answered in the target knowledge base sub-file.
[0139] The information acquisition unit 404 is configured to acquire target information associated with the target historical question from the target knowledge base sub-file according to the target historical question.
[0140] The answer acquisition unit 405 is configured to obtain an answer matched with the question to be answered according to an interface address in the target information associated with the target historical question.
[0141] It should be noted that, since the problem classification-based knowledge question answering system in the embodiment and the problem classification-based knowledge question answering method described above are based on the same inventive concept, the corresponding contents in the method embodiment are also applicable to the system embodiment, and thus will not be described in detail herein.
[0142] With reference to Figure 5 The embodiment of the present application further provides an electronic device, and the electronic device comprises:
[0143] at least one memory;
[0144] at least one processor;
[0145] at least one program;
[0146] The program is stored in the memory, and the processor executes the at least one program to implement the problem classification-based knowledge question answering method provided in the embodiment of the present disclosure.
[0147] The electronic device can be any intelligent terminal, such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a vehicle-mounted computer, etc.
[0148] The electronic device of the embodiment of the present application will be described in detail below.
[0149] The processor 1600 can be implemented in a general central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is configured to execute a related program to implement the technical solutions provided in the embodiment of the present disclosure.
[0150] The memory 1700 can be implemented in the form of a Read Only Memory (ROM), a static storage device, a dynamic storage device, or a Random Access Memory (RAM), etc. The memory 1700 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present disclosure are implemented by software or firmware, the related program codes are stored in the memory 1700 and are invoked and executed by the processor 1600 to implement the problem classification-based knowledge question answering method of the embodiments of the present disclosure.
[0151] The input / output interface 1800 is configured to realize information input and output.
[0152] The communication interface 1900 is configured to realize the communication interaction between the device and other devices. The communication can be realized by a wired manner (for example, a USB, a network cable, etc.) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, etc.).
[0153] The bus 2000 is configured to transmit information between various components (for example, the processor 1600, the memory 1700, the input / output interface 1800, and the communication interface 1900) of the device.
[0154] The processor 1600, the memory 1700, the input / output interface 1800, and the communication interface 1900 are connected to each other through the bus 2000 to realize the communication connection between them in the device.
[0155] The embodiments of the present disclosure further provide a storage medium, which is a computer readable storage medium and stores computer executable instructions for causing a computer to execute the problem classification-based knowledge question answering method.
[0156] The memory is a non-transitory computer readable storage medium and can be used to store non-transitory software programs and non-transitory computer executable programs. In addition, the memory can include a high-speed random access memory and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and these remote memories can be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0157] The embodiments described in the present disclosure are to more clearly illustrate the technical solutions of the present disclosure, and do not constitute a limitation on the technical solutions provided by the present disclosure. Those skilled in the art can know that, as technology evolves and new application scenarios appear, the technical solutions provided by the present disclosure are also applicable to similar technical problems.
[0158] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the present disclosure, and can include more or fewer steps than shown in the figures, or combine certain steps, or different steps.
[0159] The device embodiments described above are merely illustrative, and units described as separate components can or can not be physically separated, that is, can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment.
[0160] Those skilled in the art can understand that all or some steps in the above disclosed method, the functions of the modules / units in the system and the device can be implemented as software, firmware, hardware and their appropriate combinations.
[0161] The terms "first", "second", "third", "fourth" and the like (if any) in the specification of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0162] It should be understood that, in the application, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" is used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, "A and / or B" can represent three cases of only A, only B and A and B existing at the same time, wherein A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can represent a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b and c can be single or multiple.
[0163] In several embodiments provided in the application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed mutual units can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0164] The units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the embodiment scheme.
[0165] In addition, the functional units in each embodiment of the application can be integrated into a processing unit, or each unit can be physically present, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0166] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or say the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes multiple instructions for causing an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various program storage media. The above embodiments of the present application are described in detail in combination with the drawings, but the present application is not limited to the above embodiments, and various changes can be made within the knowledge range of ordinary skilled persons in the art without departing from the purpose of the present application.
[0167] The above embodiments of the present application are described in detail in combination with the drawings, but the present application is not limited to the above embodiments, and various changes can be made within the knowledge range of ordinary skilled persons in the art without departing from the purpose of the present application.
Claims
1. A knowledge question and answer method based on question classification, characterized by, The method comprises: acquiring a user-inputted question to be answered and a user role; constructing a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions, and dividing the historical knowledge base file into a plurality of knowledge base sub-files according to the roles, wherein the target information contains an interface address for obtaining an answer; selecting a target knowledge base sub-file matched with the user role, and searching for a target historical question with the greatest similarity to the question to be answered in the target knowledge base sub-file; obtaining target information associated with the target historical question from the target knowledge base sub-file according to the target historical question; obtaining an answer matched with the question to be answered according to the interface address in the target information associated with the target historical question. 2.The question classification based knowledge question answering method according to claim 1, characterized in that, The dividing of the historical knowledge base file into a plurality of knowledge base sub-files comprises: constructing a role library containing all roles in a target scenario; extracting all roles in the historical knowledge base file according to the roles in the role library to obtain a plurality of different roles; constructing a knowledge base sub-file for historical questions and target information associated with each role in the plurality of different roles to obtain a plurality of knowledge base sub-files. 3.The question classification based knowledge question answering method according to claim 2, characterized in that, The extracting of all roles in the historical knowledge base file according to the roles in the role library to obtain a plurality of different roles comprises: vectorizing the roles in the role library into role vectors; performing word segmentation on the historical knowledge base file to obtain a plurality of first segmented words; vectorizing each first segmented word to obtain a plurality of word vectors; calculating the similarity between the word vectors and the role vectors; taking a word vector with a similarity greater than a preset value as a role until all word vectors are compared, so as to extract all roles in the historical knowledge base file to obtain a plurality of different roles. 4.The question classification based knowledge question answering method according to claim 3, characterized in that, The performing of word segmentation on the historical knowledge base file to obtain a plurality of first segmented words comprises: calculating the correlation between characters; where P represents the degree of association between characters, P(xy) represents the probability of the simultaneous occurrence of character x and character y, P(x) represents the probability of the occurrence of character x, P(y) represents the probability of the occurrence of character y, z represents a string, H r (z) represents the right adjacent entropy of string z, H l (z) represents the left adjacent entropy of string z, ∈ represents a constant parameter, P(a) represents the probability of the occurrence of character a which is left adjacent or right adjacent to string z, and m represents the number of characters in the total string formed by string z and character a. performing word segmentation on the historical knowledge base file according to the correlation to obtain a plurality of first segmented words. 5.The question classification based knowledge question answering method according to claim 1, characterized in that, The searching for a target historical question with the greatest similarity to the question to be answered in the target knowledge base sub-file comprises: extracting key words in the question to be answered to obtain a plurality of key words; combining the plurality of key words and vectorizing the combined key words to obtain a key word vector; vectorizing each historical question in the target knowledge base sub-file to obtain a plurality of historical question vectors; calculating the similarity between the key word vector and each historical question vector to obtain a plurality of similarity results; sorting the plurality of similarity results, and determining a target historical question with the greatest similarity to the question to be answered according to the sorting result. 6.The question classification based knowledge question answering method according to claim 5, characterized in that, The extracting of key words in the question to be answered to obtain a plurality of key words comprises: performing word segmentation on the question to be answered to obtain a plurality of second segmented words; calculating the importance of each second segmented word; extracting key words in the question to be answered according to the importance to obtain a plurality of key words. 7.The question classification based knowledge question answering method according to claim 6, characterized in that, The calculating of the importance of each second segmented word comprises: Wherein, W represents importance, P(xy) represents probability of characters x and y appearing simultaneously, P(x) represents probability of character x appearing, P(y) represents probability of character y appearing, and a represents attention weight.
8. A question classification-based knowledge Q&A system, characterized by, The system comprises: a data acquisition unit configured to acquire a user-inputted question to be answered and a user role; a file division unit configured to construct a historical knowledge base file containing a plurality of historical questions and target information associated with the historical questions, and divide the historical knowledge base file into a plurality of knowledge base sub-files according to roles, the target information including an interface address for obtaining an answer; a data retrieval unit configured to select a target knowledge base sub-file matched with the user role, and retrieve a target historical question most similar to the question to be answered from the target knowledge base sub-file; an information acquisition unit configured to acquire target information associated with the target historical question from the target knowledge base sub-file according to the target historical question; an answer acquisition unit configured to obtain an answer matched with the question to be answered according to the interface address in the target information associated with the target historical question.
9. An electronic device, comprising: The computer readable storage medium stores computer executable instructions for causing a computer to perform the knowledge question and answer method based on question classification according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions for causing a computer to perform the knowledge question and answer method based on question classification according to any one of claims 1 to 7.
Citation Information
Patent Citations
Intelligent dialogue method and device of digital person, electronic equipment and storage medium
CN117194625A
Multi-round question and answer intention recognition method and device based on knowledge base
CN117743556A
Question and answer model training and application method, device, equipment, medium and product
CN118820412A
Document question and answer method and system based on LLM, RAG and knowledge graph
CN119474307A