Knowledge retrieval method and system based on intelligent knowledge base, computer device and computer program product

By combining vector databases and graph databases into an intelligent knowledge base, enhanced query vectors are generated, solving the problems of limited knowledge retrieval scope and fragmentation in existing technologies, and achieving more accurate knowledge retrieval and ranking.

CN123048761APending Publication Date: 2026-11-06TAIYI FEIYI TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611322586.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-28
Publication Date
2026-11-06

AI Technical Summary

Technical Problem

Existing technologies for knowledge retrieval suffer from several problems, including the inability to retrieve searched concepts when they are not described in similar terms within the text block, fragmented knowledge, and outdated knowledge occupying prominent positions, leading to insufficient retrieval accuracy.

Method used

By constructing an intelligent knowledge base, combining vector databases and graph databases, query vectors are generated and traversed along the relationship edges of key entities to determine the relevance scores of related entities. These scores are then used as weights to overlay vectors, expanding the retrieval scope and ranking the results.

Benefits of technology

It improves the accuracy of knowledge retrieval, expands the actual usability of the knowledge base, ensures that the retrieval results are semantically close to the user's query and that the knowledge is timely, and reduces the impact of outdated knowledge.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123048761A_ABST
    Figure CN123048761A_ABST
Patent Text Reader

Abstract

This application relates to a knowledge retrieval method, system, computer device, and computer program product based on an intelligent knowledge base. The intelligent knowledge base includes a vector database and a graph database. Key entities are identified from user query instructions. The graph database is then traversed along the relational edges of the key entities to obtain multiple associated entities corresponding to the key entities, and a relevance score is determined for each associated entity to the degree of association with the user query instructions. Using the relevance scores of the associated entities as weights, the vectors of the associated entities are superimposed onto the query vector to obtain an enhanced query vector. A second knowledge set is then retrieved from the vector database based on the enhanced query vector. Based on the first and second knowledge sets, a target knowledge set is determined and output. This transforms the semantic relationships recorded in the graph database into offsets in the vector space, which actually participate in the similarity calculation, thus improving the accuracy of knowledge retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a knowledge retrieval method, system, computer equipment, and computer program product based on an intelligent knowledge base. Background Technology

[0002] With the development of large language model technology, retrieval enhancement generation technology has been applied to scenarios such as enterprise knowledge management, intelligent customer service, and intelligent question answering. This type of technology typically divides a document into several text blocks, converts each text block into a vector through an embedding model, and stores it in a vector database. When responding to a user query, the query is converted into a query vector, and by calculating the similarity between the query vector and the vectors of each text block, several text blocks with high similarity are retrieved as knowledge output.

[0003] However, in practical applications, the aforementioned technologies often fail to retrieve relevant knowledge when the concepts involved in the query do not appear in similar expressions within the text blocks, resulting in insufficient recall for complex queries. Furthermore, since each text block is stored and computed independently, knowledge is fragmented. Additionally, the ranking of search results does not consider the timeliness of the knowledge itself or user usage, leading to outdated and low-quality knowledge consistently occupying prominent positions. Therefore, improving the accuracy of knowledge retrieval is a pressing technical problem that needs to be addressed in this field. Summary of the Invention

[0004] Therefore, it is necessary to provide a knowledge retrieval method, system, computer equipment, and computer program product based on an intelligent knowledge base that can improve the accuracy of knowledge retrieval, addressing the aforementioned technical problems.

[0005] Firstly, this application provides a knowledge retrieval method based on an intelligent knowledge base, which includes a vector database and a graph database. The method includes:

[0006] In response to a user's query command, a query vector corresponding to the user's query command is generated, and the first knowledge set is retrieved from the vector database based on the query vector;

[0007] The key entities are identified from the user's query instructions. The graph database is traversed along the relational edges of the key entities to obtain multiple associated entities corresponding to the key entities. The relevance score of each associated entity to the user's query instructions is then determined.

[0008] Using the relevance scores of associated entities as weights, the vectors of associated entities are superimposed on the query vector to obtain an enhanced query vector, and a second knowledge set is retrieved from the vector database based on the enhanced query vector;

[0009] Based on the first and second knowledge sets, determine the target knowledge set and output the target knowledge set.

[0010] In one embodiment, before the step of generating a query vector corresponding to a user query command in response to the user query command, the method further includes:

[0011] Retrieve the document to be imported into the database, parse the document to be imported into the database, and obtain the text content and metadata of the document to be imported into the database;

[0012] The text content is divided into blocks to obtain multiple text blocks, and a block identifier is assigned to each text block.

[0013] Each text block is converted into a text block vector, and the text block vector, block identifier, and metadata are associated and stored in the vector database;

[0014] Extract multiple entities from multiple text blocks, determine the relationships between the multiple entities, and generate an entity relationship graph with the multiple entities as entity nodes and the relationships as relationship edges;

[0015] Store the entity relationship graph in a graph database and associate each entity node with its corresponding block identifier.

[0016] In one embodiment, the steps of extracting multiple entities from multiple text blocks and determining the relationships between the multiple entities include:

[0017] Identify multiple entities corresponding to multiple text blocks and determine the entity type of each entity;

[0018] Merge multiple entities that point to the same object into a single entity, and associate the block identifiers of each entity before the merger with the merged entity;

[0019] Determine whether there are semantic relationships between any two of the merged entities, and determine the relationship type for entity pairs that have semantic relationships, thus obtaining the relationships between the multiple entities.

[0020] In one embodiment, the steps of generating a query vector corresponding to the user's query command in response to the query vector, and retrieving a first knowledge set from a vector database based on the query vector include:

[0021] Obtain contextual information associated with the user's query command; wherein the contextual information includes at least one of the following: session history, user preferences, and long-term memory;

[0022] The user's query command is semantically completed based on the context information to obtain the completed query command, and then the completed query command is converted into a query vector;

[0023] Based on the query vector, candidate knowledge sets are retrieved from the vector database, and the candidate knowledge sets are filtered to obtain the first knowledge set.

[0024] In one embodiment, the step of determining the relevance score of each associated entity to the user's query instruction includes:

[0025] Obtain the semantic similarity between related entities and user query commands;

[0026] Based on the path depth of the associated entity relative to the key entity during traversal, the path decay factor is determined, and the frequency of occurrence of the associated entity during traversal is counted; wherein, the path decay factor decreases as the path depth increases.

[0027] The initial relevance score of the associated entities is calculated based on semantic similarity, path decay factor, and frequency of occurrence.

[0028] The initial relevance score is mapped to a preset number of discrete levels, and associated entities with discrete levels below a preset level threshold are filtered out.

[0029] Obtain the matching results between the retained associated entities and user preferences and user historical behavior, determine the adjustment coefficient based on the matching results, and adjust the initial relevance score with the adjustment coefficient to obtain the relevance score of the associated entities.

[0030] In one embodiment, the text block vectors in the vector database are associated with the block identifiers of the text blocks to which they belong, and the entity nodes in the graph database are associated with the block identifiers of the text blocks from which they originate; the steps of superimposing the vectors of the associated entities onto the query vector using the relevance scores of the associated entities as weights to obtain an enhanced query vector, and retrieving the second knowledge set from the vector database based on the enhanced query vector include:

[0031] Retrieve the block identifier associated with each associated entity;

[0032] Based on the block identifier, retrieve the text block vector associated with the block identifier from the vector database, and use the text block vector as the vector of the associated entity;

[0033] The user query command is combined with each associated entity to generate a reconstructed query command, and the reconstructed query command is converted into a reconstructed query vector.

[0034] Using the relevance scores of related entities as weights, the vectors of related entities are superimposed onto the reconstructed query vector to obtain the enhanced query vector;

[0035] Calculate the similarity between the enhanced query vector and each text block vector in the vector database, and determine the knowledge corresponding to the text block vector whose similarity meets the preset retrieval conditions as the second knowledge set.

[0036] In one embodiment, the text block vectors in the vector database are associated with the block identifiers of the text blocks to which they belong. The steps of determining a target knowledge set based on a first knowledge set and a second knowledge set, and outputting the target knowledge set, include:

[0037] Merge the first knowledge set and the second knowledge set, and remove duplicates from the merged knowledge set to obtain the knowledge set to be evaluated;

[0038] The semantic score of the knowledge to be evaluated is determined based on the hit rate of each knowledge in the knowledge set to be evaluated to the associated entities and the relevance score of the hit associated entities.

[0039] The timeliness score of the knowledge to be evaluated is determined based on its duration of existence, and the feedback score is determined based on the type of user feedback received by the knowledge to be evaluated; wherein, the timeliness score decreases as the duration of existence increases.

[0040] Based on semantic score, timeliness score and feedback score, the comprehensive score of the knowledge to be evaluated is calculated;

[0041] The knowledge sets to be evaluated are sorted according to their comprehensive scores, and the knowledge sets to be evaluated that meet the preset output conditions are identified as the target knowledge sets and then output.

[0042] Secondly, this application also provides a knowledge retrieval system based on an intelligent knowledge base, the intelligent knowledge base including a vector database and a graph database, the system comprising:

[0043] The first retrieval module is used to respond to the user's query command, generate a query vector corresponding to the user's query command, and retrieve the first knowledge set from the vector database based on the query vector;

[0044] The relevance calculation module is used to identify key entities from user query instructions, traverse along the relation edges of key entities in the graph database to obtain multiple associated entities corresponding to the key entities, and determine the relevance score of each associated entity to the degree of association with the user query instructions.

[0045] The second retrieval module is used to superimpose the vectors of related entities onto the query vector using the relevance scores of related entities as weights to obtain an enhanced query vector, and retrieve the second knowledge set from the vector database based on the enhanced query vector;

[0046] The output module is used to determine the target knowledge set based on the first knowledge set and the second knowledge set, and then output the target knowledge set.

[0047] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the knowledge retrieval method based on the intelligent knowledge base described above.

[0048] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the knowledge retrieval method based on the intelligent knowledge base described above.

[0049] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps performed by the knowledge retrieval method based on the intelligent knowledge base described above.

[0050] The aforementioned knowledge retrieval method, system, computer equipment, and computer program product based on an intelligent knowledge base respond to a user query command by generating a query vector corresponding to the user query command and retrieving a first knowledge set from a vector database based on the query vector; identifying key entities from the user query command, traversing along the relational edges of the key entities in a graph database to obtain multiple associated entities corresponding to the key entities, and determining the relevance score of each associated entity to the user query command; using the relevance score of the associated entities as weights, superimposing the vectors of the associated entities onto the query vector to obtain an enhanced query vector, and retrieving a second knowledge set from the vector database based on the enhanced query vector; and determining a target knowledge set based on the first and second knowledge sets and outputting the target knowledge set.

[0051] Therefore, by using relation edges in the graph database as the connection pathways between text blocks, knowledge that differs from the literal expression of the user's query but is semantically related can be accessed through key entities. This overcomes the problem that the retrieval scope is limited by the query's own expression when only a single similarity match is performed between the query vector and the text block vector. At the same time, the importance of each associated entity is quantified by relevance score, which distinguishes the influence of each associated entity on the query semantics, thus expanding the retrieval scope while maintaining the stability of the retrieval direction. Furthermore, the relevance score is used as the weight for vector superposition, so that the semantic associations found in the graph database are transformed into offsets in the vector space and actually participate in the similarity calculation. The semantic range represented by the resulting enhanced query vector is wider than that of the original query vector. The second knowledge set retrieved based on this vector complements the first knowledge set in terms of coverage. Finally, after merging and deduplicating the two sets, they are sorted and output according to a comprehensive score that takes into account semantics, timeliness, and feedback. This ensures that the ranking results reflect not only the semantic closeness between the knowledge and the query, but also the newness of the knowledge itself and the user's recognition of it, thus improving the accuracy of knowledge retrieval. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 This is an application environment diagram of a knowledge retrieval method based on an intelligent knowledge base in one embodiment;

