A food safety knowledge graph construction method and device

By generating knowledge triples containing entities and relationships during a single knowledge extraction process and integrating them with an ontology framework of core concepts in the food safety field, the problem of error accumulation in the construction of food safety knowledge graphs is solved, thereby improving the accuracy and professionalism of the graphs.

CN122242698APending Publication Date: 2026-06-19TSINGHUA UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TSINGHUA UNIVERSITY
Filing Date
2026-02-28
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing methods for constructing food safety knowledge graphs involve multi-task pipeline processing, which leads to error accumulation and affects the accuracy of the knowledge graph.

Method used

During a knowledge extraction process, knowledge triples containing entities and relationships between entities are generated simultaneously. The statistical results are then integrated with the defined ontology framework of core concepts in the food safety field to form a knowledge graph for the food safety field.

Benefits of technology

It improves the semantic accuracy and internal consistency of knowledge graphs, ensures the logical rigor and professionalism of ontology, prevents concept drift, and enhances knowledge coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122242698A_ABST
    Figure CN122242698A_ABST
Patent Text Reader

Abstract

This disclosure relates to the field of food safety knowledge graphs, proposing a method and apparatus for constructing a food safety knowledge graph. The method includes: acquiring raw corpus in the food safety field; preprocessing the raw corpus to obtain structured semantic text blocks; extracting knowledge from the structured semantic text blocks, simultaneously generating knowledge triples containing entities and relationships between entities during a single knowledge extraction process; performing type statistics on the knowledge triples and fusing the statistical results with a predefined ontology framework containing core concepts of the food safety field to obtain an ontology; and mapping the knowledge triples to the ontology to obtain a knowledge graph in the food safety field. The food safety knowledge graph construction method provided in this disclosure improves the semantic accuracy and internal consistency of the extraction results, ultimately improving the accuracy of the obtained food safety knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of food safety knowledge graphs, and in particular to a method and apparatus for constructing a food safety knowledge graph. Background Technology

[0002] Food safety refers to the fact that food, throughout the entire chain from planting, breeding, production, processing, storage, transportation, and sales to consumption, complies with national laws, regulations, and safety standards, is free from toxic, harmless, and harmful substance contamination, possesses its due nutritional value, and will not cause acute, subacute, or chronic harm to human health.

[0003] Food safety is directly related to the health and safety of the people. It is an important foundation for ensuring basic livelihoods and maintaining social harmony and stability. It is also a key link in promoting the healthy development of the food industry and improving national governance capabilities and public health levels.

[0004] A knowledge graph is a structured semantic network with entities as nodes and relationships between entities as edges. Its core is to transform scattered, unstructured knowledge into a machine-understandable and reasonable relational form, breaking down information silos and enabling efficient organization, retrieval, and mining of knowledge. It can represent both concrete real-world things and abstract domain concepts and rules.

[0005] The core value of knowledge graphs lies in empowering the entire lifecycle management of knowledge, from knowledge accumulation and integration to retrieval, reuse, reasoning, and innovation. It solves the pain points of traditional knowledge management, such as "dispersed, disordered, difficult to connect, and low reusability," becoming a core tool for upgrading knowledge systems and improving the efficiency of research and application across various fields. Therefore, the construction of knowledge graphs is indispensable for the development of the food safety field.

[0006] Existing methods for constructing food safety knowledge graphs typically break down the process into multiple independent sub-tasks, each handled by a specialized deep learning model. However, this multi-task pipeline approach leads to errors from one task being propagated and amplified in subsequent tasks, causing error accumulation and significantly impacting the accuracy of the final knowledge graph. Therefore, improving the accuracy of food safety knowledge graph construction is a pressing issue that researchers in this field need to address. Summary of the Invention

[0007] In view of this, this disclosure proposes a method, apparatus, computer program product, and storage medium for constructing a food safety knowledge graph. In the process of constructing the food safety knowledge graph, by simultaneously generating knowledge triples containing entities and relationships between entities during a knowledge extraction process, the semantic accuracy and internal consistency of the extraction results are improved, thereby enhancing the accuracy of the final obtained food safety knowledge graph.

[0008] According to one aspect of this disclosure, a method for constructing a food safety knowledge graph is provided, the method comprising:

[0009] Obtain original corpora in the field of food safety;

[0010] The original corpus is preprocessed to obtain structured semantic text blocks;

[0011] Knowledge extraction is performed on the structured semantic text block, and knowledge triples containing entities and relationships between entities are generated simultaneously during a knowledge extraction process.

[0012] The knowledge triples are statistically analyzed, and the statistical results are integrated with a predefined ontology framework containing the core concepts of the food safety field to obtain the ontology;

[0013] By mapping the knowledge triples to the ontology, a knowledge graph in the field of food safety is obtained.

[0014] In one possible implementation, the preprocessing of the original corpus includes:

[0015] The original corpus is subjected to structured recognition to obtain structured text;

[0016] The structured text is subjected to at least one round of noise reduction processing to obtain the noise-reduced structured text;

[0017] The denoised structured text is divided into multiple text blocks according to semantic boundaries, and the length of each text block is controlled within a predetermined range to obtain structured semantic text blocks.

[0018] In one possible implementation, the knowledge extraction of the structured semantic text block, in a single knowledge extraction process, simultaneously generates knowledge triples containing entities and relationships between entities, including:

[0019] Based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing. The structured format data is used to characterize the subject and object relationships in the content of the structured semantic text block.

[0020] In one possible implementation, based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing, including:

[0021] At least two rounds of generation are performed, each outputting corresponding structured format data. Each round of generation is based on the same text to be processed, but uses different generation instructions.

[0022] The structured data output from each generation process is merged to obtain complete structured data containing the set of knowledge triples.

[0023] In one possible implementation, the step of performing type statistics on the knowledge triples and integrating the statistical results with a predefined ontology framework containing the core concepts of the food safety domain includes:

[0024] The entity types in the knowledge triples are aggregated, deduplicated, and counted to obtain type statistics results;

[0025] Based on the authoritative knowledge system in the field of food safety, a top-level ontology framework containing core concepts in the field of food safety is generated;

[0026] The top-level ontology framework containing core concepts in the field of food safety is semantically extended using a generative model to obtain the extended ontology framework.

[0027] Calculate the semantic similarity between the types in the type statistics results and the concepts in the extended ontology framework, and fuse the type statistics results and the extended ontology framework based on the similarity to obtain the ontology.

[0028] In one possible implementation, the food safety knowledge graph construction method further includes:

[0029] The concepts and relational predicates in the ontology are projected into a high-dimensional semantic space to obtain semantic vectors corresponding to the concepts and relational predicates;

[0030] Calculate the similarity between the semantic vectors, merge the concepts and relational predicates corresponding to the semantic vectors whose similarity exceeds a preset threshold, and obtain the ontology after deduplication of concepts and relational predicates;

[0031] The process of mapping the knowledge triples to the ontology to obtain the knowledge graph in the food safety field includes:

[0032] Mapping the knowledge triples onto the deduplicated ontology yields a knowledge graph in the field of food safety.

[0033] In one possible implementation, the food safety knowledge graph construction method further includes:

[0034] The knowledge graph is correlated with multimodal information to obtain a multimodal knowledge graph; the multimodal information includes at least one of images, audio, and video.

[0035] In one possible implementation, the multimodal information association of the knowledge graph includes:

[0036] A preset model is used to determine whether entities in the knowledge graph need to be supplemented with multimodal information, and the determination result is obtained.

[0037] Based on the judgment result and the entities in the knowledge graph, obtain a first preset number of multimodal information files;

[0038] The first preset number of multimodal information files are filtered at least once using a preset model to obtain a second preset number of filtered multimodal information files.

[0039] Using a preset model, the filtered multimodal information files are further filtered based on the entity and the knowledge triplet corresponding to the entity to obtain at least one multimodal information file.

[0040] Associate the at least one multimodal information file with entities in the knowledge graph.

