A question-answering method and device based on vector database
By performing word segmentation and vector conversion of input questions in the vector database, combining metadata to find the initial answer and input large language model to generate answers, the problems of inconvenient data processing and inaccurate answers in the existing technology are solved, and higher questions and answers are achieved accuracy.
Patent Information
- Application Number
- CN202410068971.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-17
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-01-17
AI Technical Summary
The prior art is not convenient enough to process new data, and cannot give sufficiently accurate answers when searching and comparing data in external documents, especially when approximate matching of some data segments or considering traditional relationship types. Data scenario.
Using a question-and-answer method based on vector database, the input vector is input to the vector database by performing word segmentation processing and vector conversion, and the target problem is determined based on the similarity matching method, and the initial answer is found in the metadata, and the input question and initial answer are finally entered. Enter a large language model to generate the target answer.
It improves the accuracy of the language model for document answers, ensures the preservation of question-and-answer structure relationships, enhances the accuracy of searches, and improves the accuracy of question answers.
Smart Images

Figure CN118093808B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of artificial intelligence technology, and in particular to a question-answering method based on a vector database. Background Art
[0002] AI large language models have good text generation and summarization capabilities. They can give relatively reasonable answers to most questions asked by natural people and quickly summarize long paragraphs of text. However, most applications of offline large language models cannot easily process new data and can only be realized by natural people entering long paragraphs of text in dialog boxes.
[0003] Existing projects such as Langchain-Chatchat use the langchain framework to easily connect external documents to large language models in the form of files, thereby realizing the application of local knowledge base question and answer. However, the specific application scenarios are not detailed enough and need additional refinement. For example, the Langchain-Chatchat project uses the CSVLoader that comes with the langchain framework, which can read table entries by row, but the content structure of the same row in the table is not retained during the conversion into a vector. And because the data search and comparison in external documents of existing projects are based on the approximation of vector data, it is impossible to give sufficiently accurate answers when it comes to scenarios that only require approximate matching of partial data fragments, or some scenarios that need to consider traditional relational data at the same time.
[0004] In view of this, how to improve the accuracy of language models in answering documents has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of this, the embodiments of this specification provide a question-answering method based on a vector database. One or more embodiments of this specification also relate to a question-answering device based on a vector database, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0006] According to a first aspect of an embodiment of this specification, a question-answering method based on a vector database is provided, comprising:
[0007] Perform word segmentation on the input question to obtain input prompt words;
[0008] Performing vector conversion on the input prompt word to obtain an input vector, inputting the input vector into a vector database, and determining a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question-and-answer document library, and at least one answer data corresponding to the question data is stored in metadata of a question-and-answer data record, the metadata is attached to the question-and-answer data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database;
[0009] Based on the target question, searching metadata for an initial answer corresponding to the target question;
[0010] The input question and the initial answer are input into a pre-trained large language model to generate a target answer, which is then sent to the user end.
[0011] According to a second aspect of an embodiment of this specification, a question-answering device based on a vector database is provided, comprising:
[0012] A processing module is configured to perform word segmentation processing on the input question to obtain input prompt words;
[0013] a determination module configured to perform vector conversion on the input prompt word to obtain an input vector, input the input vector into a vector database, and determine a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question-and-answer document library, and at least one answer data corresponding to the question data is stored in metadata of a question-and-answer data record, the metadata is attached to the question-and-answer data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database;
[0014] A search module, configured to search for an initial answer corresponding to the target question in the metadata based on the target question;
[0015] The generation module is configured to input the input question and the initial answer into a pre-trained large language model, generate a target answer, and send it to the user end.
[0016] According to a third aspect of an embodiment of this specification, a computer device is provided, including:
[0017] Memory and processor;
[0018] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above-mentioned question-answering method based on the vector database are implemented.
[0019] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the above-mentioned question-answering method based on the vector database are implemented.
[0020] An embodiment of the present specification provides a question-answering method based on a vector database, comprising: first, performing word segmentation processing on an input question to obtain an input prompt word; then performing vector conversion on the input prompt word to obtain an input vector, inputting the input vector into a vector database, and determining a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question-answering document library, and at least one answer data corresponding to the question data is stored in metadata of a question-answering data record, the metadata is attached to the question-answering data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database; secondly, based on the target question, searching the metadata for an initial answer corresponding to the target question; finally, inputting the input question and the initial answer into a pre-trained large language model to generate a target answer, and sending it to a user terminal.
[0021] By applying the method provided in the embodiments of this specification, questions and answers in the question and answer document library are stored separately before vectorization, ensuring that the question and answer structure relationship is still preserved when the vector conversion is performed later; based on the approximation of the separated questions, the initial answers are found through vector comparison, ensuring the accuracy of the search; and ultimately, only the input questions and initial answers are provided to the large language model, excluding metadata, thereby improving the accuracy of the question answers. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flowchart of a question-answering method based on a vector database provided by an embodiment of this specification;
[0023] Figure 2 It is a structural diagram of a question-answering method based on a vector database provided by an embodiment of this specification;
[0024] Figure 3 It is a structural schematic diagram of a question-answering device based on a vector database provided by an embodiment of this specification;
[0025] Figure 4 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0026] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0027] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0028] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0029] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0030] In this specification, a question-answering method based on a vector database is provided. This specification also relates to a question-answering device based on a vector database, a computer device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0031] See also Figure 1 , Figure 1 It is a flowchart of a question-answering method based on a vector database provided in an embodiment of this specification, which specifically includes the following steps.
[0032] Step S102: performing word segmentation processing on the input question to obtain input prompt words.
[0033] In the embodiment of this specification, the word segmentation processing of the input question to obtain the input prompt word includes: word segmentation processing of the question and answer document library to obtain at least one set of question and answer data, storing at least one set of the question and answer data in a list structure, wherein the first column of the list structure is the question in the question and answer data, and the second column is the answer and question and answer relationship in the question and answer data; storing the question data in a vector database, and storing the answer data in the metadata of the question and answer data record. It should be noted that the question and answer document library is updated in real time.
[0034] Here, word segmentation processing is performed, that is, determining the target word corresponding to the input question and using the target word as the input prompt word. For example, if the input question is: Which distance is closer, the company to the mall or the company to the home? At this time, the target words corresponding to the input question can be determined as: company, mall, home, distance, that is, company, mall, home, distance can be used as the input prompt words.
[0035] Step S104: perform vector conversion on the input prompt word to obtain an input vector, input the input vector into a vector database, and determine a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question and answer document library, and at least one answer data corresponding to the question data is stored in the metadata of the question and answer data record, the metadata is attached to the question and answer data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database.
[0036] It should be noted that in Milvus, metadata is used to store additional information in non-vector form associated with each vector data. The metadata here includes but is not limited to text, numerical values, timestamps, labels, descriptions or information related to vector data, which is used to describe, identify or classify vector data to meet actual needs. Metadata corresponds to vector data one by one, but it is not data in vector form, but additional information used to better manage and retrieve vector data.
[0037] Specifically, the performing vector conversion on the input prompt word to obtain the input vector includes: converting the data sequence corresponding to the input prompt word into a vector through a pre-trained target embedding model to obtain the input vector.
[0038] The similarity matching method is based on determining the target question corresponding to the input vector, including: determining the spatial distance of the input vector; and searching the vector database for the target answer corresponding to the input vector based on the spatial distance of the input vector.
[0039] In the embodiments of the present specification, the question and the answer are stored separately before vectorization, which ensures that the structural relationship is still preserved during vectorization; when the vector comparison is used to search for the initial answer, the approximation of the separated question is focused on, which ensures the accuracy of the search.
[0040] Step S106: Based on the target question, searching metadata for an initial answer corresponding to the target question.
[0041] Specifically, based on the target question, searching the metadata for an initial answer corresponding to the target question includes: determining a target question record based on the target question; and searching the metadata associated with the target question record for at least one value corresponding to the target question as the initial answer corresponding to the target question.
[0042] It should be noted that the initial answer here is the key corresponding to the input question stored in the metadata, at least one value that matches, and at least one answer corresponding to it. Therefore, the initial answer here may include one answer corresponding to the input question, or may include multiple answers corresponding to the input question.
[0043] Step S108: input the input question and the initial answer into a pre-trained large language model, generate a target answer, and send it to the user end.
[0044] Specifically, the input question and the initial answer are input into a pre-trained large language model to generate a target answer, including: inputting the input question and the initial answer into a pre-trained large language model, combining with weighted prompt word engineering, to generate the target answer.
[0045] In the embodiments of the present specification, the input information ultimately provided to the large language model includes only the initial answer part, and does not include other parts of the metadata that are not related to the input question. Therefore, deviations in the question answering process can be avoided and the accuracy of the question answers can be improved. In addition, since the amount of data input to the model is reduced, the model data processing efficiency can also be improved, thereby improving the user experience.
[0046] See also Figure 2 , Figure 2 It is a structural diagram of a question-and-answer method based on a vector database provided in an embodiment of this specification. It should be noted that the structural diagram of a question-and-answer method based on a vector database provided in an embodiment of this specification takes a question-and-answer document (ie, FAQ) as an example, and the format of the FAQ file is csv.
[0047] like Figure 2As shown in the figure, during the data preprocessing and storage process, the FAQ file is first separated into questions and answers to obtain question data, answer data and question-answer relationship; then the question data is vectorized and stored in the vector database, and the answer and question-answer relationship are still saved in the metadata. During the question-answering process, the user's input question is first segmented to obtain the input prompt word (i.e., prompt), and then the input prompt word is input into the vector database, and the question matching the input prompt word is searched by similarity to obtain the corresponding question; finally, the answer matching the corresponding question is searched in the metadata, and the input question and the found answer are used as background information, which are input into the LLM model (i.e., large language model), and the answer is generated in combination with the weighted prompt word project.
[0048] In practical applications, assume that each row is a set of questions and answers, with the first column being the question and the second column being the answer. Figure 2 In the process shown, the FAQ file is first read and segmented, and each line of data is stored separately in a list structure. It should be noted that each line of data also needs to be separated into two parts: questions and answers and stored in the data structure; then the "question" part of the data is stored in a vector database, and the answer and the relationship between the question and answer are also saved.
[0049] The current existing solution is to vectorize an entire piece of data and put it into a vector database together. The embodiment of this specification utilizes the characteristics of the document processing interface Document (i.e. document) of the langchain framework itself to store the "question" part of the data and store the "answer" in the metadata of the "document" instance. In this way, when the vector database vectorizes the data, it will only process the "question" part as the content body. At the same time, other information such as the "answer" exists in the same instance and the relationship between the data is retained.
[0050] Secondly, with the help of some natural language embedding models, the data sequence after word segmentation is converted into vectors. These trained AI embedding models will retain the semantics to a large extent, so it will be more convenient in subsequent searches.
[0051] Finally, the input question on the display interface is input into the large language model, and the target answer is output. Specifically, each time the user enters a prompt word, it is passed to the vector database and translated into a vector through the embedding model. Then, it is compared with the information in the vector database according to the distance in the vector space, and matching questions are found according to the similarity. After getting the question, the answer is taken from the metadata metadata, and then the answer and user input are provided as background information to the large language model (LLM) and the user input is further improved through the prompt word (prompt) engineering. Finally, the AI answer based on the existing FAQ knowledge is obtained.
[0052] It should be noted that the "questions" and "answers" in the embodiments of this specification can be refined into key and value, and are not limited to the question-and-answer format, and have certain scalability.
[0053] The embodiments of this specification focus on actual needs. Question and answer documents themselves are common documents for service-oriented enterprises and need to be updated all the time. Based on the original AI knowledge base question and answer, the embodiments of this specification greatly improve the accuracy of question search, make the background knowledge provided to the large language model more matched, and make most small models with 7b and 14b level parameters more effective in question and answer.
[0054] By applying the method provided in the embodiments of this specification, questions and answers in the question and answer document library are stored separately before vectorization, ensuring that the question and answer structure relationship is still preserved when the vector conversion is performed later; based on the approximation of the separated questions, the initial answers are found through vector comparison, ensuring the accuracy of the search; and ultimately, only the input questions and initial answers are provided to the large language model, excluding metadata, thereby improving the accuracy of the question answers.
[0055] Corresponding to the above method embodiment, this specification also provides a question-answering device embodiment based on a vector database. Figure 3 FIG. 1 is a schematic diagram of a question-answering device based on a vector database provided by an embodiment of the present specification. Figure 3 As shown, the device comprises:
[0056] The processing module 302 is configured to perform word segmentation processing on the input question to obtain input prompt words;
[0057] The determination module 304 is configured to perform vector conversion on the input prompt word to obtain an input vector, input the input vector into a vector database, and determine a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question-and-answer document library, and at least one answer data corresponding to the question data is stored in metadata of a question-and-answer data record, the metadata is attached to the question-and-answer data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database;
[0058] A search module 306 is configured to search the metadata for an initial answer corresponding to the target question based on the target question;
[0059] The generation module 308 is configured to input the input question and the initial answer into a pre-trained large language model, generate a target answer, and send it to the user end.
[0060] In an optional embodiment, before the processing module 302, the process includes:
[0061] Performing word segmentation processing on the question and answer document library to obtain at least one set of question and answer data, and storing at least one set of the question and answer data in a list structure, wherein the first column of the list structure is the questions in the question and answer data, and the second column is the answers and question and answer relationships in the question and answer data;
[0062] The question data is stored in a vector database, and the answer data is stored in metadata of the question and answer data record.
[0063] In an optional embodiment, the determining module 304 includes:
[0064] The data sequence corresponding to the input prompt word is converted into a vector through a pre-trained target embedding model to obtain an input vector.
[0065] In an optional embodiment, the determining module 304 includes:
[0066] determining a spatial distance of the input vectors;
[0067] Based on the spatial distance of the input vector, a target answer corresponding to the input vector is searched in the vector database.
[0068] In an optional embodiment, the search module 306 includes:
[0069] Based on the target problem, determining a target problem record;
[0070] In metadata associated with the target question record, at least one value corresponding to the target question is searched as an initial answer corresponding to the target question.
[0071] In an optional embodiment, the generating module 308 includes:
[0072] The input question and the initial answer are input into a pre-trained large language model, and combined with weighted prompt word engineering to generate a target answer.
[0073] In an optional embodiment, in the determination module 304, the question and answer document library is updated in real time.
[0074] By using the device provided in the embodiments of this specification, questions and answers in the question and answer document library are stored separately before vectorization, ensuring that the question and answer structure relationship is still preserved when the vector conversion is performed later; based on the approximation of the separated questions, the initial answers are found through vector comparison, ensuring the accuracy of the search; and ultimately, only the input questions and initial answers are provided to the large language model, excluding metadata, thereby improving the accuracy of the question answers.
[0075] The above is a schematic scheme of a question-answering device based on a vector database of this embodiment. It should be noted that the technical scheme of the question-answering device based on a vector database and the technical scheme of the question-answering method based on a vector database belong to the same concept, and the details of the technical scheme of the question-answering device based on a vector database that are not described in detail can be found in the description of the technical scheme of the question-answering method based on a vector database.
[0076] Figure 4 4 is a block diagram of a computing device 400 provided in one embodiment of the present specification. The components of the computing device 400 include but are not limited to a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and the database 450 is used to store data.
[0077] The computing device 400 also includes an access device 440 that enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).
[0078] In one embodiment of the present specification, the above components of the computing device 400 and Figure 4 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 4 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0079] The computing device 400 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 400 may also be a mobile or stationary server.
[0080] The processor 420 is used to execute the following computer executable instructions, which, when executed by the processor, implement the steps of the above-mentioned question-answering method based on the vector database.
[0081] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the question-answering method based on the vector database are of the same concept, and the details not described in detail in the technical scheme of the computing device can be found in the description of the technical scheme of the question-answering method based on the vector database.
[0082] An embodiment of the present specification also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned question-answering method based on a vector database.
[0083] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the question-answering method based on the vector database are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the question-answering method based on the vector database.
[0084] An embodiment of the present specification also provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned question-answering method based on the vector database.
[0085] The above is a schematic scheme of a computer program of this embodiment. It should be noted that the technical scheme of the computer program and the technical scheme of the question-answering method based on the vector database are of the same concept, and the details not described in detail in the technical scheme of the computer program can be found in the description of the technical scheme of the question-answering method based on the vector database.
[0086] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0087] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0088] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0089] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0090] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A question-answering method based on a vector database, comprising: Perform word segmentation on the input question to obtain input prompt words; Performing vector conversion on the input prompt word to obtain an input vector, inputting the input vector into a vector database, and determining a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question-and-answer document library, and at least one answer data corresponding to the question data is stored in metadata of a question-and-answer data record, the metadata is attached to the question-and-answer data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database; Based on the target question, searching metadata for an initial answer corresponding to the target question; Input the input question and the initial answer into a pre-trained large language model, generate a target answer, and send it to the user end; The word segmentation process of the input question to obtain the input prompt word includes: Performing word segmentation processing on the question and answer document library to obtain at least one set of question and answer data, and storing at least one set of the question and answer data in a list structure, wherein the first column of the list structure is the questions in the question and answer data, and the second column is the answers and question and answer relationships in the question and answer data; The question data is stored in a vector database, and the answer data is stored in metadata of the question and answer data record.
2. The method according to claim 1, characterized in that: The step of performing vector conversion on the input prompt word to obtain an input vector includes: The data sequence corresponding to the input prompt word is converted into a vector through a pre-trained target embedding model to obtain an input vector.
3. The method according to claim 1, characterized in that The method of determining a target problem corresponding to the input vector based on a similarity matching method includes: determining a spatial distance of the input vectors; Based on the spatial distance of the input vector, a target answer corresponding to the input vector is searched in the vector database.
4. The method according to claim 1, characterized in that: The step of searching metadata for an initial answer corresponding to the target question based on the target question includes: Based on the target problem, determining a target problem record; In metadata associated with the target question record, at least one value corresponding to the target question is searched as an initial answer corresponding to the target question.
5. The method according to claim 1, characterized in that Inputting the input question and the initial answer into a pre-trained large language model to generate a target answer includes: The input question and the initial answer are input into a pre-trained large language model, and combined with weighted prompt word engineering to generate a target answer.
6. The method according to claim 1, characterized in that The question and answer document library is updated in real time.
7. A question-answering device based on a vector database, comprising: A processing module is configured to perform word segmentation processing on the input question to obtain input prompt words; a determination module configured to perform vector conversion on the input prompt word to obtain an input vector, input the input vector into a vector database, and determine a target question corresponding to the input vector based on a similarity matching method, wherein the vector database stores question data in a question-and-answer document library, and at least one answer data corresponding to the question data is stored in metadata of a question-and-answer data record, the metadata is attached to the question-and-answer data record, and the answer data in the metadata corresponds one-to-one to the question data in the vector database; A search module, configured to search for an initial answer corresponding to the target question in the metadata based on the target question; A generation module is configured to input the input question and the initial answer into a pre-trained large language model, generate a target answer, and send it to the user end; Wherein, before the processing module, it is further configured as follows: Performing word segmentation processing on the question and answer document library to obtain at least one set of question and answer data, and storing at least one set of the question and answer data in a list structure, wherein the first column of the list structure is the questions in the question and answer data, and the second column is the answers and question and answer relationships in the question and answer data; The question data is stored in a vector database, and the answer data is stored in metadata of the question and answer data record.
8. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 6 when executing the program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an implementation program for information transmission, and when the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Problem processing method and device, computer equipment and storage medium
CN111400470A
Knowledge base question and answer method and device, electronic equipment and storage medium
CN117290492A