[0054] Figure 2 This is a flowchart illustrating a knowledge retrieval method based on an intelligent knowledge base in one embodiment;

[0055] Figure 3 This is a flowchart illustrating the intelligent knowledge base construction process in one embodiment;

[0056] Figure 4 This is a flowchart illustrating the knowledge retrieval process in a simple query scenario in one embodiment.

[0057] Figure 5 This is a flowchart illustrating the knowledge retrieval process under a mixed query scenario in one embodiment;

[0058] Figure 6 This is a schematic diagram of the structure of a knowledge retrieval system based on an intelligent knowledge base in one embodiment;

[0059] Figure 7 This is a schematic diagram of the internal structure of a computer device in one embodiment. Detailed Implementation

[0060] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0061] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0062] In traditional retrieval enhancement technologies, the knowledge retrieval process relies on a single similarity calculation between the query vector and the text block vector. The retrieval scope is limited to the literal expression of the user's query command, lacking the mining and utilization of semantic relationships between knowledge points, resulting in insufficient accuracy in knowledge retrieval. Furthermore, each text block is stored independently in the vector database and participates in similarity calculation independently. There is a lack of traceable connection paths between text blocks and between different documents, resulting in fragmented knowledge and limited ability to discover other related knowledge from a single knowledge point. Moreover, the ranking of search results is based solely on semantic similarity, without considering the novelty of the knowledge itself or user feedback on its use. This leads to outdated and low-quality knowledge occupying prominent positions for extended periods, and the knowledge base lacks the ability to self-adjust over time and based on usage.

[0063] For example, in a company's technical support knowledge base, maintenance personnel might enter the query "How to handle a continuously flashing indicator light after device startup." The document in the knowledge base describing this issue uses the phrase "Reset procedure for power-on self-test anomaly." Due to the significant difference in wording, their vectors have low similarity in the vector space. Therefore, in the ranking results calculated by existing methods, this document is unlikely to rank highly, preventing maintenance personnel from obtaining a practical and effective solution. Specifically, in this scenario, there is a clear semantic connection between "indicator light flashing" and "power-on self-test," a connection also documented in other documents in the knowledge base. However, existing methods do not incorporate this connection into the retrieval calculation, relying solely on the query's wording for a single match, leading to the omission of relevant knowledge. Meanwhile, the knowledge base also contains an older solution published three years ago, whose wording is highly similar to the query, thus ranking first in the results. However, the reset method described in that document has been superseded by device firmware upgrades, rendering the solution ineffective for maintenance personnel.

[0064] If the above problems are not addressed, a large amount of semantically related knowledge in the knowledge base will remain difficult to retrieve for a long time. The actual usability of the knowledge base will be far less than its storage capacity, and the initial investment in document organization and data entry will be difficult to translate into practical utility. At the same time, the continued output of outdated knowledge at the top will guide users to adopt invalid processing methods. In scenarios with high accuracy requirements, such as equipment maintenance, medical consultation, and legal research, the resulting incorrect handling may lead to equipment damage, decision-making errors, and other consequences, directly affecting the credibility and usability of the knowledge base.

[0065] To address the aforementioned problems, embodiments of this application provide a knowledge retrieval method based on an intelligent knowledge base, which can be applied to, for example... Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on another network server.

[0066] The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, in-vehicle terminals, industrial control terminals, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, and projection equipment. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. The terminal 102 can receive user query commands input by the user, send the user query commands to the server 104 via the network, and receive and present the target knowledge set returned by the server 104.

[0067] Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Server 104 can be configured with a central processing unit (CPU) and a graphics processing unit (GPU). The CPU can be used for processing primarily involving logic control and numerical operations, such as document parsing, text content segmentation, graph database traversal, relevance score calculation and sorting. The GPU can be used for processing primarily involving parallel matrix operations, such as vector transformation operations for embedded models and inference operations for language models. Server 104 can also be configured with internal memory and non-volatile storage media. The internal memory can be used to cache query vectors, related entities and their relevance scores, enhanced query vectors, and knowledge sets at each stage of the current retrieval process. The non-volatile storage media can be used to persistently store data from both databases and the corresponding computer programs. It should be noted that vector databases typically need to load vector indexes into memory when performing similarity calculations; therefore, the capacity of the internal memory should be commensurate with the size of the documents included in the knowledge base.

[0068] The data storage system may include a vector database and a graph database; the vector database may be a database that supports high-dimensional vector storage and approximate nearest neighbor retrieval, while the graph database may be a database that stores data in the form of nodes and edges and supports edge traversal. Both can be deployed on the same physical server, or they can be deployed on separate physical servers and interconnected via a low-latency intranet link. Furthermore, server 104 can communicate with the embedded model service and the language model service via a network; these two services can be deployed locally on server 104, or deployed on a separate inference server, or provided as an external interface.

[0069] This application provides a knowledge retrieval method based on an intelligent knowledge base, such as... Figure 2 As shown, this method is applied to Figure 1 Taking server 104 as an example, by transforming the relationships between entities recorded in the graph database into weights in a vector space and making them participate in similarity calculation, the semantic scope covered by the retrieval is expanded, thereby improving the accuracy of knowledge retrieval. This knowledge retrieval method based on an intelligent knowledge base may include steps 21 to 24, wherein:

[0070] Step 21: In response to the user's query command, generate a query vector corresponding to the user's query command, and retrieve the first knowledge set from the vector database based on the query vector.

[0071] Among them, the intelligent knowledge base can be a data set used to collect, organize and provide knowledge to the outside world. It can include vector databases and graph databases. Vector databases can be used to store the semantic representation of knowledge in the form of vectors, and graph databases can be used to store the objects involved in the knowledge and the relationships between objects in the form of nodes and edges.

[0072] User query commands are instructions entered by users to obtain knowledge. They can be questions in natural language or combinations of keywords, used to indicate the knowledge content that the user expects to obtain.

[0073] A query vector can be a multidimensional numerical sequence that corresponds to a user's query command and is used to represent the semantics of that command in a vector space.

[0074] The first knowledge set can be a collection of knowledge retrieved from a vector database based on a query vector, where each piece of knowledge closely matches the user's query command in semantic representation.

[0075] Understandably, this step first obtains a set of knowledge directly corresponding to the user's query command. Since the semantic range represented by the query vector corresponds to the expression of the user's query command itself, the first knowledge set retrieved from it has high reliability in terms of semantic closeness and can serve as a basic component for subsequent ranking; at the same time, the first knowledge set also provides a reference for subsequent steps, so that the knowledge obtained after semantic expansion can complement it.

[0076] One approach is to directly input the user's query command into the embedding model, which then outputs the corresponding query vector. Another approach is to first perform semantic processing on the user's query command before inputting the processed command into the embedding model, thus making the semantic representation of the query vector more complete.

[0077] One approach is to calculate the similarity between the query vector and the corresponding vectors of each knowledge in the vector database, and then determine the knowledge with the highest similarity as the first knowledge set. Another approach is to further reorder or filter the obtained knowledge based on the above similarity calculation, and then determine the remaining knowledge as the first knowledge set.

[0078] Step 22: Identify key entities from user query instructions, traverse along the relational edges of key entities in the graph database to obtain multiple associated entities corresponding to the key entities, and determine the relevance score of each associated entity to the degree of association with the user query instructions.

[0079] Among them, the key entity can be the object involved in the user's query command that is used to represent the core target of the command. It can be a specific thing, concept, device or event.

[0080] An entity node can be a node in a graph database used to represent an object, and a relation edge can be an edge in a graph database used to represent a certain relationship between two entity nodes.

[0081] A related entity can be an object corresponding to an entity node in a graph database that is connected to a key entity via relational edges. It can be directly connected to the key entity or indirectly connected via several relational edges.

[0082] A relevance score is a numerical value used to characterize the degree of relevance between related entities and user query commands.

[0083] Understandably, the expression used in a user's query is usually only one way of expressing the semantic meaning it refers to, while knowledge in the knowledge base that records the same or similar content may use another way of expression; the relation edges in the graph database record the associations between objects, and traversing along the relation edges allows one to reach other objects that are related to the key entity, and these objects provide specific landing points for the expansion of query semantics.

[0084] Furthermore, assigning relevance scores to each associated entity serves to differentiate the strength of the expansion. The associated entities obtained by traversing relation edges are typically numerous, and their relevance to the user's query varies. If all associated entities are treated equally, those with lower relevance will have the same impact as those with higher relevance, causing the expanded semantic scope to deviate from the original target of the user's query. Quantifying the relevance of each associated entity with a relevance score allows subsequent processing to differentiate between them based on the score, thereby maintaining the stability of the retrieval direction while expanding the semantic scope.

[0085] One approach is to input the user's query into a language model, which then identifies the objects involved and outputs key entities. Another approach is to match the words in the user's query with existing entity nodes in a graph database, identifying the objects corresponding to the successfully matched words as key entities.

[0086] One approach is to start with the entity node corresponding to the key entity and traverse along its relational edges layer by layer to a preset number of layers, identifying the objects corresponding to the entity nodes reached during the traversal as associated entities. Another approach is to select the association type of the relational edges during the traversal, continuing the traversal only along relational edges that conform to the preset association type.

[0087] One approach is to determine the relevance score based on the semantic similarity between the related entity and the user's query. Another approach is to consider, in addition to semantic similarity, the proximity of the related entity to the key entity in the graph database and the number of times it is reached during traversal, thus comprehensively determining its relevance score.

[0088] Step 23: Using the relevance scores of the associated entities as weights, superimpose the vectors of the associated entities onto the query vector to obtain the enhanced query vector, and retrieve the second knowledge set from the vector database based on the enhanced query vector.

[0089] The vector of the associated entity can be a multidimensional numerical sequence used to represent the semantics of the associated entity in the vector space.

[0090] An enhanced query vector can be a vector obtained by superimposing the query vector and the vectors of each associated entity according to their relevance scores. It can be used to represent the semantics of the query after semantic expansion.

[0091] The second knowledge set can be a collection of knowledge retrieved from a vector database based on an enhanced query vector.

[0092] Understandably, although the related entities and relevance scores have already been obtained in the previous step, they are both within a graph structure. Vector database retrieval, however, is based on the similarity between vectors. By superimposing the vectors of related entities according to their relevance scores onto the query vector, the associations recorded in the graph structure are transformed into offsets in the vector space. This causes the enhanced query vector to shift in the vector space towards the directions of the related entities, with the magnitude of the shift corresponding to the relevance scores of each related entity. Therefore, when retrieving data from the vector database using the enhanced query vector, knowledge that is semantically close to the related entities but differs from the original expression of the user's query will have a higher similarity to the enhanced query vector than to the original query vector, thus being included in the search results.

[0093] Furthermore, by using relevance scores as the weights for the superposition, related entities with higher relevance scores have a greater impact on the enhanced query vector, while related entities with lower relevance scores have a smaller impact on the enhanced query vector. As a result, the enhanced query vector expands the semantic scope while its subject remains consistent with the user's query instruction.

[0094] One approach is to input the name corresponding to the associated entity into the embedding model, and use the vector output by the embedding model as the vector of the associated entity. Another approach is to use the text block vector corresponding to the text block from which the associated entity originates as the vector of the associated entity, so that the semantics represented by the vector includes the specific context of the associated entity in the knowledge base.

[0095] One approach is to multiply the vectors of each associated entity by their relevance scores, and then add them dimension-by-dimensionally to the query vector to obtain the enhanced query vector. Another approach is to normalize the resulting vector after the addition process to ensure that the magnitude of the enhanced query vector is compatible with the magnitudes of the vectors in the vector database.

