Knowledge question and answer method, device and equipment based on large model and storage medium
By slicing and vectorizing the knowledge base and user problems, the similarity of embedded vectors is calculated, and the problems of efficiency and accuracy of large-model knowledge question and answer systems are solved in dealing with complex network interactions, achieving more efficient and accurate knowledge question and answer results.
Patent Information
- Application Number
- CN202510332424.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-06-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When existing large-model knowledge Q&A systems deal with complex and changeable network interactions, it is difficult to quickly and accurately find the most relevant content to user problems.
By segmenting the initial file in the target knowledge base based on the preset slicing strategy, the target file is generated and inputted to the preset vectorized model, the first embedding vector is obtained; the target user's question is input to the big model, the target answer is obtained and the second embedding vector is generated; the similarity between the two is calculated to determine the answer to the question.
It improves the efficiency and accuracy of big model knowledge Q&A, can find the most relevant content to user questions more quickly and accurately, and provides more accurate and targeted knowledge Q&A results.
Smart Images

Figure CN120104757A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a knowledge question answering method, device, equipment and storage medium based on a large model. Background Art
[0002] With the rapid development of Internet technology, the explosive growth of network information has made users' demand for efficient and accurate knowledge acquisition increasingly urgent. As an important bridge connecting users and information, the performance of knowledge question-answering systems is directly related to the quality of user experience. However, in the current Internet environment, some knowledge question-answering systems in society are facing many challenges, especially when dealing with complex and changeable network interaction problems. Traditional methods based on keyword matching or template reasoning seem to be inadequate. Traditional question-answering systems often rely on predefined rules or keyword libraries for matching. This method is more effective when dealing with simple and clear questions, but has limitations when facing complex and changeable network interactions. At present, knowledge question-answering systems based on large models have emerged. Large models have demonstrated powerful semantic understanding and generation capabilities through massive training data and complex neural network structures. However, even large models face the problem of how to quickly and accurately find the most relevant content to user questions in massive data.
[0003] In summary, how to improve the efficiency and accuracy of large-model knowledge question answering results is a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a knowledge question answering method, device, equipment and storage medium based on a large model, which can improve the efficiency and accuracy of knowledge question answering based on a large model. The specific scheme is as follows:
[0005] In a first aspect, the present application provides a knowledge question answering method based on a large model, comprising:
[0006] Based on a preset segmentation strategy, an initial file in the target knowledge base is segmented to obtain a target file, and the target file is input into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question;
[0007] Inputting the target user question into the target large model to obtain a target answer corresponding to the target user question, and determining a second embedding vector corresponding to the target answer based on the preset vectorization model;
[0008] A target similarity between each of the first embedding vectors and the second embedding vector is determined, so as to determine a question answer corresponding to the target user question based on the target similarity, the first embedding vector, and the target file in the target knowledge base.
[0009] Optionally, the step of segmenting the initial file in the target knowledge base based on a preset segmentation strategy to obtain the target file includes:
[0010] Determine a delimiter in the initial file, and segment the initial file in the target knowledge base based on the delimiter and a preset paragraph segmentation strategy to obtain the target file;
[0011] Or, determine a target word count based on the target knowledge question-answering task, and determine a preset sliding window step size based on the target word count, so as to segment the initial file in the target knowledge base based on the step size, preset sliding window strategy and preset word count segmentation strategy to obtain the target file.
[0012] Optionally, inputting the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file includes:
[0013] Input the target file into the preset vectorization model to obtain a target word segmentation corresponding to the target file, and determine an initial word embedding vector and a target position encoding vector corresponding to the target word segmentation;
[0014] The initial word embedding vector and the target position encoding vector are fused to obtain a fused vector, and the first embedding vector corresponding to the target file is determined based on the fused vector, a preset multi-head attention mechanism, a preset layer normalization method, and a neural network layer in the preset vectorization model.
[0015] Optionally, after inputting the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file, the method further includes:
[0016] Building a target storage table in the target knowledge base based on the first embedding vector and the target file, and generating a target vector serialization file corresponding to the first embedding vector based on a preset binary format condition;
[0017] Determine the target index corresponding to each first embedded vector in the target vector serialization file, and store the target vector serialization file and the target index in a target vector database.
[0018] Optionally, before inputting the target user question into the target macro model, the process further includes:
[0019] Acquire an initial user question through a preset user input interface, and filter target punctuation marks and target stop words in the initial user question based on a preset stop word rule library to obtain a user question to be processed;
[0020] The user question to be processed is processed based on a preset normalization processing method, a preset stem extraction technology, a preset word form restoration technology and a preset error checking mechanism to obtain the target user question.
[0021] Optionally, determining a target similarity between each of the first embedding vectors and the second embedding vector so as to determine an answer to the target user's question based on the target similarity, the first embedding vector, and the target file in the target knowledge base includes:
[0022] Determine the cosine similarity between each of the first embedding vectors and the second embedding vector in the target vector database based on the target index, and sort the cosine similarities based on a preset order condition;
[0023] According to a preset similarity threshold and a preset answer quantity condition, a target cosine similarity is determined from the sorted cosine similarities, and a target first embedding vector corresponding to the target cosine similarity is determined, so as to determine a target file corresponding to the target first embedding vector based on the target storage table, obtain the question answer corresponding to the target user question, and highlight the target file corresponding to the target first embedding vector.
[0024] Optionally, after determining the answer to the target user's question based on the target similarity, the first embedding vector and the target file in the target knowledge base, the method further includes:
[0025] The target user question, the target answer corresponding to the target user question, and the question answer corresponding to the target user question are converted into target structured data based on a preset data format, and the target structured data is stored in a preset database so that the question answer corresponding to the target user question can be directly queried based on the preset database.
[0026] In a second aspect, the present application provides a knowledge question-answering device based on a large model, comprising:
[0027] A first embedding vector determination module is used to segment an initial file in a target knowledge base based on a preset segmentation strategy to obtain a target file, and input the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question;
[0028] A second embedding vector determination module is used to input the target user question into the target large model to obtain a target answer corresponding to the target user question, and determine a second embedding vector corresponding to the target answer based on the preset vectorization model;
[0029] The question answer determination module is used to determine the target similarity between each of the first embedding vectors and the second embedding vector, so as to determine the question answer corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base.
[0030] In a third aspect, the present application provides an electronic device, including:
[0031] Memory, used to store computer programs;
[0032] A processor is used to execute the computer program to implement the aforementioned knowledge question answering method based on a large model.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned large-model-based knowledge question-answering method is implemented.
[0034] In the present application, firstly, the initial file in the target knowledge base is segmented based on the preset segmentation strategy to obtain the target file, and the target file is input into the preset vectorization model to obtain the first embedding vector corresponding to the target file; wherein the initial file is a file determined based on the user question; then the target user question is input into the target large model to obtain the target answer corresponding to the target user question, and the second embedding vector corresponding to the target answer is determined based on the preset vectorization model; finally, the target similarity between each of the first embedding vectors and the second embedding vector is determined, so as to determine the answer to the question corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base. As can be seen from the above, in the present application, the first embedding vector of the target file in the target knowledge base is calculated using the preset vectorization model, and then the second embedding vector corresponding to the target user question is calculated using the preset vectorization model, and then the target similarity between the first embedding vector corresponding to the target file and the second embedding vector corresponding to the target user question is calculated, and the answer to the question corresponding to the target user question is determined from the target file in the target knowledge base based on the target similarity. In this way, the application can provide more accurate and targeted knowledge question and answer results by matching the target user with the content of the target file in the knowledge base and returning the target file with the highest similarity as the answer to the user's question. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0036] Figure 1 A flow chart of a knowledge question answering method based on a large model provided for this application;
[0037] Figure 2 A specific knowledge base file upload flow chart provided for this application;
[0038] Figure 3 A specific flow chart of a knowledge question answering method based on a large model provided for this application;
[0039] Figure 4 A specific flow chart of a knowledge question answering method based on a large model provided for this application;
[0040] Figure 5 A schematic diagram of the structure of a knowledge question-answering device based on a large model provided in this application;
[0041] Figure 6 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] With the rapid development of Internet technology, the explosive growth of network information has made users' demand for efficient and accurate knowledge acquisition increasingly urgent. As an important bridge connecting users and information, the performance of the knowledge question-answering system is directly related to the quality of user experience. However, in the current Internet environment, some knowledge question-answering systems in society are facing many challenges, especially when dealing with complex and changeable network interaction problems, traditional methods based on keyword matching or template reasoning seem to be inadequate. Traditional question-answering systems often rely on predefined rules or keyword libraries for matching. This method is more effective when dealing with simple and clear problems, but has limitations when facing complex and changeable network interactions. At present, knowledge question-answering systems based on large models have emerged. Large models have demonstrated powerful semantic understanding and generation capabilities through massive training data and complex neural network structures. However, even large models are faced with the problem of how to quickly and accurately find the most relevant content to user questions in massive data. To this end, the present application provides a knowledge question-answering solution based on a large model, which can improve the efficiency and accuracy of large model knowledge question-answering.
[0044] See also Figure 1 As shown, the embodiment of the present invention discloses a knowledge question answering method based on a large model, which may include:
[0045] Step S11, based on a preset segmentation strategy, an initial file in the target knowledge base is segmented to obtain a target file, and the target file is input into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question.
[0046] See also Figure 2As shown, in this embodiment, a knowledge base can be created first, and then the relevant files containing the answers to the user's questions are determined according to the field to which the user's questions belong, and the files are uploaded to the knowledge base. In order to meet the storage requirements of the knowledge base, MinIO (MinIO Object Storage) is selected in this embodiment to store files. MinIO provides an efficient object storage service suitable for the storage and maintenance of large-scale document data. In order to process the files of the knowledge base, the above-mentioned initial file in the target knowledge base is segmented based on the preset segmentation strategy to obtain the target file, which may include: determining the delimiter in the initial file, and segmenting the initial file in the target knowledge base based on the delimiter and the preset paragraph segmentation strategy to obtain the target file; or, determining the target number of words based on the target knowledge question and answer task, and determining the step size of the preset sliding window based on the target number of words, so as to segment the initial file in the target knowledge base based on the step size, the preset sliding window strategy and the preset word number segmentation strategy to obtain the target file. Specifically, the file content in the knowledge base can be dynamically segmented according to the specific needs of the user. Considering the characteristics of Chinese articles, this embodiment can segment the file by paragraph or by a fixed number of words, for example, every three hundred words. In one specific implementation, first determine the separators in the initial file, such as a period, exclamation mark, semicolon, paragraph mark, etc., then traverse each initial file, and when encountering a preset separator, segment the initial file to obtain the corresponding target file. In another specific implementation, first determine the preset number of words in the target file, then set a sliding window, and the step size of the sliding window is equal to the preset number of words, and the starting position of the initialization window is the beginning of the initial file. Starting from the starting position of the sliding window, read the content of the preset number of words as the content of the current sliding window, and at the same time, check whether the content of the current sliding window is complete, such as whether it contains a complete sentence or paragraph. If the content of the sliding window is incomplete, such as being cut off in the middle of a sentence, it is necessary to make adjustments to ensure the rationality of the segmentation, determine the appropriate window content and position for segmentation, and until the sliding window traverses the initial file to obtain the corresponding target file.
[0047] It should be noted that the inputting of the target file into the preset vectorization model to obtain the first embedding vector corresponding to the target file may include: inputting the target file into the preset vectorization model to obtain the target word segmentation corresponding to the target file, and determining the initial word embedding vector and the target position encoding vector corresponding to the target word segmentation; fusing the initial word embedding vector and the target position encoding vector to obtain a fusion vector, and determining the first embedding vector corresponding to the target file based on the fusion vector, the preset multi-head attention mechanism, the preset layer normalization method and the neural network layer in the preset vectorization model. In this embodiment, the BGE model (BAAI General Embedding, i.e., the Zhiyuan General Embedding Model) can be used to generate the first embedding vector corresponding to the target file. Specifically, the target file is first divided into target word segments based on a dictionary, statistics or deep learning method, and then the target word segmentation is mapped to a low-dimensional vector representation, i.e., the initial word embedding vector, through a pre-trained word vector table. Then, the target position encoding vector corresponding to the target word segmentation is determined based on the position information of the target word segmentation in the text, and the initial word embedding vector and the target position encoding vector are added to obtain a fusion vector as the input of the BGE model encoder. In each encoder layer, multiple heads are used for parallel calculation based on the multi-head attention mechanism, and then the attention output is layer normalized, and the normalized output is input into the feedforward neural network for further feature extraction and transformation. The feedforward neural network usually consists of two fully connected layers, and activation functions such as ReLU (Rectified Linear Unit) are used in the middle to perform nonlinear transformation on the attention output. After being processed by multiple encoder layers, the first embedding vector corresponding to the target file is obtained through pooling operation. It should be pointed out that in this embodiment, the model training cycle can be executed regularly, for example, every two to three months or according to the data accumulation situation, the preset vectorization model is retrained based on the integrated latest text content data samples to enhance the recognition ability of the preset vectorization model for diversified text content.
[0048] In this embodiment, after the target file is input into the preset vectorization model to obtain the first embedding vector corresponding to the target file, it can include: constructing a target storage table in the target knowledge base based on the first embedding vector and the target file, and generating a target vector serialization file corresponding to the first embedding vector based on a preset binary format condition; determining the target index corresponding to each first embedding vector in the target vector serialization file, and storing the target vector serialization file and the target index in the target vector database. Specifically, after obtaining the first embedding vector corresponding to the target file, the target file and the corresponding first embedding vector can be stored in a spreadsheet in the target knowledge base. Generate a knowledge.pkl file corresponding to the first embedding vector, and at the same time, this embodiment can introduce a high-performance vector database management system such as ChromaDB, import the first embedding vector in the knowledge.pkl file into the ChromaDB database and construct a target index corresponding to the first embedding vector. The target index greatly accelerates the vector retrieval process, enabling the system to quickly find the vector most similar to the user's question in massive data, thereby locating the most relevant answer fragment. The ChromaDB database uses an efficient algorithm to ensure that real-time query responses can be provided even when processing large-scale data. This means that no matter how large the data set is, the ChromaDB database can quickly find the most matching results when the user initiates a query, thereby achieving fast retrieval of large-scale data sets. The optimization algorithm of the ChromaDB database not only ensures query efficiency, but also supports instant response, ensuring that the system can maintain high performance when processing large amounts of data, which can significantly enhance the user experience and provide fast and accurate search results. It should be noted that before storing vector data in the vector database, a strict data quality review mechanism can be established and implemented. Through preset standards and processes, low-quality or noisy data is eliminated to ensure the high purity and representativeness of the stored vectors. At the same time, according to business development and compliance requirements, the vector representation of the knowledge base target file is dynamically updated to maintain the system's keen perception and effective interception capabilities of emerging content.
[0049] Step S12: input the target user question into the target large model to obtain a target answer corresponding to the target user question, and determine a second embedding vector corresponding to the target answer based on the preset vectorization model.
[0050] In this embodiment, before processing the user question, a series of data cleaning operations must be performed, which is the core link of text preprocessing. That is, before the target user question is input into the target large model, it can also include: obtaining the initial user question through the preset user input interface, and filtering the target punctuation and target stop words in the initial user question based on the preset stop word rule library to obtain the user question to be processed; based on the preset normalization processing method, the preset stem extraction technology, the preset word form restoration technology and the preset error checking mechanism, the user question to be processed is processed to obtain the target user question. Specifically, the punctuation in the initial user question text is removed, the common stop words are filtered out by the stop word filtering algorithm, and the normalization processing of the initial user question text is realized, including but not limited to converting the text to lowercase, removing abnormal characters, etc. According to actual needs, the stem extraction technology or the word form restoration technology can be selected to further process the initial user question text processed above. If stem extraction technology is selected, a specific stem extraction algorithm can be used, such as the Porter stem extraction algorithm, to perform stem extraction operations on each word in the text, remove the affix part of the word, and obtain the stem form of the word, thereby simplifying the word representation and enhancing the consistency of the text. If word form restoration technology is selected, the words in the text can be restored to their basic form in the dictionary with the help of part-of-speech tagging and word morphology analysis tools, so that the words are more standardized in semantics and grammar to obtain the target user questions. It is understandable that a spelling check module can also be introduced in this embodiment to automatically identify and correct spelling errors in user questions. Semantic analysis can be used to ensure that the logic of user questions is consistent and avoid self-contradictions.
[0051] It should be noted that after obtaining the target user question, it is necessary to input the target user question into the target large model to obtain the corresponding target answer, and then input the target answer into the preset vectorization model, and use the preset vectorization model to convert the target answer into a second embedding vector in the high-dimensional space.
[0052] Step S13: determining a target similarity between each of the first embedding vectors and the second embedding vector, so as to determine an answer to the target user's question based on the target similarity, the first embedding vector and the target file in the target knowledge base.
[0053] In this embodiment, the determination of the target similarity between each of the first embedding vectors and the second embedding vector, so as to determine the answer to the question corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base, may include: determining the cosine similarity between each of the first embedding vectors and the second embedding vector in the target vector database based on the target index, and sorting the cosine similarities based on a preset order condition; determining the target cosine similarity from the sorted cosine similarities according to a preset similarity threshold and a preset answer quantity condition, and determining the target first embedding vector corresponding to the target cosine similarity, so as to determine the target file corresponding to the target first embedding vector based on the target storage table, obtain the answer to the question corresponding to the target user question, and highlight the target file corresponding to the target first embedding vector. Specifically, after obtaining the first embedding vector corresponding to the target file and the second embedding vector corresponding to the target answer, the cosine similarity can be used as an evaluation indicator to measure the similarity between the two vectors. Cosine similarity reflects the similarity by calculating the cosine value of the angle between the first embedding vector and the second embedding vector in the direction. The closer the cosine similarity is to 1, the more similar the two vectors are, that is, the more relevant the corresponding text content is. Cosine similarity calculation is one of the core steps to compare the target answer of the model answer with the target file in the knowledge base. It is used to quantify the similarity between the first embedding vector and the second embedding vector. That is, this embodiment can traverse the first embedding vector based on the target index, and calculate the cosine similarity with the second embedding vector, and then sort the cosine similarity from high to low. The answer to the question can be determined in turn by setting the number of answers and the cosine similarity threshold.
[0054] See also Figure 3 As shown, in a specific implementation, the specific process of the knowledge question and answer method based on the big model can be: the user question is raised: employee reimbursement process; then the user question is input into the big model, and the big model returns the answer: the employee reimbursement process should follow ×××; then the big model answer is matched with the knowledge base file for similarity, and the knowledge base file includes file one: "Employee Reimbursement Process", file two: "×× Company Reimbursement Process", and file three: "The Latest Reimbursement Process in 2023"; then according to the set dynamic matching strategy: return a section with the highest similarity in each file; finally, highlight the question result, and the highlighted content is: File one: The employee reimbursement process is as follows, file two: The company's reimbursement process is specific, and file three: The latest reimbursement process.
[0055] As can be seen from the above, in this embodiment, the initial file in the target knowledge base is first segmented based on the preset segmentation strategy to obtain the target file, and the target file is input into the preset vectorization model to obtain the first embedding vector corresponding to the target file; wherein the initial file is a file determined based on the user question; then the target user question is input into the target large model to obtain the target answer corresponding to the target user question, and the second embedding vector corresponding to the target answer is determined based on the preset vectorization model; finally, the target similarity between each of the first embedding vectors and the second embedding vector is determined, so as to determine the answer to the question corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base. As can be seen from the above, in this embodiment, the first embedding vector of the target file in the target knowledge base is calculated using the preset vectorization model, and then the second embedding vector corresponding to the target user question is calculated using the preset vectorization model, and then the target similarity between the first embedding vector corresponding to the target file and the second embedding vector corresponding to the target user question is calculated, and the answer to the question corresponding to the target user question is determined from the target file in the target knowledge base based on the target similarity. In this way, this embodiment can provide more accurate and targeted knowledge question and answer results by matching the target user with the contents of the target file in the knowledge base and returning the target file with the highest similarity as the answer to the user's question.
[0056] Based on the previous embodiment, it can be seen that the present application can use the files in the knowledge base to determine the answer to the user's question. Next, see Figure 4 As shown, in order to more quickly determine the result of the user's knowledge question and answer, the embodiment of the present invention further discloses a knowledge question and answer method based on a large model, which may include:
[0057] Step S21, splitting the initial file in the target knowledge base based on a preset segmentation strategy to obtain a target file, and inputting the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question.
[0058] Step S22: input the target user question into the target large model to obtain a target answer corresponding to the target user question, and determine a second embedding vector corresponding to the target answer based on the preset vectorization model.
[0059] Step S23: determining a target similarity between each of the first embedding vectors and the second embedding vector, so as to determine an answer to the target user's question based on the target similarity, the first embedding vector and the target file in the target knowledge base.
[0060] In this embodiment, after determining the answer to the question corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base, it may also include: converting the target user question, the target answer corresponding to the target user question and the answer to the question corresponding to the target user question into target structured data based on a preset data format, and storing the target structured data in a preset database, so as to directly query the answer to the question corresponding to the target user question based on the preset database. It can be understood that calling the model and calling the similarity processing are slower than directly querying from the database. In order to avoid this problem, the user question and the answer to the model and the answer to the question can be stored in the database. When the same question is asked again, it can be queried from the database first. If the query is successful, the question and the corresponding answer are returned to the user, thereby achieving a quick response. Specifically, the user question, the target answer corresponding to the user question and the answer to the question corresponding to the user question can be converted into a structured data format, and the target structured data can be stored in the database, so as to directly query the database to determine the answer to the question corresponding to the user question.
[0061] It is understandable that special optimization measures can be implemented in this embodiment for the cosine similarity calculation and database query process. For example, the processing speed and accuracy of the system can be improved by means of algorithm improvement, resource optimization allocation, and query strategy adjustment. Ensure that the system can still maintain an efficient and stable operating state in large data volumes and high concurrency scenarios, and provide users with instant and accurate question-and-answer services.
[0062] For more specific processing procedures of the above steps S21 and S22, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described again here.
[0063] As can be seen from the above, in this embodiment, the user question, the target answer corresponding to the user question, and the answer to the question corresponding to the user question are stored in a preset database, and the answer to the question corresponding to the user question is queried using the preset database. In this way, this embodiment can quickly retrieve and respond to the questions raised by the user, significantly improving the interaction efficiency and user experience of the question-answering system. At the same time, this embodiment is suitable for various industries such as customer service, online education, medical consultation, etc. that require intelligent question-answering functions, and has broad application prospects.
[0064] Accordingly, see Figure 5 As shown, the embodiment of the present application also provides a knowledge question-answering device based on a large model, which may include:
[0065] A first embedding vector determination module 11 is used to segment an initial file in a target knowledge base based on a preset segmentation strategy to obtain a target file, and input the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question;
[0066] A second embedding vector determination module 12 is used to input the target user question into the target large model to obtain a target answer corresponding to the target user question, and determine a second embedding vector corresponding to the target answer based on the preset vectorization model;
[0067] The question answer determination module 13 is used to determine the target similarity between each of the first embedding vectors and the second embedding vectors, so as to determine the question answer corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base.
[0068] As can be seen from the above, in this application, the initial file in the target knowledge base is first segmented based on the preset segmentation strategy to obtain the target file, and the target file is input into the preset vectorization model to obtain the first embedding vector corresponding to the target file; wherein the initial file is a file determined based on the user question; then the target user question is input into the target large model to obtain the target answer corresponding to the target user question, and the second embedding vector corresponding to the target answer is determined based on the preset vectorization model; finally, the target similarity between each of the first embedding vectors and the second embedding vector is determined, so as to determine the answer to the question corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base. As can be seen from the above, in this application, the first embedding vector of the target file in the target knowledge base is calculated using the preset vectorization model, and then the second embedding vector corresponding to the target user question is calculated using the preset vectorization model, and then the target similarity between the first embedding vector corresponding to the target file and the second embedding vector corresponding to the target user question is calculated, and the answer to the question corresponding to the target user question is determined from the target file in the target knowledge base based on the target similarity. In this way, the application can provide more accurate and targeted knowledge question and answer results by matching the target user with the content of the target file in the knowledge base and returning the target file with the highest similarity as the answer to the user's question.
[0069] In some specific implementations, the first embedding vector determination module 11 may include:
[0070] A target file determination unit is used to determine the delimiters in the initial file, and to segment the initial file in the target knowledge base based on the delimiters and a preset paragraph segmentation strategy to obtain the target file; or, to determine a target word count based on a target knowledge question-answering task, and to determine a preset sliding window step size based on the target word count, so as to segment the initial file in the target knowledge base based on the step size, a preset sliding window strategy and a preset word count segmentation strategy to obtain the target file.
[0071] In some specific implementations, the first embedding vector determination module 11 may include:
[0072] A target word segmentation determination unit, used to input the target file into the preset vectorization model to obtain a target word segmentation corresponding to the target file, and determine an initial word embedding vector and a target position encoding vector corresponding to the target word segmentation;
[0073] A first embedding vector determination unit is used to fuse the initial word embedding vector and the target position encoding vector to obtain a fused vector, and determine the first embedding vector corresponding to the target file based on the fused vector, a preset multi-head attention mechanism, a preset layer normalization method and a neural network layer in the preset vectorization model.
[0074] In some specific implementations, the large model-based knowledge question-answering device may further include:
[0075] a target vector serialization file generation module, configured to construct a target storage table in the target knowledge base based on the first embedding vector and the target file, and to generate a target vector serialization file corresponding to the first embedding vector based on a preset binary format condition;
[0076] The target vector serialization file storage module is used to determine the target index corresponding to each first embedded vector in the target vector serialization file, and store the target vector serialization file and the target index in a target vector database.
[0077] In some specific implementations, the large model-based knowledge question-answering device may further include:
[0078] A module for determining user questions to be processed, used to obtain an initial user question through a preset user input interface, and filter target punctuation marks and target stop words in the initial user question based on a preset stop word rule library to obtain a user question to be processed;
[0079] The target user question determination module is used to perform data processing on the user question to be processed based on a preset normalization processing method, a preset stem extraction technology, a preset word form restoration technology and a preset error checking mechanism to obtain the target user question.
[0080] In some specific implementations, the question answer determination module 13 may include:
[0081] a cosine similarity determination unit, configured to determine, based on the target index, the cosine similarities between each of the first embedding vectors and the second embedding vector in the target vector database, and to sort the cosine similarities based on a preset order condition;
[0082] A question answer determination unit is used to determine a target cosine similarity from the sorted cosine similarities according to a preset similarity threshold and a preset answer quantity condition, and determine a target first embedding vector corresponding to the target cosine similarity, so as to determine a target file corresponding to the target first embedding vector based on the target storage table, obtain the question answer corresponding to the target user question, and highlight the target file corresponding to the target first embedding vector.
[0083] In some specific implementations, the large model-based knowledge question-answering device may further include:
[0084] A database query module is used to convert the target user question, the target answer corresponding to the target user question and the question answer corresponding to the target user question into target structured data based on a preset data format, and store the target structured data in a preset database so as to directly query the question answer corresponding to the target user question based on the preset database.
[0085] Furthermore, the present application also discloses an electronic device. Figure 6 It is a structural diagram of an electronic device 20 shown according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input and output interface 25 and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the knowledge question and answer method based on the large model disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment can specifically be an electronic computer.
[0086] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0087] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0088] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the knowledge question answering method based on the large model performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.
[0089] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned knowledge question answering method based on a large model is implemented. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiment, and will not be repeated here.
[0090] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0091] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0092] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0093] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0094] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A knowledge question answering method based on a large model, characterized in that: include: Based on a preset segmentation strategy, an initial file in the target knowledge base is segmented to obtain a target file, and the target file is input into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question; Inputting the target user question into the target large model to obtain a target answer corresponding to the target user question, and determining a second embedding vector corresponding to the target answer based on the preset vectorization model; A target similarity between each of the first embedding vectors and the second embedding vector is determined, so as to determine a question answer corresponding to the target user question based on the target similarity, the first embedding vector, and the target file in the target knowledge base.
2. The knowledge question answering method based on a large model according to claim 1, characterized in that: The step of segmenting the initial file in the target knowledge base based on the preset segmentation strategy to obtain the target file includes: Determine a delimiter in the initial file, and segment the initial file in the target knowledge base based on the delimiter and a preset paragraph segmentation strategy to obtain the target file; Or, determine a target word count based on the target knowledge question-answering task, and determine a preset sliding window step size based on the target word count, so as to segment the initial file in the target knowledge base based on the step size, preset sliding window strategy and preset word count segmentation strategy to obtain the target file.
3. The knowledge question answering method based on a large model according to claim 1, characterized in that: The step of inputting the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file includes: Input the target file into the preset vectorization model to obtain a target word segmentation corresponding to the target file, and determine an initial word embedding vector and a target position encoding vector corresponding to the target word segmentation; The initial word embedding vector and the target position encoding vector are fused to obtain a fused vector, and the first embedding vector corresponding to the target file is determined based on the fused vector, a preset multi-head attention mechanism, a preset layer normalization method, and a neural network layer in the preset vectorization model.
4. The knowledge question answering method based on a large model according to claim 1, characterized in that: After inputting the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file, the method further comprises: Building a target storage table in the target knowledge base based on the first embedding vector and the target file, and generating a target vector serialization file corresponding to the first embedding vector based on a preset binary format condition; Determine a target index corresponding to each first embedded vector in the target vector serialization file, and store the target vector serialization file and the target index in a target vector database.
5. The knowledge question answering method based on a large model according to claim 1, characterized in that: Before inputting the target user question into the target large model, the method further includes: Acquire an initial user question through a preset user input interface, and filter target punctuation marks and target stop words in the initial user question based on a preset stop word rule library to obtain a user question to be processed; The user question to be processed is processed based on a preset normalization processing method, a preset stem extraction technology, a preset word form restoration technology and a preset error checking mechanism to obtain the target user question.
6. The knowledge question answering method based on a large model according to claim 4 is characterized in that: The determining of the target similarity between each of the first embedding vectors and the second embedding vector so as to determine the answer to the target user's question based on the target similarity, the first embedding vector and the target file in the target knowledge base includes: Determine the cosine similarity between each of the first embedding vectors and the second embedding vector in the target vector database based on the target index, and sort the cosine similarities based on a preset order condition; According to a preset similarity threshold and a preset answer quantity condition, a target cosine similarity is determined from the sorted cosine similarities, and a target first embedding vector corresponding to the target cosine similarity is determined, so as to determine a target file corresponding to the target first embedding vector based on the target storage table, obtain the question answer corresponding to the target user question, and highlight the target file corresponding to the target first embedding vector.
7. The knowledge question answering method based on a large model according to any one of claims 1 to 6, characterized in that: After determining the answer to the question corresponding to the target user's question based on the target similarity, the first embedding vector and the target file in the target knowledge base, the method further includes: The target user question, the target answer corresponding to the target user question, and the question answer corresponding to the target user question are converted into target structured data based on a preset data format, and the target structured data is stored in a preset database so that the question answer corresponding to the target user question can be directly queried based on the preset database.
8. A knowledge question-answering device based on a large model, characterized in that: include: A first embedding vector determination module is used to segment an initial file in a target knowledge base based on a preset segmentation strategy to obtain a target file, and input the target file into a preset vectorization model to obtain a first embedding vector corresponding to the target file; wherein the initial file is a file determined based on a user question; A second embedding vector determination module is used to input the target user question into the target large model to obtain a target answer corresponding to the target user question, and determine a second embedding vector corresponding to the target answer based on the preset vectorization model; The question answer determination module is used to determine the target similarity between each of the first embedding vectors and the second embedding vector, so as to determine the question answer corresponding to the target user question based on the target similarity, the first embedding vector and the target file in the target knowledge base.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the large model-based knowledge question answering method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the large model-based knowledge question answering method as described in any one of claims 1 to 7.