[0041] According to another aspect of this disclosure, a food safety knowledge graph construction apparatus is provided, the apparatus comprising:

[0042] The acquisition module is used to acquire raw corpora in the field of food safety.

[0043] The preprocessing module is used to preprocess the original corpus to obtain structured semantic text blocks;

[0044] The knowledge extraction module is used to extract knowledge from the structured semantic text block and generate knowledge triples containing entities and relationships between entities during a knowledge extraction process.

[0045] The ontology fusion module is used to perform type statistics on the knowledge triples and fuse the statistical results with a predefined ontology framework containing the core concepts of the food safety field to obtain the ontology;

[0046] The output module is used to map the knowledge triples to the ontology to obtain a knowledge graph in the field of food safety.

[0047] In one possible implementation, the preprocessing module is further configured to:

[0048] The original corpus is subjected to structured recognition to obtain structured text;

[0049] The structured text is subjected to at least one round of noise reduction processing to obtain the noise-reduced structured text;

[0050] The denoised structured text is divided into multiple text blocks according to semantic boundaries, and the length of each text block is controlled within a predetermined range to obtain structured semantic text blocks.

[0051] In one possible implementation, the knowledge extraction module is further configured to:

[0052] Based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing. The structured format data is used to characterize the subject and object relationships in the content of the structured semantic text block.

[0053] In one possible implementation, the knowledge extraction module is further configured to:

[0054] At least two rounds of generation are performed, each outputting corresponding structured format data. Each round of generation is based on the same text to be processed, but uses different generation instructions.

[0055] The structured data output from each generation process is merged to obtain complete structured data containing the set of knowledge triples.

[0056] In one possible implementation, the ontology fusion module is further configured to:

[0057] The entity types in the knowledge triples are aggregated, deduplicated, and counted to obtain type statistics results;

[0058] Based on the authoritative knowledge system in the field of food safety, a top-level ontology framework containing core concepts in the field of food safety is generated;

[0059] The top-level ontology framework containing core concepts in the field of food safety is semantically extended using a generative model to obtain the extended ontology framework.

[0060] Calculate the semantic similarity between the types in the type statistics results and the concepts in the extended ontology framework, and fuse the type statistics results and the extended ontology framework based on the similarity to obtain the ontology.

[0061] In one possible implementation, the device further includes:

[0062] The knowledge refinement module is used to project the concepts and relational predicates in the ontology into a high-dimensional semantic space to obtain the semantic vectors corresponding to the concepts and relational predicates.

[0063] Calculate the similarity between the semantic vectors, merge the concepts and relational predicates corresponding to the semantic vectors whose similarity exceeds a preset threshold, and obtain the ontology after deduplication of concepts and relational predicates;

[0064] In one possible implementation, the output module is further configured to:

[0065] Mapping the knowledge triples onto the deduplicated ontology yields a knowledge graph in the field of food safety.

[0066] In one possible implementation, the device further includes:

[0067] The multimodal association module is used to perform multimodal information association on the knowledge graph to obtain a multimodal knowledge graph; the multimodal information includes at least one of images, audio, and video.

[0068] In one possible implementation, the multimodal association module is further configured to:

[0069] A preset model is used to determine whether entities in the knowledge graph need to be supplemented with multimodal information, and the determination result is obtained.

[0070] Based on the judgment result and the entities in the knowledge graph, obtain a first preset number of multimodal information files;

[0071] The first preset number of multimodal information files are filtered at least once using a preset model to obtain a second preset number of filtered multimodal information files.

[0072] Using a preset model, the filtered multimodal information files are further filtered based on the entity and the knowledge triplet corresponding to the entity to obtain at least one multimodal information file.

[0073] Associate the at least one multimodal information file with entities in the knowledge graph.

[0074] According to another aspect of this disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above-described method.

[0075] According to another aspect of this disclosure, a non-volatile computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described method.

[0076] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the above-described method.

[0077] In this disclosure, after preprocessing the raw corpus in the food safety field, knowledge triples containing entities and relationships between entities are generated simultaneously during a knowledge extraction process. Type statistics are then performed on these knowledge triples, and the statistical results are fused with a predefined ontology framework containing core concepts of the food safety field to obtain an ontology. Finally, the knowledge triples are mapped onto the ontology to obtain a knowledge graph in the food safety field. Generating knowledge triples containing entities and relationships between entities simultaneously during a knowledge extraction process improves the semantic accuracy and internal consistency of the extraction results. The ontology obtained by fusing the type statistics of the knowledge triples with the ontology framework containing core concepts of the food safety field ensures the logical rigor and professionalism of the ontology, preventing concept drift. Integrating the statistical results of knowledge triples obtained from knowledge extraction from massive amounts of real data into the ontology also guarantees the knowledge coverage of the ontology. Ultimately, this improves the accuracy, professionalism, and knowledge coverage of the resulting knowledge graph.

[0078] Other features and aspects of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description

[0079] The accompanying drawings, which are included in and form part of this specification, illustrate exemplary embodiments, features, and aspects of this disclosure together with the specification and serve to explain the principles of this disclosure.

[0080] Figure 1 A flowchart is shown for a method of constructing a food safety knowledge graph according to an embodiment of this application.

[0081] Figure 2 This diagram illustrates a method for constructing a food safety knowledge graph according to an embodiment of this application.

[0082] Figure 3 This diagram shows a structural diagram of a food safety knowledge graph construction apparatus according to an embodiment of the present application.

[0083] Figure 4 A block diagram of an electronic device 1900 according to an embodiment of this application is shown. Detailed Implementation

[0084] Various exemplary embodiments, features, and aspects of this disclosure will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.

[0085] As used herein, the terms “comprising,” “including,” “having,” or variations thereof are open-ended and include one or more of the stated features, integrals, elements, steps, components, or functions, but do not exclude the presence or addition of one or more other features, integrals, elements, steps, components, functions, or groups thereof.

[0086] Although the terms first, second, third, etc., may be used herein to describe various elements / operations, these elements / operations should not be limited by these terms. These terms are only used to distinguish one element / operation from another. Therefore, without departing from the teachings of the inventive concept, a first element / operation in some embodiments may be referred to as a second element / operation in other embodiments.

[0087] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.

[0088] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.

[0089] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, data stored, data displayed, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant regions.

[0090] Knowledge graphs, as structured semantic knowledge bases, describe real-world concepts, things, and relationships in the form of "entity-relationship-entity" triples. Their core value is to break down information silos and realize the associative reasoning and interpretability of knowledge. Currently, they have been implemented in core applications in finance, healthcare, government affairs, e-commerce, education, and intelligent manufacturing.

[0091] In the field of food safety, knowledge graphs integrate core entities such as food raw materials, processing enterprises, testing indicators, additives, pathogens, food safety incidents, regulatory standards, and law enforcement agencies. This addresses industry pain points such as long food supply chains, fragmented information, difficulty in traceability, delayed risk warnings, and weak regulatory coordination. It covers the entire supply chain from farm to table, connecting regulators, enterprises, and consumers. It serves as a core technological support for intelligent food safety governance. At the regulatory end, knowledge graphs can provide standardized technical support and interpretation of test results for different foods. For enterprises, they can provide early warnings of potential food safety issues based on the type and condition of the food. For consumers, knowledge graphs can provide popular science information on common foods, addressing the problem of consumers' lack of food safety knowledge and weak discernment abilities.

[0092] Current methods for constructing food safety knowledge graphs primarily rely on a separate pipeline approach for knowledge extraction. This involves breaking down knowledge extraction into multiple independent subtasks, first identifying entities from the original corpus, and then extracting relationships between those entities—a pipeline model. This approach leads to error accumulation; errors from previous tasks are carried over to subsequent tasks and affect the accuracy of the final generated knowledge graph.