[0096] One approach is to calculate the similarity between the enhanced query vector and the corresponding vectors of each knowledge in the vector database, and then identify the knowledge with the highest similarity as the second knowledge set. Another approach is to set conditions on the quantity or similarity of the retrieved knowledge during retrieval, and then identify the knowledge that meets these conditions as the second knowledge set.

[0097] Step 24: Based on the first knowledge set and the second knowledge set, determine the target knowledge set and output the target knowledge set.

[0098] The target knowledge set can be the collection of knowledge that is ultimately output to the user.

[0099] Understandably, the first knowledge set is retrieved based on the user's query statement itself, and the knowledge within it closely matches the query statement in literal semantics. The second knowledge set is retrieved based on the semantically expanded enhanced query vector, and the knowledge within it closely matches the query statement in relational semantics. The first and second knowledge sets complement each other in terms of coverage, together constituting the complete set of knowledge obtained in this retrieval. However, there may be duplicate knowledge between the two sets, and the degree of closeness of each piece of knowledge to the user's query statement, its own novelty, and the user feedback obtained in the past all vary. Therefore, it is necessary to merge, deduplicate, and uniformly sort them to obtain an ordered and non-redundant output result.

[0100] One approach is to merge the first and second knowledge sets, remove duplicate knowledge, and then sort the knowledge based on its relevance to the user's query, selecting the top-ranked knowledge as the target knowledge set. Another approach is to consider not only relevance but also the age and relevant user feedback of each piece of knowledge to determine its ranking, selecting the top-ranked knowledge as the target knowledge set.

[0101] One approach is to directly output the content corresponding to each piece of knowledge in the target knowledge set to the terminal for presentation. Another approach is to input the target knowledge set into a language model, which then generates and outputs the response content.

[0102] In traditional retrieval enhancement generation schemes, knowledge retrieval relies solely on a single similarity calculation between the query vector and the text block vector. This single-matching method suffers from limitations in retrieval scope and the potential for overlooking relevant knowledge: the semantic range represented by the query vector corresponds precisely to the literal expression of the user's query command. When a text block containing relevant content in the knowledge base uses a different expression, the similarity between the two vectors is low, making it difficult for that text block to appear in the retrieval results; furthermore, each text block participates in the calculation independently, and existing semantic connections between knowledge points are not utilized.

[0103] In the above implementation, the relation edges in the graph database record the associations between objects. Traversing along these edges from a key entity allows access to multiple associated entities, providing specific extension points for the query semantics. Each associated entity is assigned a relevance score, allowing for differentiation in the strength of its influence on the query semantics. This relevance score is then used as the weight for vector stacking, transforming the associations in the graph structure into offsets in the vector space and actually participating in the similarity calculation. The resulting enhanced query vector covers a broader semantic range than the original query vector. The second knowledge set retrieved from this vector can encompass knowledge that differs from the user's query expression but is semantically related. After merging, deduplicating, and uniformly sorting the two batches of knowledge, the results are output, allowing literally similar knowledge and closely related knowledge to be judged on the same scale. Compared to existing technologies where the retrieval scope is limited by the query expression, this embodiment transforms existing semantic associations in the knowledge base into actual contributing factors in the retrieval calculation, effectively improving the accuracy of knowledge retrieval and expanding the actual usable scope of knowledge in the knowledge base. Based on this, this application proposes a knowledge retrieval method based on an intelligent knowledge base. During the construction of the intelligent knowledge base, the correspondence between text blocks and entity nodes is established. Furthermore, during the retrieval process, the determination of relevance scores, the construction of enhanced query vectors, and the adjudication of the target knowledge set are refined step by step. In an exemplary embodiment, the knowledge retrieval method based on an intelligent knowledge base may include steps 301 to 326, wherein:

[0104] Step 301: Obtain the document to be imported into the database, parse the document to be imported into the database, and obtain the text content and metadata of the document to be imported into the database.

[0105] The documents to be added to the database can be original materials included in the intelligent knowledge base, which can be in the form of portable document format files, word processing documents, plain text files, or hypertext markup language files, etc. The text content can be the main body of the document to be added, expressed in natural language, which carries the knowledge recorded in the document itself. Metadata can be data used to describe the attributes of the document to be added, which can include a file identifier to identify the document, a knowledge base identifier to which the document belongs, a knowledge status indicating whether the document is currently available, and attributes such as the document's creation time and domain.

[0106] Understandably, documents of different formats organize their content in different ways internally, with text, formatting information, and charts mixed together. If the raw bytes of the document are directly segmented and vectorized, the result will contain a large amount of formatting information unrelated to the knowledge itself, interfering with subsequent similarity calculations. Parsing to obtain pure text content allows subsequent steps to process only the knowledge itself.

[0107] Furthermore, extracting metadata along with text content serves to provide knowledge with attributes beyond the text itself. Text content only records the content of knowledge, but attributes such as whether the knowledge is still usable, which knowledge base it belongs to, and when it was published cannot be provided by the text content itself. Saving it together as metadata allows subsequent filtering and sorting steps to make selections based on it.

[0108] One approach is to configure separate parsers for each document format, allowing the parser to read the document and output its text and attribute fields. Another approach is to first convert all documents to a single intermediate format, and then use a unified parser to extract their text content and metadata.

[0109] Step 302: Divide the text content into blocks to obtain multiple text blocks, and assign a block identifier to each text block.

[0110] Here, a text block can be a semantically relatively complete fragment obtained by segmenting text content. A block identifier can be an identifier used to identify a text block in the intelligent knowledge base, and the block identifiers corresponding to each text block are distinct from each other.

[0111] Understandably, a document to be added to the database is usually quite long and involves multiple topics. If the entire document is converted into a vector, the semantics represented by the vector will be a mixture of multiple topics, and the similarity with any specific query will be at a moderate level, thus reducing the distinguishability of the search results. After the text content is divided into several semantically complete text blocks, the vector corresponding to each text block represents a single topic, and the similarity with the query can be clearly distinguished.

[0112] Furthermore, assigning block identifiers to each text block serves to provide a consistent reference for that text block across different locations. In subsequent processing, text blocks will be entered into the vector database as vectors and the graph database as entity nodes, respectively. The storage structures of the two are different. Using block identifiers as a common reference allows entity nodes in the graph database to trace back to their source text block, thereby obtaining the vector and original text content of that text block in the vector database.

[0113] One approach is to segment the text content into equal-length segments based on a preset number of characters, while retaining an overlap between adjacent text blocks. This ensures that semantics spanning the segmentation points are represented in both text blocks. Another approach is to input the text content into a language model, which then identifies the boundaries of semantically complete segments and segments the text according to these boundaries, resulting in each text block possessing independent semantic integrity.

[0114] It should be noted that using a language model to identify semantic boundaries results in text blocks with better semantic integrity than equal-length segmentation. This is because equal-length segmentation uses the number of characters as the basis for segmentation, and the segmentation position may fall in the middle of a complete semantic unit, causing the semantic unit to be divided into two text blocks, and the vector corresponding to either text block cannot fully represent the semantic unit. In contrast, a language model can identify the start and end positions of semantics, and its segmentation can ensure that each text block contains a complete semantic unit.

[0115] Step 303: Convert each text block into a text block vector, and associate and store the text block vector, block identifier, and metadata in the vector database.

[0116] The text block vector can be a multidimensional numerical sequence corresponding to a text block and used to represent the semantics of the text block in the vector space.

[0117] Understandably, the semantic similarity between natural languages ​​is difficult to measure directly. However, the vectors obtained by the embedding model are in the same vector space. Texts with similar semantics have vectors that are also close to each other in this space. Therefore, the degree of similarity between them can be measured by the distance or angle between the vectors.

[0118] Furthermore, storing text block vectors in association with block identifiers and metadata allows search results to be restored to readable content with their attributes. A vector itself is merely a set of numerical values; the retrieved vectors need to be traced back to their corresponding text blocks via block identifiers before they can be read by the user. Storing metadata along with the vectors allows filtering and sorting steps to obtain the attributes of the knowledge without accessing other storage.

[0119] One approach is to input the text block into the embedding model and use the vector output by the model as the text block vector. Another approach is to concatenate the text block with the title or chapter title of its document before inputting it into the embedding model, so that the resulting text block vector includes the context of the text block.

[0120] It should be noted that the content stored in the vector database associated with the text block vector can also include the original text fragment of that text block. Therefore, after retrieving the text block vector, its original text fragment can be directly obtained from the same storage location and output, without needing to query other storage locations, thus shortening the retrieval response time.

[0121] Step 304: Identify multiple entities corresponding to multiple text blocks and determine the entity type of each entity.

[0122] In this context, an entity can be an independently referential object appearing in the content recorded in the text block; it can be equipment, a fault phenomenon, a handling measure, or personnel, etc. An entity type can be an identifier used to indicate the category to which the entity belongs; it can be a device type, a phenomenon type, a measure type, etc.

[0123] Understandably, the semantics in a text block are expressed in the form of continuous sentences, in which the relationships between objects are mixed in the same text; first, the objects are identified one by one, and then the relationships between the objects are determined on this basis.

[0124] Furthermore, the possible associations between entities of the same type and between entities of different types are different. For example, an equipment entity and a phenomenon entity may have an association of "manifestation as", while a phenomenon entity and a measure entity may have an association of "processing method as". Determining the type of each entity in advance can ensure that the subsequent association determination is within a reasonable range.

[0125] One approach is to input a text block into a language model and use prompt words to instruct the model to output the entities involved and their types. Another approach is to use a pre-trained named entity recognition model to process the text block and obtain the entities and their types.

[0126] It should be noted that using language models for entity recognition has a wider range of applications than pre-trained named entity recognition models. This is because the types of entities that named entity recognition models can recognize are determined by their training data. When the domain of the knowledge base changes, the data needs to be re-annotated and retrained. In contrast, language models can specify the types of entities to be recognized through prompts, and only the prompts need to be adjusted when the domain changes. This allows the knowledge graph construction process to be independent of manual annotation and expert rules.

[0127] Step 305: Merge entities that point to the same object into a single entity and associate the block identifiers of each entity before merging with the merged entity.

[0128] Among them, referring to the same object can be used to indicate that two entities have different descriptions, but the objects they refer to are the same, such as the model name and common name of the same equipment, or the full name and abbreviation of the same measure.

[0129] Understandably, the same object often appears in different expressions in different text blocks. If each expression is saved as an independent entity, the object will correspond to multiple isolated entity nodes in the graph database. Each node carries the associations in its respective text block, and during traversal, only the associations carried by one of the nodes can be reached. After merging the expressions into the same entity, the associations that were originally scattered in multiple text blocks converge on the same entity node. Starting from this node, all related objects can be reached, and the cross-document association path is thus established.

[0130] Furthermore, associating the block identifiers corresponding to each entity before merging with the merged entity serves to preserve the source of knowledge. The merged entity node originates from multiple text blocks, and therefore has multiple corresponding block identifiers. When reaching the entity node along the relation edges during the retrieval process, all related text blocks can be obtained through these multiple block identifiers, thus enabling a single associated entity to access knowledge from multiple documents simultaneously.

[0131] One approach is to convert the names of each entity into vectors, and then identify entities whose vectors have a similarity exceeding a preset threshold as pointing to the same object. Another approach is to input each entity and its corresponding text block into a language model, which will then determine whether they point to the same object.

[0132] It should be noted that the above merging can be carried out within the same knowledge base identifier. This is because entities in different knowledge bases belong to different users, and even if they have the same name, the objects they refer to may be different; limiting the merging to the same knowledge base identifier can keep the knowledge of each user independent.

