Large language model knowledge retrieval method and system based on semantic vectorization

Through a large language model knowledge retrieval method based on semantic vectorization, a vector knowledge base is constructed and combined with multiple retrieval methods, which solves the shortcomings of existing knowledge retrieval methods in terms of accuracy and ease of use, and achieves more efficient and accurate knowledge Retrieve.

CN119336864AInactive Publication Date: 2025-01-21BEIJING NINE STAR TECH CORP

Patent Information

Application Number
CN202411289849.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2025-01-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing knowledge retrieval methods have insufficient accuracy and ease of use, resulting in poor retrieval efficiency and user experience.

Method used

Using a large language model knowledge retrieval method based on semantic vectorization, by constructing a vector knowledge base, the knowledge base files are intelligently segmented and vectorized, and combined with semantic retrieval, full-text retrieval and hybrid retrieval methods, to generate answers to questions.

Benefits of technology

It improves the accuracy of retrieval results and user experience, solves the problems of unclear reference and low semantic matching, and enhances retrieval efficiency.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The invention provides a large language model knowledge retrieval method and system based on semantic vectorization, and relates to the technical field of artificial intelligence application, and the method comprises the following steps: constructing a vector knowledge base, collecting knowledge base files related to demand content, importing the knowledge base files into a knowledge document library, carrying out intelligent word segmentation on file content through a large language model, and obtaining a knowledge retrieval result; decomposing the document into a plurality of text blocks according to a preset format of the document, vectorizing the document blocks, and storing the vectorized document blocks into a vector knowledge base; and in response to a question request related to knowledge retrieval, performing anaphora elimination and semantic expansion on question content through the large language model, vectorizing the question content, selecting a corresponding vector knowledge base according to the category of the question content, and selecting a corresponding retrieval mode to retrieve and generate an answer to the question.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence application technology, and in particular to a large language model knowledge retrieval method based on semantic vectorization. Background Art

[0002] At present, traditional customer service assistants mainly rely on full-text retrieval methods to search the knowledge base text and process it in a way that returns the content with the highest match. This method has fixed answer content, high requirements for the knowledge base text, and poor accuracy and ease of use. Summary of the invention

[0003] The purpose of the present invention is to provide a large language model knowledge retrieval method and system based on semantic vectorization to solve the problems of poor accuracy and ease of use in the current knowledge retrieval field and improve retrieval efficiency and experience.

[0004] To solve the above problems, the present invention first provides a large language model knowledge retrieval method based on semantic vectorization, including: building a vector knowledge base, collecting knowledge base files related to the required content, importing them into the knowledge document base, intelligently segmenting the file content through a large language model, decomposing it into multiple text blocks according to a preset format of the document, and vectorizing the document blocks and storing them in the vector knowledge base; responding to question requests related to knowledge retrieval, and performing reference elimination and semantic expansion on the question content through a large language model, and vectorizing the question content, selecting the corresponding vector knowledge base according to the category of the question content, and selecting the corresponding retrieval method to retrieve and generate the answer to the question.

[0005] Furthermore, the retrieval methods include semantic retrieval, full-text retrieval and hybrid retrieval; semantic retrieval calculates the vector distance between the provided question and the content of the vector knowledge base, converts the vector distance between the two, and filters out the content with the highest similarity; full-text retrieval searches through keywords of semantic analysis of the question content, matches the keywords with the content of the vector knowledge base, and filters out the content with the highest matching degree; hybrid retrieval combines vector retrieval and full-text retrieval, and merges the two retrieval results through the RRF formula.

[0006] Furthermore, the vector knowledge base includes PostgreSQL and MongoDB; PostgreSQL is only used for vector retrieval, using the PGVector plug-in as a vector retriever, and the index is HNSW; in MongoDB, the information of the vector original data is stored, and its corresponding vector ID is recorded; when searching, the vector is first recalled, and then the original data content is obtained in MongoDB according to the vector ID. If it corresponds to the same group of original data, it is merged and the content with the highest vector score is output.