[0093] This application provides a method for constructing a food safety knowledge graph. After preprocessing the original corpus in the food safety field, knowledge triples containing entities and relationships between entities are generated simultaneously during a knowledge extraction process. Type statistics are then performed on these knowledge triples, and the statistical results are fused with a predefined ontology framework containing core concepts of the food safety field to obtain an ontology. Finally, the knowledge triples are mapped onto the ontology to obtain a food safety knowledge graph. Generating knowledge triples containing entities and relationships between entities simultaneously during a single knowledge extraction process improves the semantic accuracy and internal consistency of the extraction results. The ontology obtained by fusing the type statistics of the knowledge triples with the ontology framework containing core concepts of the food safety field ensures the logical rigor and professionalism of the ontology, prevents concept drift, and guarantees the knowledge coverage of the ontology. Ultimately, this improves the accuracy, professionalism, and knowledge coverage of the resulting knowledge graph.

[0094] Figure 1 This diagram illustrates a method for constructing a food safety knowledge graph according to an embodiment of the present disclosure. Figure 1 As shown, the method may include the following steps:

[0095] S101. Obtain original corpus in the field of food safety.

[0096] The raw corpus can be an unstructured initial data set in the field of food safety, and it can take many forms, including text, images, tables, etc.

[0097] For example, authoritative books on food safety knowledge and cutting-edge research materials can be used as raw data. In one example, for the field of food safety, the raw data can be selected from national food safety standards, professional books published by authoritative institutions, relevant research papers in academic journals, and publicly available inspection reports from regulatory authorities.

[0098] As an example, we obtained a diverse collection of content from 40 authoritative books on food safety as the raw corpus. Academic journals and research papers in the field of food safety can also be used as raw corpora; this disclosure does not impose specific limitations on this.

[0099] S102. The original corpus is preprocessed to obtain structured semantic text blocks.

[0100] Preprocessing is used to improve the data quality of the original corpus, in order to overcome problems such as mixed formats, noise interference, and inappropriate length in the original data, and to create favorable conditions for the efficient and accurate understanding and processing of generative models.

[0101] Structured semantic text blocks are the preprocessed result, characterized as text fragments of moderate length, semantic coherence, and uniform format. They are independent processing units formed through a series of transformation and cleaning steps while preserving the core semantics of the original corpus. Structured semantic text blocks allow subsequent knowledge extraction steps to focus on a clearly defined and contextually complete semantic scope, helping to improve the accuracy of entity and relation recognition. For example, a structured semantic text block can contain a complete paragraph discussing "aflatoxin contamination of corn," with its character length controlled within a certain range and interfering information such as page numbers and irrelevant annotations removed.

[0102] For specific preprocessing methods, please refer to the possible implementation methods provided in this disclosure, which will not be elaborated here.

[0103] S103. Extract knowledge from the structured semantic text block, and generate knowledge triples containing entities and relationships between entities during a knowledge extraction process.

[0104] Knowledge triples are a basic representation of knowledge extraction results, often employing a "subject-relationship-object" structure to represent a simple fact or association. For example, a knowledge triple can be represented as "aflatoxin-contamination-corn," where "aflatoxin" and "corn" are entities, and "contamination" is the relationship connecting these two entities. The relationships between entities define the specific ways in which they are associated, such as "belongs to," "leads to," and "detected at," enabling discrete entities to be connected into a semantically meaningful knowledge network.

[0105] This knowledge extraction process integrates the separate subtasks of entity recognition and relation extraction found in traditional pipelines into a unified and collaborative model reasoning process, outputting complete knowledge triples containing entities and their relationships. It aims to overcome the error propagation and accumulation problems inherent in step-by-step processing. Through the model's overall understanding and joint inference of the text context, it simultaneously determines entity boundaries, entity types, and semantic relationships between entities, thus completing the transformation from unstructured text to structured triples within a single forward propagation or processing loop. Its underlying implementation technology can take various specific forms.

[0106] In one example, generative processing can be used to achieve one-time knowledge extraction. Generative processing utilizes sequence-to-sequence generative models, taking the text to be processed and the pre-defined structured output format requirements as input. The model directly generates a text sequence that conforms to the specified format, which represents the extracted knowledge triples. This approach fully relies on the powerful language understanding and generation capabilities of generative models, completing all extraction decisions in an end-to-end process.

[0107] Besides generative processing, one-time knowledge extraction can also be achieved through encoding-based joint extraction models. These methods typically employ an encoder to deeply encode the input text, obtaining contextual representations of each character or word, and then using a specific decoding architecture or a pre-designed label sequence to simultaneously predict entities and their relationships within a single model.

[0108] By performing the aforementioned knowledge extraction process on structured semantic text blocks, high-quality, internally consistent knowledge triples can be generated directly from coherent text in a single step. Placing entity recognition and relation judgment within a unified reasoning framework effectively reduces the risk of error accumulation common in step-by-step processing, providing a direct and reliable source of structured knowledge for constructing more accurate knowledge graphs.

[0109] S104. Perform type statistics on the knowledge triples and integrate the statistical results with the defined ontology framework containing the core concepts of the food safety field to obtain the ontology.

[0110] In the process of performing type statistics on knowledge triples, the entity types appearing in the knowledge triple set are analyzed and summarized. By traversing the triples, all the different entity types contained therein can be identified, and the frequency of each type can be counted.

[0111] The type here refers to the semantic category or conceptual affiliation of an entity in a knowledge triple. It is an abstract description of the category to which an entity belongs in the knowledge system of the food safety field. It is used to summarize specific, discrete entity instances under a higher-level, more general concept.

[0112] In a knowledge triple (subject-relation-object), the subject and object are usually concrete entity instances. The "type" is a classification identifier for these entity instances. For example, in the knowledge triple "aflatoxin (subject) - pollution - corn (object)," the entity instance "aflatoxin" might be of type "fungal toxin"; the entity instance "corn" might be of type "agricultural product" or "food crop."

[0113] An ontology framework is a predefined, conceptual structure used to organize knowledge in a specific domain. A well-defined ontology framework provides a logically rigorous and hierarchically structured classification system for knowledge in the field of food safety. For example, in the field of food safety, an ontology framework can be pre-constructed based on national food safety standards, containing top-level concepts such as "risky substances," "processing techniques," "regulations and standards," and "responsible entities." Under "risky substances," subcategories such as "biological risks," "chemical risks," and "physical risks" may be pre-defined.

[0114] The fusion process combines statistically derived typological results from actual data with a predefined professional ontology framework to generate an ontology that is both logically rigorous and fully reflects the true distribution of the data. This ensures that the final ontology is not only based on authoritative domain theories but also includes emerging or niche concepts discovered from actual corpora, avoiding the problem of an overly rigid ontology framework or one detached from real-world data.

[0115] During the fusion process, the semantic similarity between the entity types obtained from the triple statistics and the concepts in the semantically expanded ontology framework can be calculated. The concepts representing the actual data distribution in the statistical results can be dynamically and automatically mapped and fused into the corresponding concept nodes of the predefined framework. For example, the "pesticide residue" type that appears frequently in the data can be classified into the "chemical risk" concept branch in the framework based on high semantic similarity.

[0116] Thus, the final generated ontology retains the professionalism and structure of the predefined framework while incorporating emerging or subdivided concepts discovered from real texts that may not be covered by the original framework. The resulting ontology not only inherits and maintains the logical structure of authoritative knowledge in the domain, but also fully absorbs specific concepts mined from actual corpora.

[0117] S105. Map the knowledge triples to the ontology to obtain the knowledge graph of the food safety field.

[0118] After obtaining the knowledge triples and the fused ontology, the triples and local data can be mapped and associated to form a unified, machine-understandable and queryable semantic network, thereby completing the transformation from raw data to a structured knowledge base.

[0119] During mapping, each element (entity and relation) in the knowledge triple can be standardized, classified and connected according to the rules and structure defined by the constructed ontology. This process assigns the type position of each specific entity instance in the conceptual hierarchy and matches the relations between entities with the relation predicates defined in the ontology.