[0133] Furthermore, the above merging also applies to the process of adding new documents to the database. After a new document to be added to the database is processed to obtain its entity, this entity can be compared with existing entity nodes in the graph database to determine if they are the same object. If they are determined to be the same object, the block identifier of the new document is appended to the existing entity node, and the relationships involved by the entity in the new document are added to its relation edges; if they are determined to be a new object, a new entity node is created. In this way, the knowledge carried by the new document can be incorporated into the existing entity relationship graph, and the association between it and existing documents is established during the database entry process. During retrieval, the knowledge in both the old and new documents can be accessed simultaneously through the same entity node.

[0134] Step 306: Determine whether there is a semantic relationship between any two of the merged entities, and determine the relationship type for the entity pairs that have a semantic relationship, thereby obtaining the relationship between the multiple entities.

[0135] Semantic association can be used to indicate that two entities have a certain relationship in the recorded knowledge, such as inclusion, membership, initiation, processing, causation, etc. Association type can be an identifier used to indicate which category the above relationship belongs to.

[0136] Understandably, although the entities obtained through the aforementioned steps have been identified and merged, there is still no connection between the entities. At this point, the graph database only has nodes and no edges, so edge traversal is impossible. Only after determining the semantic relationships between pairs of entities and establishing relational edges can the graph database have a path from one entity to another, and the semantic expansion in the retrieval process will thus have a basis.

[0137] Furthermore, different association types represent different connection strengths and properties. During the retrieval process, the traversal path can be selected accordingly, and the traversal can only continue along the association types that match the intent of the current query, thereby making the association between the obtained associated entities and the user's query instructions clearer.

[0138] One approach is to input the merged entities along with their respective text blocks into a language model, which then determines whether semantic relationships exist between entity pairs and outputs the corresponding relationship type. Another approach is to establish relationships of the appropriate type for entity pairs that meet pre-defined relationship rules.

[0139] In one implementation, the association type, the credibility of the association, the source text block, and other attributes can be saved as attributes of the relation edge, so that the path can be selected based on the attributes of the relation edge during traversal, for example, only traversing along relation edges with a credibility higher than a preset value.

[0140] Step 307: Generate an entity relationship graph with multiple entities as entity nodes and relationships as relationship edges, store the entity relationship graph in the graph database, and associate each entity node with its corresponding block identifier.

[0141] Among them, the entity relationship graph can be a graph composed of entity nodes and relationship edges, used to represent the relationship structure between entities.

[0142] Understandably, if entities and relationships are stored in a table format, finding an entity's related entities requires scanning row by row and performing multiple join operations. When traversing multiple layers of relationships, the amount of computation increases rapidly with the number of layers. After storing them in a graph structure and storing them in a graph database, reaching an adjacent node from an entity node along its relation edge is a direct pointer jump. The amount of computation for multiple layers of traversal is comparable to the number of edges traversed, thus enabling semantic expansion during the retrieval process to be completed within an acceptable time.

[0143] Furthermore, associating each entity node with its corresponding block identifier establishes a retrieval path between the graph database and the vector database. Following step 303, the text block vectors in the vector database are already associated with their block identifiers; similarly, in this step, the entity nodes in the graph database are also associated with their block identifiers. Thus, the same block identifier exists simultaneously in both databases. Entity nodes obtained by traversing the graph database can retrieve their corresponding text block vectors and original text fragments from the vector database via their associated block identifiers, enabling mutual indexing of data between the two databases.

[0144] One implementation approach is to save the entity node's name, entity type, knowledge base identifier, description, and block identifier as attributes of the node, and save the association type as an attribute of the relation edge. Another approach is to maintain a separate table mapping block identifiers to entity nodes, which can be queried when needed.

[0145] In one implementation, the above-mentioned construction process can be executed in parallel on multiple documents to be added to the database, and each document to be added to the database can be checked for duplicates before execution. Understandably, the initial establishment of an enterprise knowledge base typically involves thousands to tens of thousands of documents. Vector transformation and entity extraction both require calling model inference. When processed sequentially, the time consumed per document accumulates, making the knowledge base establishment cycle unacceptably long. Distributing multiple documents to be added to the database to multiple processing units for parallel execution, with no dependencies between documents, makes the overall time inversely proportional to the degree of parallelism. Furthermore, it is common for the same document to be uploaded repeatedly through different channels. As one implementation, the content feature value of the document to be added to the database can be calculated before parsing. This feature value can be compared with the content feature values ​​of already added documents. If the comparison matches, the text block vectors and entity nodes corresponding to the already added document can be directly reused, and subsequent processing can be skipped. As another implementation, the comparison can be performed block by block after segmentation, allowing documents with partially identical content to reuse the processing results of their identical parts.

[0146] It should be noted that the vector transformation described in step 303 and the entity extraction described in steps 304 to 307 both use the text block obtained in step 302 as input and are independent of each other, thus they can be executed in parallel. Therefore, the processing time for a single document is close to the longer of the two processes, rather than the sum of the two.

[0147] Step 308: Obtain the context information associated with the user's query command.

[0148] The contextual information includes at least one of the following: conversation history, user preferences, and long-term memory. Conversation history can be the query commands and responses previously entered by the user in the current conversation. User preferences can be data characterizing the user's areas of interest and content preferences; these can be explicitly set by the user or derived from their past usage behavior. Long-term memory can be factual data related to the user that is continuously stored across multiple conversations, such as their job title, the equipment they are responsible for, and previously confirmed conclusions.

[0149] Understandably, in continuous dialogues, users often use pronouns to refer to previously mentioned objects or directly omit the subject and qualifiers. If such instructions are viewed in isolation, their semantics are incomplete, and the semantics represented by the generated query vector deviates from the user's actual intention. Introducing conversation history, user preferences, and long-term memory can restore the omitted components and make the semantics represented by the query vector consistent with the user's actual intention.

[0150] One approach is to retrieve the content of the most recent rounds of conversation in the current session as the session history. Another approach is to retrieve user-defined tags representing areas of interest as user preferences, and to retrieve persistently stored user-related facts as long-term memory.

[0151] Step 309: Perform semantic completion on the user's query command based on the context information to obtain the completed query command, and convert the completed query command into a query vector.

[0152] The completed query instruction can be a query instruction obtained by adding the omitted components to the user's query instruction and standardizing the expression.

[0153] Understandably, semantic completion incorporates the relevant components of the current query contained in the context into the query command, so that the completed query command has complete semantics even when it is removed from the context; the position of the generated query vector in the vector space is therefore closer to the user's actual intention, and the retrieval results of the first knowledge set are thus more accurate.

[0154] One approach is to input the user's query command along with contextual information into the language model, and then use prompt words to instruct the language model to output the completed query command. Another approach is to replace pronouns in the query command with the corresponding specific objects from the conversation history according to preset referential resolution rules.

[0155] It should be noted that the supplemented components can be limited to those directly related to the current query. If too many components are supplemented, the semantics of the completed query will be biased towards contextual information and deviate from the query itself.

[0156] Step 310: Based on the query vector, retrieve the candidate knowledge set from the vector database, and filter the candidate knowledge set to obtain the first knowledge set.

[0157] The candidate knowledge set can be a collection of knowledge initially retrieved from a vector database based on the query vector.

[0158] Understandably, if knowledge is retrieved with stricter conditions during the retrieval process, relevant knowledge that differs slightly from the query command will be excluded at this stage, and subsequent steps will not be able to include it. By first obtaining a larger set of candidate knowledge with more lenient conditions, more relevant knowledge can be included in the processing scope. Then, the filtering step will remove those that are not suitable for output one by one according to multiple conditions, thereby ensuring the quality of the results while maintaining the coverage.

[0159] As one implementation method, filtering can include at least one of the following four items: First, inputting candidate knowledge and user query instructions into a language model, whereby the language model determines the degree of relevance between the two and filters out candidate knowledge with a relevance lower than a preset relevance threshold, thereby eliminating those with similar expressions but whose actual content is irrelevant to the query; Second, determining the knowledge status of candidate knowledge based on the metadata associated with it, and filtering out candidate knowledge with an invalid knowledge status, thereby eliminating those that have been replaced by new versions or marked as obsolete; Third, calculating the content similarity between pairs of candidate knowledge, and deduplicating candidate knowledge with a similarity higher than a preset similarity threshold, thereby eliminating multiple copies generated due to multiple revisions of the document; Fourth, comparing the content tags of candidate knowledge with user preferences, and filtering out candidate knowledge that does not match user preferences, thereby ensuring that the output results match the actual needs of users in different positions.

[0160] It should be noted that the above four items can be executed sequentially in their order of arrangement. Therefore, the amount of knowledge processed by each item decreases progressively, while the computational cost increases sequentially. Processes with higher computational costs are therefore only applied to a smaller amount of knowledge.

[0161] In one implementation, the candidate knowledge in the candidate knowledge set can be reordered before filtering, and the candidate knowledge whose ranking results meet the preset ranking conditions can be retained. Here, the reordering can be performed by a reordering model, which takes the query command and candidate knowledge as paired inputs and outputs the matching degree between the two. Understandably, the similarity between vectors is calculated by converting the query and knowledge into vectors independently, without referencing each other during the conversion process; while the reordering model processes them in pairs, and its output matching degree more finely characterizes the semantic closeness than the former. According to this, retaining the candidate knowledge ranked higher can improve the quality of the first knowledge set.

[0162] In one implementation, the complexity of the user's query instruction can be determined, and the subsequent processing path can be established accordingly. The complexity can represent the number of objects involved in the user's query instruction and the clarity of its intent. Understandably, graph database traversal, relevance score calculation, and secondary retrieval all consume computational resources and extend response time. For query instructions involving a single object and with a clear intent, the first knowledge set is sufficient to provide the required knowledge; in this case, the increased overhead of the above processing is unlikely to yield a corresponding improvement in accuracy. However, for query instructions involving multiple objects, or whose intent needs to be determined through the relationships between objects, semantic expansion is necessary. One implementation method is to judge based on the number of entities involved in the user's query instruction. If the number of entities is one and the similarity of the first and second knowledge items in the first knowledge set is higher than a preset value, it is determined to be a simple query. Another implementation method is to input the user's query instruction into a language model, which then determines whether it requires associative reasoning to provide an answer. When determined to be a simple query, the first knowledge set can be directly identified as the target knowledge set and output; when determined to be a complex query, step 311 and subsequent steps continue.

[0163] Step 311: Determine the key entities from the user query instructions, and traverse along the relational edges of the key entities in the graph database to obtain multiple associated entities corresponding to the key entities.

[0164] The meanings of key entities and related entities have been described above. One implementation method is to input the user's query into a language model, which then identifies the objects involved and ranks them according to their importance in the query, selecting the top-ranked objects as key entities. Another implementation method is to match the words in the user's query with the names of existing entity nodes in the graph database, identifying the successful matches as key entities.

[0165] One implementation approach is to use a breadth-first search, starting from the entity nodes corresponding to the key entities and traversing layer by layer to a preset number of layers. Another approach is to select the association type of the relationship edges during the traversal, continuing traversal only along relationship edges that match the preset association type.

[0166] It should be noted that the number of traversal levels can be adapted to the number of relation edges. If the number of levels is too small, the number of associated entities obtained will be limited, and the scope of semantic expansion will be restricted accordingly; if the number of levels is too large, the associated entities obtained will include many that are weakly related to the user's query, and the amount of computation required for subsequent processing will increase accordingly. Therefore, the number of traversal levels can be two to three.

[0167] It should also be noted that the above traversal can be limited to the range of entity nodes with the same knowledge base identifier as the one corresponding to the current query. Understandably, the same intelligent knowledge base can simultaneously include documents from multiple users. Each user's document carries its own knowledge base identifier when it is added to the database. This identifier is stored in the vector database along with the text block vector and in the graph database along with the entity nodes. During retrieval, this identifier is used to limit the retrieval range of the vector database and the traversal range of the graph database. This ensures that the knowledge touched upon in this retrieval, the entity nodes traversed, and the final target knowledge set output are all within the user's own knowledge scope. Therefore, the knowledge of each user remains independent in both storage and retrieval stages.

