End-side knowledge graph construction and maintenance method and system based on small language model
By iteratively extracting entity and relation information and combining it with a verification-first strategy, the problems of information omission and illusion in knowledge graph construction by small language models are solved, improving the ability to capture details of entity descriptions and the accuracy of retrieval.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF ELECTRONICS SCI & TECH OF CHINA
- Filing Date
- 2026-03-02
- Publication Date
- 2026-05-12
AI Technical Summary
Small language models suffer from information omission and illusion problems in knowledge graph construction, especially when dealing with long text blocks with high information density, making it difficult to accurately extract entity relationships.
A small language model is used to extract iterative entity and relation information. Combined with a verification-first strategy, the relation information of the previous round is verified through iterative loops to reduce illusions and improve accuracy.
It significantly improves the ability of small language models to capture details in entity descriptions, reduces noise in the index graph during retrieval, alleviates information omission and illusion problems, and improves the robustness and consistency of knowledge graphs.
Smart Images

Figure CN122021833A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of knowledge graph construction and maintenance technology, specifically relating to a method and system for constructing and maintaining edge-side knowledge graphs based on a small language model. Background Technology
[0002] In the field of Knowledge Graph Enhanced Retrieval-Enhanced Generation (KG-RAG), mainstream frameworks such as GraphRAG and LightRAG have achieved high-quality knowledge base construction through the joint extraction capabilities of large language models (LLMs). However, for deployment requirements on edge or end-device devices, small language models (SLMs) with fewer than 10 bytes of parameters are difficult to directly adapt to complex extraction frameworks due to their weak instruction compliance capabilities.
[0003] Against this backdrop, the lightweight system MiniRAG was proposed. Its core logic is to sacrifice storage space and noise reduction pressure during retrieval in exchange for extreme speed and low cost in the construction phase, demonstrating certain application potential in resource-constrained scenarios.
[0004] However, MiniRAG has significant shortcomings in the accuracy of knowledge graph construction, which severely restricts the system's robustness and knowledge consistency. During the knowledge graph construction stage, when faced with long text blocks with high information density, single inference often suffers from information omissions and illusions due to the limitations of SLM's semantic understanding capabilities. This can result in omissions of entity relations that meet the extraction criteria or the addition of incorrect information to entity relations. Summary of the Invention
[0005] To address the issues of information omission and illusion in long context processing in existing methods, this invention proposes a method and system for constructing and maintaining edge-side knowledge graphs based on a small language model.
[0006] The objective of this invention is achieved through the following technical solution:
[0007] The first aspect of this invention discloses a method for constructing and maintaining an edge-side knowledge graph based on a small language model, comprising the following steps:
[0008] S11. Obtain at least one text block from the same technical field;
[0009] S12. Using a small language model, extract a list of entity information to be updated from the text block. The list of entity information to be updated contains at least one entity information, and each entity information includes at least two elements.
[0010] The entity information list includes at least two entities to be updated and the entity information corresponding to each entity to be updated;
[0011] S13. Using a small language model, extract the relationship information to be updated between each entity pair based on the text block, the list of entity information to be updated, and the prompt words constructed based on the entity information. The entity pair includes two entities, and the iteration number is set to 0.
[0012] S14. Using a small language model, extract the iterative entity information list and the iterative relationship information between entity pairs based on the text block, the entity information list to be updated and the relationship information to be updated, and increment the iteration count by one.
[0013] S15. In response to the iteration count being less than a preset value, the iterated entity information list is updated to the entity information list to be updated and the iterated relationship information is updated to the relationship information to be updated, and then step S14 is continued until the iteration count is equal to the preset value, so as to obtain the final entity information list and the final relationship information between entity pairs.
[0014] The second aspect of this invention discloses an edge-side knowledge graph construction and maintenance system based on a small language model, comprising a memory and a controller connected in sequence. The memory stores a computer program, and the controller is used to read the computer program and execute the edge-side knowledge graph construction and maintenance method based on a small language model described in the first aspect.
[0015] The beneficial effects of this invention are:
[0016] The solution of this invention is more adaptable to the capability boundaries of small language models. In the same graph indexing task, this method significantly improves the ability of SLM to capture details of entity descriptions and reduces noise in the index graph during retrieval, effectively alleviating the information omission and illusion problems of SLM in long context processing. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. 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.
[0018] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0020] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0021] It should be noted that, unless otherwise specified, the embodiments and features described in this invention can be combined with each other.
[0022] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0023] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use, or the orientation or positional relationship commonly understood by those skilled in the art. They are only used for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention. In addition, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0024] In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0025] The first aspect of this invention discloses a method for constructing and maintaining an edge-side knowledge graph based on a small language model, such as... Figure 1As shown, it includes steps S11 to S19. It should be noted that the step identifiers in this scheme are only for the convenience of describing the method and do not constitute a limitation on the order of steps. The order of each step is based on its verbal description and the sequential connection of each signal.
[0026] S11. Obtain at least one text block.
[0027] Specifically, first, at least one piece of text data from the same technical field is collected, then cleaned to remove garbled characters, duplicate paragraphs, and irrelevant advertising information. When the length of the text data exceeds a first length threshold, it is segmented into at least two text blocks. When the length of the text data is less than or equal to the first length threshold, segmentation is not required, and the text data is used directly as a text block.
[0028] The first length threshold is set to less than or equal to 1200 tokens. When splitting, adjacent text blocks are set to overlap by 100 tokens, and the original metadata information is retained for each text block.
[0029] To facilitate the differentiation between text blocks and text data, a hash function is further applied to each text block to generate a unique corresponding text block number. The hash function can be MD5, MD4, or similar functions.
[0030] S12. Using a small language model, extract a list of entity information to be updated from the text block. The list of entity information to be updated contains entity information of at least one entity, and each entity information includes at least two elements.
[0031] In this step, the extraction of the entity information list to be updated uses a small language model. Entity recognition prompts are used to identify entities of preset types, such as names, organizations, locations, and concepts. The small language model then adds brief descriptions to these entities, outputting a speculative list of entity information to be updated. This list contains information on at least one entity, including at least two elements: a type identifier, an entity name, an entity category, and an entity description. Each element is separated by a preset delimiter, such as "<|>". The type identifier for the entity information is "entity", for example: (entity <|> entity name <|> entity type <|> entity description).
[0032] Small language models can use Qwen3-4B-instruct.
[0033] For example, the extracted entity information is as follows:
[0034] ("entity"<|>"Alex"<|>"person"<|>"Alex is a character who experiences frustration and is observant of the dynamics among other characters.")
[0035] S13. Using a small language model, extract the relationship information to be updated between each entity pair based on the text block, the list of entity information to be updated, and the prompt words constructed based on the entity information. Set the iteration count to 0. Each entity pair includes two entities. The two entities in the entity pair include a source entity and a target entity.
[0036] This step takes a text block and the list of entity information to be updated output from step S12 as input, constructs prompt words containing known entity information, forces SLM to only look for the two ends of the relationship in the given entity information list, and adds a brief description to the relationship. SLM outputs a list of inferred relationships. The elements of the relationship information to be updated in the inferred relationship list include, but are not limited to, type identifiers, source entity names, target entity names, relationship descriptions, and relationship keywords, with each element separated by a preset delimiter. The type identifier of the relationship information can be "relationship", for example: (relationship <|>source entity name<|>target entity name<|>relationship description<|>relationship keywords).
[0037] S14. Using a small language model, extract the iterative entity information list and the iterative relationship information between entity pairs based on the text block, the list of entity information to be updated, and the relationship information to be updated, and increment the iteration count by one.
[0038] When faced with text blocks with high information density, single-step inference often suffers from illusions due to the limitations of SLM's semantic understanding capabilities, resulting in the omission of entity relations that meet the extraction criteria or the addition of incorrect information to entity relations. To address this, this step adopts an entity relation extraction based on a verification-first strategy.
[0039] The validation-first strategy provides the entity relations extracted in the previous round as candidate answers to the SLM, forcing the SLM to perform reverse validation first and then re-extract.
[0040] S15. In response to the iteration count being less than a preset value, the iterated entity information list is updated to the entity information list to be updated and the iterated relationship information is updated to the relationship information to be updated, and then step S14 is continued until the iteration count is equal to the preset value, so as to obtain the final entity information list and the final relationship information between entity pairs.
[0041] The number of iterations is set according to the specific situation, with a maximum of 2 iterations.
[0042] Finally, the elements in the final relation information include, but are not limited to, type identifiers, source entity names, target entity names, relation descriptions, and relation keywords.
[0043] Steps S14 and S15 use the text block and the entity relationships from the previous output as input, iterating continuously to obtain the final entity and relationship information. The verification-first strategy does not self-correct, i.e., it doesn't ask "Anything missing?", but instead provides an initial answer—the relationship information from the previous round—and requires the model to verify it first. This forces SLM to look for evidence that the existing list is incorrect before performing extraction. The verification process, such as checking whether an entity conforms to the defined type, is essentially deriving the premise backward from the conclusion. This backward path contains supplementary information not found in standard forward thought chains. Through iterative loops, SLM verifies the relationship information from the previous round in each iteration. Because each round starts from the original text again for verification and generation, the model is more likely to capture deep, hidden relationships in high-density text, reduces the illusion of small models, and improves the accuracy of relationship information extraction.
[0044] S16. Checking and formatting entity information and final relationship information.
[0045] Specifically, for entity information: first, extract the first element of the entity information and determine whether it is an entity type identifier based on the first element, i.e., its first element should be entity; in response to the first element being an entity type identifier, determine the number of elements in the entity information; in response to the number of elements in the entity information being greater than 4 or less than 4, delete the entity information.
[0046] By validating the elements in the entity information, we ensure that it includes a type identifier, entity name, entity category, and entity description. If the conditions are not met, the record is invalid and discarded.
[0047] During formatting, the entity name is extracted and converted to all uppercase to serve as a unique entity ID in the knowledge graph, eliminating node duplication caused by case differences. The entity type field is also converted to uppercase to establish a unified type hierarchy. The standardized entity name, entity type, and entity description are extracted and associated with the source text block number, then encapsulated into a standardized entity dictionary.
[0048] For the final relationship information: firstly extract the first element of the final relationship information and determine whether it is a type identifier of the relationship information based on the first element; in response to the first element being a type identifier of the relationship information, determine the number of elements in the final relationship information; in response to the number of elements in the final relationship information being greater than 5 or less than 5, delete the final relationship information.
[0049] During formatting, the source and target entity names are extracted from the final relation information, and a full uppercase conversion is enforced. The relation description and keywords are extracted, associated with the source text block numbers, and encapsulated into a standardized relation information dictionary.
[0050] S17. Concurrent result collection.
[0051] For each entity, entities with the same name in the entity dictionary are merged to obtain the entity to be written. ,in, For entities The key is the entity name. To and All related entity dictionaries, include , where n is the number of entity dictionaries with the same entity name. Entities to be written. It contains a dictionary of all entity information about this entity name extracted from different text blocks.
[0052] For example, taking the entity name "APPLE" as an example, its for:
[0053] {
[0054] "APPLE": [
[0055] # Information from the first text block
[0056] {
[0057] "entity_name": "APPLE",
[0058] "entity_type": "ORG",
[0059] "description": "A US-based tech giant..."
[0060] "source_id": "chunk-hash-1"
[0061] },
[0062] # Information from the 5th text block
[0063] {
[0064] "entity_name": "APPLE",
[0065] "entity_type": "FRUIT",
[0066] "description": "A red fruit..."
[0067] "source_id": "chunk-hash-5"
[0068] },
[0069] # Information from the 10th text block
[0070] {
[0071] "entity_name": "APPLE",
[0072] "entity_type": "ORG",
[0073] "description": "A new iPhone has been released...",
[0074] "source_id": "chunk-hash-10
[0075] }
[0076] ],
[0077] That is, the entity "APPLE" appears in all 10 text blocks.
[0078] Regarding the final relation information: First, the source entity names and target entity names in the relation information dictionary are undirected and normalized; then, the relation information dictionaries with the same source entity names and target entity names in the normalized relation information dictionaries are merged to obtain the relation to be written. ,in, A tuple containing the source entity name and the target entity name. To and A dictionary containing all relevant relational information. include ,in The number of dictionaries containing relationship information between source and target entity names.
[0079] For example, after performing undirected normalization on source entity name a and target entity name b and source entity name b and target entity name a in two different relation information dictionaries, they are both source entity name a and target entity name b, ensuring that the source entity name and target entity name are arranged in ascending order of strings.
[0080] A tuple consisting of the source entity name 'APPLE' and the target entity name 'IPHONE'. for:
[0081] :
[0082] {
[0083] # The key is the sorted tuple ('APPLE', 'IPHONE')
[0084] ('APPLE', 'IPHONE'): [
[0085] # Record 1: Extraction result from text block-1
[0086] {
[0087] "src_id": "APPLE", # Original source entity
[0088] "tgt_id": "IPHONE", # Original target entity
[0089] "description": "Apple released the iPhone 15", # Relationship description
[0090] "keywords": "release, product", # keywords
[0091] "source_id": "chunk-hash-1", # Source text block ID
[0092] "metadata": {
[0093] "created_at": "2025-12-25T10:00:00"
[0094] }
[0095] },
[0096] # Second record: Extraction results from text block-2
[0097] {
[0098] "src_id": "IPHONE", # Note: Here src is IPHONE
[0099] "tgt_id": "APPLE", # Here tgt stands for APPLE
[0100] "description": "The iPhone is Apple's most famous product."
[0101] "keywords": "famous, product",
[0102] "source_id": "chunk-hash-2",
[0103] "metadata": {
[0104] "created_at": "2025-12-25T10:00:05"
[0105] }
[0106] } ]
[0108] S18. Perform disambiguation processing on entities.
[0109] Entity disambiguation is a core task in the field of knowledge graph construction. Its goal is to map ambiguous entities mentioned in text to unique, corresponding real entities in the knowledge graph. If multiple different names are found to actually represent the same entity only during the write phase, multiple additional database read operations will be performed. These database read operations take significantly longer than the SLM call, thus impacting the overall time.
[0110] To address this, first consider the i-th entity to be written. The entity names in the data are vectorized to obtain entity name vectors. Then calculate the vectors of any two entity names. The similarity score is used to determine if there is any ambiguity between the two entities. Specifically, if the similarity score is greater than a first threshold, then for the two corresponding entities to be written... Merge the entities; if the similarity is greater than or equal to the second threshold and less than or equal to the first threshold, merge the corresponding entities to be written. The input to the small language model is used to determine whether they are the same entity again. If the first threshold is greater than the second threshold, when the small language model determines that they are the same entity, the two corresponding entities to be written are considered. Merge.
[0111] If a small language model determines that the two entities are not the same or that the similarity is less than the second threshold, no action is taken.
[0112] The similarity here can be calculated using cosine similarity. The corresponding first threshold can be set to any value between 0.89 and 0.92. The second threshold can be set to any value between 0.80 and 0.84.
[0113] Treat the entity to be written The merging process involves combining information from entities with shorter names into the list of entities with longer names. For example, if the similarity between the name vectors of "NYC" and "NEW YORK CITY" is 0.93, then the entity information for "NYC" needs to be merged into "NEW YORK CITY". Simultaneously, the source entity name or target entity name field in the relationship information involving the merged entities needs to be modified.
[0114] This step, after deduplication by uppercase normalization, further disambiguation is performed at the semantic level to prevent synonymous but different entities from being identified as independent nodes in existing methods, thereby reducing the problem of knowledge fragmentation.
[0115] S19. Incremental maintenance of knowledge graph.
[0116] Specifically, this step includes the entity information writing step and the relationship information writing step.
[0117] The entity information writing steps specifically include steps S1911 to S1915.
[0118] S1911, Based on the entity to be written The entity name is queried from the knowledge graph, and the entity category and entity description corresponding to the entity name are extracted from the knowledge graph.
[0119] S1912, Statistics of entities to be written Based on the frequency of each entity type in the historical entity information, update the entity type with the highest frequency to the entity type corresponding to that entity name.
[0120] Count the frequency of each entity type, sort the results from highest to lowest frequency, and take the entity type with the highest frequency as the final entity type for that entity name. For example, the entity name "APPLE" in... There are 3 records of type "ORG" and 1 record of type "FRUIT". This entity already exists in the knowledge graph and its type is "ORG". According to the statistical results, "ORG" appears 4 times and "FRUIT" appears once. Therefore, the entity type of "APPLE" is finally determined to be "ORG".
[0121] S1913, Extract the entity to be written The entity description in the knowledge graph is concatenated with the entity description corresponding to the entity name in the knowledge graph to obtain the concatenated entity description.
[0122] The concatenation in this step is handled directly by string concatenation.
[0123] S1914. Length determination is performed on the spliced entity description. In response to the length of the spliced entity description being greater than the second length threshold, the spliced entity description is input into a small language model for summary fusion to obtain an entity description to be updated with a length less than or equal to the second length threshold.
[0124] The second length threshold can be set according to specific circumstances, such as 500 tokens or other values.
[0125] S1915. The entity name, the entity type to be updated, and the entity description to be updated are encapsulated and written into the knowledge graph.
[0126] The steps for writing relational information specifically include steps S1921 to S1925.
[0127] S1921, Extract the relation to be written The source entity name and target entity name are identified in the knowledge graph. Then, it is checked whether there is an edge from the source entity name to the target entity name in the knowledge graph. If there is an edge from the source entity name to the target entity name in the knowledge graph, the relation description, relation keywords and text block number of the edge are extracted from the knowledge graph.
[0128] S1922, Treating Write Relationships The keywords of the relationship in the knowledge graph and the keywords of the corresponding relationship in the knowledge graph are deduplicated and then connected with a delimiter to obtain the keywords to be updated.
[0129] Furthermore, after deduplication, the data can be sorted alphabetically.
[0130] S1923, Treating Write Relationships The text block numbers in the knowledge graph and the corresponding text block numbers in the knowledge graph are deduplicated and then connected with a delimiter to obtain the text block number to be updated.
[0131] S1924, Treating Write Relationships The relation description in the graph and the relation description corresponding to the edge in the knowledge graph are concatenated to obtain the relation description to be updated.
[0132] Furthermore, the length of the relation description to be updated is determined. If the length of the relation description to be updated is greater than the third length threshold, the relation description to be updated is input into a small language model for summary fusion to obtain a relation description to be updated with a length less than or equal to the third length threshold.
[0133] The third length threshold can be set according to specific circumstances, such as 500 tokens or other values.
[0134] S1925. The source entity name, target entity name, keyword to be updated, text block number to be updated, and relation description to be updated are encapsulated and written into the knowledge graph.
[0135] By adopting the above steps to maintain the knowledge graph, redundant storage of a large number of semantically repetitive but not completely identical characters is avoided, the construction cost of vector index is reduced, key facts are prevented from being buried during the retrieval stage, and the reasoning performance of the system in high-frequency update or long-cycle tasks is improved.
[0136] Furthermore, a hash function can be used to calculate a unique ID for all entity names, facilitating indexing in a vector database.
[0137] The second aspect of this invention discloses an edge-side knowledge graph construction and maintenance system based on a small language model, comprising a memory and a controller connected in sequence. The memory stores a computer program, and the controller is used to read the computer program and execute the edge-side knowledge graph construction and maintenance method based on a small language model described in the first aspect. Specifically, the memory may include, but is not limited to, random-access memory (RAM), read-only memory (ROM), flash memory, first-in-first-out (FIFO) memory, and / or first-in-last-out (FILO) memory, etc.; the controller may not be limited to using a microcontroller of the STM32F105 series. Furthermore, the computer device may also include, but is not limited to, a power supply unit, a display screen, and other necessary components.
[0138] The operating principle of the system disclosed in the second aspect of the present invention is detailed in the first aspect and will not be repeated here.
[0139] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.
Claims
1. A method for constructing and maintaining an edge-side knowledge graph based on a small language model, characterized in that, Includes the following steps: S11. Obtain at least one text block from the same technical field; S12. Using a small language model, extract a list of entity information to be updated from the text block. The list of entity information to be updated contains at least one entity information, and each entity information includes at least two elements. S13. Using a small language model, extract the relationship information to be updated between each entity pair based on the text block, the list of entity information to be updated, and the prompt words constructed based on the entity information. The entity pair includes two entities, and the iteration number is set to 0. S14. Using a small language model, extract the iterative entity information list and the iterative relationship information between entity pairs based on the text block, the entity information list to be updated and the relationship information to be updated, and increment the iteration count by one. S15. In response to the iteration count being less than a preset value, the iterated entity information list is updated to the entity information list to be updated and the iterated relationship information is updated to the relationship information to be updated, and then step S14 is continued until the iteration count is equal to the preset value, so as to obtain the final entity information list and the final relationship information between entity pairs.
2. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 1, characterized in that, The elements in the entity information include a type identifier, entity name, entity category, and entity description; After obtaining the final entity and the final relationship information between entity pairs, the process also includes: Extract the first element of the entity information and determine whether it is an entity type identifier based on the first element; In response to the first element being an entity type identifier, determine the number of elements in the entity information; If the number of elements in the entity information is greater than 4 or less than 4, delete the entity information.
3. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 1, characterized in that, The elements in the final relationship information include a type identifier, a source entity name, a target entity name, a relationship description, and relationship keywords; After obtaining the final entity and the final relationship information between entity pairs, the process also includes: Extract the first element of the final relation information and determine whether it is a type identifier of relation information based on the first element; In response to the first element being a type identifier for relational information, determine the number of elements in the final relational information; If the number of elements in the final relation information is greater than 5 or less than 5, delete the final relation information.
4. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 1, characterized in that, The elements in the entity information include a type identifier, entity name, entity category, and entity description; After obtaining the final list of entity information and the final relationship information between entity pairs, the process also includes: After performing uppercase conversion on the entity name and entity type in the entity information, along with the entity description and the text block number corresponding to the entity, they are encapsulated into an entity dictionary. Merge entity dictionaries with the same entity name to obtain the entity to be written. ,in, For entity name, To and All related entity dictionaries, include , where n is the number of entity dictionaries with the same entity name; Treat the entity to be written The entity names in the code are ambiguous and need to be resolved.
5. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 4, characterized in that, The entity to be written The entity names in the document undergo ambiguity resolution, including: For the i-th entity to be written The entity names in the data are vectorized to obtain entity name vectors. ; Calculate the vector of any two entity names Similarity; In response to the similarity being greater than a first threshold, for two corresponding entities to be written... Merge; In response to a similarity greater than or equal to a second threshold and less than or equal to a first threshold, the corresponding two entities to be written are... Input a small language model to determine whether they are the same entity, and the first threshold is greater than the second threshold; In response to the small language model determining that they are the same entity, for the two corresponding entities to be written... Merge.
6. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 4, characterized in that, The final relationship information includes a type identifier, source entity name, target entity name, relationship description, and relationship keywords; After obtaining the final list of entity information and the final relationship information between entity pairs, the process also includes: After performing capitalization on the source entity name and target entity name in the final relation information, along with the relation description, relation keywords, and the text block number corresponding to the final relation information, it is encapsulated into a relation information dictionary; After performing undirected normalization on the source entity names and target entity names in the relation information dictionary, the relation information dictionaries with the same source entity names and target entity names are merged to obtain the relation to be written. ,in, A tuple containing the source entity name and the target entity name. To and A dictionary containing all relevant relational information. include ,in The number of dictionaries containing relationship information between source and target entity names.
7. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 6, characterized in that, The relationship to be written is obtained This also includes: Based on the entity to be written The entity name is queried from the knowledge graph, and the entity category and entity description corresponding to the entity name are extracted from the knowledge graph. Statistics of entities to be written Based on the frequency of each entity type in the historical entity information, the entity type with the highest frequency is selected as the entity type to be updated for that entity name; Extract the entity to be written The entity description in the knowledge graph is concatenated with the entity description corresponding to the entity name in the knowledge graph to obtain the concatenated entity description. The length of the spliced entity description is determined. If the length of the spliced entity description is greater than the second length threshold, the spliced entity description is input into a small language model for summary fusion to obtain an entity description to be updated with a length less than or equal to the second length threshold. The entity name, the entity type to be updated, and the entity description to be updated are encapsulated and written into the knowledge graph.
8. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 6, characterized in that, The relationship to be written is obtained This also includes: Extract the relationship to be written The source entity name and target entity name are identified in the knowledge graph. Then, it is checked whether there is an edge from the source entity name to the target entity name in the knowledge graph. If there is an edge from the source entity name to the target entity name in the knowledge graph, the relation description, relation keywords and text block number of the edge are extracted from the knowledge graph. Treating write relationships The keywords of the relationship in the knowledge graph and the keywords of the relationship corresponding to the edge in the knowledge graph are deduplicated and then connected with a delimiter to obtain the keywords to be updated. Treating write relationships The text block numbers in the text graph and the text block numbers corresponding to the edge in the knowledge graph are deduplicated and then connected with a delimiter to obtain the text block number to be updated. Treating write relationships The relation description in the knowledge graph and the relation description corresponding to the edge are concatenated to obtain the relation description to be updated. The source entity name, target entity name, keyword to be updated, text block number to be updated, and relationship description to be updated are encapsulated and written into the knowledge graph.
9. The method for constructing and maintaining an edge-side knowledge graph based on a small language model according to claim 8, characterized in that, After obtaining the description of the relationship to be updated, the process also includes: The length of the relation description to be updated is determined. If the length of the relation description to be updated is greater than the third length threshold, the relation description to be updated is input into a small language model for summary fusion to obtain a relation description to be updated with a length less than or equal to the third length threshold.
10. A terminal-side knowledge graph construction and maintenance system based on a small language model, comprising a memory and a controller connected in sequence, wherein the memory stores a computer program, characterized in that, The controller is used to read the computer program and execute the edge knowledge graph construction and maintenance method based on a small language model as described in any one of claims 1 to 9.