[0120] For example, in the mapping of a specific knowledge triple “aflatoxin B1-contamination-corn”, the entity instance “aflatoxin B1” will be classified under the concept node “fungal toxins” in the ontology, “corn” will be classified under the “agricultural products” node, and the relation “contamination” will correspond to the “contamination” relation predicate defined in the ontology.

[0121] A knowledge graph in the field of food safety can be a knowledge base stored and represented in the form of a graph structure, where nodes represent specific instances (entities) of concept categories defined by the ontology, and edges represent specific relationships between instances that conform to the ontology specification.

[0122] This structure transforms knowledge from isolated text fragments into an interconnected network that can be reasoned about and retrieved. For example, in a food safety knowledge graph, there might be a fact that "aflatoxin B1" (node, type: fungal toxin) is connected to "corn" (node, type: agricultural product) through a "contamination" relation (edge), while the "corn" node might be connected to the higher-level concept node "grains" through a "belongs" relation.

[0123] In this embodiment, structured semantic text blocks are obtained by preprocessing the original corpus in the food safety field. Knowledge extraction is performed on the structured semantic text blocks, and knowledge triples containing entities and relationships between entities are generated simultaneously during the knowledge extraction process. Type statistics are performed on the knowledge triples, and the statistical results are fused with a predefined ontology framework containing the core concepts of the food safety field to obtain an ontology. The knowledge triples are then mapped onto the ontology. Thus, generating knowledge triples containing entities and relationships between entities simultaneously during a single knowledge extraction process reduces the error propagation and accumulation that may occur when entity identification and relationship extraction are separated into independent subtasks, improving the semantic accuracy and internal consistency of the knowledge extraction results. By performing type statistics on the knowledge triples and fusing the results with the predefined ontology framework, the final ontology maintains logical rigor and professionalism based on the core concept framework of the domain while incorporating type information statistically discovered from actual data, ensuring the ontology's knowledge coverage and adaptability to actual corpora. By mapping the knowledge triples to the fused ontology, a large number of discretely extracted facts can be systematically organized into a structurally rigorous and conceptually clear knowledge system. The combined effect of these processes ultimately improves the accuracy, structural standardization, and knowledge completeness of the constructed food safety knowledge graph.

[0124] In one possible implementation, the preprocessing of the original corpus includes:

[0125] The original corpus is subjected to structured recognition to obtain structured text;

[0126] The structured text is subjected to at least one round of noise reduction processing to obtain the noise-reduced structured text;

[0127] The denoised structured text is divided into multiple text blocks according to semantic boundaries, and the length of each text block is controlled within a predetermined range to obtain structured semantic text blocks.

[0128] Structured recognition is used to transform raw corpora, such as images, scanned documents, or complex document layouts, into plain text or semi-structured data containing textual content and its basic logical structure.

[0129] For example, the original corpus is usually scanned books, which are texts stored in Portable Document Format (PDF) or image format. These image-based, unstructured contents need to be accurately converted into structured text that is easy to process later.

[0130] As an example, large models can be used to perform structured recognition on raw text corpora. For instance, the GOT-OCR2.0 model can be used as a model for structured recognition of raw text corpora. This model enhances the processing capabilities of optical characters, such as plain text, mathematical formulas, molecular formulas, complex charts, musical scores, and even geometric shapes. By inputting raw text corpora from the food safety field into this model, it can accurately identify common complex elements in food safety texts, such as complex tables like "additive limit standards" and special chemical molecular formulas, thereby accurately converting visual, unstructured content into structured text. The format of the structured text can be a text format with a fixed expression format, such as JavaScript Object Notation (JSON) or Extensible Markup Language (XML). This disclosure does not limit the specific structured text format.

[0131] As an example, a script can be written to call an OCR library to perform structured recognition on the original corpus. For example, a Python script can be written to call the EasyOCR library to perform structured recognition on the original corpus and obtain structured text.

[0132] This process converts unstructured data into structured text and reduces the loss of accuracy in the original corpus.

[0133] The structured text obtained through the above steps usually contains some noisy data, such as metadata noise from headers, footers, chapter numbers, footnotes, watermarks, etc., which are present in the original corpus. Furthermore, the character encoding and typesetting format of the structured text obtained from original corpora from different sources may also be different. Therefore, it is necessary to denoise the structured text obtained through the above steps.

[0134] As an example, text can be denoised and its character encoding and formatting standardized by writing automated scripts such as Python scripts. Alternatively, large models can be used to denoise structured text.

[0135] As an example, by adjusting the prompts in the script or the large model, multiple rounds of noise reduction at different granularities can be performed on structured text to obtain more accurate results.

[0136] Noise reduction processing reduces noise data in the text, improving the accuracy of structured text data.

[0137] When large language models process extremely long texts, they may encounter problems such as forgetting context, decreased ability to follow instructions, and even "model illusion". Therefore, this disclosure divides the denoised structured text obtained from the above steps into multiple text blocks according to semantic boundaries.

[0138] As an example, a large language model can be used to segment the denoised structured text into multiple text blocks according to semantic boundaries. While ensuring semantic coherence, the structured text can be segmented into multiple semantic text blocks of approximately 1500 characters in length. By processing data from 40 books in the field of food safety, approximately 450 independent semantic text blocks are ultimately obtained. The 1500-character length given in this disclosure is merely an example; those skilled in the art can adjust the length of the text blocks according to actual needs, and this disclosure does not impose any limitations on this.

[0139] In this embodiment, by sequentially performing structured recognition, at least one round of noise reduction, and length-controlled segmentation according to semantic boundaries on the original corpus, structured recognition transforms image-based or complexly formatted original materials into machine-readable text, creating conditions for automated processing. Noise reduction removes interfering information such as headers, footers, and irrelevant details, improving the purity of the text data and reducing the misleading effect of noise on semantic understanding. Segmentation according to semantic boundaries, with the length of each text block controlled within a predetermined range, makes the semantics carried by each text block more concentrated and complete, fitting the optimal processing window of the generative model. These steps work together to transform the original corpus into high-quality, standardized structured semantic text blocks, providing clear, accurate, and easily processed input for subsequent knowledge extraction steps, thereby improving the accuracy of subsequent knowledge extraction.

[0140] In one possible implementation, the knowledge extraction of the structured semantic text block, in a single knowledge extraction process, simultaneously generates knowledge triples containing entities and relationships between entities, including:

[0141] Based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing. The structured format data is used to characterize the relationship between the subject and object in the content of the structured semantic text block.

[0142] In this implementation, by leveraging the overall understanding and sequence generation capabilities of generative models, entity recognition, type judgment, and relation extraction are completed simultaneously in a unified reasoning process, and structured results conforming to a predetermined format are directly output.

[0143] The structured output requirements for entities and relationships can be a pre-defined set of instructions or format specifications used to constrain the organization and content elements of the generative model output. These requirements specify which fields the output data should include (e.g., subject, subject type, relationship, object, object type), and the separators or order between fields.

[0144] Structured data is the specific text generated by the generative model after meeting the above output requirements. Its content is formatted and directly represents the subject, object, and their semantic relationships extracted from the text to be processed. For example, structured data can be a string following the format "subject | subject type | relation | object | object type", where "subject" and "object" are the specific entities identified in the text, "relation" is the semantic connection between them, and "subject type" and "object type" are the determinations of the categories to which these entities belong.

[0145] As an example, generative models can be used to output structured data representing the relationships between subjects and objects in structured semantic text blocks. For instance, the model can output data that strictly follows the structured format of "subject|subject type|relationship|object|object type" to represent the relationships between subjects and objects. This process stimulates the model's contextual collaborative reasoning ability. For example, when the model identifies "aflatoxin" as a "fungal toxin" in the context, this judgment becomes a clue, guiding the model to more accurately infer that the relationship between "aflatoxin" and "corn" is "contamination" rather than "production." By generating and outputting structured data in a single step, compared to multi-task pipeline processing, the error of the output results is reduced, and the semantic accuracy and internal consistency of the knowledge extraction results are improved.