[0168] Step 312: Obtain the semantic similarity between the associated entity and the user's query command.

[0169] Semantic similarity can be a numerical value used to characterize the semantic closeness between related entities and user query instructions.

[0170] Understandably, although the associated entities obtained by traversing along the relation edges are related to the key entities, this association is established based on the text content when the document is entered into the database, and has no corresponding relationship with the specific intent of this query; introducing semantic similarity can give higher evaluations to those associated entities that are close to this query themselves.

[0171] One approach is to convert the names of the related entities and the user's query command into vectors, and then use the cosine similarity between these vectors as the semantic similarity. Another approach is to concatenate the name of the related entity with its description before conversion, so that the resulting semantic similarity reflects the specific meaning of the related entity.

[0172] Step 313: Determine the path decay factor based on the path depth of the associated entity relative to the key entity during traversal, and count the frequency of occurrence of the associated entity during traversal; wherein, the path decay factor decreases as the path depth increases.

[0173] Here, path depth can be the number of relational edges traversed from the entity node corresponding to the key entity to the entity node corresponding to the associated entity. Path decay factor can be a numerical value corresponding to path depth, used to characterize the strength of the association between the associated entity and the key entity. Frequency of occurrence can be the number of times the associated entity is reached during the traversal.

[0174] Understandably, for related entities directly connected to a key entity, the connection is clearly defined by a single relational edge. However, for related entities indirectly connected via multiple relational edges, the connection weakens with each level of transmission. If related entities at different path depths are treated equally, entities at a greater distance will be affected in the same way as those closer to the key, causing the expanded semantics to deviate from the original query's target. Decreasing the path decay factor as path depth increases ensures that the evaluation of a related entity aligns with the actual strength of its connection to the key entity.

[0175] Furthermore, if the same related entity can be reached from the key entity via multiple different paths, it indicates that the connection between it and the key entity is recorded in multiple places in the knowledge base, and the connection is therefore more reliable than one with only one path; incorporating the frequency of occurrence into the evaluation can give related entities with multiple confirmations a higher evaluation.

[0176] One implementation method is to take the path decay factor as a power of the path depth with a base less than one, causing it to decrease exponentially as the path depth increases. Another implementation method is to take the path decay factor as the reciprocal of the path depth, causing it to decrease inversely as the path depth increases.

[0177] Step 314: Calculate the initial relevance score of the associated entities based on semantic similarity, path decay factor, and frequency of occurrence.

[0178] The initial relevance score is a numerical value calculated from the above three data points and used to initially characterize the degree of association between the related entity and the user's query command.

[0179] Understandably, semantic similarity reflects how closely related entities are to the current query, path decay factor reflects the tightness of their connection with key entities, and frequency of occurrence reflects the sufficiency of the connection in the knowledge base. Each of the three describes one aspect of the degree of association, and each has its limitations when used alone. For example, evaluating solely based on semantic similarity will give high scores to entities whose names are close to the query but have no actual connection in the knowledge base, while evaluating solely based on path decay factor will give all directly connected related entities the same evaluation.

[0180] One approach is to assign appropriate weights to the three data points and then sum them using a weighted average to obtain an initial relevance score. Another approach is to first normalize the three data points to the same value range before performing a weighted sum. It should be noted that the sum of the three weights can be set to one, thus ensuring that the resulting initial relevance score falls within the same value range as the three data points.

[0181] Step 315: Map the initial relevance score to a preset number of discrete levels, and filter out associated entities whose discrete levels are lower than a preset level threshold.

[0182] Among them, the discrete level can be an identifier used to characterize the degree of correlation, which is obtained by dividing the initial correlation score according to the value range.

[0183] Understandably, the initial relevance score is a continuous value, and its value is affected by factors such as the calculation method of semantic similarity and the specific distribution of the traversal path, resulting in slight fluctuations. If this score is directly used as the weight of the vector superposition, the fluctuations will be directly transmitted to the enhanced query vector. After mapping it to several discrete levels, the score fluctuations within the same level range are grouped into the same level, and the weights remain stable.

[0184] Furthermore, among the associated entities obtained by traversing along the relation edges, some entities have a weak association with the user's query command. If their vectors are involved in the superposition, the enhanced query vector will shift in a direction unrelated to the current query, and the second knowledge set obtained from it will therefore contain a large amount of irrelevant knowledge. By removing such associated entities before superposition, the direction of the enhanced query vector can be focused on the direction that is indeed related to the current query.

[0185] One approach is to divide the initial relevance score range into a predetermined number of intervals, and determine the discrete level based on the interval the score falls into. Another approach is to divide the intervals according to the distribution of scores for each associated entity, ensuring that each level contains a similar number of associated entities.

[0186] It should be noted that the number of discrete levels can be five. If the number of levels is too small, related entities with different degrees of association will be grouped into the same category, resulting in insufficient differentiation; if the number of levels is too large, the differences between levels will be close to continuous values, and the effect of suppressing fluctuations will be weakened.

[0187] Step 316: Obtain the matching results between the retained associated entities and user preferences and user historical behavior, determine the adjustment coefficient based on the matching results, and adjust the initial relevance score with the adjustment coefficient to obtain the relevance score of the associated entities.

[0188] The user's historical behavior can be a record of the user's past operations in this intelligent knowledge base, which may include clicks, viewing duration, confirmations, feedback, etc. The adjustment coefficient can be a value determined based on the above matching conditions, used to increase or decrease the initial relevance score.

[0189] Understandably, the initial relevance score obtained through the aforementioned steps is entirely determined by the content and structure of the knowledge base itself, and is the same for all users. However, the actual needs pointed to by the same query command differ for different users. For example, for the same equipment name, maintenance personnel are concerned with troubleshooting, while procurement personnel are concerned with its technical parameters. Incorporating user preferences and historical user behavior into the evaluation can improve the relevance of related entities that match the user's focus, thereby enhancing the direction of the query vector's offset to align with their actual needs.

[0190] As one approach, matching criteria can include the degree to which the associated entity matches the user's interest tags, the frequency with which the associated entity has been clicked in the user's historical behavior, and the types of feedback the user has previously given to the knowledge corresponding to the associated entity.

[0191] One approach is to assign an adjustment coefficient to each matching condition, sum the adjustment coefficients, and then multiply the sum of these coefficients by the initial correlation score to obtain the correlation score. Another approach is to directly add each adjustment coefficient to the initial correlation score.

[0192] It should be noted that positive matches correspond to positive adjustment coefficients, and negative matches correspond to negative adjustment coefficients. Therefore, related entities that align with the user's concerns receive higher scores, while related entities for which the user has previously expressed negative feedback receive lower scores. The direction of semantic expansion continuously adjusts as the user interacts with the platform.

[0193] Step 317: Obtain the block identifier associated with each associated entity.

[0194] Understandably, after step 307, each entity node in the graph database has been associated with and stored as a block identifier of the text block from which it originated; the associated entities obtained by traversing along the relation edges correspond to the entity nodes in the graph database, and the block identifier associated with the node can be obtained from the node. The block identifier also exists in the vector database, thus providing a basis for cross-database data retrieval.

[0195] One approach is to read the block identifier attribute of an entity node during the traversal process. Another approach is to query the block identifiers of the corresponding entity nodes in batches according to the retained associated entities after the traversal is complete.

[0196] Step 318: Based on the block identifier, retrieve the text block vector associated with the block identifier from the vector database, and use the text block vector as the vector of the associated entity.

[0197] Understandably, using text block vectors as vectors for associated entities serves to ensure that the semantics represented by the vector align with the actual meaning of the associated entity within the knowledge base. Associated entities exist as names in graph databases, and the same name can refer to different objects and carry different meanings in different domains and knowledge bases. For example, the same term may have different meanings in technical documents and management regulations. If only the name is converted into a vector, the resulting vector represents the general meaning of the name detached from its context, and the resulting enhanced query vector will shift in a direction unrelated to the knowledge base. However, text block vectors, converted from the entire text block from which the associated entity originates during the construction phase, represent the specific context of the associated entity within the knowledge base. Using them as vectors for associated entities ensures that the shift direction of the enhanced query vector falls within the semantic distribution of the knowledge base itself.

[0198] Furthermore, since the text block vector has already been generated and stored in step 303, it can be retrieved here by block identifier without having to call the embedding model again for conversion, thus shortening the response time of this retrieval.

[0199] As one implementation, when a certain associated entity is associated with multiple block identifiers, the average of the text block vectors corresponding to each block identifier can be taken as the vector of the associated entity. Alternatively, the text block vector corresponding to the one with the highest semantic similarity to the user's query command can be taken as the vector of the associated entity.

[0200] Step 319: Combine the user query command with each associated entity to generate a reconstructed query command, and convert the reconstructed query command into a reconstructed query vector.

[0201] Specifically, the reconstructed query instruction can be a query instruction that has undergone semantic expansion at the textual level, obtained by combining the user's query instruction with the retained associated entities. The reconstructed query vector can be a multidimensional numerical sequence corresponding to the reconstructed query instruction, used to represent the semantics of the instruction in a vector space.

[0202] Understandably, after the user query command and related entities are combined at the text level, the resulting reconstructed query command already contains the descriptions corresponding to each related entity. When the whole is converted into a vector, the embedding model will process the semantic relationship between the query command and each related entity together. The resulting reconstructed query vector is therefore a semantically fused whole. Using this reconstructed query vector as the basis for subsequent superposition is better than using the original query vector as the basis.

[0203] One approach is to concatenate the user's query command with each associated entity in descending order of relevance score, and then input this concatenation into a language model. The language model will then generate a fluent and semantically complete reconstructed query command. Another approach is to use a pre-defined sentence template, filling the user's query command and associated entities into the corresponding positions to obtain the reconstructed query command.

[0204] It should be noted that the related entities participating in the combination can be limited to a few with high relevance scores. Too many related entities participating in the combination will make the reconstructed query too long, and the semantics represented by it will be scattered by numerous related entities, thus deviating from the main focus of this query.

[0205] Step 320: Using the relevance scores of the associated entities as weights, the vectors of the associated entities are superimposed onto the reconstructed query vector to obtain the enhanced query vector.

[0206] Understandably, when expanding a query command only at the text level, all related entities enter the same statement, and their weight in the corresponding vector is uniformly determined by the embedding model during transformation, resulting in a near-equal influence among related entities. However, the actual degree of relevance between related entities in the knowledge base and the current query varies significantly. This equal influence means that entities with weak or strong relevance will have an equal impact on the retrieval direction. After weighted superposition at the vector level, the vectors of each related entity are multiplied by their relevance scores and then summed. Their contribution to enhancing the query vector's offset is proportional to the relevance score, thus the retrieval direction is dominated by entities with strong relevance. Therefore, text-level reconstruction enables semantic integration, while vector-level superposition allows for precise allocation of the expansion range according to the degree of relevance.

[0207] One approach is to multiply the vectors of each associated entity by its relevance score, and then add them dimension-by-dimensionally to the reconstructed query vector to obtain the enhanced query vector. Another approach is to normalize the relevance scores before adding them, ensuring the sum remains within a preset range, so that the reconstructed query vector maintains its dominant position in the overall result.

[0208] It should be noted that the enhanced query vector can be normalized after the overlay is completed. This is because the similarity calculation in the vector database is usually based on the angle between vectors, and the magnitude of the overlaid vector is larger than that of the original vector. After normalization, the magnitude of the enhanced query vector is comparable to that of each text block vector in the vector database, thus making the similarity calculation result more stable.