[0007] Furthermore, the vector knowledge base is connected to a question-and-answer platform, which can input questions to be retrieved and is provided with a custom process. The custom process includes an intention judgment unit, which performs intention judgment on the questions to be retrieved and performs retrieval based on the matching results of the corresponding vector knowledge base.

[0008] The present invention also provides a large language model knowledge retrieval system based on semantic vectorization, including: a user question and answer module, which inputs questions related to knowledge retrieval and sends the questions to a large model docking module; a large model docking module, which eliminates references and semantically expands the question content through a large language model, and vectorizes the question content, and matches the corresponding vector knowledge base by the category of the question content; a retrieval module, which selects a corresponding retrieval method to search in the vector knowledge base and generates answers to the questions; the construction of the vector knowledge base includes: collecting knowledge base files related to the required content, importing them into a knowledge document library, intelligently segmenting the file content through a large language model, decomposing it into multiple text blocks according to a preset document format, and vectorizing the document blocks and storing them in the vector knowledge base.

[0009] Furthermore, the retrieval methods include semantic retrieval, full-text retrieval and hybrid retrieval; semantic retrieval calculates the vector distance between the provided question and the content of the vector knowledge base, converts the vector distance between the two, and filters out the content with the highest similarity; full-text retrieval searches through keywords of semantic analysis of the question content, matches the keywords with the content of the vector knowledge base, and filters out the content with the highest matching degree; hybrid retrieval combines vector retrieval and full-text retrieval, and merges the two retrieval results through the RRF formula.

[0010] Furthermore, the vector knowledge base includes PostgreSQL and MongoDB; PostgreSQL is only used for vector retrieval, using the PGVector plug-in as a vector retriever, and the index is HNSW; in MongoDB, the information of the vector original data is stored, and its corresponding vector ID is recorded; when searching, the vector is first recalled, and then the original data content is obtained in MongoDB according to the vector ID. If it corresponds to the same group of original data, it is merged and the content with the highest vector score is output.

[0011] Furthermore, the user question and answer module can be configured with a custom process, which includes an intention judgment unit, which performs intention judgment on the question to be retrieved, and performs retrieval based on the matching result with the corresponding vector knowledge base.

[0012] According to a large language model knowledge retrieval method and system based on semantic vectorization provided by the present invention, user questions and knowledge base file contents are vectorized using semantic vectorization, and the semantic richness of the questions can be expanded at the same time, so as to avoid user questions being unclear and resulting in a low match with the content in the vector knowledge base and unclear reference caused by continuous dialogue. The expanded questions can then be retrieved according to the selected retrieval method, which can greatly improve the accuracy of the retrieval results and enhance the user retrieval experience. DETAILED DESCRIPTION

[0013] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below. It should be understood that the specific embodiments described here are only used to explain the present invention and are not used to limit the present invention.

[0014] Example 1

[0015] In order to solve the problem of poor accuracy and ease of use in the current knowledge retrieval field and improve retrieval efficiency and experience, this embodiment provides a large language model knowledge retrieval method and system based on semantic vectorization, including the following steps:

[0016] Build a vector knowledge base and collect knowledge base files related to the required content, such as user manuals of related products, Q&A files of related knowledge types, and user rules and regulations. After the collection is completed, import them into the knowledge document library. During the import process, the file content will be intelligently segmented through a large language model, and the file will be divided into multiple document blocks according to the set document format. A document block can be a question and an answer or the complete content of a type of business. The document block is vectorized and stored in the vector knowledge base.

[0017] Obtain knowledge retrieval-related question requests provided by users, eliminate references and expand semantics of question content through a large language model, vectorize the question content, select the corresponding vector knowledge base based on the category of the question content, and select the corresponding retrieval method to retrieve and generate answers to the questions.

[0018] This can solve the problem of unclear reference objects and expand the semantic richness of the questions, avoiding the situation where the user's questions are unclear and lead to a low match with the content in the vector library and unclear reference caused by continuous dialogue.

[0019] When searching for knowledge in the vector library, you can use three methods: semantic search, full-text search, and hybrid search:

[0020] Semantic retrieval calculates the distance between user questions and knowledge base content through vector distance, thereby obtaining mathematical similarity and obtaining the optimal answer to the question.

[0021] Full-text search is a traditional search method, suitable for finding key subjects and predicates.

[0022] Hybrid search uses vector search and full-text search at the same time, and merges the two search results through the RRF formula, making the search results richer and more accurate.

[0023] Since the search scope after hybrid retrieval is very large and similarity filtering cannot be performed directly, it is usually necessary to use a re-ranking model to re-rank the results and use the re-ranking scores for filtering. After the query is completed, the vector knowledge base takes the content with the highest matching degree and combines it with the question, and then sends it to the large language model through the pre-made prompt words to obtain the answer.

[0024] The vector knowledge base includes PostgreSQL and MongoDB. Since images or other binary content cannot be vectorized, MongoDB is added to store binary content to make the answers clearer and easier to understand.

[0025] PostgreSQL is only used for vector retrieval, and the PG Vector plug-in is used as the vector retriever, with the index HNSW. In MongoDB, the information of the vector original data is stored, and the corresponding vector ID is recorded. When searching, the vector is first recalled, and then the original data content is obtained from MongoDB according to the vector ID. If it corresponds to the same set of original data, it is merged and the vector score is the highest score.

[0026] The vector knowledge base is connected to a question-and-answer platform, which can input questions to be retrieved and has a custom process. The custom process includes an intention judgment unit, which performs intention judgment on the questions to be retrieved and searches the corresponding vector knowledge base based on the results.

[0027] For example, for more complex scenarios, the questioning stage can be added to the intention judgment stage, and the large model can determine the direction of the question. If it is judged to be about xx, it will enter knowledge base 1; if it is about xxx, it will enter knowledge base 2.

[0028] Complex question and answering can be achieved through customized processes, rather than being limited to the analysis of questions within a single knowledge base.

[0029] Example 2

[0030] Based on Example 1, this embodiment provides a large language model knowledge retrieval system based on semantic vectorization, which can implement the method provided in Example 1, including:

[0031] The user question and answer module inputs questions related to knowledge retrieval and sends them to the large model docking module;

[0032] The large model docking module uses a large language model to eliminate references and expand the semantics of the question content, and vectorizes the question content, matching the category of the question content with the corresponding vector knowledge base;

[0033] The retrieval module selects the corresponding retrieval method to search the vector knowledge base and generate the answer to the question;

[0034] The construction of the vector knowledge base includes: collecting knowledge base files related to the required content, importing them into the knowledge document library, intelligently segmenting the file content through a large language model, decomposing it into multiple text blocks according to the preset format of the document, and vectorizing the document blocks and storing them in the vector knowledge base.

[0035] In the description of this embodiment, it should be noted that those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment method can be implemented by instructing the control device through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the above-mentioned method embodiments, wherein the storage medium may be a memory, a disk, an optical disk, etc.

[0036] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.

[0037] 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.

[0038] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0039] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A large language model knowledge retrieval method based on semantic vectorization, characterized in that: include: Build a vector knowledge base, collect knowledge base files related to the required content, import them into the knowledge document base, perform intelligent word segmentation on the file content through a large language model, decompose them into multiple text blocks according to the preset format of the document, vectorize the document blocks, and store them in the vector knowledge base; In response to question requests related to knowledge retrieval, the question content is dereferenced and semantically expanded through a large language model, and the question content is vectorized. The corresponding vector knowledge base is selected according to the category of the question content, and the corresponding retrieval method is selected to retrieve and generate the answer to the question.

2. The large language model knowledge retrieval method based on semantic vectorization according to claim 1 is characterized in that: The retrieval methods include semantic retrieval, full-text retrieval and hybrid retrieval; Semantic retrieval calculates the vector distance between the provided question and the content of the vector knowledge base, converts it into the similarity between the two, and selects the content with the highest similarity; Full-text search uses keywords from semantic analysis of question content to search, matches keywords with the content of the vector knowledge base, and selects the content with the highest matching degree; Hybrid search combines vector search and full-text search, and merges the two search results through the RRF formula.