[0146] In this embodiment, based on the text to be processed and the structured output requirements for entities and relationships, generative processing generates and outputs structured format data in a single step. This structured format data is used to characterize the relationship between subjects and objects within the structured semantic text block. Thus, the generative model simultaneously completes entity recognition, type determination, and relationship extraction during a single inference process, ensuring that all extraction decisions share the same set of context encoding. This avoids the error propagation and accumulation problems that may occur when entity recognition and relationship extraction are separated into independent sub-tasks. The structured output requirements provide clear formatting requirements for the model's free text generation, resulting in output results with good standardization and parsability.

[0147] In one possible implementation, based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing, including:

[0148] At least two rounds of generation are performed, each outputting corresponding structured format data. Each round of generation is based on the same text to be processed, but uses different generation instructions.

[0149] The structured data output from each generation process is merged to obtain complete structured data containing the set of knowledge triples.

[0150] Generative instructions are the prompt text input to a generative model. Their content guides the model to focus on specific aspects of the text being processed and constrains the format and scope of the generative model's output. Different generative instructions can reflect different requirements regarding the focus, extraction granularity, or semantic relevance. Differences in generative instructions can cause the model to produce structured outputs with different focuses and coverage when faced with the exact same text.

[0151] As an example, using a generative model, in a single generation process, two rounds of generation are performed on the same structured semantic text block to generate the structured format data in the above steps. One round can use broader generation instructions, such as "generate structured format data for common concepts in this text block," while the other round can use more granular generation instructions, such as "generate structured format data for all possible concepts in this text block." Finally, the structured format data generated in the two rounds are merged to obtain complete structured data containing the set of knowledge triples. It should be noted that although this example illustrates a two-round generation process in a single generation, those skilled in the art will understand that the solution disclosed herein can be flexibly configured with different focus points and / or granularities by changing the prompt words according to the actual needs of the scenario.

[0152] In this embodiment, at least two rounds of generation are executed. Each round is based on the same text to be processed but uses different generation instructions, outputting corresponding structured format data. Then, the structured format data output from each round of generation are merged to obtain complete structured data containing a set of knowledge triples. Thus, different generation instructions guide the model to focus on semantic information at different levels or granularities in the text, enabling implicit relationships, secondary entities, or marginal expressions that may be missed in a single round of generation to be captured in other rounds. The merging operation of multiple rounds of output brings together these extraction results from different perspectives into the same dataset, effectively improving the coverage breadth and content density of the knowledge triple set, while retaining the semantic richness brought about by multi-dimensional interpretation of the same text.

[0153] In one possible implementation, the step of performing type statistics on the knowledge triples and integrating the statistical results with a predefined ontology framework containing the core concepts of the food safety domain includes:

[0154] The entity types in the knowledge triples are aggregated, deduplicated, and counted to obtain type statistics results;

[0155] Based on the authoritative knowledge system in the field of food safety, a top-level ontology framework containing core concepts in the field of food safety is generated;

[0156] The top-level ontology framework containing core concepts in the field of food safety is semantically extended using a generative model to obtain the extended ontology framework.

[0157] Calculate the semantic similarity between the types in the type statistics results and the concepts in the extended ontology framework, and fuse the type statistics results and the extended ontology framework based on the similarity to obtain the ontology.

[0158] The top-level ontology framework is a highly abstract and streamlined hierarchical structure of core concepts pre-constructed based on authoritative knowledge systems in the field of food safety. These authoritative knowledge systems can be represented by recognized concept classifications found in national standards, industry norms, classic textbooks, or domain ontology libraries. This framework does not aim to cover all details, but rather to anchor the most stable and core conceptual framework of the field.

[0159] As an example, based on authoritative knowledge systems in the field of food safety, a top-level ontology framework containing core concepts in the field of food safety can be generated. This can be achieved by domain experts defining a top-level ontology framework that includes core concepts such as "risky substances," "processing technology," and "regulations and standards," based on authoritative knowledge systems such as HACCP principles and national food safety standard classifications. Alternatively, a top-level ontology framework containing core concepts in the field of food safety can be generated using a large language model based on authoritative knowledge systems in the field of food safety.

[0160] Based on the generated top-level ontology framework, a generative model is used to semantically expand the concepts within the framework. For example, "regulations and standards" can be expanded to include concepts such as "national mandatory standards" and "national recommended standards." This step generates a top-level ontology framework containing core domain concepts based on authoritative knowledge systems in the food safety field. This establishes professional anchor points for the ontology's construction, ensuring its logical rigor and professionalism, and preventing concept drift.

[0161] As an example, the aggregation, deduplication, and counting of entity types in the knowledge triples can be performed by writing a script to traverse all knowledge triples, count all found entity types, and then perform deduplication and counting to obtain the aggregation result. Alternatively, aggregation can be performed by a large language model, such as inputting the knowledge triples into the large language model and having the model output the entity type statistics of the knowledge triples.

[0162] By aggregating, deduplicating, and counting entity types, we can determine which entity types are frequently mentioned, which are relatively sparse, and the complete set of specific names for all types within the current corpus. This process is an induction from concrete facts to abstract concepts. For example, a script can be written to iterate through all knowledge triple files, extract the values ​​of the "subject type" and "object type" fields from each triple, summarize them, perform frequency statistics, and remove duplicate type names. In one example, after statistically analyzing the triple set in the food safety field, we might obtain dozens of entity types such as "fungi toxins," "pesticide residues," "food additives," "processing enterprises," "testing institutions," and "limit standards," along with their respective frequencies.

[0163] As an example, the semantics of concepts in the top-level ontology framework can be calculated, along with the semantic similarity between the concepts and the types in the entity type statistics. Based on this semantic similarity, the entity types in the knowledge triples can be integrated into the top-level ontology framework. For instance, the concepts in the top-level ontology framework and the type concepts in the entity type statistics can be uniformly encoded to generate semantic vectors. The encoding model can be selected specifically for the food safety domain, such as the Sentence-BERT model. The generated semantic vectors are then normalized, and the cosine similarity is calculated through the dot product of the vectors to obtain the semantic similarity result. For each entity type in the type statistics, a corresponding concept with high similarity is found in the top-level ontology framework, and this concept is integrated into the corresponding concept within the ontology framework.

[0164] For example, if the type statistics include the concept of "pesticide residue," and its similarity to the concept of "chemical risk" in the top-level ontology framework is calculated to be the highest (85%), then the concept of "pesticide residue" will be integrated into the ontology framework as a sub-concept of "chemical risk." Similarly, the concept of "bacterial residue" will be integrated into the ontology framework as a sub-concept of "biological risk." For the above similarity fusion rules, a similarity threshold, such as 80%, can also be set to integrate entity types into all concepts in the top-level framework whose semantic similarity exceeds the threshold. The specific fusion rules and semantic similarity threshold are not specifically limited in this disclosure; those skilled in the art can select an appropriate similarity threshold for judgment based on the actual scenario requirements.

[0165] In this embodiment, type statistics are obtained by aggregating, deduplicating, and counting entity types in knowledge triples. A top-level ontology framework containing core concepts in the food safety field is generated based on an authoritative knowledge system in the food safety field. A generative model is used to semantically extend this top-level ontology framework to obtain an extended ontology framework. The semantic similarity between the types in the type statistics and the concepts in the extended ontology framework is calculated. Based on this similarity, the type statistics and the extended ontology framework are fused to obtain the ontology. Thus, by generating a top-level ontology framework containing core concepts in the food safety field based on an authoritative knowledge system in the food safety field and semantically extending the framework, the logical rigor and professionalism of the ontology are ensured, and concept drift is prevented. By aggregating, deduplicating, and counting entity types in knowledge triples to obtain type statistics, emerging knowledge concepts not covered by existing frameworks can be discovered from massive amounts of data, ensuring the knowledge coverage and adaptability of the ontology to domain development. By fusing these two aspects, both the logical rigor and professionalism of the ontology and its knowledge coverage can be guaranteed, thereby improving the logical rigor, professionalism, and knowledge coverage of the final knowledge graph.