[0209] Step 321: Calculate the similarity between the enhanced query vector and each text block vector in the vector database, and determine the knowledge corresponding to the text block vector whose similarity meets the preset retrieval conditions as the second knowledge set.

[0210] Understandably, the vector database used in this step is the same one used in step 310. The difference between the results obtained from retrieving the enhanced query vector from the same vector database and the results obtained from the first retrieval stems entirely from the change in the query vector itself. Since the enhanced query vector has shifted towards the direction of the associated entities, the similarity between text block vectors that are semantically close to the associated entities but differ from the original query instruction and the enhanced query vector is increased, thus entering the second knowledge set. The same vector database is used twice, eliminating the need to create separate indexes for semantic expansion, thereby saving storage and maintenance costs.

[0211] One approach is to pre-select the top few items in a ranking based on similarity, from highest to lowest. Another approach is to pre-select items whose similarity exceeds a pre-defined similarity threshold.

[0212] It should be noted that the number of the second knowledge set can be less than the number of the candidate knowledge set in step 310. Since the semantics represented by the enhanced query vector has been expanded by the related entities, the search results are more focused, and a smaller number can cover the knowledge touched by the expansion. The role of the candidate knowledge set is to ensure the initial coverage, so a larger number is used.

[0213] Step 322: Merge the first knowledge set and the second knowledge set, and remove duplicates from the merged knowledge set to obtain the knowledge set to be evaluated.

[0214] The knowledge set to be evaluated can be a collection of knowledge that has been merged and deduplicated and is used in subsequent scoring and ranking.

[0215] Understandably, the difference between the first and second knowledge sets stems from the difference in the vectors used during retrieval. The first knowledge set is retrieved using the query vector, and text blocks with high similarity to it are close to the query instruction in expression. The second knowledge set is retrieved using an enhanced query vector, whose position has been shifted according to relevance scores towards the directions of the associated entities. Text blocks with high similarity to it are close to the associated entities in expression. Thus, the two sets of knowledge cover two categories: expression similarity and relevance similarity, respectively. Knowledge that differs significantly from the query instruction in expression but contains relevant content about associated entities has a lower similarity in the first knowledge set and a higher similarity in the second knowledge set. Only after merging the two sets of knowledge can this knowledge be included in the output range.

[0216] Furthermore, the two batches of knowledge are retrieved from two vectors that are close to each other, and their results overlap. At the same time, the same knowledge may exist in the knowledge base as multiple copies with similar content due to multiple revisions of the document. If all such duplicate knowledge is sorted, the output results will contain multiple entries with the same or similar content, occupying the space that could be used to present other related knowledge.

[0217] As one implementation method, deduplication can include merging knowledge with the same block identifier and keeping only one of them; the same block identifier means that the two originate from the same text block and their contents are exactly the same. This method has the least computational overhead and can be the first process to be executed.

[0218] As another implementation method, deduplication can also include calculating the similarity between the vectors corresponding to each piece of knowledge and merging knowledge with a similarity higher than a preset threshold; knowledge with different block identifiers but highly similar vectors usually consists of different versions or different expressions of the same document.

[0219] As another implementation method, deduplication can also include inputting knowledge pairs with vector similarity in the middle range into the language model, and the language model determines whether the content expressed by the two is the same, and merges those that are determined to be the same; when the same content is recorded in a way that is very different, the similarity between their vectors may be lower than a preset threshold and cannot be identified by the former method.

[0220] The three deduplication methods described above can be used in the order listed. It should be noted that when using them in this order, methods with lower computational overhead are processed first to reduce the amount of knowledge, while methods with higher computational overhead are only applied to the remaining knowledge, thus controlling the overall computational overhead.

[0221] Step 323: Determine the semantic score of the knowledge to be evaluated based on the hit rate of each knowledge in the knowledge set to be evaluated to the associated entities and the relevance score of the hit associated entities.

[0222] The hit rate indicates which related entities appear in the content of the knowledge to be evaluated. The semantic score is a numerical value used to characterize the semantic similarity between the knowledge to be evaluated and the current query.

[0223] Understandably, through the aforementioned steps, each associated entity has obtained a relevance score reflecting its degree of relevance to the current query. If a piece of knowledge to be evaluated matches an associated entity with a high relevance score, it indicates that the content recorded by that knowledge falls within the semantic scope pointed to by the expanded query, and its semantic score should therefore be high. If the associated entity it matches has a low relevance score, or if it does not match any associated entities, its semantic score will be correspondingly low. Thus, the semantic score inherits the evaluation results accumulated in the aforementioned steps, rather than recalculating the similarity.

[0224] One approach is to sum the relevance scores of all associated entities matched by the knowledge to be evaluated to obtain the semantic score of the knowledge. Another approach is to factor in the similarity between the knowledge to be evaluated and the user's query instruction in the summed scores.

[0225] Step 324: Determine the timeliness score of the knowledge to be evaluated based on its duration of existence, and determine the feedback score of the knowledge to be evaluated based on the type of user feedback received by the knowledge to be evaluated; wherein, the timeliness score decreases as the duration of existence increases.

[0226] The duration of existence can be the time elapsed from the creation time of the document from which the knowledge to be evaluated originated to the present time. The timeliness score can be a numerical value used to characterize the newness or staleness of the knowledge to be evaluated. User feedback can be the evaluations made by users during their past use of the knowledge, and its types can include positive confirmation, negative confirmation, reports, and ignores. The feedback score can be a numerical value used to characterize the degree of recognition the knowledge to be evaluated has previously received.

[0227] Understandably, the content recorded in knowledge gradually loses its applicability as the objects it describes change; for example, a device's processing flow changes with firmware upgrades. If ranking is based solely on semantic closeness, older knowledge with closer wording will continue to occupy higher positions. Allowing timeliness scores to decay with increasing storage duration allows newly added knowledge to achieve higher rankings with equal semantic closeness. Furthermore, whether a piece of knowledge truly solves a user's problem is judged by the user's actual usage results, which are accumulated in the knowledge base as user feedback. Incorporating this into the ranking criteria allows previously positively validated knowledge to gradually rise, while previously criticized or negatively evaluated knowledge gradually sinks. The knowledge base thus possesses the ability to self-adjust with time and usage.

[0228] One implementation method is to assign a time-sensitive score to a power less than one, with the ratio of duration to a preset decay period as the exponent, causing it to decay exponentially as duration increases. Another implementation method is to assign a time-sensitive score that decreases linearly with duration, and sets it to zero when duration exceeds a preset upper limit.

[0229] It should be noted that the aforementioned decay period can be set according to the domain of the knowledge to be evaluated. This is because the update speed of knowledge varies in different domains. For example, software configuration knowledge is updated more frequently, while basic principle knowledge remains applicable for a longer period of time. Using the same decay period for different domains will cause knowledge in the slower-updating domains to have its weight reduced prematurely.

[0230] One approach is to assign a score to each type of user feedback, and then sum the scores of all feedback received to obtain the feedback score. Positive confirmations correspond to positive scores, while negative confirmations and reports correspond to negative scores. Another approach is to assign greater weight to more recent feedback, allowing the feedback score to better reflect recent usage.

[0231] Step 325: Calculate the comprehensive score of the knowledge to be evaluated based on the semantic score, timeliness score, and feedback score.

[0232] The overall score is a numerical value that is calculated by combining the above three scores and is used to characterize the overall priority of the knowledge to be evaluated.

[0233] Understandably, the semantic score reflects how closely the knowledge relates to the current query, the timeliness score reflects the freshness of the knowledge itself, and the feedback score reflects the level of recognition the knowledge has previously received. These three aspects are independent of each other, and any one of them alone has its limitations as a ranking criterion. After combining the three, knowledge that is close to the query, relatively recent, and has received positive feedback in the past will be ranked at the highest position, meeting the user's actual needs.

[0234] One approach is to first normalize the three scores to the same range, then assign them appropriate weights and sum them to obtain a comprehensive score. Another approach is to first sort by semantic score, and then make local adjustments to the sorting result using the timeliness score and feedback score.

[0235] It should be noted that the three scores fall within different ranges before normalization. The semantic score varies with the number of associated entities hit, the timeliness score is between zero and one, and the feedback score can be positive or negative. If a weighted sum is directly applied, the score with the larger range will dominate the calculation result, and the effects of the other two scores will be masked. Only after normalization can each score accurately reflect its proportion in the ranking.

[0236] Furthermore, the weights of the above three items can be configured according to the application scenario. In scenarios with high timeliness requirements, the weight of the timeliness score can be increased; in scenarios where the knowledge base has accumulated a lot of user feedback, the weight of the feedback score can be increased.

[0237] Step 326: Sort the knowledge sets to be evaluated according to the comprehensive scores, and determine the knowledge sets to be evaluated that meet the preset output conditions as the target knowledge sets, and output the target knowledge sets.

[0238] One implementation method is to preset the output condition as the top few scores arranged from highest to lowest. Another implementation method is to preset the output condition as the overall score being higher than a preset score threshold.

[0239] Furthermore, based on the block identifiers associated with each piece of knowledge in the target knowledge set, the original text fragments associated with those block identifiers are retrieved from the vector database and output. Understandably, the objects processed in the preceding steps are vectors and fractions, which do not contain readable text; while the block identifiers are stored in the vector database along with the original text fragments during the construction phase, allowing the sorting results to be restored to the original knowledge content through a query. Thus, the block identifiers assigned during the construction phase serve two functions during the retrieval process: first, enabling the associated entities in the graph database to obtain their corresponding text block vectors; second, enabling the final sorting results to be restored to the original text content.

[0240] In one implementation, the similarity and overall score of each piece of knowledge can be provided along with the output, so that users can understand the basis for the ranking of the knowledge in the corresponding position.

[0241] In one implementation, the target knowledge set, along with the user's query command, can be input into a language model. The language model then generates and outputs the response, and marks the source of the knowledge used in each paragraph within the response.

[0242] In one implementation, user feedback on the output knowledge can be received and recorded in the corresponding knowledge's user feedback log for subsequent retrieval calculations of feedback scores. This creates a loop between the knowledge base's output and user feedback, allowing the knowledge base to continuously adjust its ranking as it is used.

[0243] In traditional retrieval enhancement generation schemes, the knowledge base construction process and the retrieval process are separated. Even when a knowledge graph is introduced, the graph is usually maintained independently of the vector database, and there is a lack of usable correspondence between the two. In the above implementation, by assigning block identifiers to each text block during the construction process and associating these block identifiers with both the text block vectors in the vector database and the entity nodes in the graph database, a clear access path is established between the two databases. During the retrieval process, the associated entities obtained by traversing along the relation edges can directly obtain the already generated and stored text block vectors through their block identifiers. Furthermore, by merging entities pointing to the same object into the same entity node and aggregating their block identifiers, the associations originally scattered across multiple documents are aggregated onto the same node. A single traversal starting from this node can access the knowledge in multiple documents. Compared to the existing technology where the knowledge graph and vector database are independent and the conclusions obtained from the graph are difficult to reduce to specific knowledge, this embodiment allows the associations discovered by the graph to be transformed into text block vectors that can directly participate in vector calculations, thus improving both the accuracy of retrieval and the utilization efficiency of the knowledge base. To make the technical solution of this application clearer, the following will further explain the construction method of the above-mentioned intelligent knowledge base and the knowledge retrieval method based on the intelligent knowledge base, in combination with specific application scenarios.

[0244] like Figure 3 As shown, in an exemplary embodiment, during the construction phase of the intelligent knowledge base, the server receives documents uploaded by users. These documents can be portable document format files, word processing documents, plain text files, or hypertext markup language files. The server parses the documents according to various formats and extracts metadata from them. The extracted metadata includes file_id, kb_id, and status, i.e., file ID, knowledge ID, and knowledge status, etc. The extracted metadata is then stored in MySQL.

