Method for complementing bionic prototype memory attention network through few-sample citrus knowledge graph
By constructing a biomimetic prototype memory attention network to complete the citrus knowledge graph, and utilizing multi-component memory modules and loss constraints, the problem of representation and adaptation of the citrus knowledge graph in scenarios with few samples was solved. This achieved efficient completion and improved timeliness of the knowledge graph, supporting intelligent applications in the citrus industry.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-27
- Publication Date
- 2026-03-27
AI Technical Summary
Existing citrus knowledge graphs have weak relation representation capabilities in scenarios with few samples, lack a memory mechanism adapted to the evolution of citrus knowledge, and are at risk of overfitting under scarce samples, making it difficult for knowledge graphs to adapt to the technological iteration and intelligent applications of the citrus industry.
We construct a biomimetic prototype memory and attention network to complete a few-sample citrus knowledge graph. By using multi-component memory modules (short-term, working, and long-term memory) and a memory replay mechanism, combined with attention mechanisms and loss constraints, we generate stable relation prototypes, thereby improving the completeness and timeliness of the knowledge graph.
It effectively represents the knowledge associations of citrus, dynamically adapts to the evolution of industry knowledge, reduces the risk of overfitting, improves the completeness and timeliness of the citrus knowledge graph, and provides reliable intelligent knowledge support for the citrus industry.
Smart Images