[0166] As an example, Neo4j can be used as a graph database. Based on the ontology constructed in the above steps, the knowledge triples are converted into node files and edge files for Neo4j. Using Neoj4j's import function, the node files and edge files are imported, and graph reasoning and completion are performed according to the ontology rules to obtain the final food safety knowledge graph.

[0167] In one possible implementation, the method further includes:

[0168] The concepts and relational predicates in the ontology are projected into a high-dimensional semantic space to obtain semantic vectors corresponding to the concepts and relational predicates; the similarity between the semantic vectors is calculated, and the concepts and relational predicates corresponding to the semantic vectors with similarity exceeding a preset threshold are merged to obtain the ontology after deduplication of concepts and relational predicates;

[0169] The process of mapping the knowledge triples to the ontology to obtain the knowledge graph in the food safety field includes:

[0170] Mapping the knowledge triples onto the deduplicated ontology yields a knowledge graph in the field of food safety.

[0171] Semantic vectors are numerical representations obtained by mapping terms from natural language text to a high-dimensional continuous vector space using an embedding model. These vectors capture the deep semantic features of terms, ensuring that semantically similar terms are geometrically close in the vector space. Concepts correspond to category nodes in the ontology used to represent a class of entity instances, such as "risky substances," "processing enterprises," and "testing standards." Relational predicates correspond to edge labels in the ontology used to connect two concepts and represent the type of association between them, such as "pollution," "detected at," and "belongs to." Projecting concepts and relational predicates into the high-dimensional semantic space involves calling the semantic embedding model to generate the corresponding feature vector for each concept name and each relational predicate name in the ontology.

[0172] The specific ways to merge can be to incorporate one concept as an alias or synonym of another concept, while retaining the attribution relationship of all its sub-concepts and instances; or to create a new, more general concept to replace the original multiple redundant concepts and adjust the hierarchical structure in the ontology.

[0173] For example, after the ontology is constructed, semantic vector projection and similarity calculation are performed. It is found that the cosine similarity of the semantic vectors of the concepts "production company" and "production enterprise" reaches 0.92, exceeding the preset threshold of 0.90. At this point, "production enterprise" can be retained as the preferred term, "production company" can be marked as a synonym of "production enterprise," and all sub-concepts and their instance relationships originally belonging to "production company" can be transferred to the concept of "production enterprise." Similarly, if the semantic vector similarity of the relational predicates "detection" and "determination" reaches 0.91, the two can be merged, and "detection" can be uniformly used as the standard relational predicate in subsequent mappings.

[0174] In another example, a text embedding model can be used to calculate the semantic vectors projected from concepts and relational predicates in the ontology into a high-dimensional space. By calculating the cosine similarity between semantic vectors, concepts and relational predicates with high semantic similarity in the ontology can be fused. For example, when the similarity between two concepts "production company" and "production enterprise" in the ontology exceeds 92%, the two concepts are automatically merged to obtain a deduplicated ontology. The similarity threshold of 92% selected in this disclosure is only an example. During the execution process, those skilled in the art can flexibly set the specific similarity threshold according to the needs of the actual scenario, and this disclosure does not make specific limitations on it.

[0175] The specific method for mapping the knowledge triples to the deduplicated ontology obtained in the above steps to obtain the knowledge graph in the field of food safety can be found in step S105, and will not be repeated here.

[0176] In this embodiment, by projecting concepts and relational predicates from the ontology into a high-dimensional semantic space, semantic vectors corresponding to the concepts and relational predicates are obtained. The similarity between semantic vectors is calculated, and the concepts and relational predicates corresponding to semantic vectors with similarity exceeding a preset threshold are merged to obtain an ontology with deduplicated concepts and relational predicates. Knowledge triples are then mapped onto the deduplicated ontology to obtain a knowledge graph in the field of food safety. Thus, semantic vector projection converts concepts and relational predicates in natural language form into computable numerical forms, providing a quantitative basis for redundant identification at the semantic level. The combination of similarity calculation and preset threshold can objectively and consistently filter out semantically highly similar term pairs, avoiding the inconsistency problems that may arise from relying on manual review. The merging operation systematically integrates redundant concepts and relational predicates, making the ontology structure more refined and the semantic boundaries clearer. Mapping knowledge triples onto the deduplicated ontology allows the entity types and relational descriptions that originally had different expressions in the triples to be uniformly merged into a standardized concept and predicate system. The above steps work together to reduce redundancy and ambiguity in the ontology caused by the diverse sources of terminology or differences in expression habits, improve the compactness and standardization of the ontology, and thus make the final knowledge graph clearer at the concept level and more consistent in relation expression, effectively enhancing the structural regularity and machine readability of the knowledge graph.

[0177] In one possible implementation, the method further includes:

[0178] The knowledge graph is correlated with multimodal information to obtain a multimodal knowledge graph; the multimodal information includes at least one of images, audio, and video.

[0179] Multimodal information is a carrier of information that is carried and disseminated in other physical forms, distinct from textual symbols. For example, images are visual information stored in the form of pixel matrices, capable of intuitively presenting the appearance, structure, spatial layout, or change process of things; audio is auditory information stored in the form of waveforms, capable of recording speech narration, natural sounds, or musical melodies; video is dynamic audiovisual information stored in the form of a continuous sequence of frames, capable of reproducing complete operational processes, event occurrences, or spatiotemporal evolution. These different modalities of information describe the same entity from their respective perceptual channels, complementing textual information.

[0180] For example, for the entity "aflatoxin", its multimodal information may include photos of the moldy appearance of contaminated corn, schematic diagrams of the toxin's molecular structure, audio clips of experts explaining its harmful mechanisms, and instructional videos demonstrating the testing procedures.

[0181] In this embodiment, the knowledge graph is correlated with multimodal information to obtain a multimodal knowledge graph; the multimodal information includes at least one of images, audio, and video. Thus, multimodal information correlation expands the expression dimension of traditional knowledge graphs from single text to multiple media forms such as images, audio, and video, transforming a knowledge graph originally composed only of symbols into a multimodal knowledge graph that integrates multiple information forms. This significantly improves the intuitiveness and richness of knowledge presentation, and enhances the efficiency and depth of users' understanding of complex concepts.

[0182] In one possible implementation, multimodal information association is performed on the knowledge graph, including:

[0183] A preset model is used to determine whether entities in the knowledge graph need to be supplemented with multimodal information, and the determination result is obtained.

[0184] Based on the judgment result and the entities in the knowledge graph, obtain a first preset number of multimodal information files;

[0185] The first preset number of multimodal information files are filtered at least once using a preset model to obtain a second preset number of filtered multimodal information files.

[0186] Using a preset model, the filtered multimodal information files are further filtered based on the entity and the knowledge triplet corresponding to the entity to obtain at least one multimodal information file.

[0187] Associate the at least one multimodal information file with entities in the knowledge graph.

[0188] The pre-defined model can be a large language model fine-tuned by instructions. It analyzes information such as entity name, entity type, relationships, and attribute descriptions to comprehensively determine whether the entity is suitable for explanation through non-textual media. The judgment result is the output of this step, usually represented by a binary label or confidence score, used to characterize whether the entity needs to initiate the subsequent multimodal information acquisition process. For example, if specific chemical substance entities such as "aflatoxin," "ochratoxin A," and "melamine" from the food safety knowledge graph are input into the large language model, and the instruction "Is this entity suitable for understanding through images, audio, or video?" is given, the model outputs "Yes." However, for abstract system entities such as "Food Safety Law," "Production Licensing System," and "Traceability Management System," the model output may be "No."

[0189] Based on the judgment result and the entities in the knowledge graph, obtaining a first preset number of multimodal information files is a process of collecting candidate multimedia resources from external data sources for entities that are determined to need supplemented multimodal information.