[0245] Subsequently, the server segments the text based on LLM and assigns a chunk_id to each chunk. At this point, the metadata of the same document has been stored in MySQL, and its text content has been divided into several chunks carrying chunk_ids. The construction process is thus divided into two parallel processes.

[0246] One of the steps involves vectorization. The server embeds the model into vectors via embedding, converting each block into a corresponding vector, and stores the vectors and metadata in a vector database. This vector database can use Qdrant, and its vector data payload includes chunk_id, kb_id, file_id, and the original text fragment.

[0247] The other branch is ontology extraction processing. The server extracts the ontology, identifies entities, and extracts relationships based on LLM, obtaining the entities and relationships between entities from each block, and stores the ontology in a graph database. This graph database can use Neo4j, and its storage content includes entity nodes and relationship edges. The attributes of the nodes include name, type, kb_id, and description, and the attributes of the edges include relationship and type.

[0248] Therefore, the same chunk_id exists simultaneously in the vector data payload of the vector database and the node attributes of the graph database, allowing the two databases to index each other using this identifier. Similarly, the file_id and kb_id in MySQL are identical to their corresponding fields in both databases, thus enabling the three databases to communicate with each other through the same set of identifiers. It should be noted that when the same intelligent knowledge base serves multiple users simultaneously, the kb_id can be used to isolate the knowledge of each user, limiting the search scope during retrieval.

[0249] like Figure 4 As shown, in the knowledge retrieval stage, for user query commands with relatively simple structures, the server can process them according to the following path: receiving input, integrating long text and memory preferences, with the aim of solving the user's personalized query understanding; rewriting the input based on LLM, performing semantic optimization and semantic completion on the input to improve the accuracy of query expression; vectorizing the query based on embedding to obtain the corresponding query vector; retrieving the Top 10 based on the vector database; and finally, returning knowledge that reaches the threshold based on the reranker model ranking, that is, only those ranking above the configured threshold are returned to the user as knowledge.

[0250] For user queries with complex structures, the server processes them using a mixed query approach. For example... Figure 5 As shown, the hybrid query includes five stages: perception, metadata filtering, association, secondary retrieval enhancement, and result integration. The specific process is as follows.

[0251] In the perception phase, the server receives input, integrates long context and memory preferences, rewrites the input based on LLM, vectorizes the query based on embedding, retrieves the Top 300 from the vector database, and returns knowledge that meets the threshold based on the reranker model ranking. Returning the Top 300 instead of the Top 10 ensures the breadth of the retrieval, resulting in more than 300 pieces of knowledge being output, thus allowing relevant knowledge with discrepancies between the description and the query to be processed as much as possible.

[0252] During the metadata filtering phase, the server performs three processes sequentially: First, filtering low-quality content based on noise and expiration, i.e., using LLM to determine the relevance between knowledge and input; content with a relevance less than a threshold is considered knowledge noise, and outdated knowledge is directly filtered out; Second, filtering redundant content, i.e., filtering knowledge with duplicate content or content similarity reaching 90%, based on the cosine similarity between knowledge vectors; Third, filtering content based on user preferences, i.e., using LLM to determine content tags; content matching user preferences is retained, while content that is not of interest is filtered out.

[0253] During the association phase, the server simulates the human thought process of making connections, discovers semantic relationships between various concepts based on the knowledge graph, and expands the semantic coverage of the query. The specific processing includes the following five steps.

[0254] The first step is to extract key entities from user queries based on LLM and sort the entities.

[0255] The second step involves querying the relationships between entities in the graph database and traversing the database to discover related concepts. For example, when the key entity is "machine learning," traversal can reveal related concepts such as "deep learning," "neural network," and "model training."

[0256] The third step is to calculate semantic relevance to prevent semantic shift. Here, the semantic relevance of each candidate concept to the original query is calculated using the following formula:

[0257] Conceptual semantic relevance = W1 × Vector similarity + W2 × Path decay factor + W3 × Frequency of occurrence

[0258] Where W1 + W2 + W3 = 1; the path decay factor is 0.5 raised to the power of depth, meaning that the factor halves with each additional layer of path depth. Concepts directly connected to key entities have a path decay factor of 0.5, those connected by two relation edges have a factor of 0.25, and those connected by three relation edges have a factor of 0.125. Understandably, this step is called "preventing semantic shift" because the candidate concepts obtained from the traversal include those with weak relevance to the original query. If these concepts participate in subsequent vector construction, they will shift the query semantics in an irrelevant direction. Only after quantifying these concepts through the above calculations can they be distinguished.

[0259] The fourth step is to assign a relevance score to each concept, which means converting the semantic relevance of the concepts obtained above into a specific and usable relevance score. This score can be discretely quantified into 5 levels, and low-level concepts can be filtered out.

[0260] The fifth step is to adjust the association strength based on user preferences and historical behavior. The calculation formula is as follows:

[0261] Final score = Original score × (1 + Cumulative adjustment factor)

[0262] The adjustment coefficients include: +0.2 for interest tag similarity matching; +0.15 for historical high-frequency clicks; +0.4 for positive feedback; and -0.4 for negative feedback. For example, if a concept has an original score of 0.60, and it matches both interest tag similarity and historical high-frequency clicks, then the cumulative adjustment coefficient is 0.35, and its final score is 0.60 × 1.35 = 0.81.

[0263] During the secondary retrieval enhancement phase, the server takes the original query and the expanded concept set as input and performs the following processes in sequence.

[0264] The first step is query reconstruction, which involves semantically combining the original query with related concepts, sequentially concatenating the two to form a new query statement, and generating a new input query through LLM.

[0265] The second step is weight allocation, which involves assigning different weights to each concept based on their relevance.

[0266] The third step is to enhance the query vector construction. This involves generating vectors for the new query and each concept using the embedding model, and then adding these vectors together using the following formula to construct a new query vector:

[0267] New query vector = New input query vector + Concept 1 relevance × Concept 1 vector + Concept 2 relevance × Concept 2 vector + ...

[0268] The fourth step is threshold adjustment, which involves adjusting the similarity threshold used in the second retrieval based on the number and relevance distribution of concepts obtained from the first query. Understandably, the position of the augmented query vector in the vector space has shifted after being superimposed. If the threshold from the first retrieval is used, the knowledge reached through expansion may be excluded due to a threshold that is too high, or a large amount of irrelevant knowledge may be introduced due to a threshold that is too low.

[0269] The fifth step is vector secondary retrieval, which involves searching the vector database using the new query vector.

[0270] The sixth step is to output enhanced search results, that is, to retrieve 20 pieces of knowledge with high similarity as the output of this stage.

[0271] During the results integration phase, the server takes the results from Phase 2 and Phase 4 (i.e., the results from the metadata filtering phase and the results from the secondary retrieval enhancement phase) and performs the following processing sequentially.

[0272] The first step is deduplication, which can be achieved through methods such as deduplication with the same chunk_id, deduplication with content similarity > 90%, and semantic deduplication based on LLM.

[0273] The second step is multi-dimensional scoring, which involves calculating three scores for each piece of knowledge after deduplication:

[0274] The semantic score is determined based on whether the extended set appears in the knowledge, and its value is the product of the concept of the extended set and its relevance.

[0275] The timeliness score is determined according to the exponential decay model. Its calculation formula is: Timeliness score = 0.5 raised to the power of (number of days since document creation ÷ domain decay cycle); where the domain decay cycle is set according to the domain to which the knowledge belongs, with a smaller value for frequently updated domains and a larger value for slowly updated domains.

[0276] The feedback score is determined by accumulating the values ​​based on the type of feedback received for that knowledge item, with positive confirmation receiving +0.2, negative confirmation receiving -0.2, reports receiving -0.2, and ignoring receiving -0.05.

[0277] The third step is to perform a comprehensive scoring, which involves normalizing all the scores mentioned above and multiplying them by their respective weights to obtain a comprehensive score:

[0278] Overall score = Semantic score × W1 + Timeliness score × W2 + Feedback score × W3

[0279] Where W1 + W2 + W3 = 1.

[0280] The fourth step is metadata mapping, which involves querying relevant knowledge fragments by chunk_id and restoring the sorted results from vectors and scores back to the original readable text.

[0281] Fifth step, output the final result, which can be in the following format:

[0282] Document 1 - Similarity 0.95, overall score 0.92;

[0283] Document 2 - Similarity 0.88, overall score 0.87.

[0284] In a practical application of a company's technical support knowledge base, maintenance personnel input the query "How to handle the continuous flashing of the indicator light after device startup". During the perception phase, the query is rewritten after incorporating previously mentioned device models from the current session, retrieving and returning the Top 300 results, which are then ranked and retained by a reranker. In the metadata filtering phase, entries with relevance below the threshold, expired status markers, and duplicate entries with 90% content similarity are filtered out. In the association phase, the key entity is "indicator light flashing", and related concepts such as "power-on self-test", "firmware version", and "reset process" are discovered. "Power-on self-test" is directly connected to the key entity, with a path decay factor of 0.5, a vector similarity of 0.62, and appears twice, placing it at a higher level after quantification. Furthermore, due to the interest tag matching, an additional 0.2 is added, ultimately increasing the score from 0.66 to 0.79. In the secondary search enhancement stage, the original query was combined with concepts such as "power-on self-test" and "reset process" to construct a new query vector, outputting 20 enhanced search results, including a document titled "Reset Process for Power-on Self-test Anomalies" that was previously difficult to find. In the results integration stage, this document had a higher semantic score because it hit two highly relevant concepts; while another old version of the processing method published three years ago, although similar in wording, had a document creation period much longer than the decay period of this field, resulting in a significant decrease in timeliness score, and had previously received negative confirmation feedback with a negative score; after normalization and weighting, the former's overall score was higher than the latter, and when outputting through metadata mapping, the actually effective processing method was placed first.

[0285] In this example, the relational edges of the graph database provide extended landing points for the query semantics, the relevance score distinguishes the influence strength of each extended landing point, the weighted superposition at the vector level makes the extension actually work in the calculation of similarity, and the comprehensive adjudication of the three scores makes the output result take into account the content closeness, the newness of knowledge, and previous usage feedback, thereby improving the accuracy of knowledge retrieval.

[0286] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0287] In other embodiments, this application proposes a knowledge retrieval system 600 based on an intelligent knowledge base, please refer to... Figure 6 The intelligent knowledge base includes vector databases and graph databases. The knowledge retrieval system 600 based on the intelligent knowledge base includes:

[0288] The first retrieval module 601 is used to respond to the user's query command, generate a query vector corresponding to the user's query command, and retrieve the first knowledge set from the vector database based on the query vector;

[0289] The relevance calculation module 602 is used to determine key entities from user query instructions, traverse along the relation edges of key entities in the graph database to obtain multiple associated entities corresponding to the key entities, and determine the relevance score of each associated entity to the degree of association with the user query instructions.

[0290] The second retrieval module 603 is used to superimpose the vectors of related entities onto the query vector using the relevance scores of related entities as weights to obtain an enhanced query vector, and retrieve the second knowledge set from the vector database based on the enhanced query vector;

[0291] Output module 604 is used to determine the target knowledge set based on the first knowledge set and the second knowledge set, and output the target knowledge set.

[0292] In one exemplary embodiment, the knowledge retrieval system 600 based on an intelligent knowledge base further includes a knowledge base construction module 605, wherein:

[0293] The knowledge base construction module 605 is used to obtain documents to be added to the database, parse the documents to be added to the database, and obtain the text content and metadata of the documents to be added to the database; to divide the text content into blocks, obtain multiple text blocks, and assign block identifiers to each text block; to convert each text block into a text block vector, and associate and store the text block vector, block identifier, and metadata in a vector database; to extract multiple entities from multiple text blocks, determine the relationships between multiple entities, generate an entity relationship graph with multiple entities as entity nodes and relationships as relationship edges; and to store the entity relationship graph in a graph database, and associate and store each entity node with its corresponding block identifier.