Figure CN121745255A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of computer artificial intelligence, and particularly relates to a few-shot citrus knowledge graph completion bionic prototype memory attention network method. BACKGROUND
[0002] Under the background of the evolution from digitization to intelligence and the deep integration into the agricultural field, knowledge graph relying on the structured information capability has become the core support for the intelligent transformation of the citrus industry. In traditional citrus cultivation, information exists in a scattered and unstructured form, which leads to great difficulty in knowledge reuse and hinders the landing of intelligent applications, such as the dependence on manual experience for planting guidance and the lack of systematic knowledge support for market analysis. In recent years, although the citrus knowledge graph has shown advantages in integrating industry chain information and supporting the construction of digital platforms, it can provide underlying knowledge support for intelligent applications such as planting guidance and market analysis, there are still obvious shortcomings in the existing technical system. At present, the knowledge graph generally has the problem of insufficient integrity, and the citrus knowledge graph is no exception, such as the lack of relationships between some new citrus varieties and production areas and pest control methods. Especially in the citrus industry, few-shot knowledge scenarios are very common, such as the relationship between rare pests and symptoms, and the number of corresponding triples is often insufficient, highlighting the problem of sample scarcity. Therefore, few-shot knowledge graph completion technology is highly adaptable to the citrus industry and has important application value. However, although the existing technology has made some progress, there are still defects when it is applied to the citrus industry: (1) weak few-shot relationship representation capability: citrus knowledge has strong correlation, such as the diagnostic relationship between "Huanglongbing-leaf symptoms" and "bacterial wilt-leaf symptoms" has structural similarity, but existing methods mostly handle each type of few-shot task in isolation, failing to fully exploit this type of associated information; (2) lack of memory mechanism adapted to the evolution of citrus knowledge: citrus knowledge is constantly updated, with new pests and varieties, new cultivation techniques, and improved varieties emerging, and existing methods do not build an effective memory storage and updating mechanism, which cannot simulate the process of human dynamic accumulation of knowledge, making it difficult for the knowledge graph to adapt to the iteration of industrial technology; (3) overfitting risk is prominent under the condition of sample scarcity: the knowledge in the subdivided field of citrus is extremely scarce, and existing methods do not design a special loss constraint mechanism for the characteristics of industrial knowledge, which is prone to overfitting of the model due to insufficient data when training such few-shot tasks, limiting the landing value of the technology in the citrus application scenario.
[0003] Therefore, it is urgent to develop a few-shot knowledge graph completion optimization method that adapts to the characteristics of citrus, to break through the bottleneck of existing technology and improve the support capability of the knowledge graph for the digital and intelligent transformation of the citrus industry. SUMMARY
[0004] The embodiment of the present application aims to provide a few-shot citrus knowledge graph completion biomimetic prototype memory attention network method to realize efficient representation and correlation mining of few-shot relations in citrus industry knowledge, construct a biomimetic memory updating mechanism adapting to the dynamic evolution of industry knowledge, reduce the overfitting risk of the model in the ultra-few-shot scene through targeted loss constraint, and then accurately complete the missing triple information in the citrus knowledge graph, and improve the integrity and timeliness of the citrus knowledge graph.
[0005] To solve the above technical problems, the technical solution adopted by the present application is a few-shot citrus knowledge graph completion biomimetic prototype memory attention network method, comprising the following steps: S1: For a few-shot task relation in the citrus knowledge graph An entity pair , the neighborhood of the head entity and the tail entity is defined respectively, and the semantic representation of the entity pair is generated ; S2: Construct a memory module containing transient memory, working memory and long-term memory, and generate a memory enhanced prototype vector through memory playback and update ; S3: Calculate the similarity between the query representation And the memory enhanced prototype vector , and evaluate the credibility of the query representation triple based on the similarity; S4: Construct a support set and a positive and negative query set, construct a ranking loss and a prototype smoothing loss, and obtain a few-shot citrus knowledge graph completion model through element training to minimize the total loss.
[0006] Further, the specific steps of S1 are: S1.1: decompose the few-shot task relation Into forward representation And backward representation , wherein Indicates the embedding dimension, and the query vector And the key vector Are generated by linear transformation S1.2: Use a bilinear product function , in the form of splicing the forward representation And the backward representation , to simulate the pairwise interaction between the head entity And the tail entity ; S1.3: For the neighbors Of the head entity , use a feedforward neural network to integrate the information of adjacent entities and adjacent relations to learn the semantic representation Of the neighbor, and use the semantic representation mapping to value vectors by linear transformation , representing the head entity , representing the neighbor entity representing the neighbor relationship S1.4: calculating the relevance score of the neighbor relationship and the task relationship by using the bilinear dot product , and normalizing the attention weight by using the softmax function ; S1.5: generating the weighted neighbor representation of the head entity by using the attention weight and the value vector of the neighbor , and fusing the weighted neighbor representation of the head entity and the pre-trained entity embedding to obtain the enhanced representation of the head entity ; ; ; S1.6: generating the enhanced representation of the tail entity ; ; S1.7: performing vector splicing on the enhanced representation of the head entity and the enhanced representation of the tail entity , and then performing nonlinear transformation on the vector splicing result by using the position forward feedforward neural network to obtain the semantic representation of the entity pair .
[0007] Further, the S2 specific steps are as follows: S2.1: based on the semantic representation of each triple in the support set , calculating the attention weight of the semantic representation of each triple in the support set relative to each triple in the query set , and performing weighted summation on the semantic representation of each triple in the support set to obtain the weighted prototype vector of the few-shot task relationship ; ; ; ; ; S2.2: constructing a multi-level memory module including a transient memory module, a working memory module and a long-term memory module, and dynamically updating the multi-level memory module, wherein the transient memory module adopts a first-in-first-out cache queue structure and is used for temporarily storing the latest prototype vector generated by the current task; the transient memory module is updated immediately after each new task The working memory module adopts a clustering central library structure, which is used to cluster prototype vectors transferred from transient memory to store representative prototypes, and uses a frequency matrix to count the frequency at which prototypes are recalled. The working memory module is used to periodically cluster and integrate prototypes in the transient memory; The long-term memory module adopts a priority queue structure to store frequently used prototypes migrated from working memory, and performs priority management and obsolete prototype elimination based on recall frequency and storage time. S2.3: Utilize an attention mechanism to extract prototype features relevant to the current query task from immediate memory, working memory, and long-term memory respectively. Calculate the aggregation weight of each prototype feature, generate a memory representation of each prototype feature based on the aggregation weight, and fuse the memory representations of each prototype feature to generate a memory-enhanced prototype vector. .
[0008] Furthermore, the implementation methods of the immediate memory module, working memory module, and long-term memory module in S2.2 are as follows: The instantaneous memory module is based on a dynamic cache pool, uses a first-in-first-out cache queue as the storage structure, sets the cache capacity through hyperparameters, and establishes a real-time receiving, temporary storage, and full-capacity migration mechanism. The working memory module is implemented based on K-Means clustering and frequency matrix, and uses a cluster center library as the storage structure. The K-Means clustering algorithm clusters the batch prototypes of transient memory transfer, and the number of clusters K is determined by the validation set optimization. The long-term memory module is implemented based on a priority queue and a decay mechanism. It uses a priority queue as the storage structure and establishes a priority calculation mechanism based on recall frequency and storage time.
[0009] Furthermore, the specific steps of S2.3 are as follows: S2.3.1: From instantaneous memory Select the top K relevant prototype features Extract representative prototype content related to the current task from the working memory module. Extracting high-frequency core prototype content relevant to the current task from long-term memory modules. ; S2.3.2: For the candidate prototypes extracted from each memory module, calculate their aggregation weights using the attention mechanism and generate task representations for each level of memory; S2.3.3: The transient memory representation, working memory representation, and long-term memory representation generated in S2.3.2 are fused to generate a prototype vector based on memory enhancement. .
[0010] Further, S3 specific steps are: S3.1: Calculate similarity between query and memory enhanced prototype vector. S3.2: Evaluate the semantic fit of the query to the memory prototype based on the similarity.
[0011] Further, the similarity calculation formula between query and memory enhanced prototype vector in S3.1 is: Wherein: is the semantic representation of query , is the memory enhanced prototype vector, is the query, is the support set, and represents element-wise product.
[0012] Further, S4 specific steps are: S4.1: Construct support set, positive query set and negative query set from citrus knowledge graph dataset. The negative query set is generated by replacing the tail entity of each entity pair in the positive query set , and the calculation formula of the negative query set is: Wherein: is the negative query set, is the head entity, is the wrong tail entity, is the correct tail entity, is the positive query set. S4.2: Build and minimize ranking loss function , so that the similarity score of the positive query set is higher than that of the negative query set , and the calculation formula of the ranking loss function is: Wherein: is the ranking loss function, is the hinge loss function, is the margin hyperparameter, is the similarity score between query positive entity pair and support set , is the similarity score between query negative entity pair and support set , is the query positive entity pair, to query negative entity pairs; S4.3: Constructing a prototype smoothing loss of memory reinforcement ; S4.4: Combining the ranking loss and the smoothing loss to obtain a total loss function, minimizing the total loss function through meta-training of batch sampling to obtain a few-shot citrus knowledge graph completion model.
[0013] The beneficial effects of the present application are: 1) The present application breaks the limitations of existing methods for isolated task processing by constructing a multi-component memory bank containing transient, working and long-term memory, fully excavates the associated knowledge of citrus knowledge such as planting and market, generates more rich and stable relationship prototypes, and effectively solves the representation problem of few-shot knowledge such as citrus planting, prevention and market analysis; 2) The present application is characterized by continuous updating of knowledge such as new varieties of pests and diseases in different citrus producing areas and new planting techniques, and the bionic memory updating mechanism combined with memory playback can realize smooth transition of information to long-term memory and reuse of old knowledge, dynamically accumulate new knowledge of the industry, avoid the problem that the existing method cannot adapt to technical iteration due to lack of memory updating, and ensure the timeliness of the citrus knowledge graph; 3) The present application uses memory reinforcement prototype smoothing triple loss to constrain the similarity of new and old knowledge, which can cope with the few-shot scenario of triplets in the subdivided field of citrus, and experimental verification shows that it is more robust on complex data sets than existing methods, providing more reliable knowledge support for intelligent application of the citrus industry. BRIEF DESCRIPTION OF DRAWINGS
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0015] Figure 1 is a flowchart of the present application; Figure 2 is a memory updating and recall mechanism flowchart of the present application; Figure 3 is a memory storage mechanism flowchart of the present application; Figure 4 is a memory recall mechanism flowchart of the present application. DETAILED DESCRIPTION
[0016] Clearly, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.
[0017] The application point of the present application is that, aiming at the characteristics of strong correlation and scarce samples of citrus few-sample knowledge (such as rare disease and pest-symptom correlation, new variety-prevention method correlation, etc.), a multi-component memory storage structure containing transient memory, working memory and long-term memory is proposed. The transient memory quickly captures the latest knowledge of citrus (such as the correlation of new varieties of diseases and pests), the working memory integrates the same knowledge of citrus through clustering (such as the representative prototype of the susceptibility of different citrus varieties to bacterial wilt), and the long-term memory stores high-frequency core knowledge (such as the key correlation of mainstream varieties and common diseases), thereby generating stable relationship prototypes that are more suitable for the industry scene and solving the problem of weak representation of few-sample relationship. Secondly, combined with the characteristics of continuous updating of citrus industry knowledge (such as iteration of new cultivation techniques and emergence of disease and pest varieties), a bionic memory updating mechanism is designed. The mechanism smoothes the integration of new information of citrus industry in the transient memory to the working memory through clustering compression, and then migrates the high-value industry core knowledge (such as the variety-disease relationship of high-frequency consultation) in the working memory to the long-term memory according to the query frequency. At the same time, the mechanism realizes the reuse of old knowledge by means of memory playback, avoids the forgetting of old knowledge caused by the iteration of new knowledge of the industry, and ensures that the knowledge graph can dynamically adapt to the evolution of the technology of the citrus industry. Finally, for the ultra-few-sample scene containing only single-digit triples in the subdivided fields of the citrus industry, a memory reinforcement prototype smoothing triple loss function is constructed. The loss function constrains the similarity of new and old knowledge of the citrus industry, which not only prevents overfitting of the model to scarce samples, but also avoids catastrophic forgetting caused by learning of new knowledge.
[0018] The following will further illustrate the few-sample completion bionic prototype memory attention network for citrus knowledge graph constructed by the present application in detail in combination with the drawings.
[0019] As shown in Figure 1 , the method for constructing the few-sample completion bionic prototype memory attention network for citrus knowledge graph constructed by the present application comprises the following steps: S1: For a few-sample task relationship in the citrus knowledge graph , an entity pair (e.g. =“citrus”, =“bacterial wilt”, =“susceptible to infection”), the neighborhood of the head entity and the tail entity thereof is defined respectively, and the semantic representation of the entity pair is generated through an entity pair feature information encoder; The specific steps for S1 are as follows: S1.1: Considering the semantic bidirectionality of relations in the citrus industry (e.g., the semantics of "susceptible" and "being susceptible" are different), the few-sample task relations will be... Decompose into forward representation (e.g., the forward semantics of "susceptibility to infection" in "citrus → ulcer disease") and backward representation (e.g., the backward semantic meaning of "susceptible to infection" in "ulcer disease ← citrus"), where, Indicates the embedding dimension. This represents the relational transformation matrix.
[0020] Then, a query vector is generated through linear transformation. and key vector The query vector As shown in equation (1), the query vector Used to map forward relations to query semantics; in: For query vector, For task relationship The forward representation, The first learnable parameter matrix, .
[0021] key vector As shown in equation (2), the key vector Used to map proximity relationships to key semantics; in: For key vectors, It is a head entity Proximity relationships (e.g., "citrus - good storage"), This is the second learnable parameter matrix. .
[0022] S1.2: Using the bilinear product function , previously indicated and backward representation The splicing method simulates the head entity. Tail-end entity Paired interactions between; The bilinear product function is shown in equation (3): in: It is a bilinear product (function). For head entities (such as the pre-trained vector of "citrus"). For tail entities (such as the pre-trained vector of "ulcer disease"); Bilinear product function By capturing the higher-order associations between the two, we can characterize the interactive semantics of entity pairs (such as the association strength of "variety characteristics - disease susceptibility").
[0023] S1.3: For head entities Neighbors (e.g., the relationship in "citrus - shelf life") = "Storage resistant", physical =“Storage period” Represents head entity Neighborhood relations representation (This method represents neighbor entity representations) and integrates information about neighbor entities and neighbor relationships using a feedforward neural network to learn semantic representations of neighbors. As shown in equation (4): in: To learn the semantic representations of neighbors, To correct the linear unit, For head entity Relationships among neighbors For head entity Entities in the neighborhood The first learnable parameter matrix shared by all neighbors. , The second learnable parameter matrix is shared by all neighbors. .
[0024] Semantic representation of neighbors Mapped to a value vector through a linear transformation As shown in equation (5): in: For value vectors, For the third learnable parameter matrix, value vector Used to store supporting information about the relationship between neighbors and tasks (such as the auxiliary judgment information of "susceptible to storage" for "susceptible to ulcer disease").
[0025] S1.4: To measure the semantic relevance between neighbor relationships and task relationships (e.g., the semantic relevance between "storable" and "susceptible to ulcers"), a relevance score is calculated using a bilinear dot product. As shown in equation (6), in: The relevance score. For query vector, This is the first learnable weight vector. , This is the transpose of the key vector; In a specific embodiment of the present invention It is a learnable weight vector used to capture the interaction strength between relationships (such as the interaction strength between "storage characteristics" and "disease characteristics"). Then, use soft max normalization to obtain the attention weights. As shown in equation (7): in: For attention weights, For all sets belonging to the neighbor set element Summation, It is an exponential function. Indicates neighbors Task-related attention weights (e.g., the weight of the impact of "storability" on "citrus susceptibility to canker").
[0026] S1.5: Combining attention weights Value vectors of neighbors (e.g., a weighted aggregation of all neighbors of "citrus" regarding "susceptibility to ulcer disease"), generating a head entity. The weighted neighbor representation is shown in equation (8): in: For head entity The weighted neighbors said, For the set of neighbors of the head entity, For all sets belonging to the neighbor set elements Summation, The value vector of the neighbors; Combined with weighted neighbor representation and pre-trained entity embeddings To generate head entity Enhanced representation As shown in equation (9): in: For head entity The enhanced representation, For pre-trained entity embeddings, As the first learnable parameter, As the second learnable parameter, this operation fuses the entity's own embedding with the weighted information of its neighbors to obtain a more task-specific entity representation (such as the basic features of "citrus" + the enhanced features of "susceptibility to ulcer disease" from its neighbors).
[0027] For tail entities (e.g., "ulcer disease") and its surrounding areas (e.g., "ulcer disease - transmission route" or "ulcer disease - prevention and treatment agents"), perform the same process as S1.1 to S1.5 above to obtain the tail entity enhancement representation. .
[0028] S1.7: Head Entity Augmentation Representation Tail-end entity enhancement representation Entity pairs are calculated using a position-forward feedforward neural network. semantic representation As shown in equation (10): in: For entity pairs semantic representation, For the first trainable parameters, As the second learnable parameter, As the third trainable parameter, .
[0029] This operation concatenates the enhanced representations of the "head entity - tail entity" and then uses linear transformation and activation functions to obtain the final semantic representation of the entity pair (such as the complete semantic vector of "citrus - ulcer disease - susceptible to infection"), which is used for subsequent reasoning and judgment in knowledge graph completion.
[0030] In summary, in the specific implementation of this application, S1 first defines the neighborhood of entity pairs for few-sample tasks, including head entity, tail entity, and their respective neighboring relationships and entities; then, through an entity pair feature information encoder, the task relationship is first decomposed into forward and backward representations and mapped to query vectors and key vectors, and the interaction of entity pairs is simulated using a bilinear product function. Then, the "relationship-entity" information of the neighbors is integrated through a feedforward neural network and mapped to a value vector. The correlation between the neighbors and the task relationship is calculated to obtain attention weights. The weights are combined to generate enhanced representations of head entity and tail entity. Finally, the semantic representation of the entity pair is generated by combining the positional feedforward neural network, providing semantic support for subsequent knowledge graph completion.
[0031] S2: To address the memory enhancement needs of completing the citrus knowledge graph with few samples, a memory module including immediate memory, working memory, and long-term memory is constructed. Reliable relation prototypes are generated through memory playback and updating to support knowledge reasoning. Given query set A query For example, searching for "Are tangerines susceptible to anthrax?", and supporting sets A set of triples (For example, “Papapa orange - susceptible to anthracnose”, “Ugly orange - susceptible to anthracnose”), calculate the few-sample task relationship. The specific method for initializing the prototype vector is shown in S2.1: S2.1: Based on support set Semantic representation of each triple Utilizing attention mechanisms to compute support sets Semantic representation of each triple Relative to each triple in the query set Attention weight For support sets each triple in the support set The semantic representations are weighted summed to obtain the few-shot task relation The weighted prototype vector As shown in equation (11): ; Wherein: is the semantic representation of the triple in the support set, is the weighted prototype vector, is the attention weight; The attention weight The calculation formula of the attention weight is shown in equation (12): Wherein: is the semantic representation of the query set triple, is the semantic representation of the support set kth triple, is the semantic representation of the support set ith triple, is the element-wise product, is the attention weight.
[0032] The attention weight is used to measure the semantic similarity between the query and the support set triple (such as the semantic overlap degree of the "Rougan-Carbonaceous Disease Query" and the "Ugly Orange-Carbonaceous Disease Triple"), and the attention weight embodies the contribution degree of the support set triple to the current query; S2.2: Construct a multi-level memory module including a transient memory module, a working memory module and a long-term memory module, and dynamically update the multi-level memory module, wherein the transient memory module adopts a first-in-first-out cache queue structure and is used for temporarily storing the latest prototype vector generated by the current task; the transient memory module is updated immediately after each new task; The working memory module adopts a cluster center library structure and is used for clustering the prototype vectors migrated from the transient memory module to store representative prototypes, and using a frequency matrix to count the frequency of prototype recall; the working memory module periodically clusters and integrates the prototypes in the transient memory; The long-term memory module adopts a priority queue structure and is used for storing high-frequency use prototypes migrated from the working memory, and performs priority management and obsolete prototype elimination based on recall frequency and storage time.
[0033] The implementation methods of the transient memory module, the working memory module and the long-term memory module are as follows: The implementation method of the short-term memory module, the working memory module and the long-term memory module in S2.2 is as follows: the short-term memory module is implemented based on a dynamic cache pool, adopts a first-in first-out cache queue as a storage structure, sets the cache capacity through a hyperparameter, and establishes a real-time receiving, temporary storage and full-capacity migration mechanism; The working memory module is implemented based on K-Means clustering and a frequency matrix, stores the clustering centers (i.e., “representative prototypes”) generated by the K-Means algorithm, and the K-Means clustering algorithm clusters the batch prototypes migrated from the short-term memory. The number K of clusters is determined by tuning the validation set. The long-term memory module is implemented based on a priority queue and a decay mechanism, adopts a priority queue as a storage structure, establishes a priority calculation mechanism based on recall frequency and storage time (the higher the frequency and the newer the storage time, the higher the priority), and when the long-term memory is full, deletes the prototype with the lowest priority (i.e., the prototype with low recall frequency and long storage time), thereby avoiding capacity expansion.
[0034] As shown in Figure 2 , the above module processing flow is as follows: The short-term memory module is responsible for temporarily storing the latest prototype information of the current task to capture short-term task characteristics. The input includes the initial relationship prototype of the current task and the new prototype vector generated by each query task, and the output includes the original prototype set without clustering, and the batch data of prototypes to be clustered transported to the working memory when the capacity limit is reached.
[0035] As shown in Figure 3 and Figure 4 , the working memory module clusters and compresses the data transmitted from the short-term memory, and stores the representative prototypes. The input comes from the batch data of original prototypes migrated from the short-term memory when the capacity is full, and from the high-frequency prototype features from the long-term memory during the memory recall process to assist clustering optimization. The output result is the compact representative prototype obtained after K-Means clustering, and the high-frequency recall prototypes selected by the frequency matrix are output to the long-term memory when the capacity is full.
[0036] The long-term memory module is used to store high-frequency core prototype features to prevent key information from being forgotten. The input includes the Top-H high-frequency recall prototypes sorted and output when the working memory is full, and the clustered prototypes from the working memory during the memory recall process, which are used to cross-verify the importance of the prototypes. The output is a long-term stable high-frequency prototype feature library, and the Top-K prototypes most relevant to the current task are output to the “prototype aggregator” during the memory recall stage.
[0037] Specifically, the short-term memory module stores the latest information (such as the new relationship of “see you tomorrow-ulcer disease” just learned), and generates an initial prototype vector every time Immediately update the instantaneous memory. The calculation method is shown in equation (13): Where: N is the total number of prototype vectors stored in the instantaneous memory, and n is an index variable used to traverse all prototype vectors from 1 to N. For short-term memory, This is the initial prototype vector.
[0038] Ensure that the latest knowledge is stored to enable rapid adaptation to new tasks (such as quickly incorporating disease relationships of new citrus varieties).
[0039] The working memory module stores representative prototypes after clustering and periodically updates the transient memory. The initial prototype vector in Perform K-Means clustering (utilizing unsupervised clustering features to aggregate patterns) to store transient memories. The prototypes are integrated into working memory in a compact form, retaining representative prototypes (such as clustering and storing different categories of prototypes, such as "citrus varieties susceptible to citrus canker" and "citrus varieties susceptible to anthracnose"). When integrating new information from transient memory, working memory first performs cluster analysis on the new input prototype vector and its original content. If there is a cluster category similar to the new prototype in the original content, the new prototype will be incorporated into that category to update the representative prototype; if there is no similar category, a new cluster category will be generated to store the new prototype.
[0040] Long-term memory stores frequently used prototype features, through a frequency matrix. Record the number of times prototypes are recalled in working memory. When the working memory capacity reaches its limit, select the prototypes with the highest recall frequency (such as "citrus-ulcer disease" or other frequently queried prototypes) and store them in long-term memory. If the long-term memory capacity exceeds its limit, remove outdated prototypes (such as prototypes of old citrus varieties that have been phased out) to ensure that the most important information is retained in long-term memory.
[0041] S2.3: Utilize an attention mechanism to extract prototype features relevant to the current query task from immediate memory, working memory, and long-term memory respectively. Calculate the aggregation weight of each prototype feature, generate a memory representation of each prototype feature based on the aggregation weight, and fuse the memory representations of each prototype feature to generate a memory-enhanced prototype vector. ; Using information from the memory module, memories related to the current query task are generated and merged into a new prototype. Immediate memory candidate retrieval and aggregation are performed. When processing new query tasks (such as the query for "Ehime No. 38 - Brown Spot Disease"), the specific steps are as follows: S2.3.1: From instantaneous memory Select the top K relevant prototype features extracting representative prototype content related to the current task from the working memory module extracting high-frequency core prototype content related to the current task from the long-term memory module ; selecting the top K candidate prototypes from the transient memory , calculating their aggregated weights through an attention mechanism, and generating a task-specific transient memory representation , as shown in equation (14): where: is the transient memory representation, is the weight of the kth candidate prototype selected from the transient memory , is the transient memory of the Kth candidate prototype.
[0042] The calculation method is shown in equation (15): where: is the similarity function, is the nth candidate prototype vector in the transient memory, is the kth relevant prototype vector in the transient memory, is the mean vector of the probability distribution, is the variance vector of the probability distribution, is the probability distribution assumption, is the covariance matrix of the distribution.
[0043] S2.3.2: For the candidate prototypes extracted from each memory module, use an attention mechanism to calculate their aggregated weights respectively, and generate the task representation of each level of memory; S2.3.3: Fuse the transient memory representation, working memory representation and long-term memory representation generated in S2.3.2 to generate a prototype vector based on memory enhancement .
[0044] The above process combines the latest information (transient), representative information (working), and high-frequency important information (long-term), so that the prototype can capture the key features of the current task and inherit the experience of previous tasks (such as combining the latest data of "Ehime 38", the clustering prototype of "citrus brown spot", and the high-frequency prototype of "citrus brown spot" to generate a more reliable "Ehime 38-brown spot" prototype), improving the adaptability and generalization ability of the model in the completion of the citrus knowledge graph with few samples.
[0045] In an embodiment of the present application, S2 utilizes the dynamic update of biomimetic memory and the multi-source information fusion rule to provide a memory-enhanced prototype representation for the few-sample relationship completion of the citrus knowledge graph, solves the problem of insufficient information for knowledge reasoning in the few-sample scenario, enables the model to efficiently utilize historical knowledge and the latest data to complete the completion task (such as accurately predicting whether the relationship of “Yue Ming 38- Brown Spot” is established).
[0046] S3: Calculate the similarity between the query representation and the memory-enhanced prototype vector, evaluate the credibility of the query representation triple based on the similarity, and support the reasoning judgment of knowledge completion.
[0047] The similarity calculation formula is shown in formula (16) Wherein: is the semantic representation of the query , is the memory-enhanced prototype vector (fusing the prototype of “citrus varieties susceptible to scab disease” of instantaneous, working, and long-term memory), is the support set, and represents the element-wise product.
[0048] The similarity score measures the semantic fit degree (such as the element-level matching degree of “citrus semantics” and “prototype of varieties susceptible to scab disease”) between the query and the memory prototype. The higher the score, the more reasonable the triple (such as “citrus-scab disease” with a high score indicating that the variety is indeed susceptible to scab disease), thereby providing a basis for judging the completion of the knowledge graph and solving the reasoning problem of the citrus variety-disease relationship in the few-sample scenario. This process utilizes the objective characteristics of vector similarity (the element overlap degree of semantic vectors reflects semantic relevance), and realizes the quantitative evaluation of the rationality of knowledge triples.
[0049] S4: Construct positive and negative query sets, and minimize the total loss function combining ranking loss and smoothing loss to train and optimize the model parameters, and obtain the few-sample citrus knowledge graph completion model; S4.1: Given the query relationship , construct the support set from the citrus knowledge graph dataset , the positive query set , and the negative query set , randomly extract entity pairs from the citrus knowledge graph dataset to construct the support set , and a batch of entity pairs to construct the positive query set the tail entity of each entity pair in the training set (e.g., replace the tail entity "scab" of "citrus - scab" with "blight", and make sure that the replaced triple is not a correct triple in the training / validation / test set), negative query set The construction method is shown in formula (17): wherein: is a negative query set, is a head entity in the citrus knowledge graph dataset, is an incorrect tail entity, is a correct tail entity, is a positive query set; incorrect tail entity as shown in formula (18): wherein: is an incorrect tail entity, is a head entity in the citrus knowledge graph dataset a candidate tail entity set under the relationship .
[0050] S4.2: Build and minimize the ranking loss function so that the similarity score of the positive query set is higher than that of the negative query set , the ranking loss function is shown in formula (19): wherein: is a hinge loss function, is a margin hyperparameter. is the similarity score between the query positive entity pair and the support set , is the similarity score between the query negative entity pair and the support set .
[0051] The ranking loss function uses the objective cognitive rule that "the score of positive samples should be higher than that of negative samples" to force the model to learn features that can distinguish between positive and negative triples (e.g., the score of "citrus - scab positive query" is higher than that of "citrus - blight negative query").
[0052] S4.3: Since the new samples (e.g., the disease relationship of the new variety "seedless citrus") of the citrus knowledge graph overlap with the old samples (e.g., the disease relationship of "common citrus"), in order to avoid the model overfitting the new task or forgetting the old task, a memory-enhanced prototype smoothing loss is constructed . The specific calculation method is: calculate and store each old task prototype diagonal covariance matrix of ; based on the covariance and the standard Gaussian noise (simulating the distribution fluctuation of the prototype by the randomness of the noise, conforming to the fuzzy law of the knowledge in the natural scene), generate the smoothed feature embedding of the old task prototype , the calculation mode is as shown in formula (20): Wherein: is the old task prototype, is the diagonal covariance matrix of each old task prototype , is the smoothed feature embedding of the old task prototype, is the standard Gaussian noise.
[0053] Smooth loss As shown in formula (21): Wherein: is the farthest embedding belonging to the same class (such as the prototype farthest from the current sample in the “ulcer disease susceptible variety” class), is the nearest embedding belonging to different classes (such as the prototype nearest to the current sample in the “anthracnose disease susceptible variety” class), is the balance coefficient, is the feature embedding vector of the current sample.
[0054] The loss ensures that the new task prototype and the old task prototype distribution have sufficient distinction (such as the “non-nuclear citrus- ulcer disease” new prototype and the “common citrus- ulcer disease” old prototype distribution will not overlap too much), S4.4: combine the ranking loss and the smoothing loss to obtain the total loss function, minimize the total loss function by batch sampling meta-training, and obtain the few-shot citrus knowledge graph completion model.
[0055] The embodiment of the application utilizes the batch sampling meta-training program to minimize the total loss, optimizes the model parameters, and finally enables the model to accurately reason new relationships and retain the reasoning ability of old knowledge in the few-shot completion task of the citrus knowledge graph.
[0056] To verify the effectiveness of the few-shot citrus knowledge graph completion model proposed in the application, the application performs experiments on two public datasets, NELL-One and Wiki-One, for different small sample K settings (including 1-shot, 3-shot and 5-shot), and compares the performance with a variety of advanced methods: FAAN is a method based on graph neural network, which enhances embedding by encoding direct neighbor of entity; GANA is a method based on meta-learning, which learns single relationship specific meta information representation; CIAN models entity interaction through task perception and entity pair perception dual attention; APINet uses interactive attention encoder and adaptive prototype network to process multiple semantic relationships. The detailed performance comparison results of all models on the above datasets are summarized in Table 1.
[0057] Table 1 Comparison results of experiments on NELL-One and Wiki-One datasets
[0058] Through public dataset experiment verification, the few-shot citrus knowledge graph completion model proposed in the application has better indicators on core tasks than existing methods, and provides more reliable knowledge support for intelligent application of citrus industry.
[0059] Each embodiment in the specification is described in a relevant manner, and the same or similar parts between each embodiment can be referred to each other. Each embodiment focuses on the difference from other embodiments. Especially, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0060] The above only describes the preferred embodiments of the application, and is not used to limit the protection scope of the application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the application shall be included in the protection scope of the application.
Claims
1. A biomimetic prototype memory and attention network method for completing a few-sample citrus knowledge graph, characterized in that... Includes the following steps: S1: Targeting few-shot task relationships in the citrus knowledge graph An entity pair Define the neighborhoods of the head and tail entities respectively, and generate semantic representations of the entity pairs. ; S2: Construct a memory module that includes immediate memory, working memory, and long-term memory, and generate memory-enhancing prototype vectors through memory playback and updates. ; S3: Calculate the query representation With memory-enhanced prototype vectors The similarity between the three elements is used to assess the credibility of the query representation triples. S4: Construct a support set and positive and negative query sets, build a ranking loss and a prototype smoothing loss, and minimize the total loss through meta-training to obtain a few-sample citrus knowledge graph completion model.
2. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 1, characterized in that, The specific steps for S1 are as follows: S1.1: The few-sample task relationship Decompose into forward representation and backward representation ,in Represent the embedding dimension and generate a query vector through a linear transformation. and key vector Represents the relational transformation matrix; S1.2: Using the bilinear product function , previously indicated and backward representation The splicing method simulates the head entity. Tail-end entity Paired interactions between; S1.3: For head entities Neighbors By integrating information about neighboring entities and their relationships using a feedforward neural network, semantic representations of neighbors are learned. The semantic representation of neighbors Mapped to a value vector through a linear transformation , Represents head entity Representation of neighborly relations Represents the neighboring entity; S1.4: Calculate the correlation score between neighbor relations and task relations using bilinear dot product. Attention weights are obtained by normalizing them using the softmax function. ; S1.5: Utilizing attention weights Value vectors of neighbors Generate head entity Weighted neighbors Then the head entity Weighted neighbors With pre-trained entity embeddings Merge to obtain the head entity Enhanced representation ; S1.6: For the tail entity Enhanced representation of the generated tail entity ; S1.7: Enhanced representation of the head entity Tail-end entity enhancement representation Vector concatenation is performed, followed by a nonlinear transformation using a position-forward feedforward neural network to obtain entity pairs. semantic representation .
3. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 1, characterized in that, The specific steps for S2 are as follows: S2.1: Based on support set Semantic representation of each triple Utilizing attention mechanisms to compute support sets Semantic representation of each triple Relative to each triple in the query set Attention weight For support sets each of the three groups The semantic representation is weighted and summed to obtain the task relation for a small number of samples. Weighted prototype vector ; S2.2: Construct a multi-level memory module that includes a transient memory module, a working memory module, and a long-term memory module, and dynamically update the multi-level memory module. The transient memory module adopts a first-in-first-out cache queue structure to temporarily store the latest prototype vector generated by the current task; the transient memory module is updated immediately after each new task. The working memory module adopts a clustering central library structure, which is used to cluster prototype vectors transferred from transient memory to store representative prototypes, and uses a frequency matrix to count the frequency at which prototypes are recalled. The working memory module is used to periodically cluster and integrate prototypes in the transient memory; The long-term memory module adopts a priority queue structure to store frequently used prototypes migrated from working memory, and performs priority management and obsolete prototype elimination based on recall frequency and storage time. S2.3: Utilize an attention mechanism to extract prototype features relevant to the current query task from immediate memory, working memory, and long-term memory respectively. Calculate the aggregation weight of each prototype feature, generate a memory representation of each prototype feature based on the aggregation weight, and fuse the memory representations of each prototype feature to generate a memory-enhanced prototype vector. .
4. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 3, characterized in that, The implementation methods of the immediate memory module, working memory module, and long-term memory module in S2.2 are as follows: The instantaneous memory module is based on a dynamic cache pool, uses a first-in-first-out cache queue as the storage structure, sets the cache capacity through hyperparameters, and establishes a real-time receiving, temporary storage, and full-capacity migration mechanism. The working memory module is implemented based on K-Means clustering and frequency matrix, and uses a cluster center library as the storage structure. The K-Means clustering algorithm clusters the batch prototypes of transient memory transfer, and the number of clusters K is determined by the validation set optimization. The long-term memory module is implemented based on a priority queue and a decay mechanism. It uses a priority queue as the storage structure and establishes a priority calculation mechanism based on recall frequency and storage time.
5. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 3, characterized in that, The specific steps of S2.3 are as follows: S2.3.1: From instantaneous memory Select the top K relevant prototype features Extract representative prototype content related to the current task from the working memory module. Extracting high-frequency core prototype content relevant to the current task from long-term memory modules. ; S2.3.2: For the candidate prototypes extracted from each memory module, calculate their aggregation weights using the attention mechanism and generate task representations for each level of memory; S2.3.3: The transient memory representation, working memory representation, and long-term memory representation generated in S2.3.2 are fused to generate a prototype vector based on memory enhancement. .
6. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 1, characterized in that, The specific steps for S3 are as follows: S3.1: Calculate the query With memory-enhanced prototype vectors Similarity between them; S3.2: Evaluate the query based on the aforementioned similarity. Semantic fit with the memory prototype.
7. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 6, characterized in that, Query in S3.1 With memory-enhanced prototype vectors The formula for calculating the similarity between them is: in: For query semantic representation, To enhance the memory of prototype vectors, For query, To support the collection, This indicates element-wise product.
8. The method for completing a few-sample citrus knowledge graph using a biomimetic prototype memory and attention network according to claim 1, characterized in that, The specific steps for S4 are as follows: S4.1: Constructing a support set from the citrus knowledge graph dataset positive query set and negative query set The negative query set By replacing the positive query set The tail entity is generated for each entity pair in the negative query set. The calculation formula is: in: For negative query sets, For the head entity, This is an incorrect tail entity. For the correct tail entity, It is a positive query set; S4.2: Construct and minimize the ranking loss function This makes the positive query set The similarity score is higher than that of the negative query set. Similarity score, ranking loss function The calculation formula is: in: For ranking loss function, Let the hinge loss function be... This is the margin hyperparameter. To query positive entity pairs With support set Similarity score between them To query negative entity pairs With support set Similarity score between them To query positive entity pairs, To query negative entity pairs; S4.3: Constructing a prototype smoothing loss for memory reinforcement ; S4.4: Combine the ranking loss and smoothing loss to obtain the total loss function, and minimize the total loss function through batch sampling meta-training to obtain the few-sample citrus knowledge graph completion model.
Citation Information
Patent Citations
Few-sample knowledge reasoning method based on double-prototype network
CN116361489A
Automatic optimization method and system based on intelligent data memory bank
CN118503390A
Few-sample knowledge graph completion model and method
CN119358661A
Method and system for complementing few-sample knowledge graph fusing relation perception information bottleneck
CN121303295A
Drug repositioning method and system fusing multi-source knowledge graph
WO2024138803A1