[0190] The retrieval operation can be based on the entity name, entity alias, or their associated attribute values, and can be performed through application programming interfaces (APIs) to search and download from public or authorized image search engines, audio and video material libraries, scientific databases, and other channels.

[0191] The first preset quantity is a pre-set initial collection quantity, the value of which can be flexibly configured according to the importance of the entity, the cost of resource acquisition, and the fault tolerance requirements of subsequent screening. This disclosure does not impose specific limitations on this quantity. For example, for the entity "aflatoxin" that is determined to require additional images, the top 20 image files are retrieved and downloaded from the image search engine using the entity name as the keyword, as the initial candidate image set of the first preset quantity.

[0192] Then, a preset model is used to perform at least one round of filtering on the first preset number of multimodal information files to obtain a second preset number of filtered multimodal information files, which is used to perform coarse-grained filtering on the initially collected multimedia files. The filtering at this stage focuses on the low-level attributes and explicit semantics of the files, such as the resolution, clarity, and format integrity of the images, as well as the degree of matching between the file content and entity names in shallow semantics.

[0193] The preset model can be a visual language model with image-text matching capabilities, which can identify and label image content and calculate the relevance score between the image content and the entity name text. After one or more rounds of screening, files with high scores and acceptable quality are retained to form a smaller second preset candidate set.

[0194] For example, a visual language model is used to score the aforementioned 20 candidate images, filtering out images with low resolution, containing a large number of obscured watermarks, or whose actual subjects are clearly unrelated to "aflatoxin", and retaining 10 images with clear content and clearly related to the toxin theme as the second preset number of screening results.

[0195] Then, using a preset model, the filtered multimodal information files are filtered again based on the entity and the knowledge triplet corresponding to the entity to obtain at least one multimodal information file, so as to perform fine-grained filtering of candidate multimedia files through deep semantic matching and context alignment.

[0196] The selection process at this stage no longer relies solely on the superficial relevance between the file content and the entity name, but instead incorporates the entity's complete semantic context within the knowledge graph as a reference. The pre-defined model simultaneously receives the entity name, several knowledge triples corresponding to the entity (e.g., "aflatoxin-contamination-corn", "aflatoxin-produced in-Aspergillus flavus", "aflatoxin-increased risk-liver cancer"), and candidate multimedia files. It comprehensively judges whether the file highly matches a specific semantic aspect of the entity and whether it can accurately represent the entity's form, state, or role in its typical knowledge scenario.

[0197] After this round of screening, at least one multimedia file with the highest content matching degree and the strongest representativeness will be further selected from the second preset number of candidate files.

[0198] For example, for the entity "aflatoxin", after understanding its knowledge triplet information, the second-round screening model prioritizes retaining photos that can intuitively present the typical detection scenario of "contaminated corn showing blue-green fluorescence under ultraviolet light", as well as scientific illustrations showing the "chemical structure of aflatoxin B1", while filtering out images that, although containing the toxin name label, actually show the appearance of experimental instruments or are irrelevant to the laboratory environment, and finally selects the two most representative and recognizable images.

[0199] Finally, the at least one multimodal information file is associated with the entity in the knowledge graph, and the high-quality multimedia resources that have been screened and confirmed are bound to the target entity, thus completing the final operation of constructing the multimodal knowledge graph.

[0200] Specific implementations of associations may include: adding a "multimedia resource" field to the entity's attribute table to store the local path or network URI of the file; establishing dedicated relation edges in the graph database that point from entity nodes to multimedia resource nodes, such as "with image", "with audio", "associated with video"; or vectorizing the multimedia file into features, storing it in a vector database, and establishing an index mapping with the entity identifier.

[0201] For example, the two typical photos of "aflatoxin contaminated corn" that were finally selected are stored on a designated media server, and two "with image" relationships are added to the "aflatoxin" entity in the knowledge graph, pointing to the access addresses of the two image files respectively.

[0202] In this embodiment of the disclosure, multimodal information association of a knowledge graph includes using a preset model to determine whether entities in the knowledge graph need additional multimodal information to obtain a determination result, obtaining a first preset number of multimodal information files based on the determination result and entities in the knowledge graph, using the preset model to perform at least one round of filtering on the first preset number of multimodal information files to obtain a second preset number of filtered multimodal information files, using the preset model to further filter the filtered multimodal information files based on entities and their corresponding knowledge triples to obtain at least one multimodal information file, and associating the at least one multimodal information file with entities in the knowledge graph. Therefore, by using a pre-defined model to determine the necessity of entities, multimodal information supplementation is only performed on entities that genuinely have visualization or auditory needs, avoiding the waste of computational resources and accumulation of data noise caused by blindly collecting multimedia resources for all entities. By setting a first preset quantity and performing at least one round of quality and surface relevance-oriented screening, a large number of low-quality and weakly related candidate files are effectively filtered out, significantly reducing the data processing pressure in subsequent processing stages. In the second screening, the knowledge triples corresponding to the entities are introduced as semantic judgment criteria, enabling the screening model to conduct fine evaluation of multimedia files from high-order semantic dimensions such as typical scenarios, typical relationships, and typical states of the entities, ensuring a deep fit between the final associated files and the core semantic aspects of the entities. The high-quality multimodal files obtained from the screening are explicitly associated with the entities, so that when users query the entity, they can simultaneously obtain highly matched image, audio, or video resources. The above steps work together to construct a complete multimodal information supplementation pipeline, from demand judgment, resource collection, multi-level screening to final association. While ensuring the quality of associated resources, it controls the resource consumption of the entire process. Ultimately, it transforms the knowledge graph, which was originally composed of only text symbols, into a multimodal knowledge graph that deeply integrates entities and diverse media, significantly improving the intuitiveness of knowledge presentation and the efficiency of information transmission.

[0203] Figure 2 This diagram illustrates a method for constructing a food safety knowledge graph according to an embodiment of this application. Figure 2 As shown, in the preprocessing step, authoritative books in the field of food safety are used as raw corpora for structured recognition, text cleaning (i.e., noise reduction), and then semantic boundary segmentation to obtain structured semantic text blocks; in the knowledge extraction step, knowledge is extracted from each structured semantic text block through a large language model API; in the knowledge refinement step, a semantic embedding model is used to refine the preliminary text graph (i.e., ontology), merging redundant concepts and relational predicates in the ontology; in the modality supplementation step, a visual language model is used to supplement the text knowledge graph modally; finally, an ontology model in the field of food safety and a multimodal food safety knowledge graph are obtained.

[0204] Figure 3 This diagram illustrates a structural diagram of a food safety knowledge graph construction apparatus according to an embodiment of this application, such as... Figure 3 As shown, the device may include:

[0205] Module 201 is used to acquire raw corpora in the field of food safety;

[0206] Preprocessing module 202 is used to preprocess the original corpus to obtain structured semantic text blocks;

[0207] The knowledge extraction module 203 is used to extract knowledge from the structured semantic text block and generate knowledge triples containing entities and relationships between entities during a knowledge extraction process.

[0208] The ontology fusion module 204 is used to perform type statistics on the knowledge triples and fuse the statistical results with a predefined ontology framework containing the core concepts of the food safety field to obtain an ontology;

[0209] Output module 205 is used to map the knowledge triples to the ontology to obtain the knowledge graph in the field of food safety.

[0210] In one possible implementation, the preprocessing module 202 is further configured to:

[0211] The original corpus is subjected to structured recognition to obtain structured text;

[0212] The structured text is subjected to at least one round of noise reduction processing to obtain the noise-reduced structured text;

[0213] The denoised structured text is divided into multiple text blocks according to semantic boundaries, and the length of each text block is controlled within a predetermined range to obtain structured semantic text blocks.

[0214] In one possible implementation, the knowledge extraction module 203 is further configured to:

[0215] Based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing. The structured format data is used to characterize the subject and object relationships in the content of the structured semantic text block.

[0216] In one possible implementation, the knowledge extraction module 203 is further configured to:

[0217] At least two rounds of generation are performed, each outputting corresponding structured format data. Each round of generation is based on the same text to be processed, but uses different generation instructions.

[0218] The structured data output from each generation process is merged to obtain complete structured data containing the set of knowledge triples.

[0219] In one possible implementation, the ontology fusion module 204 is further configured to:

[0220] The entity types in the knowledge triples are aggregated, deduplicated, and counted to obtain type statistics results;

[0221] Based on the authoritative knowledge system in the field of food safety, a top-level ontology framework containing core concepts in the field of food safety is generated;

[0222] The top-level ontology framework containing core concepts in the field of food safety is semantically extended using a generative model to obtain the extended ontology framework.

[0223] Calculate the semantic similarity between the types in the type statistics results and the concepts in the extended ontology framework, and fuse the type statistics results and the extended ontology framework based on the similarity to obtain the ontology.

[0224] In one possible implementation, the device further includes:

[0225] The knowledge refinement module is used to project the concepts and relational predicates in the ontology into a high-dimensional semantic space to obtain the semantic vectors corresponding to the concepts and relational predicates.

[0226] Calculate the similarity between the semantic vectors, merge the concepts and relational predicates corresponding to the semantic vectors whose similarity exceeds a preset threshold, and obtain the ontology after deduplication of concepts and relational predicates;

[0227] In one possible implementation, the output module 205 is further configured to:

[0228] Mapping the knowledge triples onto the deduplicated ontology yields a knowledge graph in the field of food safety.

[0229] In one possible implementation, the device further includes:

[0230] The multimodal association module is used to perform multimodal information association on the knowledge graph to obtain a multimodal knowledge graph; the multimodal information includes at least one of images, audio, and video.

[0231] In one possible implementation, the multimodal association module is further configured to:

[0232] A preset model is used to determine whether entities in the knowledge graph need to be supplemented with multimodal information, and the determination result is obtained.

[0233] Based on the judgment result and the entities in the knowledge graph, obtain a first preset number of multimodal information files;

[0234] The first preset number of multimodal information files are filtered at least once using a preset model to obtain a second preset number of filtered multimodal information files.

[0235] Using a preset model, the filtered multimodal information files are further filtered based on the entity and the knowledge triplet corresponding to the entity to obtain at least one multimodal information file.

[0236] Associate the at least one multimodal information file with entities in the knowledge graph.

[0237] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0238] This disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the above method.

[0239] This disclosure also provides a non-volatile computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method.

[0240] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.

[0241] Figure 4 This is a block diagram illustrating an apparatus 1900 for knowledge graph construction according to an exemplary embodiment. For example, apparatus 1900 may be provided as a server or terminal device. (Refer to...) Figure 4 The apparatus 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by the processing component 1922. The application programs stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1922 is configured to execute instructions to perform the methods described above.

[0242] Device 1900 may also include a power supply component 1926 configured to perform power management of device 1900, a wired or wireless network interface 1950 configured to connect device 1900 to a network, and an input / output interface 1958 (I / O interface). Device 1900 can operate on an operating system, such as Windows Server, stored in memory 1932. TM macOS X TM Unix TM Linux TM FreeBSD TM Or similar.

[0243] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions that can be executed by a processing component 1922 of the device 1900 to perform the above-described method.

[0244] Computer-readable storage media can be tangible devices capable of holding and storing programs / instructions used by instruction execution devices. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0245] The computer program (or computer-readable program instructions) described herein can be downloaded from a computer-readable storage medium to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage medium in the respective computing / processing device.

[0246] The computer program (or computer program instructions) used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the computer-readable program instructions to implement various aspects of this disclosure.

[0247] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0248] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0249] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0250] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0251] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for constructing a food safety knowledge graph, characterized in that, include: Obtain original corpora in the field of food safety; The original corpus is preprocessed to obtain structured semantic text blocks; Knowledge extraction is performed on the structured semantic text block, and knowledge triples containing entities and relationships between entities are generated simultaneously during a knowledge extraction process. The knowledge triples are statistically analyzed, and the statistical results are integrated with a predefined ontology framework containing the core concepts of the food safety field to obtain the ontology; By mapping the knowledge triples to the ontology, a knowledge graph in the field of food safety is obtained.

2. The method according to claim 1, characterized in that, The preprocessing of the original corpus includes: The original corpus is subjected to structured recognition to obtain structured text; The structured text is subjected to at least one round of noise reduction processing to obtain the noise-reduced structured text; The denoised structured text is divided into multiple text blocks according to semantic boundaries, and the length of each text block is controlled within a predetermined range to obtain structured semantic text blocks.

3. The method according to claim 1, characterized in that, The knowledge extraction process for the structured semantic text block generates knowledge triples containing entities and relationships between entities during a single knowledge extraction process, including: Based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing. The structured format data is used to characterize the subject and object relationships in the content of the structured semantic text block.

4. The method according to claim 3, characterized in that, Based on the text to be processed and the structured output requirements for entities and relationships, structured format data is generated and output in a single step through generative processing, including: At least two rounds of generation are performed, each outputting corresponding structured format data. Each round of generation is based on the same text to be processed, but uses different generation instructions. The structured data output from each generation process is merged to obtain complete structured data containing the set of knowledge triples.

5. The method according to claim 1, characterized in that, The step of performing type statistics on the knowledge triples and integrating the statistical results with a predefined ontology framework containing the core concepts of the food safety field includes: The entity types in the knowledge triples are aggregated, deduplicated, and counted to obtain type statistics results; Based on the authoritative knowledge system in the field of food safety, a top-level ontology framework containing core concepts in the field of food safety is generated; The top-level ontology framework containing core concepts in the field of food safety is semantically extended using a generative model to obtain the extended ontology framework. Calculate the semantic similarity between the types in the type statistics results and the concepts in the extended ontology framework, and fuse the type statistics results and the extended ontology framework based on the similarity to obtain the ontology.

6. The method according to claim 1, characterized in that, The method further includes: The concepts and relational predicates in the ontology are projected into a high-dimensional semantic space to obtain semantic vectors corresponding to the concepts and relational predicates; Calculate the similarity between the semantic vectors, merge the concepts and relational predicates corresponding to the semantic vectors whose similarity exceeds a preset threshold, and obtain the ontology after deduplication of concepts and relational predicates; The process of mapping the knowledge triples to the ontology to obtain the knowledge graph in the food safety field includes: Mapping the knowledge triples onto the deduplicated ontology yields a knowledge graph in the field of food safety.

7. The method according to claim 1, characterized in that, The method further includes: The knowledge graph is correlated with multimodal information to obtain a multimodal knowledge graph; the multimodal information includes at least one of images, audio, and video.

8. The method according to claim 7, characterized in that, The step of performing multimodal information association on the knowledge graph includes: A preset model is used to determine whether entities in the knowledge graph need to be supplemented with multimodal information, and the determination result is obtained. Based on the judgment result and the entities in the knowledge graph, obtain a first preset number of multimodal information files; The first preset number of multimodal information files are filtered at least once using a preset model to obtain a second preset number of filtered multimodal information files. Using a preset model, the filtered multimodal information files are further filtered based on the entity and the knowledge triplet corresponding to the entity to obtain at least one multimodal information file. Associate the at least one multimodal information file with entities in the knowledge graph.

9. A food safety knowledge graph construction device, characterized in that, The device includes: The acquisition module is used to acquire raw corpora in the field of food safety. The preprocessing module is used to preprocess the original corpus to obtain structured semantic text blocks; The knowledge extraction module is used to extract knowledge from the structured semantic text block and generate knowledge triples containing entities and relationships between entities during a knowledge extraction process. The ontology fusion module is used to perform type statistics on the knowledge triples and fuse the statistical results with a predefined ontology framework containing the core concepts of the food safety field to obtain the ontology; The output module is used to map the knowledge triples to the ontology to obtain a knowledge graph in the field of food safety.

10. A non-volatile computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.