[0294] In one exemplary embodiment, the knowledge base construction module 605 includes an entity recognition unit 6051, an entity merging unit 6052, and a relationship determination unit 6053, wherein:

[0295] The entity recognition unit 6051 is used to recognize multiple entities corresponding to multiple text blocks and determine the entity type of each entity;

[0296] The entity merging unit 6052 is used to merge multiple entities that point to the same object into a single entity, and associate the block identifiers of each entity before merging with the merged entity;

[0297] The relationship determination unit 6053 is used to determine whether there is a semantic relationship between any two of the merged entities, and to determine the relationship type for the entity pairs that have a semantic relationship, thereby obtaining the relationship between the multiple entities.

[0298] In one exemplary embodiment, the first retrieval module 601 includes a context acquisition unit 6011, a query completion unit 6012, and a candidate filtering unit 6013, wherein:

[0299] The context acquisition unit 6011 is used to acquire context information associated with the user's query command; wherein, the context information includes at least one of the following: session history, user preferences, and long-term memory;

[0300] The query completion unit 6012 is used to semantically complete the user query command based on the context information, obtain the completed query command, and convert the completed query command into a query vector;

[0301] The candidate filtering unit 6013 is used to retrieve candidate knowledge sets from the vector database based on the query vector, and filter the candidate knowledge sets to obtain the first knowledge set.

[0302] In one exemplary embodiment, the relevance calculation module 602 includes a similarity acquisition unit 6021, a traversal statistics unit 6022, an initial scoring unit 6023, a grade quantification unit 6024, and a preference adjustment unit 6025, wherein:

[0303] The similarity acquisition unit 6021 is used to acquire the semantic similarity between related entities and user query instructions;

[0304] The traversal statistics unit 6022 is used to determine the path decay factor based on the path depth of the associated entity relative to the key entity during traversal, and to count the frequency of occurrence of the associated entity during traversal; wherein, the path decay factor decreases as the path depth increases.

[0305] The initial scoring unit 6023 is used to calculate the initial relevance score of the associated entities based on semantic similarity, path decay factor and frequency of occurrence.

[0306] The grading unit 6024 is used to map the initial correlation score to a preset number of discrete grades and filter out related entities whose discrete grades are lower than a preset grade threshold.

[0307] The preference adjustment unit 6025 is used to obtain the matching results between the retained related entities and user preferences and user historical behavior, determine the adjustment coefficient based on the matching results, and adjust the initial relevance score with the adjustment coefficient to obtain the relevance score of the related entities.

[0308] In one exemplary embodiment, the second retrieval module 603 includes an identifier acquisition unit 6031, a vector retrieval unit 6032, a query reconstruction unit 6033, a vector overlay unit 6034, and a secondary retrieval unit 6035, wherein:

[0309] The identifier acquisition unit 6031 is used to acquire the block identifier associated with each associated entity;

[0310] The vector retrieval unit 6032 is used to retrieve the text block vector associated with the block identifier from the vector database based on the block identifier, and use the text block vector as the vector of the associated entity;

[0311] The query reconstruction unit 6033 is used to combine the user query command with each associated entity to generate a reconstruction query command, and convert the reconstruction query command into a reconstruction query vector.

[0312] The vector overlay unit 6034 is used to overlay the vectors of related entities onto the reconstructed query vector using the relevance scores of related entities as weights, to obtain an enhanced query vector;

[0313] The secondary retrieval unit 6035 is used to calculate the similarity between the enhanced query vector and each text block vector in the vector database, and to determine the knowledge corresponding to the text block vector whose similarity meets the preset retrieval conditions as the second knowledge set.

[0314] In one exemplary embodiment, the output module 604 includes a merging and deduplication unit 6041, a semantic scoring unit 6042, a timeliness feedback scoring unit 6043, a comprehensive scoring unit 6044, and a sorting output unit 6045, wherein:

[0315] Merging and deduplication unit 6041 is used to merge the first knowledge set and the second knowledge set, and to deduplicatize the merged knowledge set to obtain the knowledge set to be evaluated;

[0316] The semantic scoring unit 6042 is used to determine the semantic score of the knowledge to be evaluated based on the hit status of each knowledge to be evaluated in the knowledge set to be evaluated against the associated entities and the relevance score of the hit associated entities.

[0317] The timeliness feedback scoring unit 6043 is used to determine the timeliness score of the knowledge to be evaluated based on the duration of its existence, and to determine the feedback score of the knowledge to be evaluated based on the type of user feedback received by the knowledge to be evaluated; wherein, the timeliness score decreases as the duration of existence increases.

[0318] The comprehensive scoring unit 6044 is used to calculate the comprehensive score of the knowledge to be evaluated based on semantic score, timeliness score and feedback score;

[0319] The sorting output unit 6045 is used to sort the knowledge set to be evaluated according to the comprehensive score, and to determine the knowledge set to be evaluated that meets the preset output conditions as the target knowledge set, and output the target knowledge set.

[0320] The modules in the aforementioned knowledge retrieval system based on intelligent knowledge base can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.

[0321] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input system. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input system are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a knowledge retrieval method based on an intelligent knowledge base. The display unit is used to form a visually visible image and can be a display screen, a projection system, or a virtual reality imaging system. The display screen can be an LCD screen or an e-ink screen. The input system of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0322] Those skilled in the art will understand that Figure 7The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0323] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0324] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0325] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method of knowledge retrieval based on an intelligent knowledge base, characterized by, The intelligent knowledge base includes a vector database and a graph database, and the method includes: In response to a user query command, a query vector corresponding to the user query command is generated, and a first knowledge set is retrieved from the vector database based on the query vector; Key entities are identified from the user query instructions. The graph database is traversed along the relational edges of the key entities to obtain multiple associated entities corresponding to the key entities. The relevance score of each associated entity to the user query instructions is then determined. Using the relevance scores of the associated entities as weights, the vectors of the associated entities are superimposed onto the query vector to obtain an enhanced query vector, and a second knowledge set is retrieved from the vector database based on the enhanced query vector; Based on the first knowledge set and the second knowledge set, a target knowledge set is determined and output.

2. The method according to claim 1, characterized in that, Before the step of generating a query vector corresponding to a user query command in response to the user query command, the method further includes: Obtain the document to be imported into the database, parse the document to be imported into the database, and obtain the text content and metadata of the document to be imported into the database; The text content is divided into blocks to obtain multiple text blocks, and a block identifier is assigned to each text block. Each text block is converted into a text block vector, and the text block vector, the block identifier, and the metadata are associated and stored in the vector database. Multiple entities are extracted from multiple text blocks, and the relationships between the multiple entities are determined. An entity relationship graph is generated with the multiple entities as entity nodes and the relationships as relationship edges. The entity relationship graph is stored in the graph database, and each entity node is associated with its corresponding block identifier.

3. The method according to claim 2, characterized in that, The step of extracting multiple entities from multiple text blocks and determining the relationships between the multiple entities includes: Identify multiple entities corresponding to the multiple text blocks, and determine the entity type of each entity; Merge entities that point to the same object into a single entity, and associate the block identifiers of each entity before merging with the merged entity; Determine whether there is a semantic relationship between any two of the merged entities, and determine the relationship type for the entity pairs that have a semantic relationship, thereby obtaining the relationship between the multiple entities.

4. The method according to claim 1, characterized in that, The step of generating a query vector corresponding to the user's query command in response to the user's query command, and retrieving the first knowledge set from the vector database based on the query vector includes: Obtain contextual information associated with the user's query instruction; wherein the contextual information includes at least one of session history, user preferences, and long-term memory; The user query instruction is semantically completed based on the context information to obtain the completed query instruction, and the completed query instruction is converted into the query vector. Based on the query vector, a candidate knowledge set is retrieved from the vector database, and the candidate knowledge set is filtered to obtain the first knowledge set.

5. The method according to claim 1, characterized in that, The step of determining the relevance score of each associated entity to the user query instruction includes: Obtain the semantic similarity between the associated entity and the user query instruction; Based on the path depth of the associated entity relative to the key entity in the traversal, a path decay factor is determined, and the frequency of occurrence of the associated entity in the traversal is counted; wherein, the path decay factor decreases as the path depth increases; The initial relevance score of the associated entity is calculated based on the semantic similarity, the path decay factor, and the frequency of occurrence. The initial relevance score is mapped to a preset number of discrete levels, and associated entities with discrete levels below a preset level threshold are filtered out. Obtain the matching results between the retained associated entities and user preferences and user historical behavior, determine the adjustment coefficient based on the matching results, and adjust the initial relevance score with the adjustment coefficient to obtain the relevance score of the associated entities.

6. The method according to claim 1, characterized in that, The text block vectors in the vector database are associated with the block identifiers of the text blocks to which they belong, and the entity nodes in the graph database are associated with the block identifiers of the text blocks from which they originate. The step of using the relevance scores of the associated entities as weights to superimpose the vectors of the associated entities onto the query vector to obtain an enhanced query vector, and retrieving the second knowledge set from the vector database based on the enhanced query vector, includes: Obtain the block identifier associated with each of the aforementioned associated entities; Based on the block identifier, the text block vector associated with the block identifier is obtained from the vector database, and the text block vector is used as the vector of the associated entity; The user query instruction is combined with each of the associated entities to generate a reconstructed query instruction, and the reconstructed query instruction is converted into a reconstructed query vector; Using the relevance scores of the associated entities as weights, the vectors of the associated entities are superimposed onto the reconstructed query vector to obtain the enhanced query vector; Calculate the similarity between the enhanced query vector and each text block vector in the vector database, and determine the knowledge corresponding to the text block vector whose similarity satisfies the preset retrieval conditions as the second knowledge set.

7. The method according to claim 1, characterized in that, The text block vectors in the vector database are associated with the block identifiers of the text blocks to which they belong. The step of determining the target knowledge set based on the first knowledge set and the second knowledge set, and outputting the target knowledge set, includes: Merge the first knowledge set and the second knowledge set, and remove duplicates from the merged knowledge set to obtain the knowledge set to be evaluated; The semantic score of the knowledge to be evaluated is determined based on the hit rate of each knowledge to be evaluated in the knowledge set to be evaluated to the associated entity and the relevance score of the associated entity that was hit. Based on the duration of the knowledge to be evaluated, a timeliness score is determined, and based on the type of user feedback received by the knowledge to be evaluated, a feedback score is determined; wherein, the timeliness score decreases as the duration of the knowledge increases. Based on the semantic score, the timeliness score, and the feedback score, a comprehensive score for the knowledge to be evaluated is calculated. The knowledge set to be evaluated is sorted according to the comprehensive score, and the knowledge set to be evaluated that meets the preset output conditions is determined as the target knowledge set and the target knowledge set is output.

8. A knowledge retrieval system based on an intelligent knowledge base, characterized in that, The intelligent knowledge base includes a vector database and a graph database, and the system includes: The first retrieval module is used to respond to a user query command, generate a query vector corresponding to the user query command, and retrieve a first knowledge set from the vector database based on the query vector; The relevance calculation module is used to determine key entities from the user query instructions, traverse along the relation edges of the key entities in the graph database to obtain multiple associated entities corresponding to the key entities, and determine the relevance score of the degree of association between each associated entity and the user query instructions. The second retrieval module is used to superimpose the vectors of the associated entities onto the query vector using the relevance scores of the associated entities as weights to obtain an enhanced query vector, and retrieve a second knowledge set from the vector database based on the enhanced query vector; The output module is used to determine a target knowledge set based on the first knowledge set and the second knowledge set, and output the target knowledge set.

9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the knowledge retrieval method based on an intelligent knowledge base as described in any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.