A bulk commodity knowledge graph construction method, device and equipment and a readable storage medium
Patent Information
- Application Number
- CN202611394440.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]本申请的目的是提供一种大宗商品知识图谱构建方法、装置、设备及可读存储介质,解决了知识图谱在构建过程中,多源异构数据处理能力不足、新商品适应性差等技术问题
[0015]应用本申请实施例所提供的方法,从大宗商品领域的原始数据中识别各实体及其所属的商品类型,并针对每个实体对其各模态数据分别编码,得到各模态特征向量;根据实体所属的商品类型与当前处理类型确定各模态的融合权重,利用融合权重对各模态特征向量进行跨模态融合与语义对齐,得到实体的实体向量表示;基于各实体之间的关联关系构建大宗商品知识图谱,以实体向量表示作为节点特征,在知识图谱上进行预训练,得到图结构信息增强后的优化实体向量表示;从大宗商品知识图谱中选取待处理的第一实体与第二实体,基于第一实体对应的第一优化实体向量表示和第二实体对应的第二优化实体向量表示,按照当前处理类型对第一实体与第二实体进行处理,并根据处理结果更新大宗商品知识图谱。
Smart Images

Figure CN123012845A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device, and readable storage medium for constructing a knowledge graph of bulk commodities. Background Technology
[0002] Knowledge graphs can support applications such as supply chain analysis and price forecasting for bulk commodities. However, existing methods for constructing bulk commodity knowledge graphs typically employ single-modal or simple multimodal stitching strategies, and the alignment, disambiguation, and linking of entities mainly rely on manual rules or require a large amount of labeled data, making it difficult to cover complex naming conventions and rapidly emerging new commodity types.
[0003] In conclusion, how to effectively construct a knowledge graph of bulk commodities is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this application is to provide a method, apparatus, equipment and readable storage medium for constructing a knowledge graph of bulk commodities, which solves the technical problems of insufficient multi-source heterogeneous data processing capability and poor adaptability to new commodities during the construction of knowledge graphs.
[0005] To solve the above-mentioned technical problems, this application provides the following technical solution: A method for constructing a knowledge graph for bulk commodities includes: Identify entities and their respective commodity types from the raw data in the commodity sector, and encode each modal data of each entity separately to obtain modal feature vectors; The fusion weights of each modality are determined based on the product type to which the entity belongs and the current processing type. The fusion weights are then used to perform cross-modal fusion and semantic alignment on the feature vectors of each modality to obtain the entity vector representation of the entity. A bulk commodity knowledge graph is constructed based on the relationships between entities. The entity vector representation is used as node features. Pre-training is performed on the knowledge graph to obtain an optimized entity vector representation with enhanced graph structure information. Select a first entity and a second entity to be processed from the commodity knowledge graph. Based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, process the first entity and the second entity according to the current processing type, and update the commodity knowledge graph according to the processing result.
[0006] Preferably, pre-training is performed on the knowledge graph, including: Negative samples are differentiated and weighted according to the type of relationship between entities through inter-entity comparative learning; the negative samples corresponding to the same type of goods relationship and the substitute relationship have lower weights than the negative samples corresponding to the complementary goods relationship and the unrelated goods relationship. The mask entity prediction loss, link prediction loss, and supply chain path prediction loss are weighted and summed to obtain the multi-task structure loss, and the graph structure information is learned using the multi-task structure loss. The domain knowledge constraint loss is obtained by weighted summation of product classification constraints, price relevance constraints, and geographical proximity constraints, and then the domain knowledge constraint loss is used to constrain the entity vector representation.
[0007] Preferably, before constructing a commodity knowledge graph based on the relationships between entities, the following steps are also included: The overall similarity is calculated based on the similarity of physical attributes, market characteristics, and supply chain among products; Based on the comprehensive similarity, several reference products with the highest similarity to the target product are determined from the existing products; The sample data of the reference product is obtained as a support set. The parameters of the generation process of each modal feature vector corresponding to the target product are adjusted using the support set so that the multimodal fusion encoding of the target product is adapted to the product type of the target product.
[0008] Preferably, the processing of the first entity and the second entity includes: The rule-guided layer matches the first entity and the second entity according to a preset set of rules; If a match is successful, the processing results for the first entity and the second entity are determined based on the matching result; if no match is found, the process proceeds to the probabilistic inference layer. The feature vectors of the first entity and the second entity are extracted using the probabilistic inference layer, and then input into different models. The prediction results of the different models are weighted and fused to output the processing probability and confidence. When the confidence level of the output of the probabilistic reasoning layer is lower than a preset threshold, the large model semantic layer is used for reasoning, and the processing result containing the evidence chain is output.
[0009] Preferably, when the confidence level output by the probabilistic inference layer is lower than a preset threshold, reasoning is performed using the large model semantic layer to output a processing result containing a chain of evidence, including: Retrieve relevant knowledge from the product knowledge base based on the current processing type, and embed the retrieved knowledge into the input prompts to build enhanced prompts; The enhanced prompts are organized according to the thought chain template, and the domain-fine-tuned large language model is invoked to generate inference responses; Extract structured reasoning results from the reasoning response, including fields such as thought process, conclusion, confidence level, and key evidence. The inference response and the structured inference result are stored in a case library for continuous optimization of the large language model.
[0010] Preferably, the fusion weights of each modality are determined based on the product type to which the entity belongs and the current processing type, including: The product type to which the entity belongs and the current processing type are input into the predictor network to obtain the fusion weights of each modality after the predictor network has calculated them.
[0011] Preferably, cross-modal fusion and semantic alignment include: Using the feature vector of each modality as the query and the feature vectors of other modalities as the key and value, calculate the attention weight of that modality to other modalities; Aggregate feature information from other modalities based on the attention weights; By using intermodal contrastive learning, different modal feature vectors of the same entity are used as positive samples, and modal feature vectors of different entities are used as negative samples, thus narrowing the distance between positive samples and widening the distance between negative samples.
[0012] A knowledge graph construction device for commodities, comprising: The data acquisition and entity recognition module is used to identify each entity and its commodity type from the raw data in the commodity field, and to encode each modal data of each entity to obtain the feature vector of each modality. The multimodal fusion encoding module is used to determine the fusion weight of each modality based on the product type to which the entity belongs and the current processing type, and to use the fusion weight to perform cross-modal fusion and semantic alignment on the feature vectors of each modality to obtain the entity vector representation of the entity; The knowledge graph construction and pre-training module is used to construct a bulk commodity knowledge graph based on the relationship between entities. The entity vector representation is used as node features, and pre-training is performed on the knowledge graph to obtain an optimized entity vector representation with graph structure information enhancement. The entity processing and updating module is used to select a first entity and a second entity to be processed from the bulk commodity knowledge graph, process the first entity and the second entity according to the current processing type based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, and update the bulk commodity knowledge graph according to the processing result.
[0013] An electronic device, comprising: Memory, used to store computer programs; A processor is used to implement the steps of the above-described method for constructing a knowledge graph of bulk commodities when executing the computer program.
[0014] A readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for constructing a knowledge graph of bulk commodities.
[0015] Applying the method provided in the embodiments of this application, entities and their respective commodity types are identified from the original data in the commodity domain, and each entity's modal data is encoded separately to obtain modal feature vectors. The fusion weights of each modality are determined based on the commodity type of the entity and the current processing type. These fusion weights are then used to perform cross-modal fusion and semantic alignment on the modal feature vectors to obtain the entity vector representation of the entity. A commodity knowledge graph is constructed based on the relationships between entities, using the entity vector representations as node features. Pre-training is performed on the knowledge graph to obtain optimized entity vector representations with enhanced graph structure information. A first entity and a second entity to be processed are selected from the commodity knowledge graph. Based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, the first entity and the second entity are processed according to the current processing type, and the commodity knowledge graph is updated based on the processing results.
[0016] By identifying entities and their respective commodity types from raw data in the commodity sector and encoding each modality separately, a data foundation tailored to different commodity types is provided for subsequent differentiated fusion. The fusion weights for each modality are adaptively determined based on the commodity type of the entity and the current processing type. These weights are then used to perform cross-modal fusion and semantic alignment of the feature vectors of each modality, aligning multi-source heterogeneous data in a unified vector space. Simultaneously, the entity vector representations can dynamically emphasize different modal information according to the processing scenario, achieving adaptive fusion of multi-source heterogeneous data. Thus, a knowledge graph is constructed based on the relationships between entities, and the generated entity vector representations are used as node features for pre-training on this knowledge graph. The entity vector representations further incorporate graph structure information on top of the original modal information. That is, the optimized entity vector representations can simultaneously reflect the entity's own attributes and its position and relationships in the knowledge graph. Based on this, entities to be processed are selected from the knowledge graph and processed based on their respective optimized entity vector representations. The processing results are then fed back to update the knowledge graph, forming a complete closed loop from construction to processing to updating.
[0017] In other words, this application achieves continuous optimization of the knowledge graph during the construction process through the synergistic effect of adaptive multimodal fusion and graph structure enhancement pre-training, effectively solving technical problems such as insufficient multi-source heterogeneous data processing capabilities and poor adaptability to new products in the existing technology.
[0018] Accordingly, this application also provides a commodity knowledge graph construction apparatus, equipment, and readable storage medium corresponding to the above-described commodity knowledge graph construction method, which have the above-described technical effects, and will not be described in detail here. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating the implementation of a method for constructing a knowledge graph for bulk commodities in this application. Figure 2 This is a system architecture diagram of a specific implementation method for constructing a knowledge graph of bulk commodities in this application. Figure 3 This is a schematic diagram of the structure of a knowledge graph construction device for bulk commodities in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application; Figure 5 This is a schematic diagram of the specific structure of an electronic device in an embodiment of this application. Detailed Implementation
[0021] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] Please refer to Figure 1 , Figure 1 This is a flowchart of a method for constructing a knowledge graph of bulk commodities according to an embodiment of this application. The method includes the following steps.
[0023] S101. Identify each entity and its commodity type from the raw data in the commodity field, and encode each modal data of each entity to obtain the modal feature vector.
[0024] Bulk commodities refer to large quantities of homogeneous, tradable basic industrial raw materials such as crude oil, copper, and soybeans, which are used in industrial and agricultural production.
[0025] Raw data in the commodities sector typically originates from various sources, including news reports, industry reports, price databases, geographic information systems (GIS), and customs statistics tables. Data formats encompass a range of types, such as unstructured text, semi-structured tables, and structured records. For example, text data may come from industry news and contract documents, time-series data from price series and production data, geographic data from coordinates and transportation routes, and structured data from financial statements and statistical tables.
[0026] First, named entity recognition technology can be used to extract specific entities related to commodities from the raw data and label each entity with its corresponding commodity type. Commodity type refers to the classification system of commodities, used to identify the commodity category or specific variety to which an entity belongs. For example, WTI crude oil belongs to the crude oil category within the energy category, and its specifications include API gravity.
[0027] Then, the modal data associated with each entity are encoded separately, transforming the heterogeneous raw data into a unified numerical feature vector form. In this paper, "modality" refers to different data formats such as text, time-series prices, geospatial data, and structured data.
[0028] In this way, each modal data of each entity corresponds to an independent feature vector, providing a standardized data input format for subsequent cross-modal fusion.
[0029] S102. Determine the fusion weights of each modality based on the product type to which the entity belongs and the current processing type. Use the fusion weights to perform cross-modal fusion and semantic alignment on the feature vectors of each modality to obtain the entity vector representation of the entity.
[0030] The data distribution characteristics differ significantly across different commodity types. For example, the crude oil sector relies more on time-series price data and physical attributes such as API level, while the soybean sector relies more on geographical information about production areas and inventory data. Different processing types also have different focuses on data modalities. Processing type refers to the specific operation to be performed on the entity, including but not limited to entity alignment, relation extraction, price impact analysis, entity disambiguation, and entity linking. Different processing types correspond to different modal emphasis requirements. For instance, entity alignment tasks rely more on textual descriptions to determine name consistency, while price impact analysis tasks rely more on time-series price data to determine price correlation.
[0031] Based on the product type of the entity and the type of processing required, the fusion weights of each modality are adaptively determined, enabling the contribution of each modality to dynamically adjust according to the actual scenario during the fusion process of multi-source heterogeneous data. On this basis, the determined fusion weights are used to perform cross-modal attention fusion and semantic alignment on the feature vectors of each modality, aggregating the multi-modal information of the same entity into a unified entity vector representation. This entity vector representation is a numerical summary of the entity's comprehensive information, used for subsequent graph structure pre-training and entity processing.
[0032] In one specific embodiment of this application, the fusion weight of each modality is determined based on the product type to which the entity belongs and the current processing type, including: Input the product type and current processing type of the entity into the predictor network to obtain the fusion weights of each modality after the predictor network has calculated them.
[0033] This predictor network is a learnable neural network module that learns the mapping relationship between product type, processing type and modal weights through training. After training, it can quickly generate the optimal fusion weight configuration for any combination of product type and processing type, without the need for manual setting of weights for each scenario, thus balancing fusion effect and deployment efficiency.
[0034] In one specific embodiment of this application, cross-modal fusion and semantic alignment include: Using the feature vector of each modality as the query and the feature vectors of other modalities as the key and value, calculate the attention weight of that modality to other modalities; By aggregating feature information from other modalities based on attention weights, deep interactive fusion between modalities can be achieved. By using intermodal contrastive learning, different modal feature vectors of the same entity are used as positive samples, and modal feature vectors of different entities are used as negative samples, thus narrowing the distance between positive samples and widening the distance between negative samples.
[0035] In this process, contrastive learning is optimized using the InfoNCE loss function. Contrastive learning alignment, by comparing positive and negative samples, brings different modal representations of the same entity closer together in the vector space, while keeping representations of different entities further apart, thus ensuring multimodal consistency.
[0036] Cross-modal attention mechanisms enable each modality to pay attention to important information in other modalities during fusion, achieving deep interactive fusion; contrastive learning ensures that the representations of the same entity in different modalities are close to each other in the vector space, while the representations of different entities are far apart, thereby ensuring the consistency and discriminative power of the multimodal semantic space.
[0037] S103. Construct a bulk commodity knowledge graph based on the relationships between entities, use entity vector representations as node features, and perform pre-training on the knowledge graph to obtain optimized entity vector representations with enhanced graph structure information.
[0038] The relationships between entities can be extracted from the raw data, including upstream and downstream relationships in the supply chain, similar competitive relationships, geographical proximity relationships, and price linkage relationships. Knowledge graphs use a graph structure to represent knowledge systems, where nodes represent entities and edges represent relationships between entities, used for storing and reasoning about domain knowledge. Graph structure-enhanced pre-training: Pre-training is performed on the product knowledge graph to learn entity and relationship representations containing rich semantic and structural information, incorporating graph structure information.
[0039] Since a knowledge graph is a graph structure data with entities as nodes and relationships as edges, in this embodiment, an initial commodity knowledge graph is first constructed based on the aforementioned relationships. Then, the generated entity vector representations are used as the initial features of each entity node in the knowledge graph. Pre-training is performed on the constructed graph structure, and through the message passing mechanism of the graph neural network, the vector representation of each entity can aggregate information from its neighboring nodes, thereby further integrating graph structure information on top of the original modal information. Thus, the optimized entity vector representation includes the entity's own attribute information, its position in the knowledge graph, its relationships with upstream and downstream entities, and the cluster structure information among similar entities.
[0040] In one specific embodiment of this application, before constructing a commodity knowledge graph based on the relationships between entities, the following steps are also included: The overall similarity is calculated based on the similarity of physical attributes, market characteristics, and supply chain among products; Based on the overall similarity, several reference products with the highest similarity to the target product are identified from the existing products. Sample data of reference products are obtained as a support set. The parameters of the generation process of each modal feature vector corresponding to the target product are adjusted using the support set, so that the multimodal fusion encoding of the target product is adapted to the product type of the target product.
[0041] Multimodal fusion, which integrates various data types such as text, time series, geographic, and image data to obtain a more comprehensive information representation, can employ adaptive cross-modal attention fusion. Adaptive cross-modal attention fusion is a fusion method that dynamically adjusts the weights of different modalities based on product type and task type, avoiding the tedious process of manually setting weights.
[0042] To address the cold start problem of emerging commodities (such as lithium and cobalt) and rare commodities (such as rhodium and indium) being difficult to model quickly due to insufficient training samples, this study selects reference commodities from mature commodities that are highly similar to the target commodity in terms of physical attributes, market behavior, and supply chain location. Using their sample data as a support set, the study performs rapid parameter adjustment through meta-learning, enabling the target commodity to quickly obtain an adapted encoding model under limited sample conditions, thereby effectively expanding the commodity coverage of the knowledge graph.
[0043] Meta-learning is a learning method that enables models to quickly adapt to new tasks, and can achieve rapid adaptation to new product types with only a small number of samples.
[0044] In one specific embodiment of this application, pre-training on a knowledge graph includes: Negative samples are weighted differently according to the relationship type between entities through inter-entity comparative learning; the weight of negative samples corresponding to the same type of goods is lower than that of negative samples corresponding to complementary goods, and the weight of negative samples corresponding to substitute goods is lower than that of negative samples corresponding to unrelated goods. The mask entity prediction loss, link prediction loss, and supply chain path prediction loss are weighted and summed to obtain the multi-task structural loss, and the multi-task structural loss is used to learn graph structure information. We obtain the domain knowledge constraint loss by weighted summation of product classification constraints, price relevance constraints, and geographical proximity constraints, and then use the domain knowledge constraint loss to constrain the entity vector representation.
[0045] Among them, the geographical proximity constraint uses the Havesing formula to calculate the geographical distance between entities, and constrains the vector representation of entities whose geographical distance is less than a set threshold to be close to each other.
[0046] Inter-entity comparative learning uses a differentiated weighting strategy to keep entities with similar or substitute product relationships at a moderate level rather than pushing them too far apart, thus preserving the natural connections between products.
[0047] The multi-task structural loss learns semantic information in graph structures from different perspectives through three sub-tasks: mask entity prediction, link prediction, and path prediction.
[0048] Domain knowledge constraint loss is a loss function that incorporates domain-specific knowledge (such as product classification, price correlation, and geographical proximity) into pre-training, enabling the model to learn representations that conform to domain rules. Specifically, domain knowledge constraint loss incorporates commodity domain knowledge from three dimensions: product classification, price correlation, and geographical proximity. This ensures that the learned entity vector representations conform to known domain rules. The three losses work together to optimize and ensure that the pre-trained entity vector representations possess discriminative power, structural awareness, and domain consistency.
[0049] S104. Select the first entity and the second entity to be processed from the bulk commodity knowledge graph. Based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, process the first entity and the second entity according to the current processing type, and update the bulk commodity knowledge graph according to the processing results.
[0050] Specifically, after the above steps, each entity node in the knowledge graph has obtained an optimized entity vector representation that integrates multimodal information and graph structure information. Based on this, this step selects any two entities from the knowledge graph that need to be processed, namely the first entity and the second entity. Using their respective optimized entity vector representations as the basis for judgment, the corresponding processing operation is performed according to the current processing type. The processing results include merging duplicate nodes referring to the same real-world object, disambiguating statements, or linking text references to corresponding nodes in the knowledge graph. Based on the processing results, the knowledge graph is then updated accordingly.
[0051] In one specific embodiment of this application, the processing of the first entity and the second entity includes: The rule-guided layer matches the first entity and the second entity according to a preset set of rules; If a match is successful, the processing results for the first and second entities are determined based on the matching results; if no match is found, the process proceeds to the probabilistic inference layer. The feature vectors of the first entity and the second entity are extracted using the probabilistic inference layer, and then input into different models. The prediction results of the different models are weighted and fused to output the processing probability and confidence. When the confidence level of the probabilistic inference layer output is lower than a preset threshold, the large model semantic layer is used for inference, and the output contains the processing result containing the evidence chain.
[0052] The confidence score is calculated based on the consistency among the predictions of the three models, the degree to which each prediction deviates from the median, and the quality of the feature vectors.
[0053] The rules in the rule-guided layer correspond to the geographical proximity constraints in the pre-training stage. By setting a reverse threshold, rapid exclusion is achieved. The rule-guided layer is used to quickly process simple cases with clear judgment criteria; for example, a consistent unified social credit code necessarily indicates the same entity, balancing processing efficiency and reliability. The probabilistic inference layer handles moderately complex cases, using ensemble learning to predict output probabilities and providing quantitative confidence assessments. The large-model semantic layer intervenes when the confidence level of the probabilistic inference layer is insufficient, handling cases requiring complex semantic understanding. This three-layer decision-making system, composed of the rule-guided layer, probabilistic inference layer, and large-model semantic layer, automatically selects the optimal decision path based on confidence levels. The three-layer architecture works collaboratively, balancing processing efficiency, coverage, and result interpretability.
[0054] In one specific embodiment of this application, when the confidence level output by the probabilistic inference layer is lower than a preset threshold, inference is performed using a large model semantic layer, and a processing result containing a chain of evidence is output, including: Retrieve relevant knowledge from the product knowledge base based on the current processing type, and embed the retrieved knowledge into the input prompts to build enhanced prompts; The enhanced prompts are organized according to the thought chain template, and the large language model, which has been fine-tuned for the domain, is called to generate inference responses; Extract structured reasoning results from the reasoning response, including fields such as thought process, conclusion, confidence level, and key evidence. The reasoning response and structured reasoning results are stored in a case library to continuously optimize the large language model.
[0055] In other words, Retrieval Enhanced Generation (RAG) enables large language models to refer to specialized information in external knowledge bases during reasoning, thus alleviating the illusion problem caused by the model's own knowledge limitations.
[0056] The Chain of Reasoning (CoT) technique guides large language models through step-by-step reasoning. By decomposing complex problems into multiple reasoning steps, it improves the interpretability and accuracy of solutions. Specifically, the CoT reasoning template guides the large model to output a traceable judgment process through step-by-step reasoning, significantly enhancing the interpretability of the reasoning results. The continuous accumulation of a case library allows the large language model to be continuously optimized during practical use, forming a closed-loop iterative mechanism.
[0057] Among them, the retrieval-enhanced generation combines information retrieval and large language model generation technologies to enhance the accuracy and reliability of generated answers by retrieving relevant knowledge bases.
[0058] After constructing a commodity knowledge graph, massive, dispersed, and heterogeneous data can be transformed into structured, reasonable domain knowledge, providing support for supply chain analysis, risk management, and intelligent decision-making. In supply chain analysis, the knowledge graph can clearly display the hierarchy and supply relationships between products and enterprises, assisting researchers and fund managers in conducting comprehensive intelligent investment research and analysis from pre-investment to post-investment. For example, it can quickly assess the impact of events such as geopolitical conflicts on specific commodities or industries. In risk management, by constructing a dynamic causal knowledge graph that includes upstream and downstream relationships, the transmission path of price risks can be identified, supply chain risks can be predicted in advance, and visualized traceability and contagion path analysis can be achieved from a single entity to the entire chain, ensuring the security of strategic resources. In intelligent decision-making, the knowledge graph supports semantic-based intelligent queries and question answering. Its transparent reasoning paths and basis can effectively alleviate the illusion problem of large models, integrating multi-dimensional data such as price, supply and demand, macroeconomics, and public opinion to provide a basis for comprehensive judgment, ultimately providing reliable technical support for investment decisions, rule-making, and real-time response in the commodity sector.
[0059] Applying the method provided in the embodiments of this application, entities and their respective commodity types are identified from the original data in the commodity domain, and each entity's modal data is encoded separately to obtain modal feature vectors. The fusion weights of each modality are determined based on the commodity type of the entity and the current processing type. These fusion weights are then used to perform cross-modal fusion and semantic alignment on the modal feature vectors to obtain the entity vector representation of the entity. A commodity knowledge graph is constructed based on the relationships between entities, using the entity vector representations as node features. Pre-training is performed on the knowledge graph to obtain optimized entity vector representations with enhanced graph structure information. A first entity and a second entity to be processed are selected from the commodity knowledge graph. Based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, the first entity and the second entity are processed according to the current processing type, and the commodity knowledge graph is updated based on the processing results.
[0060] By identifying entities and their respective commodity types from raw data in the commodity sector and encoding each modality separately, a data foundation tailored to different commodity types is provided for subsequent differentiated fusion. The fusion weights for each modality are adaptively determined based on the commodity type of the entity and the current processing type. These weights are then used to perform cross-modal fusion and semantic alignment of the feature vectors of each modality, aligning multi-source heterogeneous data in a unified vector space. Simultaneously, the entity vector representations can dynamically emphasize different modal information according to the processing scenario, achieving adaptive fusion of multi-source heterogeneous data. Thus, a knowledge graph is constructed based on the relationships between entities, and the generated entity vector representations are used as node features for pre-training on this knowledge graph. The entity vector representations further incorporate graph structure information on top of the original modal information. That is, the optimized entity vector representations can simultaneously reflect the entity's own attributes and its position and relationships in the knowledge graph. Based on this, entities to be processed are selected from the knowledge graph and processed based on their respective optimized entity vector representations. The processing results are then fed back to update the knowledge graph, forming a complete closed loop from construction to processing to updating.
[0061] In other words, this application achieves continuous optimization of the knowledge graph during the construction process through the synergistic effect of adaptive multimodal fusion and graph structure enhancement pre-training, effectively solving technical problems such as insufficient multi-source heterogeneous data processing capabilities and poor adaptability to new products in the existing technology.
[0062] It should be noted that, based on the above embodiments, the embodiments of this application also provide corresponding improvement schemes. In the preferred / improved embodiments, the same or corresponding steps as in the above embodiments can be referred to each other, and the corresponding beneficial effects can also be referred to each other; however, these will not be elaborated upon in the preferred / improved embodiments herein.
[0063] To facilitate those skilled in the art to better understand and implement the commodity knowledge graph construction method provided in the embodiments of this application, the following detailed explanation of the commodity knowledge graph construction method is given with reference to specific application scenarios.
[0064] Please refer to Figure 2 A system that specifically implements this method for constructing a knowledge graph for bulk commodities may include the following architectural elements (it should be noted that...). Figure 2 The described module and Figure 3 The modules described all correspond to Figure 1 The steps corresponding to the method shown are modularly expressed. Due to the different granularity of the division of functions or steps, the module names and functions are not exactly the same. However, since both correspond to the specific implementation description of the method, they can still be referenced to each other in the description of similar or related functions.
[0065] The input layer is used to receive multi-source heterogeneous data in the commodity sector, including text data (news, reports, contract documents), time series data (price series, production data), geographic data (coordinates, transportation routes), and structured data (financial reports, statistical tables).
[0066] The multimodal fusion encoding module, connected to the input layer, is used to fuse and encode the multi-source heterogeneous input data. It includes: an adaptive cross-modal attention fusion submodule, which dynamically adjusts the fusion weights of each modality based on the product type and task type (processing type); an inter-modal contrastive learning alignment submodule, which ensures the consistency of different modal representations through contrastive learning; and a meta-learning adapter submodule, which handles the cold start problem for new and rare products.
[0067] The graph structure enhancement pre-training module, connected to the multimodal fusion encoding module, is used for multi-task pre-training on the product knowledge graph. It includes: an entity comparison learning loss submodule, used to enhance the discriminative ability of entity representations; a multi-task structure loss submodule, used to learn graph structure information, including masked entity prediction, link prediction, and path prediction; and a domain knowledge constraint loss submodule, used to incorporate product domain expertise such as product classification, price relevance, and geographical proximity.
[0068] The three-layer decision-making module, a connection graph structure enhancement pre-training module, is used to process entities. It includes: a rule-guided layer for rapid judgment based on deterministic rules; a probabilistic reasoning layer for probabilistic reasoning using encoding and machine learning models; and a large-model semantic layer for deep semantic reasoning through domain fine-tuning, feature description, retrieval enhancement generation, and thought chain reasoning. The rule-guided layer, probabilistic reasoning layer, and large-model semantic layer work collaboratively.
[0069] The output layer connects the three decision-making modules and is used to output a unified knowledge graph after alignment, disambiguation, and linking.
[0070] The self-optimization module connects to the output layer and is used to iteratively improve the system through incremental learning and continuous optimization.
[0071] The multimodal fusion encoding module encodes multi-source heterogeneous data (text, time series, geographic, and structured data) from the commodity domain into high-quality vector representations. It employs an adaptive cross-modal attention mechanism to dynamically adjust the fusion weights of each modality based on commodity type (e.g., crude oil, copper, soybeans) and task type (e.g., entity alignment, price analysis). Contrastive learning ensures consistency across different modal representations, and a meta-learning adapter is specifically introduced to address the cold-start problem for new and rare commodities.
[0072] Specifically, a three-layer progressive coding architecture can be adopted: a modality-specific coding layer, which converts the original data of each modality into feature vectors; an adaptive fusion layer, which dynamically weights and fuses data based on product type and task type; and a contrastive alignment layer, which achieves multimodal semantic space alignment through contrastive learning. Meanwhile, a meta-learning adapter provides rapid adaptation capabilities for rare product types.
[0073] Adaptive cross-modal attention fusion dynamically adjusts the importance weights of different modalities based on product type and task type, and achieves deep interactive fusion through a cross-modal attention mechanism. By using a predictor network to learn the mapping relationship between product type, task type, and modal weights, the tediousness and subjectivity of manually setting weights are avoided.
[0074] Intermodal contrastive learning alignment, through the contrastive learning loss function (InfoNCE), narrows the distance between different modal representations of the same entity and widens the distance between representations of different entities, ensuring consistency of different modalities in the vector space. Positive and negative sample sampling is performed based on product-aware masks, taking into account product substitution relationships, supply chain connections, etc.
[0075] The meta-learning adapter provides rapid adaptation capabilities for new and rare products. Utilizing a small number of support set samples, it rapidly adjusts model parameters through a meta-learning algorithm (based on the MAML (Model-Agnostic Meta-Learning) algorithm). Its core innovation is the measurement of perceived similarity between products, calculating similarity based on physical attributes, market characteristics, and supply chain location to guide transfer learning from similar products.
[0076] Similarity is calculated based on product attributes. Calculation dimensions are illustrated below: Physical property similarity (40%): chemical composition, physical properties, etc.; Market characteristics similarity (30%): price fluctuations, demand patterns, etc.; Supply chain similarity (30%): upstream and downstream relationships, processing technology, etc.
[0077] The graph structure enhancement pre-training module employs Graph Neural Networks (GNNs) for pre-training on a large-scale product knowledge graph, learning entity and relation representations rich in semantic and structural information. Through a multi-task learning framework, it simultaneously optimizes contrastive learning loss, structural prediction loss, and domain knowledge constraint loss, enabling the model to understand complex relationships between products, supply chain paths, and market mechanisms. Based on a multimodal fusion encoder, it performs multi-task pre-training on the product knowledge graph. This includes three core training tasks: a contrastive learning task to enhance the discriminative ability of representations; a structural prediction task (masked entity prediction, link prediction, and path prediction) to learn graph structure information; and a domain knowledge constraint task to incorporate product-specific knowledge.
[0078] The inter-entity contrastive learning loss learns to distinguish the representations of different entities by comparing positive and negative sample pairs. In this step, inter-entity contrastive learning focuses on differentiating the representations of different entities, unlike the aforementioned contrastive learning for different modalities of the same entity. Considering the characteristics of the product domain, a negative sampling strategy for product perception is designed, taking into account the substitution and complementarity relationships between products rather than random sampling, and assigning differentiated weights to negative samples. Same commodity: The weight of negative samples is reduced to 0.3 because two products in the same category should not be pushed too far apart.
[0079] Substitute relationship: The negative sample weight is reduced to 0.5 because there is a natural association between substitutes (such as Brent crude oil and WTI crude oil).
[0080] Complementary relationships: Negative samples are weighted at 1.0 because complementary products (such as crude oil and gasoline) should be distinguished normally.
[0081] Irrelevant product relationships: Negative samples are weighted at 1.0.
[0082] Finally, the InfoNCE loss is calculated.
[0083] The multi-task structural loss consists of three sub-tasks: masked entity prediction (learning entity context), link prediction (learning relationships between entities), and path prediction (learning supply chain structure). These three tasks work together to learn the structural information of the product knowledge graph.
[0084] Domain knowledge constraint loss incorporates domain-specific knowledge into the pre-training process, including three constraints: product classification constraint (similar products should be represented as close as possible), price correlation constraint (products with linked prices should be represented as close as possible), and geographical proximity constraint (entities with geographically close locations should be represented as close as possible).
[0085] Specifically, given the input entity representation matrix and the product knowledge graph, the following three constraints are calculated: Constraint 1: Product Classification Constraint (Weight 0.5). Based on the product category labels provided by the knowledge graph, calculate the average Euclidean distance between entity representations of similar products. The goal is to make the representations of similar products as close as possible. Specifically, it involves iterating through all pairs of entities with the same label, calculating the L2 norm of the difference between their vectors, and using the average distance of all similar entity pairs as the constraint loss.
[0086] Constraint 2: Price Relevance Constraint (weight 0.3). This constraint compares the cosine similarity matrix between entity representations with the actual price relevance matrix provided by the knowledge graph, using mean squared error (MSE) as the loss function. The goal is to ensure that highly price-correlated goods (such as crude oil and gasoline) also have high similarity in the vector space.
[0087] Constraint 3: Geographic Proximity Constraint (Weight 0.2). Iterate through all entity pairs and calculate their geographic distance using the Havesing formula. For entity pairs with a geographic distance less than 100 kilometers, calculate the L2 distance between their representation vectors, and take the average distance of all entity pairs satisfying the condition as the constraint loss. The goal is that geographically proximate entities (such as different mines from the same production area) should also be proximate in the vector space.
[0088] A three-layer decision-making module intelligently selects decision paths based on problem complexity and confidence level, achieving efficient and accurate entity alignment, disambiguation, and linking. It employs a three-layer collaborative decision-making architecture: a rule-guided layer handles simple cases with deterministic rules; a probabilistic inference layer uses machine learning models to handle most cases; and a large-model semantic layer handles complex cases, providing deep semantic inference. All three layers share vector representations generated by a pre-trained encoder. A confidence-driven intelligent routing mechanism is also employed. 1. The rule-guided layer quickly processes explicit cases based on deterministic rules; 2. When the rule layer is uncertain, the probabilistic inference layer uses the vector representation generated by the pre-trained encoder to make probability judgments; 3. When the confidence level of the probability layer is insufficient, the domain-enhanced large model is invoked for deep reasoning. The semantic layer of the large model adopts a domain-fine-tuned large language model, which, based on basic data and encoded data, combines retrieval enhancement generation and thought chain reasoning to handle complex semantic problems.
[0089] All three decision-making processes provide interpretable chains of evidence. Furthermore, reinforcement learning can be incorporated into the RAG and CoT processes for optimization.
[0090] The rule-guided layer rapidly processes explicit cases based on deterministic rules, including code matching rules (Unified Social Credit Code, HS Code), geographical constraint rules (distance threshold), unit compatibility rules, and time window rules. This layer handles approximately 20% of simple cases, providing immediate response and high reliability.
[0091] This function takes two entity attribute dictionaries as input, matches five rules sequentially according to priority, and returns the result immediately upon a successful match. Rule 1: Unified Social Credit Code Matching (Highest Priority, Confidence Level 1.0). If two entities both contain the Unified Social Credit Code field and their values are equal, they are determined to be the same entity, with a confidence level set to the highest value of 1.0. This rule applies to corporate entities registered in China. The Unified Social Credit Code is a legally recognized unique identifier, and a match constitutes a complete determination.
[0092] Rule 2: HS Code Matching (Second Highest Priority, Confidence 0.8). If two entities both contain HS code fields with equal values, they are considered the same entity, with a confidence level of 0.8. Although HS codes (Customs Commodity Codes) are highly standardized, there is a possibility that different commodities may share the same code (e.g., the first 6 digits are the same but the last few digits are different), therefore the confidence level is slightly lower than that of uniform code matching.
[0093] Rule 3: Geographic Distance Conflict Detection (Confidence Level 0.9). If both entities contain geographic coordinate fields, calculate the geographic distance between them. If the distance exceeds 1000 kilometers, they are determined to be different entities, with a confidence level of 0.9. This rule is based on domain knowledge that commodity entities are typically located in specific geographic areas. For example, the geographical location of the same mine, oil field, or processing plant is fixed and it is impossible for them to appear in two places 1000 kilometers apart simultaneously.
[0094] Rule 4: Unit Compatibility Check (Confidence Level 0.7). If both entities contain a unit field, check whether their units of measurement are compatible. For example, ton and metric ton are compatible, but ton and barrel are not. If the units are incompatible, they are determined to be different entities, with a confidence level of 0.7.
[0095] Rule 5: Time Window Overlap Check (Confidence Level 0.6). If two entities both contain a valid time window field, check if their valid time windows overlap. If there is no overlap, they are determined to be different entities, with a confidence level of 0.6. This rule applies to entities with time-sensitive characteristics (such as futures contracts and temporary production capacity).
[0096] Default return: If none of the five rules match, an uncertain result is returned with a confidence level of 0.0, indicating that the evidence is that no rule is matched. In this case, the case will be transferred to the probabilistic inference layer for processing.
[0097] The probabilistic inference layer integrates multiple machine learning models (gradient boosting trees, neural networks, graph neural networks), extracts features from vector representations generated by a pre-trained encoder, and fuses the prediction results of each model using an ensemble learning method. This layer handles approximately 60% of medium-complexity cases, providing probabilistic judgments and interpretable feature importance analysis.
[0098] This system receives vector representations of two entities and optional context information. It then performs the following six steps: Step 1: Feature Engineering. Four types of features are extracted from the two vector representations and contextual information: basic features (two original vectors), interaction features (concatenation, difference vectors, element-wise multiplication), similarity features (cosine similarity, L2 Euclidean distance), and contextual features (relevant features are extracted if context exists). These features collectively constitute the model's input.
[0099] Step 2: Multi-model prediction. The GBDT, neural network, and graph neural network models are called sequentially, each taking the extracted features as input and outputting an aligned probability prediction value, which is stored in a dictionary.
[0100] Step 3: Ensemble Learning and Fusion. The predictions from the three models are weighted and averaged according to their learnable weights. The weights are normalized using the Softmax function to ensure the sum is 1. If all weights are close to zero (a degenerate case), the result is reduced to a simple average.
[0101] Step 4: Confidence Calculation. The confidence score is calculated from three dimensions: inter-model consistency (50% weight, measured by the standard deviation of the predicted values; the smaller the standard deviation, the higher the consistency), prediction probability confidence (30% weight, measured by the degree to which the predicted values deviate from 0.5; the further away from 0.5, the more confident the prediction), and feature quality (20% weight, measured by normalization of the smaller of the two vector norms).
[0102] Step 5: Feature Importance Analysis. Analyze the contribution of each feature to the final prediction, providing interpretability.
[0103] Step Six: Alignment Judgment. If the final predicted probability is greater than 0.5, they are determined to be the same entity; otherwise, they are different entities.
[0104] The integrated large-scale model semantic layer combines three technologies: domain fine-tuning, retrieval-enhanced generation (RAG), and CoT (CoT) reasoning, to handle the most complex 20% of cases. First, the basic large-scale language model undergoes further pre-training and instruction fine-tuning within the product domain. Then, during reasoning, relevant knowledge bases are retrieved, and CoT templates guide the step-by-step reasoning process. Finally, continuous improvement is achieved through a self-optimization module.
[0105] The main inference process for large models is as follows: Receive the input prompt text. Perform the following seven steps: Step 1: Retrieve relevant knowledge. Based on the input prompts, retrieve the most relevant knowledge points from the product knowledge base. Record the retrieval time and the number of knowledge points retrieved (maximum of the top 5).
[0106] Step 2: Build Enhanced Hints. Embed the retrieved knowledge points in a structured format before the original hint text to create an enhanced hint template based on knowledge and answer questions.
[0107] Step 3: Apply the mind chain template. Select a mind chain template for the entity alignment task type, organize the enhanced hints according to the template format, and guide the large model through step-by-step reasoning.
[0108] Step 4: Large Model Generation. The generation method for the domain-fine-tuned large language model is invoked, setting a maximum generation length of 1000 tokens, a temperature coefficient of 0.1 (low temperature ensures deterministic output), and disabling random sampling to generate a structured inference response.
[0109] Step 5: Parse the response. Parse four fields from the text response of the large model: thought process (a textual description of step-by-step reasoning), conclusion (yes or no), confidence score, and a list of key evidence.
[0110] Step Six: Confidence Assessment. A comprehensive evaluation of the quality of the original response, parsed results, and retrieved knowledge of the large model is conducted to determine the final confidence level.
[0111] Step 7: Self-Optimization. Record the input hints, model response, parsing results, and confidence scores of this inference into the case library for subsequent model fine-tuning and performance tracking.
[0112] Therefore, this application includes both technological innovation and application innovation.
[0113] In terms of technological innovation, this application proposes an adaptive multimodal fusion mechanism that dynamically predicts weights based on product type and task type, eliminating the need for manual setting of fusion weights. It achieves unification of the multimodal semantic space through cross-modal contrastive learning alignment and introduces meta-learning technology to quickly adapt to new product types, effectively solving the cold start problem. Regarding the graph structure enhancement pre-training framework, this application designs a multi-task loss function combining contrastive learning, structural tasks, and domain constraints. The structural tasks include product-specific tasks such as supply chain path prediction, and deeply integrates commodity domain knowledge such as product classification, physical attributes, and market mechanisms into the pre-training process. This application also constructs an integrated large-scale model system, employing a three-layer architecture of domain fine-tuning, retrieval enhancement generation, and thought chain reasoning. It can generate entity comparison text descriptions using vector representations to supplement the initial task input, possesses self-optimization capabilities based on online user feedback, and provides detailed reasoning chains and evidence support to ensure interpretability.
[0114] In addition, this application designs an intelligent three-layer decision-making system, which adopts a collaborative working mode of rule-guided layer, probabilistic reasoning layer and large model semantic layer. The system automatically selects the decision level through a confidence-driven intelligent routing mechanism, and each layer of decision provides a basis and evidence.
[0115] In terms of application innovation, this application demonstrates a deep understanding of the unique characteristics of the commodity sector, fully utilizing expertise in HS codes, futures contracts, and supply chain relationships to address commodity-specific issues such as specification differences, origin premiums, and price transmission. The system employs a modular design, facilitating the addition of new commodity and task types, supporting incremental learning and continuous evolution of the knowledge graph over time, and supporting multiple languages to handle cross-border commodity trade scenarios. Regarding the balance between practicality and efficiency, approximately 80% of simple cases are processed quickly by the first two layers, while approximately 20% of complex cases are analyzed in depth by a large model, ensuring the overall system response time meets real-time requirements.
[0116] Corresponding to the above method embodiments, this application also provides a commodity knowledge graph construction device. The commodity knowledge graph construction device described below and the commodity knowledge graph construction method described above can be referred to each other.
[0117] See Figure 3 As shown, the device includes the following modules: The data acquisition and entity recognition module 101 is used to identify each entity and its commodity type from the raw data in the commodity field, and to encode each modal data of each entity to obtain the feature vector of each modality. The multimodal fusion coding module 102 is used to determine the fusion weight of each modality based on the product type to which the entity belongs and the current processing type, and to use the fusion weight to perform cross-modal fusion and semantic alignment on the feature vectors of each modality to obtain the entity vector representation of the entity; The knowledge graph construction and pre-training module 103 is used to construct a bulk commodity knowledge graph based on the relationship between entities. It uses entity vector representation as node features and performs pre-training on the knowledge graph to obtain optimized entity vector representations with enhanced graph structure information. The entity processing and updating module 104 is used to select the first entity and the second entity to be processed from the bulk commodity knowledge graph, process the first entity and the second entity according to the current processing type based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, and update the bulk commodity knowledge graph according to the processing results.
[0118] Using the apparatus provided in this application embodiment, entities and their respective commodity types are identified from raw data in the commodity domain. For each entity, its modal data is encoded separately to obtain modal feature vectors. The fusion weights of each modality are determined based on the commodity type of the entity and the current processing type. These fusion weights are then used to perform cross-modal fusion and semantic alignment on the modal feature vectors to obtain entity vector representations. A commodity knowledge graph is constructed based on the relationships between entities. Entity vector representations are used as node features, and pre-training is performed on the knowledge graph to obtain optimized entity vector representations with enhanced graph structure information. A first entity and a second entity to be processed are selected from the commodity knowledge graph. Based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, the first entity and the second entity are processed according to the current processing type. The commodity knowledge graph is then updated based on the processing results.
[0119] By identifying entities and their respective commodity types from raw data in the commodity sector and encoding each modality separately, a data foundation tailored to different commodity types is provided for subsequent differentiated fusion. The fusion weights for each modality are adaptively determined based on the commodity type of the entity and the current processing type. These weights are then used to perform cross-modal fusion and semantic alignment of the feature vectors of each modality, aligning multi-source heterogeneous data in a unified vector space. Simultaneously, the entity vector representations can dynamically emphasize different modal information according to the processing scenario, achieving adaptive fusion of multi-source heterogeneous data. Thus, a knowledge graph is constructed based on the relationships between entities, and the generated entity vector representations are used as node features for pre-training on this knowledge graph. The entity vector representations further incorporate graph structure information on top of the original modal information. That is, the optimized entity vector representations can simultaneously reflect the entity's own attributes and its position and relationships in the knowledge graph. Based on this, entities to be processed are selected from the knowledge graph and processed based on their respective optimized entity vector representations. The processing results are then fed back to update the knowledge graph, forming a complete closed loop from construction to processing to updating.
[0120] In other words, this application achieves continuous optimization of the knowledge graph during the construction process through the synergistic effect of adaptive multimodal fusion and graph structure enhancement pre-training, effectively solving technical problems such as insufficient multi-source heterogeneous data processing capabilities and poor adaptability to new products in the existing technology.
[0121] In one specific embodiment of this application, the predictor network in the multimodal fusion coding module 102 is used to calculate and output the fusion weights of each modality after inputting the product type to which the entity belongs and the current processing type into the predictor network.
[0122] In one specific embodiment of this application, the multimodal fusion coding module includes: The cross-modal attention fusion submodule is used to calculate the attention weight of each modality to other modalities using the feature vector of each modality as the query and the feature vectors of other modalities as the key and value, and to aggregate the feature information of other modalities based on the attention weight; The contrastive learning alignment submodule is used to learn between modalities by using different modal feature vectors of the same entity as positive samples and modal feature vectors of different entities as negative samples, thereby narrowing the distance between positive samples and widening the distance between negative samples.
[0123] In one specific embodiment of this application, the knowledge graph construction and pre-training module 103 is further used to calculate a comprehensive similarity based on the physical attribute similarity, market feature similarity, and supply chain similarity between commodities before constructing a commodity knowledge graph based on the relationship between various entities; determine several reference commodities with the highest similarity to the target commodity from existing commodities based on the comprehensive similarity; obtain sample data of the reference commodities as a support set, and use the support set to adjust the parameters of the generation process of each modal feature vector corresponding to the target commodity, so that the multimodal fusion encoding of the target commodity is adapted to the commodity type of the target commodity.
[0124] In one specific embodiment of this application, the knowledge graph construction and pre-training module is specifically used to differentiate and weight negative samples according to the relationship type between entities through inter-entity comparative learning, wherein the weight of negative samples corresponding to the same type of goods relationship is lower than the weight of negative samples corresponding to the complementary goods relationship, and the weight of negative samples corresponding to the substitute goods relationship is lower than the weight of negative samples corresponding to the unrelated goods relationship; the masked entity prediction loss, link prediction loss and supply chain path prediction loss are weighted and summed to obtain the multi-task structure loss; and the product classification constraint, price correlation constraint and geographical proximity constraint are weighted and summed to obtain the domain knowledge constraint loss.
[0125] In one specific embodiment of this application, the entity processing and updating module includes: The rule guidance layer is used to match the first entity and the second entity according to a preset set of rules. If the match is successful, the processing result of the first entity and the second entity is determined based on the matching result. If the match is not successful, the process is transferred to the probabilistic reasoning layer. The probabilistic inference layer is used to extract the feature vectors of the first entity and the second entity, input them into different models respectively, and then weight and fuse the prediction results of the different models to output the processing probability and confidence level.
[0126] In one specific embodiment of this application, the entity processing and updating module includes: The large model semantic layer is specifically used to retrieve relevant knowledge from the product knowledge base according to the current processing type, embed the retrieved knowledge into the input prompts to build enhanced prompts, organize the enhanced prompts according to the thought chain template, call the domain-fine-tuned large language model to generate inference responses, and extract structured inference results from the inference responses, including thought process, conclusion, confidence level and key evidence fields. The continuous optimization layer is specifically used to store inference responses and structured inference results in a case library for continuous optimization of the large language model.
[0127] Corresponding to the above method embodiments, this application also provides an electronic device. The electronic device described below and the commodity knowledge graph construction method described above can be referred to in correspondence.
[0128] See Figure 4 As shown, the electronic device includes: Memory 332 is used to store computer programs; The processor 322 is used to implement the steps of the commodity knowledge graph construction method in the above method embodiments when executing a computer program.
[0129] For details, please refer to Figure 5 , Figure 5 This is a schematic diagram of the specific structure of an electronic device provided in this embodiment. The electronic device can vary significantly due to differences in configuration or performance. It may include one or more central processing units (CPUs) (e.g., one or more processors) and a memory 332. The memory 332 stores one or more computer programs 342 or data 344. The memory 332 can be temporary or permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332 and execute the series of instruction operations stored in the memory 332 on the electronic device 301.
[0130] Electronic device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341.
[0131] The steps in the commodity knowledge graph construction method described above can be implemented using the structure of electronic devices.
[0132] Corresponding to the above method embodiments, this application also provides a readable storage medium. The readable storage medium described below can be referred to in conjunction with the commodity knowledge graph construction method described above.
[0133] A readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the commodity knowledge graph construction method described in the above method embodiments.
[0134] The readable storage medium can specifically be a USB flash drive, external hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or any other readable storage medium capable of storing program code.
[0135] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0136] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0137] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0138] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "include," "contain," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.
[0139] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for constructing a knowledge graph for bulk commodities, characterized in that, include: Identify entities and their respective commodity types from the raw data in the commodity sector, and encode each modal data of each entity separately to obtain modal feature vectors; The fusion weights of each modality are determined based on the product type to which the entity belongs and the current processing type. The fusion weights are then used to perform cross-modal fusion and semantic alignment on the feature vectors of each modality to obtain the entity vector representation of the entity. A bulk commodity knowledge graph is constructed based on the relationships between entities. The entity vector representation is used as node features. Pre-training is performed on the knowledge graph to obtain an optimized entity vector representation with enhanced graph structure information. Select a first entity and a second entity to be processed from the commodity knowledge graph. Based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, process the first entity and the second entity according to the current processing type, and update the commodity knowledge graph according to the processing result.
2. The method according to claim 1, characterized in that, Pre-training on the knowledge graph includes: Negative samples are differentiated and weighted according to the type of relationship between entities through inter-entity comparative learning; the negative samples corresponding to the same type of goods relationship and the substitute relationship have lower weights than the negative samples corresponding to the complementary goods relationship and the unrelated goods relationship. The mask entity prediction loss, link prediction loss, and supply chain path prediction loss are weighted and summed to obtain the multi-task structure loss, and the graph structure information is learned using the multi-task structure loss. The domain knowledge constraint loss is obtained by weighted summation of product classification constraints, price relevance constraints, and geographical proximity constraints, and then the domain knowledge constraint loss is used to constrain the entity vector representation.
3. The method according to claim 1, characterized in that, Before constructing a commodity knowledge graph based on the relationships between entities, it also includes: The overall similarity is calculated based on the similarity of physical attributes, market characteristics, and supply chain among products; Based on the comprehensive similarity, several reference products with the highest similarity to the target product are determined from the existing products; The sample data of the reference product is obtained as a support set. The parameters of the generation process of each modal feature vector corresponding to the target product are adjusted using the support set so that the multimodal fusion encoding of the target product is adapted to the product type of the target product.
4. The method according to claim 1, characterized in that, Processing the first entity and the second entity includes: The rule-guided layer matches the first entity and the second entity according to a preset set of rules; If a match is successful, the processing results for the first entity and the second entity are determined based on the matching result; if no match is found, the process proceeds to the probabilistic inference layer. The feature vectors of the first entity and the second entity are extracted using the probabilistic inference layer, and then input into different models. The prediction results of the different models are weighted and fused to output the processing probability and confidence. When the confidence level of the output of the probabilistic reasoning layer is lower than a preset threshold, the large model semantic layer is used for reasoning, and the processing result containing the evidence chain is output.
5. The method according to claim 4, characterized in that, When the confidence level output by the probabilistic inference layer is lower than a preset threshold, inference is performed using the large model semantic layer, and a processing result containing the evidence chain is output, including: Retrieve relevant knowledge from the product knowledge base based on the current processing type, and embed the retrieved knowledge into the input prompts to build enhanced prompts; The enhanced prompts are organized according to the thought chain template, and the domain-fine-tuned large language model is invoked to generate inference responses; Extract structured reasoning results from the reasoning response, including fields such as thought process, conclusion, confidence level, and key evidence. The inference response and the structured inference result are stored in a case library for continuous optimization of the large language model.
6. The method according to claim 1, characterized in that, The fusion weights for each modality are determined based on the product type to which the entity belongs and the current processing type, including: The product type to which the entity belongs and the current processing type are input into the predictor network to obtain the fusion weights of each modality after the predictor network has calculated them.
7. The method according to claim 1, characterized in that, Cross-modal fusion and semantic alignment include: Using the feature vector of each modality as the query and the feature vectors of other modalities as the key and value, calculate the attention weight of that modality to other modalities; Aggregate feature information from other modalities based on the attention weights; By using intermodal contrastive learning, different modal feature vectors of the same entity are used as positive samples, and modal feature vectors of different entities are used as negative samples, thus narrowing the distance between positive samples and widening the distance between negative samples.
8. A knowledge graph construction device for bulk commodities, characterized in that, include: The data acquisition and entity recognition module is used to identify each entity and its commodity type from the raw data in the commodity field, and to encode each modal data of each entity to obtain the feature vector of each modality. The multimodal fusion encoding module is used to determine the fusion weight of each modality based on the product type to which the entity belongs and the current processing type, and to use the fusion weight to perform cross-modal fusion and semantic alignment on the feature vectors of each modality to obtain the entity vector representation of the entity; The knowledge graph construction and pre-training module is used to construct a bulk commodity knowledge graph based on the relationship between entities. The entity vector representation is used as node features, and pre-training is performed on the knowledge graph to obtain an optimized entity vector representation with graph structure information enhancement. The entity processing and updating module is used to select a first entity and a second entity to be processed from the bulk commodity knowledge graph, process the first entity and the second entity according to the current processing type based on the first optimized entity vector representation corresponding to the first entity and the second optimized entity vector representation corresponding to the second entity, and update the bulk commodity knowledge graph according to the processing result.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the commodity knowledge graph construction method as described in any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the steps of the commodity knowledge graph construction method as described in any one of claims 1 to 7.