A method and system for storing and invoking a knowledge representation data structure
By using an equivalence relation record table and a globally unique expression hash index, the problems of storage redundancy and query latency in existing technologies are solved. This enables fast addressing of point-to-point equivalence relations and automated derivation of rule knowledge, thereby improving query efficiency and resource utilization.
Patent Information
- Application Number
- CN202611133157.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-08-25
AI Technical Summary
Existing knowledge representation data structures suffer from storage redundancy, write amplification, and cache oscillation under mixed loads during storage and retrieval. They cannot achieve fast addressing of point-to-point equivalence relations, and rule knowledge cannot automatically complete the leapfrog derivation from instance to parent class rule within the database.
An equivalence relation record table and a globally unique expression hash index are used to eliminate reverse index copies. A unified hash index is used to enable bidirectional queries of shared memory cache pages, eliminating page replacement oscillations. The automatic derivation of rule knowledge is achieved through instance-class registration axioms and variable substitution derivation mechanisms.
It achieves fast addressing of point-to-point equivalence relations, reduces disk and memory resource consumption, improves cache hit rate, reduces index storage space, and enables large-scale equivalence inference and rule instantiation on lightweight servers.
Smart Images

Figure CN122633689A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method and system for storing and retrieving knowledge representation data structures. Background Technology
[0002] Knowledge representation is a core research area in artificial intelligence, aiming to transform human knowledge into a formal representation that can be stored, processed, and reasoned about by computers. With the massive accumulation of data across various industries, how to efficiently and uniformly store and retrieve knowledge has become a critical issue.
[0003] Currently, the main storage methods for knowledge representation data structures include:
[0004] (1) A triplet knowledge graph storage system based on RDF (Resource Description Framework)
[0005] The corresponding RDF-based triplet storage structure typically uses a subject-predicate-object unidirectional columnar storage table in its physical storage layout. In this implementation, the database management system must maintain two physically independent index structures: a forward index (subject + predicate → object) and a reverse index (object → subject + predicate).
[0006] The implementation scheme has the following main technical defects in application:
[0007] Severe storage redundancy: Each knowledge record needs to occupy an independent hash bucket entry and memory page in two sets of indexes. When the data volume reaches hundreds of millions, the disk usage and memory buffer pool pressure increase sharply.
[0008] The write amplification effect is significant: each knowledge record inserted must be inserted simultaneously in the B+ tree or hash table of two sets of indexes. This operation may trigger double the page splits, resulting in double the disk I / O throughput.
[0009] Under mixed load, cache oscillations are severe: when forward and reverse queries arrive alternately, the database buffer pool is repeatedly flushed with hot data from both sets of indexes; forward queries load memory page A, and reverse queries immediately require memory page B and load it, while simultaneously evicting page A; the processor's level 1 and level 2 data caches, as well as the TLB (Translation Lookaside Buffer), fail frequently, resulting in unpredictable and significant jitter in query latency.
[0010] (2) Ontology formal storage system based on OWL (Web Ontology Language)
[0011] This implementation serializes knowledge into specific XML / RDF format documents for storage, relying on axioms, class hierarchies, and attribute constraints to achieve semantic definition. However, when performing semantic determinations such as "A is equivalent to B," the processor must load the complete ontology file and traverse the complex tree structure for deep reasoning and matching. Therefore, this implementation cannot complete the fast addressing of point-to-point equivalence relations in O(1) time, making it unsuitable for high-frequency query scenarios.
[0012] (3) Equivalent entity alignment scheme based on Union-Find
[0013] This implementation scheme uses arrays or pointers to implement a tree-like equivalence class merging structure, which is specifically used for equivalence clustering of atomic entities (such as string IDs). However, its storage unit can only hold the ID of a single entity and cannot represent the equivalence mapping relationship between complex structured expressions such as "entity A that satisfies condition X" and "entity B that satisfies condition Y", resulting in extremely limited application boundaries.
[0014] In summary, the existing physical storage structure of knowledge data is asymmetrical, forcing database management systems to maintain two sets of physical indexes—forward and reverse—leading to storage redundancy, write amplification, and cache oscillations under mixed loads. Simultaneously, rule-based knowledge cannot be uniformly incorporated into the equivalent storage and query chain, necessitating reliance on an external inference engine. Specifically, existing implementations can be summarized into the following two related sub-problems:
[0015] Sub-problem 1: The unidirectional columnar storage of the traditional directed triplet scheme forces the system to maintain dual indexes, resulting in significant latency jitter in forward and reverse queries under mixed loads, and a doubling of disk and memory resource consumption;
[0016] Sub-problem 2: Existing technologies cannot use a unified physical storage format to simultaneously carry factual knowledge, class axiom knowledge, and rule knowledge; when a query is initiated with a specific instance, it is impossible to automatically complete the leapfrog deduction from the instance to the parent class rule within the database.
[0017] Furthermore, for example, because the storage of corresponding rules and instances is separate, when the knowledge base stores a rule "the pH value of acidic substances is less than 7," and a user queries "what is the pH value of hydrochloric acid?", the processor must rely on an external inference engine to execute the Tableau algorithm or rule expansion logic to establish the semantic channel "hydrochloric acid is an acidic substance" before the rule can be applied. This process involves the generation of a large number of temporary intermediate tables and multiple disk I / Os (input / output), resulting in uncontrollable latency and thus failing to meet real-time requirements.
[0018] In view of this, the present invention is hereby proposed. Summary of the Invention
[0019] The purpose of this invention is to provide a method and system for storing and retrieving knowledge representation data structures, so as to realize fast addressing of point-to-point equivalence relations, thereby solving the technical problems existing in the prior art.
[0020] The objective of this invention is achieved through the following technical solution:
[0021] A method for storing a knowledge representation data structure, comprising:
[0022] An equivalence relation record table is constructed in the computer's external storage medium. Each record in the record table includes a first expression field and a second expression field, and the two fields have no distinction between primary key and foreign key in terms of physical byte arrangement.
[0023] Write the first expression and the second expression, which have a semantically equivalent mapping relationship, into the first expression field and the second expression field, respectively.
[0024] A globally unique expression hash index is constructed for each record in the record table to establish a hash index table corresponding to the record table.
[0025] The equivalent semantic pair formats with semantic equivalence mapping relationships include:
[0026] For atomic instances, an encoding format is used that directly maps them to literal string constants;
[0027] For structured semantics of compound assertions that need to carry parameter dependencies or logical mappings, a unified string encoding format consisting of predicate identifiers and parameter lists is adopted, wherein the predicate identifier is the character identifier of its corresponding predicate.
[0028] A storage structure for registering class-implied axioms is introduced into the equivalence relation record table. This storage structure includes:
[0029] When the processor receives a query and the hash index is not found, it extracts the query predicate and parameter list, searches for rule records with the same predicate in the index table, and then returns the query registration class axiom to verify the inheritance relationship between the predicate and the found rule records with the same predicate. After the verification is successful, variable substitution is performed to generate a derivation record, which is written to the storage medium, and the hash index of the record is updated.
[0030] The method also includes an index deduplication-driven automatic derived record appending mechanism, which includes:
[0031] When new records<A, B> After being written to the storage medium, the processor automatically searches the memory index table for all associated addresses with B as the key; if an associated record is found...<B, C> Then a derived record will be automatically appended to the end of the record table.<A, C> And update the hash index table synchronously.
[0032] The process of establishing the hash index table corresponding to the record table includes:
[0033] Obtain the physical sector address of the record on the disk. In the unified hash index table in memory, insert the first expression and the second expression carried by the first expression field and the second expression field as keys respectively, and set the storage location value corresponding to the two keys to the physical sector address.
[0034] The conflict resolution mechanism implemented for the aforementioned equivalence relation includes: obtaining the list of corresponding physical addresses in the hash index table.
[0035] For new records<X,Y> Search the index table for Hash(X) to obtain all existing equivalent records associated with X, and then iterate through the existing equivalent records.<X, Z> It checks whether Y and Z satisfy the mutual exclusion rule. If they are not mutually exclusive, it continues. If they are mutually exclusive, it marks the equivalence class containing X, Y, and Z as conflicting and suspends the automatic propagation derivation of the equivalence class. It generates an audit work order containing conflict details, original source, and equivalence link and pushes it to the manual audit end. It updates the record status according to the returned audit processing result.
[0036] A method for invoking a knowledge representation data structure, based on the aforementioned method for storing the knowledge representation data structure, includes the following:
[0037] When the processor receives a query request for the target expression T, it finds the physical address through the unified hash index and reads the complete single record.
[0038] The complete single record is subjected to symmetric extraction processing, which includes: if the binary string of the target expression T fully matches the content of the first expression field, the system bus outputs the content carried by the second expression field; otherwise, the content carried by the first expression field is directly output.
[0039] The method also includes performing a vector approximate matching scan when a hash lookup misses, including:
[0040] The processor transforms the target expression and the keys in the index table into bag-of-words vectors, and calculates the nearest Top-N candidate records using cosine similarity to achieve fuzzy retrieval and knowledge correction.
[0041] A system for storing and retrieving knowledge representation data structures, comprising:
[0042] A physical storage layer is used as a storage medium to construct an equivalence relation record table, wherein a single record in the record table includes a first expression field and a second expression field, and the two fields have no primary key and foreign key distinction in physical byte arrangement; and, the first expression and the second expression with semantic equivalence mapping relationship are respectively written into the first expression field and the second expression field.
[0043] The index layer is used to construct a globally unique expression hash index for a single record in the record table, so as to establish a hash index table corresponding to the record table;
[0044] The processor layer is used to find the physical address and read the complete single record through a unified hash index after receiving a query request for the target expression T; and to perform symmetric extraction processing on the complete single record. The symmetric extraction processing includes: if the binary string of the target expression T matches the content of the first expression field, the system bus outputs the content carried by the second expression field; otherwise, the content carried by the first expression field is directly output.
[0045] A readable storage medium for storing a computer program, which, when executed by a processor, enables the implementation of the methods described above.
[0046] Compared with the prior art, the storage and retrieval method and system for knowledge representation data structures provided by the present invention eliminates the inverted index copy. When the processor undertakes bidirectional mixed load, forward and reverse queries share the same memory cache page, thus effectively avoiding page replacement oscillations, enabling fast addressing of point-to-point equivalence relations, and significantly improving cache hit rate. Moreover, it eliminates the need to build a separate inverted index file for the object column, significantly reducing disk space usage and making the hot index data in memory more compact. Attached Figure Description
[0047] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 A schematic diagram of the processing flow of the method provided in the embodiments of the present invention;
[0049] Figure 2 This is a schematic diagram of the data writing and index building process provided in an embodiment of the present invention;
[0050] Figure 3 This is a schematic diagram of a branchless bidirectional symmetrical call process provided in an embodiment of the present invention;
[0051] Figure 4 This is a schematic diagram of the class registration derivation process provided in an embodiment of the present invention;
[0052] Figure 5 This is a schematic diagram of the equivalence transit derivation process provided in an embodiment of the present invention;
[0053] Figure 6 This is a schematic diagram of the equivalence relation conflict handling process provided in an embodiment of the present invention. Detailed Implementation
[0054] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the specific content of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments, which do not constitute a limitation of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.
[0055] First, the following explanations are provided for the terms that may be used in this article:
[0056] The term "and / or" means that either or both can be achieved simultaneously. For example, X and / or Y means that it includes both "X" or "Y" as well as the three cases of "X and Y".
[0057] The terms "comprising," "including," "containing," "having," or other similar semantic descriptions should be interpreted as non-exclusive inclusion. For example, including a technical feature element (such as raw material, component, ingredient, carrier, dosage form, material, size, part, component, mechanism, device, step, process, method, reaction conditions, processing conditions, parameter, algorithm, signal, data, product or article of manufacture, etc.) should be interpreted as including not only the expressly listed technical feature element, but also other technical feature elements that are not expressly listed and are well-known in the art.
[0058] The term "composed of" excludes any technical features not expressly listed. When used in a claim, it closes the claim to exclude all technical features other than those expressly listed, except for associated conventional impurities. If the term appears only in a clause of a claim, it limits the claim to the elements expressly listed in that clause; elements recited in other clauses are not excluded from the overall claim.
[0059] Unless otherwise explicitly specified or limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to the internal connection between two components. Those skilled in the art can understand the specific meaning of the above terms in this document according to the specific circumstances.
[0060] When concentration, temperature, pressure, size, or other parameters are expressed as numerical ranges, such ranges should be understood to specifically disclose all ranges formed by any pairing of upper limits, lower limits, or preferred values within that range, regardless of whether the range is explicitly stated; for example, if the numerical range "2 to 8" is stated, then that range should be interpreted to include ranges such as "2 to 7", "2 to 6", "5 to 7", "3 to 4 and 6 to 7", "3 to 5 and 7", "2 and 5 to 7", etc. Unless otherwise stated, the numerical ranges described herein include both their endpoints and all integers and fractions within that range.
[0061] The terms “center,” “longitudinal,” “lateral,” “length,” “width,” “thickness,” “upper,” “lower,” “front,” “back,” “left,” “right,” “vertical,” “horizontal,” “top,” “bottom,” “inner,” “outer,” “clockwise,” and “counterclockwise” indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience and simplification of description and do not imply that the device or component referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this document.
[0062] This invention provides a method and system for storing and retrieving knowledge representation data structures. The implementation of this method and system mainly includes the following processing methods:
[0063] (1) Adopt a record storage structure with two fields and equal physical status.
[0064] An equivalence relation record table is constructed in the computer's external storage medium, which includes multiple records. Each single record can be composed of a "first expression field" and a "second expression field". The two fields have no primary key and foreign key distinction in physical byte arrangement. The first expression and the second expression with semantic equivalence mapping relationship are then written into the first expression field and the second expression field, respectively.
[0065] To achieve uniformity of expression, embodiments of the present invention also provide the following two equivalent forms of layered coding protocols:
[0066] For atomic instances, such as entities, numerical values, or simple facts with explicit designations, an encoding format that directly maps them to literal string constants is used; that is, the processor can directly map them to literal string constants without adding function parentheses, such as China, generator No. 001.
[0067] For structured semantics: that is, for structured semantics that need to carry compound assertions that require parameter dependencies or logical mappings, the processor can adopt a unified encoding format for the "predicate identifier (parameter list)" string. That is, it adopts a unified string encoding format composed of predicate identifier and parameter list to encode it as "predicate identifier (ordered parameter set)". The ordered parameter set is the corresponding parameter list, such as capital (China). The predicate identifier is the character identifier of the corresponding predicate, that is, the exclusive encoding name of the corresponding predicate.
[0068] The physical storage content of an equivalence equation record (i.e., a single record) in the equivalence relation record table can be presented as any combination of "atomic instance <equivalent to> atomic instance", "atomic instance <equivalent to> structured compound expression", or "structured compound expression <equivalent to> structured compound expression". The corresponding structured compound expression is a "predicate identifier (ordered parameter set)" expression for structured semantics. The processor can use a unified hash function to calculate the feature code to build an index for all the above forms, which can ensure complete consistency from the top-level data format to the bottom-level hash addressing (i.e., hash index).
[0069] In summary, the above processing method can eliminate the directionality of the calling process from the root of physical storage. For any record, the two fields are absolutely equal in the address space, and there is no longer a need to distinguish between the subject storage area and the object storage area, thus laying the physical foundation for subsequent bidirectional symmetric sharing of single indexes.
[0070] (2) Bidirectional unified addressing mechanism under single hash index
[0071] A globally unique expression hash index is constructed for each record in the record table to establish a hash index table corresponding to the record table. Further, the physical sector address of the record on the disk can be obtained. In the unified hash index table in memory, the first expression carried by the first expression field and the second expression field are inserted as keys respectively, and the storage location value corresponding to the two keys is set to the physical sector address.
[0072] Specifically, a globally unique expression hash index table can be built in memory. When a record is written, the processor synchronously extracts the strings of the first expression field and the second expression field, calculates the signature code using the same hash function, and inserts them into the same hash index bucket to update the corresponding hash index table. The two keys corresponding to the two fields are mapped to the same physical sector address of the record on the disk.
[0073] By implementing the bidirectional unified addressing mechanism under the single hash index, the processor uses the exact same hash function and address fetch instructions to access the same memory page of the same hash index table, regardless of whether the query is "from A to B" or "from B to A". Moreover, forward and reverse queries share the same cache pipeline, which can fundamentally eliminate the page replacement overhead and cache thrashing problem of traditional dual-index schemes under mixed loads.
[0074] (3) Data symmetric calling logic based on the above storage structure
[0075] When the processor receives a query request for the target expression T, it can find the physical address (i.e., the physical sector address) through the unified hash index and read the complete record. Then, it performs symmetric extraction on the complete single record: if the binary string of the target expression T matches the content of the first expression field, the system bus outputs the content carried in the second expression field; otherwise, it directly outputs the content of the first expression field without direction judgment.
[0076] Based on the corresponding data symmetric calling logic, the underlying calling logic does not need to perform if-else (if-otherwise) branch judgment of the direction flag bit, thus making the time overhead of the processor instruction pipeline almost completely consistent when performing bidirectional query, and the delay standard deviation approaches zero.
[0077] (4) Instance-class registration axiom and variable substitution derivation mechanism
[0078] The mechanism may include: when the processor receives a query and the hash index is not found, extracting the query predicate and parameter list, searching for rule records with the same predicate in the index table; then, returning the registry class axiom to verify the inheritance relationship between the predicate and the found rule records with the same predicate, and performing variable substitution after the verification is successful to generate a derivation record, writing it to the storage medium, and updating the hash index of the record.
[0079] Specifically, a storage structure containing axioms of the registration class is introduced into the equivalence relation record table, such as registration class (hydrochloric acid, acidic substance) ↔ True; when the processor receives a query for pH value (hydrochloric acid) and the hash index does not find it, it can automatically extract the query predicate pH value and parameter list [hydrochloric acid], search for the rule record with the same predicate in the hash index table, pH value (acidic substance) ↔ less than 7; then, the registration class axiom is checked back to verify the inheritance relationship of "hydrochloric acid → acidic substance". After the verification is successful, variable substitution is performed, the derivation record pH value (hydrochloric acid) ↔ less than 7 is automatically generated, written to storage, and the hash index is updated.
[0080] Based on the above mechanism, the rule expansion and instantiation derivation that traditionally required an external inference engine can be completely transformed into the processor's lookup operation on the unified hash index and the append write operation to the end of the equivalence relation record table; thus, rule knowledge is no longer isolated from the fact base, realizing a fully automatic closed-loop link of "fact-rule-instantiation conclusion".
[0081] (5) Automatic Derivative Record Appendage Mechanism Driven by Index Deduplication
[0082] When new records<A, B> After being written to disk (i.e., storage medium), the processor automatically searches the memory index table for all associated addresses with B as the key. If an associated record is found...<B, C> Then a derived record will be automatically appended to the end of the record table.<A, C> And update the unified hash index table simultaneously.
[0083] Based on the above mechanism, the transitive closure derivation that traditional graph databases require an external inference engine to complete can be transformed into a simple database operation where the processor directly performs hash deduplication on the index and sequentially writes the tail blocks of the storage table, without having to load and traverse the entire graph model.
[0084] Based on the main technical means adopted in the above embodiments of the present invention, the implementation of the embodiments of the present invention has the following significant advantages over existing solutions:
[0085] Because the reverse index copy is eliminated, when the processor is handling bidirectional mixed loads, forward and reverse queries share the same memory cache page, which makes the latency of forward and reverse queries highly equal, eliminates page replacement oscillations, and can significantly improve the cache hit rate.
[0086] The embodiments of the present invention can also eliminate the need to build a separate inverted index file for the object column, thereby halving the index storage space, significantly reducing disk usage, and making the hot index data in memory more compact;
[0087] This invention also achieves deep integration of the reasoning process and storage query, that is, the transfer of derived knowledge is directly completed by the processor's underlying IO logic, without the need for a large external inference engine computing node, and large-scale equivalent reasoning and rule instantiation can be achieved on a general-purpose lightweight server.
[0088] To facilitate a further understanding of the embodiments of the present invention, the specific implementation process of the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0089] The present invention provides a storage and retrieval implementation scheme for a knowledge representation data structure. Figure 1 As shown, its overall architecture is divided into three layers: physical storage layer (SSD / HDD), memory index layer (RAM), and processor instruction control layer (CPU), with the layers arranged from bottom to top as storage layer, index layer, and processor layer.
[0090] The physical storage layer serves as a storage medium, in which an equivalence relation record table is constructed. Each record in the record table includes a first expression field and a second expression field, and the two fields have no primary key or foreign key distinction in physical byte arrangement. Furthermore, the first expression and the second expression, which have semantic equivalence mapping relationships, are written into the first expression field and the second expression field, respectively. Specifically, the storage layer can be an equivalence relation record table on disk, where each record has equivalent dual fields, with no primary key or foreign key distinction, directly recording all equivalence relation pairs. It implements index construction through an index layer, building a corresponding hash index table. That is, after the data contained in the equivalence relation pairs in the physical storage layer is read, it can be used to build a global hash index in memory, thereby constructing a hash index table. Moreover, the established hash index entries are mapped to the physical addresses of the actual equivalence relation pair records on disk, ensuring that the original data can be quickly located during queries.
[0091] The index layer is used to construct a globally unique hash index for each record in the record table, thereby establishing a hash index table corresponding to the record table. Specifically, it can be a unified hash index table in memory, and both keys of the single hash index table share the same memory page. It searches for the contents of the record table in the storage layer through physical address mapping. It receives write / query requests from the processor layer and returns the index lookup results to the processor layer. At the same time, it reads data from the physical storage layer and loads it into memory according to the processor's instructions. Furthermore, it acts as a high-speed cache for the physical storage layer data, with all read and write requests first passing through the memory index layer, and then the index layer completes the physical address mapping and disk I / O operations.
[0092] The processor layer, upon receiving a query request for the target expression T, locates the physical address using a unified hash index and reads the complete single record; and performs symmetric extraction processing on the complete single record. This symmetric extraction processing includes: if the binary string of the target expression T fully matches the content of the first expression field, the system bus outputs the content carried by the second expression field; otherwise, it directly outputs the content carried by the first expression field. Specifically, the processor layer is the request initiator, sending write / query requests to the memory index layer; simultaneously, it receives the index lookup results and read data from the memory index layer, driving subsequent derivation, processing, and expansion processes, including: a knowledge encoding and parsing module, a bidirectional query module, a registration derivation module, an equivalence transitive derivation module, a conflict handling module, and an approximate matching expansion module, etc., wherein:
[0093] Knowledge Encoding and Parsing Module: Used to parse and encode expressions and symbols in write / query requests, generating unified key values that can be used for hash indexes;
[0094] Bidirectional query module: Used for bidirectional equivalence relation queries based on hash tables with in-memory index layer, supporting reverse lookup of equivalent objects from any field;
[0095] Registration derivation module: used to register new equivalence relations into the system, update memory indexes and synchronously write them to the physical storage layer;
[0096] The equivalence transitivity derivation module is used to derive transitive equivalence chains based on existing equivalence relations, such as A=B, B=C→ A=C, and to expand the set of equivalence relations.
[0097] Conflict handling module: Used to handle contradictions or inconsistencies between equivalence relations (such as the simultaneous existence of conflicts between A=B and A≠B), ensuring data consistency;
[0098] Approximate matching extension module: This module extends the support for approximate matching (such as fuzzy equivalence and similarity relationships) to the existing exact equivalence query, thereby enhancing query capabilities.
[0099] In this embodiment of the invention, an equivalence relation record table is instantiated in a non-volatile storage medium of a computer. Its implementation structure can be as shown in Table 1, including completely symmetrical field encoding storage: the first expression field and the second expression field both adopt a unified predicate identifier (ordered parameter set) string or atomic instance string encoding format, and are completely equivalent in physical byte arrangement. This data structure completely eliminates the directional constraints between the subject and object of the traditional triplet.
[0100] Table 1
[0101]
[0102] In this embodiment of the invention, the physical structure of the corresponding unified expression index unit (i.e., the memory hash index table) can be as shown in Table 2. The hash keys corresponding to the atomic instance "Beijing" and the structured semantic "Capital (China)" all contain the physical address 0x0001 in their value list. This means that no matter whether the processor initiates a query from either "Beijing" or "Capital (China)", it can obtain the complete set of associated records through a single hash lookup, that is, the same equivalence relation record, without the need to switch between different index tables.
[0103] Table 2
[0104]
[0105] In this embodiment of the invention, the corresponding data writing and index building process is as follows: Figure 2 As shown, it may include:
[0106] At the beginning, that is, after the process starts, it receives heterogeneous knowledge input; that is, the processor receives external knowledge input and generates the first and second expressions with equivalent encoding through the knowledge encoding and parsing module.
[0107] The heterogeneous input knowledge is parsed into an equivalent encoded string, which generates the first expression A and the second expression B; the format can be "predicate identifier (ordered parameter set)";
[0108] Call disk I / O to generate records<A, B> Write physical address 0x01; this will append the record to the end of the free page of the equivalence relation record table and obtain the physical storage address Ptr (pointer) of the record.
[0109] Memory operations: Obtain the physical sector address of the record on the disk, insert the first expression and the second expression as keys in the unified hash index table in memory, and set the values to this physical address; and the two keys coexist in the same memory page of the same hash table, thus constructing the physical basis for the single-table bidirectional pointer mapping;
[0110] That is, calculating Hash(A) and Hash(B), including:
[0111] Calculate the hash value Hash(A) of expression A, insert an entry (Hash(A) → Ptr) into the global unified hash index table, that is, insert a key-value pair (Hash(A), 0x01) into the unified hash index table, and establish the mapping from expression A to physical address;
[0112] Calculate the hash value Hash(B) of expression B, insert an entry (Hash(B) → Ptr) in the same global hash index table, that is, insert a key-value pair (Hash(B), 0x01) in the same hash index table, establish the mapping of B to the same physical address, and the processing ends.
[0113] The corresponding data symmetric calling process in the implementation of this invention is as follows: Figure 3 As shown, the corresponding branchless bidirectional symmetric call flow can include:
[0114] After the process starts, the processor receives the retrieval request (i.e., the query request) and extracts the target expression T contained in the request;
[0115] Call the hash function to calculate the hash value Hash(T) of the target expression T;
[0116] Search for Hash(T) in the unified hash index table, that is, complete one address lookup in the unified hash index table (time O(1)); if the physical address list is hit, then execute the following step (31); otherwise, execute step (32).
[0117] Step (31), if the physical address list is hit, then:
[0118] Retrieve the physical address list [Ptr1, Ptr2, ...] corresponding to the hash index table, and iterate through the address list, including: batch loading all associated sector data pointed to by the pointers into memory. Specifically, it can read the complete equivalence relationship records of all associated physical addresses from the disk into the memory buffer. The records contain the first field F1 and the second field F2. For each record, perform symmetric result extraction, that is: compare whether the target expression T and the first field F1 are binary identical; if so, output the second field F2, otherwise output the first field F1; for each hit record, only one string comparison needs to be performed; regardless of whether the query is forward (e.g., from A to B) or reverse (e.g., from B to A), the same sequence of machine instructions is executed, and the delay is completely symmetrical.
[0119] Based on the above output fields, all equivalent fields of the output are collected and merged to form a complete result set. The final result set is then returned, and the query processing process ends.
[0120] Step (32): If no match is found, perform approximate matching expansion (such as fuzzy query), or directly return "query failed" and the process ends.
[0121] The instance-class registration derivation process in the implementation of this embodiment of the invention is as follows: Figure 4 As shown, it may include:
[0122] After the start process is initiated, receive the query Q = pH value (hydrochloric acid), that is, receive the user's query request, with the target being Q = "pH value (hydrochloric acid)".
[0123] Calculate Hash(Q) and search for Hash(Q) in the unified hash index table; if not found, execute step (41), if found, execute step (42).
[0124] Step (41), when not found, extract the predicate pH value of the query Q and the parameter list [hydrochloric acid]; traverse the index table, perform a prefix scan in the index table to obtain all keys with the pH value as the prefix; find the key pH value (acidic substance); for each rule record corresponding to the prefix key, perform the following operations:
[0125] Read the corresponding physical address record; from the index keys with "pH value" as the prefix, read the rule record <pH value (parameter list), conclusion> and extract its rule parameter list [acidic substance].
[0126] For each rule parameter, compare it one by one with the query parameter [hydrochloric acid], according to the comparison result;
[0127] If it is a perfect match (no difference), directly use the rule conclusion to return the result and the process ends.
[0128] If a mismatch [acidic substance] is found, that is, a difference is found (such as the rule parameter is "acidic substance" and the query parameter is "hydrochloric acid"): then enter the equivalent transfer derivation process to construct the query registration class (hydrochloric acid, acidic substance) and search for its hash value in the index table, aiming to verify the equivalence relationship between "hydrochloric acid" and "acidic substance" and provide a basis for subsequent variable substitution and new rule generation; that is, construct the registration query R = "registration class (hydrochloric acid, acidic substance)", calculate Hash(R) and search in the index table:
[0129] If the search is not found, output query failure, return empty, and the process ends.
[0130] If the search is found, read the axiom record <registration class (hydrochloric acid, acidic substance), true>, verify the inheritance relationship, and after verification, perform variable substitution, replacing "acidic substance" in the rule parameter with "hydrochloric acid" to generate a new record <pH value (hydrochloric acid), less than 7>.
[0131] Append the new record to the equivalence relationship record table through disk I / O. [[ID=二十九]]
[0132] [[ID=三十]]Update the in-memory hash index table and insert entries for Hash(pH value (hydrochloric acid)) and Hash(less than 7).[[ID=三十一]] [[ID=三十二]]
[0133] Return result: The deduced conclusion "less than 7" will be returned to the user as the query result, and the process will end.
[0134] In the above reasoning process, the processor only traverses the keys in the index table with PH value as the prefix, and performs a range scan by utilizing the ordered nature of the hash table, without having to traverse the entire table; the corresponding inheritance verification process is implemented by back-checking the registration class axiom, which is another O(1) hash lookup operation, without involving tree structure recursion; moreover, the newly generated records are persisted to disk and the index is updated to realize the materialization of the results, and subsequent identical queries can be directly hit in O(1) time without repeated reasoning, thus realizing "one-time reasoning, multiple reuse".
[0135] The corresponding equivalence transitive derivation process in the implementation of this invention is as follows: Figure 5 As shown, it may include:
[0136] The process is initiated; the trigger condition for the new process is that the new record has been written.<A, B> Write to disk;
[0137] The processor looks up Hash(B) in the unified hash index table;
[0138] Get the list of all physical addresses associated with expression B, that is, all records containing expression B;
[0139] Iterate through the address list, read the record for each physical address, and then analyze the results:
[0140] If a record exists<B, C> (And C≠A): Then proceed to the deduplication check stage, and perform string deduplication comparison: check whether an equivalent relationship already exists in the existing records.<A,C> To check the records<A, C> Does it already exist? If it already exists, skip to avoid generating duplicate records and end the process; if it does not exist, continue the derivation to generate a new equivalence relation record.<A,C> And mark the type as "derivative", and append a derived equivalence relation record.<A, C> Update the memory hash index table to add two entries: Hash(A) → new address and Hash(C) → new address; then, with the new record...<A, C> This process is executed recursively from the starting point, meaning it terminates if a closed loop is detected or the maximum depth is reached, thus ending the process.
[0141] If no record exists<B, C> If (or C=A), then skip to the next record.
[0142] In the above processing, the derivation is based entirely on index lookup and string comparison, without the need to build a graph structure or load a graph traversal engine; all operations are standard atomic operations of the database system kernel, and the derivation chain can be interrupted and resumed, making it suitable for large-scale concurrent scenarios.
[0143] The implementation process of the corresponding equivalence relation conflict handling mechanism in the embodiments of the present invention is as follows: Figure 6 As shown, it may include:
[0144] Triggering condition: New equivalence relation record<X, Y> Ready to write;
[0145] For new records<X,Y> The unified hash index table is used to look up Hash(X) to obtain a list of all existing records that are equivalent to X, in the form of:<X, Z> Traverse existing equivalent records<X, Z> And check whether Y and Z satisfy the mutual exclusion rule, based on the check results:
[0146] If they are not mutually exclusive, continue checking the next existing record.
[0147] If a mutual exclusion conflict is found, the conflict handling process begins: the equivalence class containing X, Y, and Z is marked as conflicting, and the automatic propagation derivation of that equivalence class is paused. A review work order containing conflict details, the original source (i.e., the original knowledge source identifier), and the equivalence link context is generated and pushed to the manual review end. Afterwards, the review results are received, and the record status is updated based on the returned review processing results, including:
[0148] If coexistence is confirmed, the mutual exclusion rule whitelist is updated, the locking of the equivalence class is released, the conflict resolution is completed, and the process ends.
[0149] If Z is confirmed to be correct and Y to be incorrect, then refuse to write a new record.<X, Y> Once the lock is released, the conflict resolution is complete, and the process ends.
[0150] If Y is confirmed to be correct and Z to be incorrect, then delete the old record.<X, Z> Update the hash index table, unlock, conflict resolution complete, and the process ends.
[0151] The implementation of the corresponding approximate matching extension capability in the implementation process of this embodiment of the invention may include:
[0152] When a hash lookup fails, the algorithm automatically downgrades to a vector approximation matching scan. The process of performing a vector approximation matching scan includes: the processor converting the target expression and the keys in the index table into bag-of-words vectors, and calculating the nearest Top-N candidate records using cosine similarity, which is compatible with fuzzy search and knowledge correction scenarios.
[0153] To achieve the core objective of "bidirectional unbiased querying," in addition to the implementation method of the globally unique expression hash index provided in the embodiments of this invention, a lightweight alternative can be adopted using a database middleware encapsulation simulation scheme. That is, the underlying layer still uses a traditional triplet table for storage, but an interceptor is written at the database middleware level to automatically rewrite all user-initiated reverse query SQL statements as scans of the forward index table, and to create the illusion of symmetrical calls at the application layer.
[0154] For the "rule instantiation derivation" problem, in addition to using the physical symmetric storage structure and built-in registration derivation mechanism provided in the embodiments of this invention, an external inference engine mounting scheme can also be adopted. That is, an independent inference engine is deployed outside the database, which periodically or as needed pulls facts and rules from the database, completes the inference, and writes the conclusion back to the database.
[0155] Through the above description of the embodiments, those skilled in the art can clearly understand that the above embodiments can be implemented by software, or by using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions of the above embodiments can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard drive, etc.), including several instructions to cause a computer device (such as a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0156] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims. The information disclosed in the background section is intended only to enhance the understanding of the overall background technology of the present invention and should not be construed as an admission or implication in any way that such information constitutes prior art known to those skilled in the art.
Claims
1. A method for storing a knowledge representation data structure, characterized in that, include: An equivalence relation record table is constructed in the computer's external storage medium. Each record in the record table includes a first expression field and a second expression field, and the two fields have no distinction between primary key and foreign key in terms of physical byte arrangement. Write the first expression and the second expression, which have a semantically equivalent mapping relationship, into the first expression field and the second expression field, respectively. A globally unique expression hash index is constructed for each record in the record table to establish a hash index table corresponding to the record table.
2. The storage method for the knowledge representation data structure according to claim 1, characterized in that, The equivalent semantic pair formats with semantic equivalence mapping relationships include: For atomic instances, an encoding format is used that directly maps them to literal string constants; For structured semantics of compound assertions that need to carry parameter dependencies or logical mappings, a unified string encoding format consisting of predicate identifiers and parameter lists is adopted, wherein the predicate identifier is the character identifier of its corresponding predicate.
3. The method for storing knowledge representation data structures according to claim 2, characterized in that, A storage structure for registering class-implied axioms is introduced into the equivalence relation record table. This storage structure includes: When the processor receives a query and the hash index is not found, it extracts the query predicate and parameter list, searches for rule records with the same predicate in the index table, and then returns the query registration class axiom to verify the inheritance relationship between the predicate and the found rule records with the same predicate. After the verification is successful, variable substitution is performed to generate a derivation record, which is written to the storage medium, and the hash index of the record is updated.
4. The method for storing a knowledge representation data structure according to any one of claims 1 to 3, characterized in that, The method also includes an index deduplication-driven automatic derived record appending mechanism, which includes: When new records<A, B> After being written to the storage medium, the processor automatically searches the memory index table for all associated addresses with B as the key; if an associated record is found...<B, C> Then a derived record will be automatically appended to the end of the record table.<A, C> And update the hash index table simultaneously.
5. The method for storing knowledge representation data structures according to claim 4, characterized in that, The process of establishing the hash index table corresponding to the record table includes: Obtain the physical sector address of the record on the disk. In the unified hash index table in memory, insert the first expression and the second expression carried by the first expression field and the second expression field as keys respectively, and set the storage location value corresponding to the two keys to the physical sector address.
6. The method for storing knowledge representation data structures according to claim 4, characterized in that, The conflict resolution mechanism implemented for the aforementioned equivalence relation includes: For new records<X,Y> Search the index table for Hash(X) to obtain all existing equivalent records associated with X, and then iterate through the existing equivalent records.<X, Z> It checks whether Y and Z satisfy the mutual exclusion rule. If they are not mutually exclusive, it continues. If they are mutually exclusive, it marks the equivalence class containing X, Y, and Z as conflicting and suspends the automatic propagation derivation of the equivalence class. It generates an audit work order containing conflict details, original source, and equivalence link and pushes it to the manual audit end. It updates the record status according to the returned audit processing result.
7. A method for calling a knowledge representation data structure, characterized in that, The storage method based on the knowledge representation data structure according to any one of claims 1 to 6, the retrieval method includes: When the processor receives a query request for the target expression T, it finds the physical address through the unified hash index and reads the complete single record. The complete single record is subjected to symmetric extraction processing, which includes: if the binary string of the target expression T fully matches the content of the first expression field, the system bus outputs the content carried by the second expression field; otherwise, the content carried by the first expression field is directly output.
8. The method for calling the knowledge representation data structure according to claim 7, characterized in that, The method also includes performing a vector approximate matching scan when a hash lookup misses, including: The processor transforms the target expression and the keys in the index table into bag-of-words vectors, and calculates the nearest Top-N candidate records using cosine similarity to achieve fuzzy retrieval and knowledge correction.
9. A system for storing and retrieving knowledge representation data structures, characterized in that, include: The physical storage layer is used as a storage medium to construct an equivalence relation record table. Each record in the record table includes a first expression field and a second expression field, and the two fields have no primary key and foreign key distinction in physical byte arrangement. In addition, the first expression and the second expression, which have a semantically equivalent mapping relationship, are written into the first expression field and the second expression field, respectively; The index layer is used to construct a globally unique expression hash index for a single record in the record table, so as to establish a hash index table corresponding to the record table; The processor layer is used to find the physical address and read the complete single record using a unified hash index when a query request for the target expression T is received. Furthermore, a symmetric extraction process is performed on the complete single record, which includes: if the binary string of the target expression T fully matches the content of the first expression field, the system bus outputs the content carried by the second expression field; Otherwise, directly output the content carried by the first expression field.
10. A readable storage medium for storing a computer program, characterized in that, When the computer program is executed by the processor, it can implement the storage method of the knowledge representation data structure according to any one of claims 1-6 and the calling method of the knowledge representation data structure according to any one of claims 7-8.