3. The large language model knowledge retrieval method based on semantic vectorization according to claim 1 is characterized in that: The vector knowledge base includes PostgreSQL and MongoDB; PostgreSQL is only used for vector retrieval, using the PGVector plug-in as the vector retriever, with the index being HNSW. In MongoDB, the information of the vector original data is stored, and its corresponding vector ID is recorded. When searching, first recall the vector, then obtain the original data content in MongoDB according to the vector ID. If they correspond to the same group of original data, merge them and output the content with the highest vector score.

4. The large language model knowledge retrieval method based on semantic vectorization according to claim 1 is characterized in that: The vector knowledge base is connected to a question-and-answer platform, which can input questions to be retrieved and is provided with a custom process. The custom process includes an intention judgment unit, which performs intention judgment on the questions to be retrieved and performs retrieval based on the results of matching the corresponding vector knowledge base.

5. A large language model knowledge retrieval system based on semantic vectorization, characterized in that: include: The user question and answer module inputs questions related to knowledge retrieval and sends them to the large model docking module; The large model docking module uses a large language model to eliminate references and expand the semantics of the question content, and vectorizes the question content, matching the category of the question content with the corresponding vector knowledge base; The retrieval module selects the corresponding retrieval method to search the vector knowledge base and generate the answer to the question; The construction of the vector knowledge base includes: collecting knowledge base files related to the required content, importing them into the knowledge document library, intelligently segmenting the file content through a large language model, decomposing it into multiple text blocks according to the preset format of the document, and vectorizing the document blocks and storing them in the vector knowledge base.

6. The large language model knowledge retrieval system based on semantic vectorization according to claim 5 is characterized in that: The retrieval methods include semantic retrieval, full-text retrieval and hybrid retrieval; Semantic retrieval calculates the vector distance between the provided question and the content of the vector knowledge base, converts it into the similarity between the two, and selects the content with the highest similarity; Full-text search uses keywords from semantic analysis of question content to search, matches keywords with the content of the vector knowledge base, and selects the content with the highest matching degree; Hybrid search combines vector search and full-text search, and merges the two search results through the RRF formula.

7. The large language model knowledge retrieval system based on semantic vectorization according to claim 5 is characterized in that: The vector knowledge base includes PostgreSQL and MongoDB; PostgreSQL is only used for vector retrieval, using the PGVector plug-in as the vector retriever, with the index being HNSW. In MongoDB, the information of the vector original data is stored, and its corresponding vector ID is recorded. When searching, first recall the vector, then obtain the original data content in MongoDB according to the vector ID. If they correspond to the same group of original data, merge them and output the content with the highest vector score.

8. The large language model knowledge retrieval system based on semantic vectorization according to claim 5 is characterized in that: The user question and answer module can configure a custom process, which includes an intention judgment unit, which performs intention judgment on the question to be retrieved, and performs retrieval based on the result matching the corresponding vector knowledge base.

Citation Information

Patent Citations

  • Method for realizing document question and answer by using large language model

    CN117972059A

  • LLM-based insurance professional knowledge management system

    CN118035418A

  • Diversity-enhanced text retrieval enhancement generation method and system

    CN118260406A

  • Intelligent legal question and answer method based on retrieval enhanced language model

    CN118277538A

  • Question and answer processing method and device, electronic equipment and storage medium

    CN118427209A

Cited By

  • Multi-round health dialogue method and system based on dynamic user state and real-time knowledge constraint

    CN119886359A

  • Retrieval enhancement generation method based on large model and related equipment

    CN120353942A

  • Railway multi-mode knowledge base question-answering system construction method of hybrid RAG architecture

    CN120448512A

  • Construction method of railway multimodal knowledge base question answering system based on hybrid RAG architecture

    CN120448512B

  • Enterprise credit repair guiding method and device based on large model, and medium

    CN120525056A