A knowledge graph and RAG-based scientific and technological service field knowledge base construction method and system
By combining knowledge graphs and RAG technology, a knowledge base for the field of science and technology services is constructed, which solves the shortcomings of traditional knowledge bases in terms of knowledge representation, retrieval efficiency and dynamic updates, realizes efficient and personalized knowledge retrieval and generation, and improves the intelligence level of science and technology services.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2026-03-17
AI Technical Summary
Traditional knowledge bases in the field of science and technology services suffer from problems such as incomplete knowledge representation, low retrieval efficiency, difficulty in dynamic updates, and lack of personalized services, making it difficult to meet users' needs for high efficiency and accuracy.
By combining knowledge graph and RAG technology, a knowledge base for the field of science and technology services is constructed. Through data cleaning, quadruple structure, contrastive learning and cross-entropy loss training, efficient retrieval and generation are achieved, providing personalized services.
It significantly improves the intelligence level of the knowledge base, enhances the accuracy and personalization of search results, supports complex queries and reasoning, meets diverse user needs, and ensures the timeliness and accuracy of the knowledge base.
Smart Images

Figure CN119940500B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and knowledge engineering technology, and in particular to a method and system for constructing a knowledge base for the technology service field based on knowledge graphs and RAG. Background Technology
[0002] In the field of technology services, the construction and management of knowledge bases are crucial for technology transfer, innovation support, and service optimization. However, traditional knowledge base construction methods have the following shortcomings:
[0003] 1. Incomplete representation of knowledge.
[0004] Traditional knowledge bases typically employ structured databases or simple text storage methods, making it difficult to comprehensively represent complex scientific and technological knowledge. Knowledge in the scientific and technological field is highly specialized and complex, involving a large amount of entity, relationship, and attribute information. For example, in patent analysis, a technology may involve multiple inventors, affiliated institutions, technical fields, application scenarios, and other multi-dimensional information. Because traditional knowledge bases lack structured representations of knowledge, they struggle to effectively capture these complex relationships, resulting in incomplete knowledge representation and limiting the in-depth application of knowledge.
[0005] 2. Low retrieval efficiency
[0006] Existing knowledge bases largely rely on keyword matching or simple rule engines for retrieval, resulting in low levels of intelligence and difficulty in meeting users' demands for efficient and accurate searches. For example, in technical consultations, users often need to sift through massive amounts of literature and data to find content highly relevant to their needs. Traditional search tools, lacking semantic and contextual understanding, frequently return numerous irrelevant or low-quality results, forcing users to spend considerable time on secondary filtering. Furthermore, existing retrieval systems struggle to support complex queries and reasoning, such as analyzing the relationship chains between technologies to predict technological development trends or potential application scenarios.
[0007] 3. Difficulty in dynamic updates
[0008] The technology sector is characterized by rapid knowledge updates and a constant stream of emerging technologies. Traditional knowledge bases, lacking dynamic update mechanisms, struggle to keep pace. For instance, in technology transfer, the commercial prospects and market applications of new technologies require real-time updates, while traditional knowledge bases often rely on periodic batch updates, failing to meet these real-time requirements. Furthermore, the wide variety and dispersion of data sources often lead to inconsistencies in data formats and data redundancy when integrating new data, further complicating dynamic updates.
[0009] 4. Lack of personalized services
[0010] As technological innovation deepens, users' demands for technology services are becoming increasingly diversified and personalized. For example, researchers may need in-depth analysis of specific technical fields, while enterprises may be more concerned with the commercial prospects and market applications of technologies. However, existing knowledge bases often adopt a "one-size-fits-all" approach, making it difficult to meet the personalized needs of different users. Furthermore, users are placing higher demands on the timeliness and accuracy of services, making it difficult for traditional knowledge bases to provide high-quality customized services in a short period.
[0011] In summary, traditional knowledge base construction methods have significant shortcomings in knowledge representation, retrieval efficiency, and dynamic updates, making it difficult to meet the growing demands of the technology service sector. Currently, there is a lack of an intelligent knowledge base construction method that combines knowledge graphs and RAG technology. Knowledge graphs, as a structured knowledge representation method, can effectively capture entity, relation, and attribute information, supporting complex queries and reasoning; while RAG technology can combine external knowledge sources to generate high-quality natural language responses. Combining these two technologies can significantly improve the intelligence level and service quality of the knowledge base. Summary of the Invention
[0012] (I) Purpose of the Invention
[0013] This invention aims to provide a method for constructing a knowledge base in the field of science and technology services based on knowledge graphs and RAG. It realizes the structured representation of knowledge through knowledge graphs and achieves efficient knowledge retrieval and generation by combining RAG technology, thereby improving the intelligence level and service capabilities of the knowledge base.
[0014] (II) Technical Solution
[0015] To achieve the objective of this invention, the present invention adopts the following technical solution:
[0016] The primary objective of this invention is to provide a method for constructing a knowledge base in the field of science and technology services based on knowledge graphs and RAG, comprising the following steps:
[0017] Step S1: Data collection and preprocessing, including data cleaning, deduplication, labeling, and standardization.
[0018] Step S2 Knowledge Graph Construction: Construct a science and technology knowledge graph and a personal knowledge graph respectively. The science and technology knowledge graph contains entity-relationship-entity-attribute quadruple information.
[0019] Step S3: RAG model construction;
[0020] Step S4: Knowledge base construction and dynamic updating;
[0021] Step S5 Knowledge Retrieval and Generation: Based on the user's query information, the RAG model is used in conjunction with the user's personal knowledge graph to retrieve relevant scientific and technological achievements from the science and technology knowledge graph. The generation module generates a response in natural language form based on the search results.
[0022] Furthermore, step S1, data collection and preprocessing, includes the following steps:
[0023] Step S1.1 Collect multi-source data in the field of science and technology services, including data resources such as scientific and technological achievements, technology needs, technical documents, standards and norms, and science and technology policies, as well as relevant business knowledge, procedures and service content such as scientific and technological innovation, scientific and technological achievement evaluation, scientific and technological assessment, paper retrieval, high-tech enterprise cultivation, science and technology finance, technology contract registration, intellectual property, and inspection and testing.
[0024] Step S1.2 involves cleaning, deduplicating, labeling, and standardizing the collected data;
[0025] Step S1.3 converts unstructured data (such as text and images) into structured data;
[0026] Furthermore, step S2, knowledge graph construction, includes the following steps:
[0027] Step S2.1 Extract literature materials from the science and technology service database, parse the text and generate text information of scientific and technological achievements;
[0028] Step S2.2 Entity recognition is performed on the corresponding text to extract the entity-relationship-entity-attribute quadruple and store it in the science and technology knowledge graph. Through ontology mapping, intelligent matching of the attributes of ontology objects with the fields of the dataset is supported. The value conversion logic from the dataset to the graph data is determined in the form of configuration mapping rules. The knowledge graph creates unique identification information for the data and enables fast positioning. This ensures that all nodes in the database have a source and basis.
[0029] Step S2.3 involves constructing a personal knowledge graph for each user based on their uploaded results, user needs, user tags, historical questions, and questions they are interested in. This personal knowledge graph can integrate personalized information representing various types of users.
[0030] Furthermore, step S3, RAG model construction, includes the following steps:
[0031] Step S3.1 Design the RAG model, including a retrieval module and a generation module. The retrieval module is responsible for retrieving knowledge fragments related to the user's question from the knowledge graph. The input is the user's input text + the user's knowledge graph. Based on the user's input text and the user's knowledge graph, it generates a user entity-relationship-entity-attribute quadruple and performs similarity matching with the quadruple of the science and technology knowledge graph. The output is the knowledge fragments related to the input, such as entities, relations, and attributes. The generation module generates a response in natural language form based on the retrieved knowledge fragments. The input is the user's input text + the retrieved knowledge fragments, and the output is the generated response text.
[0032] Step S3.2 Initialize the generation module using a pre-trained language model;
[0033] Select a suitable pre-trained language model for the generation task, load the weights of the pre-trained model, initialize the parameters of the generation module, design the input format, concatenate the user input and the retrieved knowledge fragments as the input of the generation module, design the output format, and ensure that the generated response meets the task requirements.
[0034] Step S3.3 Train the retrieval module to enable it to efficiently retrieve relevant knowledge from the knowledge graph;
[0035] Step S3.3.1 Construct a training dataset, including user input, relevant knowledge fragments and their relevance labels, sample knowledge fragments from the science and technology knowledge graph, and label their relevance to the question;
[0036] Step S3.3.2 Use a Transformer-based dual-tower model to design the model input and output, supporting the retrieval of knowledge fragments from the science and technology knowledge graph;
[0037] Step S3.3.3 uses contrastive learning combined with cross-entropy loss to train the retrieval module in order to maximize the retrieval probability of relevant knowledge fragments and minimize the retrieval probability of irrelevant knowledge fragments;
[0038] The loss function is as follows:
[0039] L=C1*L InfoNCE +C2*L CE +C3
[0040]
[0041] Where N is the number of samples, z i It is the feature representation of the anchor sample, z i + It is the feature representation of positive samples, z j τ is the feature representation of negative samples, τ is the temperature parameter used to control the sharpness of the distribution, K is the number of negative samples, C is the number of classes, and yi,c y is the true label of sample i. If sample i belongs to category c, then y i,c =1, otherwise y i,c =0, p i,c C1 and C2 are the probability that sample i belongs to class c as predicted by the model, C1 and C2 are the loss weights, and C1 + C2 = 1, and C3 is the adjustment coefficient.
[0042] Step S3.3.4 Design an efficient query algorithm to support the rapid retrieval of relevant knowledge fragments from the knowledge graph, and use the graph database Neo4j to optimize query performance.
[0043] Step S3.4 uses a joint training strategy to optimize both the retrieval and generation modules simultaneously, and uses reinforcement learning to optimize the response quality of the generation module.
[0044] Furthermore, step S4, knowledge base construction and dynamic updating, includes the following steps:
[0045] Step S4.1 combines the knowledge graph with the RAG model to construct a knowledge base for the technology service field;
[0046] Step S4.2 enables dynamic updates to the knowledge base, including real-time access to new data and incremental updates to the knowledge graph;
[0047] Step S4.3 uses the RAG model to optimize the knowledge base, improving retrieval and generation efficiency.
[0048] Furthermore, step S5, knowledge retrieval and generation, includes the following steps:
[0049] Step S5.1 Receive user queries and use the RAG model combined with the user's personal knowledge graph to retrieve relevant scientific and technological achievements from the science and technology knowledge graph;
[0050] Step S5.2 The generation module generates a response in natural language based on the search results;
[0051] Step S5.3 provides multimodal output (such as text and charts) to meet diverse user needs.
[0052] Furthermore, step S5 is followed by step S6, which includes feedback and optimization, specifically the following steps:
[0053] Step S6.1 Collect user feedback, including query satisfaction and response accuracy;
[0054] Step S6.2: Iteratively optimize the RAG model and knowledge graph using feedback data;
[0055] Step S6.3 Regularly update the knowledge base to maintain the timeliness and accuracy of the knowledge.
[0056] The second objective of this invention is to provide a knowledge base construction system for the technology service field based on knowledge graphs and RAG, for implementing the method described above.
[0057] (III) Technical Effects
[0058] Compared with the prior art, the method and system for constructing a knowledge base in the field of science and technology services based on knowledge graphs and RAG of the present invention have the following beneficial and significant technical effects:
[0059] (1) Intelligent upgrading of information retrieval and consulting services
[0060] In traditional technology services, information retrieval and consulting services largely rely on keyword matching and simple rule engines. Their level of intelligence is low, making it difficult to accurately capture users' true intentions, resulting in insufficient relevance and usability of search results. For example, when a user searches for "the application of artificial intelligence in medicine," traditional search tools may only return documents containing the keywords "artificial intelligence" and "medicine," failing to understand the user's specific needs (such as technical details, application cases, or commercial prospects). This keyword-based search method lacks semantic and contextual understanding, often returning a large number of irrelevant or low-quality results. Users need to spend a significant amount of time on secondary filtering, severely impacting service efficiency and user experience.
[0061] To address this issue, this invention significantly improves the accuracy and personalization of search results by combining a scientific knowledge graph with a personal knowledge graph and intelligently matching it with search information. Specifically, the scientific knowledge graph is a structured knowledge base built upon massive amounts of scientific literature, patents, papers, and other data, covering entities such as technical fields, research teams, and innovative achievements, as well as their interrelationships. The personal knowledge graph, on the other hand, is built based on personalized data such as users' historical behavior, interest tags, and areas of interest, accurately depicting users' needs and preferences. By combining the two, the system can simultaneously understand professional knowledge in the scientific field and users' personalized needs, providing a solid foundation for subsequent searches and services.
[0062] When a user submits a search request, the system not only analyzes the keywords entered by the user, but also combines scientific and technological knowledge graphs and personal knowledge graphs to perform contextual understanding and semantic reasoning. For example, when a user searches for "the application of artificial intelligence in medicine," the system not only returns relevant technical literature, but also provides more targeted search results based on the user's professional background (such as whether they are a medical professional) and interests (such as whether they are interested in the commercialization of technology). This intelligent matching mechanism significantly improves the accuracy and usability of search results, meeting users' needs for efficient and precise services.
[0063] Furthermore, by combining knowledge graphs and intelligent retrieval technologies, the system can flexibly respond to the needs of different users and provide customized service solutions. For example, for researchers, the system will prioritize returning cutting-edge technologies and academic papers; while for enterprise users, the system will focus on technology application cases and market analysis reports. This personalized service not only improves the accuracy of search results but also greatly enhances user satisfaction.
[0064] (2) Knowledge Graph Representation of Quadruple Structure
[0065] Traditional knowledge graphs often employ a triple (entity-relationship-entity) structure. While this can represent basic semantic relationships, it suffers from insufficient information representation in complex scenarios. For example, when representing "a research team developed a certain technology," the triple can only express the "research and development" relationship between "research team" and "technology," but cannot further describe attribute information such as development time, technology maturity, etc. This limitation in information representation restricts the application of knowledge graphs in complex scenarios.
[0066] To address this issue, this invention innovatively introduces a quadruple structure (entity-relationship-entity-attribute) to represent nodes and edges in a scientific and technological knowledge graph, significantly enhancing its expressive power and practicality. The quadruple structure can not only represent relationships between entities but also describe the attribute information of those relationships. For example, when representing "a research team developed a certain technology," the quadruple can further describe attribute information such as the development time and technology maturity. This structure enables the knowledge graph to more comprehensively express complex scientific and technological knowledge.
[0067] When constructing a science and technology knowledge graph, the system extracts entities, relationships, and attributes from data sources such as scientific literature, patents, and papers, and constructs quadruples. By using ontology mapping technology, the quadruples are intelligently matched with dataset fields, ensuring data consistency and scalability. For example, when integrating patent data from different sources, the system can automatically identify and unify different representations of the same entity, avoiding data redundancy and conflicts.
[0068] By introducing a quadruple structure, this invention significantly improves the structuring of the knowledge graph, facilitating knowledge management and retrieval. For example, in technical consulting, the system can quickly retrieve technologies, teams, and application cases related to user needs, and provide detailed attribute information. Furthermore, the quadruple structure supports complex queries and reasoning, such as predicting technological development trends or potential application scenarios by analyzing the relationship chains between technologies.
[0069] (3) Training by combining contrastive learning with cross-entropy loss
[0070] While the traditional cross-entropy loss function effectively measures the difference between the model's predictions and the true labels during retrieval module training, its generalization ability is insufficient, easily leading to overfitting. For example, in retrieval tasks, the cross-entropy loss function may cause the model to rely excessively on specific patterns in the training data, failing to generalize well to unseen data. On the other hand, contrastive learning learns feature representations by bringing positive sample pairs closer together and pushing negative sample pairs apart, effectively improving the model's generalization ability, but its training process is complex and difficult to converge.
[0071] To address this issue, this invention employs a combination of contrastive learning and cross-entropy loss to train the retrieval module. This overcomes the insufficient generalization ability of cross-entropy loss and resolves the convergence problem of contrastive learning. Specifically, contrastive learning constructs positive and negative sample pairs, enabling the model to learn more discriminative feature representations. For example, in a retrieval task, positive sample pairs can be knowledge fragments highly relevant to the user's question, while negative sample pairs are knowledge fragments unrelated to the user's question. Through contrastive learning, the model can better distinguish between relevant and irrelevant knowledge fragments, thereby improving retrieval accuracy.
[0072] During training, the cross-entropy loss function is used to measure the difference between the model's predictions and the true labels, ensuring that the model can accurately predict the similarity of positive sample pairs. For example, in retrieval tasks, the cross-entropy loss function can be used to measure the relevance between the knowledge fragments predicted by the model and the user's question. By combining contrastive learning and cross-entropy loss, the model can not only learn discriminative feature representations but also accurately predict the similarity of positive sample pairs, thereby significantly improving the performance of the retrieval module.
[0073] Furthermore, by introducing temperature and boundary parameters, this invention further optimizes the combined training process of contrastive learning and cross-entropy loss. The temperature parameter controls the sharpness of the similarity distribution, while the boundary parameter controls the degree of separation between negative sample pairs. By adjusting these parameters, the model can better balance generalization ability and convergence speed, thereby improving training efficiency and retrieval performance.
[0074] By combining scientific and technological knowledge graphs with personal knowledge graphs and retrieval information, introducing a quadruple structure, and employing a combination of contrastive learning and cross-entropy loss in training, this invention significantly improves the intelligence level and service quality of knowledge bases in the field of science and technology services. These innovative technologies provide strong support for the intelligent transformation of the science and technology service industry and have broad application prospects. Attached Figure Description
[0075] Figure 1 This is a schematic diagram of the overall architecture of a specific embodiment of the present invention. Detailed Implementation
[0076] To better understand the present invention, the following embodiments further illustrate its content. Throughout the accompanying drawings, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions. The described embodiments are some, but not all, of the embodiments of the present invention. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. The structure and technical solutions of the present invention will be further described in detail below with reference to the accompanying drawings, and the following embodiments of the present invention are given.
[0077] Example 1
[0078] like Figure 1 As shown, a method for constructing a knowledge base for the technology service field based on knowledge graphs and RAG includes the following steps:
[0079] Step S1: Data collection and preprocessing, including data cleaning, deduplication, labeling, and standardization.
[0080] Step S2 Knowledge Graph Construction: Construct a science and technology knowledge graph and a personal knowledge graph respectively. The science and technology knowledge graph contains entity-relationship-entity-attribute quadruple information.
[0081] Step S3: RAG model construction;
[0082] Step S4: Knowledge base construction and dynamic updating;
[0083] Step S5 Knowledge Retrieval and Generation: Based on the user's query information, the RAG model is used in conjunction with the user's personal knowledge graph to retrieve relevant scientific and technological achievements from the science and technology knowledge graph. The generation module generates a response in natural language form based on the search results.
[0084] Furthermore, step S1, data collection and preprocessing, includes the following steps:
[0085] Step S1.1 Collect multi-source data in the field of science and technology services, including data resources such as scientific and technological achievements, technology needs, technical documents, standards and norms, and science and technology policies, as well as relevant business knowledge, procedures and service content such as scientific and technological innovation, scientific and technological achievement evaluation, scientific and technological assessment, paper retrieval, high-tech enterprise cultivation, science and technology finance, technology contract registration, intellectual property, and inspection and testing.
[0086] Step S1.2 involves cleaning, deduplicating, labeling, and standardizing the collected data;
[0087] Specifically, the collected data is processed by removing duplicate records to ensure data uniqueness, filling missing values (e.g., using the mean, median, or mode) or deleting them, detecting and handling outliers (e.g., using box plots or the 3σ principle), and standardizing the data format; some data are manually labeled, such as by technology category, demand category, sentiment tag, etc.
[0088] Text data can be processed by word segmentation, stop word removal, and stemming, for example, using NLTK or Jieba for Chinese word segmentation; numerical data can be normalized or standardized, such as Min-Max normalization or Z-score standardization; and categorical data can be one-hot encoded or label encoded.
[0089] Step S1.3 converts unstructured data (such as text and images) into structured data;
[0090] Use pre-trained language models (such as BERT, Word2Vec) to convert text into vector representations, for example, use BERT to generate embedded representations of text; use convolutional neural networks (CNNs) to convert images into vector representations, for example, use ResNet to extract image features; use multilayer perceptrons (MLPs) or embedding layers to convert tabular data into vector representations, for example, concatenate numerical and categorical features in a table into a vector.
[0091] Through the above steps, multi-source data in the field of science and technology services are collected, covering scientific and technological achievements, demand-side data and related business knowledge; the data is cleaned, deduplicated, labeled and standardized to ensure data quality; finally, unstructured data (such as text and images) is converted into structured data to lay the foundation for subsequent feature extraction and modeling.
[0092] Furthermore, step S2, knowledge graph construction, includes the following steps:
[0093] Step S2.1 Extract literature materials from the science and technology service database, parse the text and generate text information of scientific and technological achievements;
[0094] Step S2.2 Entity recognition is performed on the corresponding text to extract the entity-relationship-entity-attribute quadruple and store it in the science and technology knowledge graph. Through ontology mapping, intelligent matching of the attributes of ontology objects with the fields of the dataset is supported. The value conversion logic from the dataset to the graph data is determined in the form of configuration mapping rules. The knowledge graph creates unique identification information for the data and enables fast positioning. This ensures that all nodes in the database have a source and basis.
[0095] Specifically, Named Entity Recognition (NER) models are used to extract entities from text, such as technology names, organization names, and personnel names. Relationship extraction models are used to identify relationships between entities, such as "development" and "application." Entity attributes are extracted from text, such as the maturity of the technology, application field, and technology description, for example ("Deep Learning", "Applied to", "Image Recognition", "Technology Description: An Image Classification Method Based on Convolutional Neural Networks.").
[0096] Ontology mapping matches entities, relationships, and attributes with ontology objects in the knowledge graph; for example, mapping "artificial intelligence algorithm" to the "technology" node in the knowledge graph; configuring mapping rules from dataset fields to knowledge graph attributes, determining value transformation logic, for example, mapping the "technology maturity" field to the "maturity" attribute in the knowledge graph, creating unique identification information (such as URI) for each node in the knowledge graph, supporting fast location and query.
[0097] The above steps introduce a quadruple structure (entity-relationship-entity-attribute) to represent nodes and edges in a scientific and technological knowledge graph, significantly improving the expressive power and practicality of the knowledge graph. The quadruple structure can not only represent relationships between entities but also describe the attribute information of those relationships. This structure allows the knowledge graph to more comprehensively express complex scientific and technological knowledge. By introducing the quadruple structure, this invention significantly improves the structuring level of the knowledge graph, facilitating knowledge management and retrieval. Furthermore, the quadruple structure supports complex queries and reasoning, such as predicting technological development trends or potential application scenarios by analyzing the relationship chains between technologies.
[0098] Step S2.3 involves constructing a personal knowledge graph for each user based on their uploaded results, user needs, user tags, historical questions, and questions they are interested in. This personal knowledge graph can integrate personalized information representing various types of users.
[0099] Specifically, entities such as user names, technology names, and organization names are extracted from user data, and relationships between entities are identified, such as "User A follows technology B". Attributes of entities are extracted, such as user's technology preferences and historical behavior. For example, the technologies followed by a user are associated with technology nodes in a knowledge graph to construct a personal knowledge graph.
[0100] The above steps can generate user profiles based on personal knowledge graphs, representing users' personalized information, such as their technology preferences, historical behavior, and areas of interest, and use personal knowledge graphs to provide users with personalized recommendations of scientific and technological achievements.
[0101] Furthermore, step S3, RAG model construction, includes the following steps:
[0102] Step S3.1 Design the RAG model, including a retrieval module and a generation module. The retrieval module is responsible for retrieving knowledge fragments related to the user's question from the knowledge graph. The input is the user's input text + the user's knowledge graph. Based on the user's input text and the user's knowledge graph, it generates a user entity-relationship-entity-attribute quadruple and performs similarity matching with the quadruple of the science and technology knowledge graph. The output is the knowledge fragments related to the input, such as entities, relations, and attributes. The generation module generates a response in natural language form based on the retrieved knowledge fragments. The input is the user's input text + the retrieved knowledge fragments, and the output is the generated response text.
[0103] When a user submits a search request, the system not only analyzes the keywords entered by the user, but also combines the user's personal knowledge graph to perform contextual understanding and semantic reasoning. For example, when a user searches for "the application of artificial intelligence in medicine," the system not only returns relevant technical literature, but also provides more targeted search results based on the user's professional background (such as whether they are a medical professional) and interests (such as whether they are interested in the commercialization of technology). This intelligent matching mechanism significantly improves the accuracy and usability of search results, meeting users' needs for efficient and precise services.
[0104] Step S3.2 Initialize the generation module using a pre-trained language model;
[0105] Select a suitable pre-trained language model for the generation task, load the weights of the pre-trained model, initialize the parameters of the generation module, design the input format, concatenate the user input and the retrieved knowledge fragments as the input of the generation module, design the output format, and ensure that the generated response meets the task requirements.
[0106] Step S3.3 Train the retrieval module to enable it to efficiently retrieve relevant knowledge from the knowledge graph;
[0107] Step S3.3.1 Construct a training dataset, including user input, relevant knowledge fragments and their relevance labels, sample knowledge fragments from the science and technology knowledge graph, and label their relevance to the question;
[0108] Step S3.3.2 Use a Transformer-based dual-tower model to design the model input and output, supporting the retrieval of knowledge fragments from the science and technology knowledge graph;
[0109] Step S3.3.3 uses contrastive learning combined with cross-entropy loss to train the retrieval module in order to maximize the retrieval probability of relevant knowledge fragments and minimize the retrieval probability of irrelevant knowledge fragments;
[0110] The loss function is as follows:
[0111] L=C1*L InfoNCE +C2*L CE +C3
[0112]
[0113] Where N is the number of samples, z i It is the feature representation of the anchor sample, z i + It is the feature representation of positive samples, z j τ is the feature representation of negative samples, τ is the temperature parameter used to control the sharpness of the distribution, K is the number of negative samples, C is the number of classes, and y i,c y is the true label of sample i. If sample i belongs to category c, then y i,c =1, otherwise y i,c =0, p i,c C1 and C2 are the probability that sample i belongs to class c as predicted by the model, C1 and C2 are the loss weights, and C1 + C2 = 1, and C3 is the adjustment coefficient.
[0114] Step S3.3.4 Design an efficient query algorithm to support the rapid retrieval of relevant knowledge fragments from the knowledge graph, and use the graph database Neo4j to optimize query performance.
[0115] Step S3.4 uses a joint training strategy to optimize both the retrieval and generation modules simultaneously, and uses reinforcement learning to optimize the response quality of the generation module;
[0116] The above steps employ contrastive learning combined with cross-entropy loss to train the retrieval module. This overcomes the insufficient generalization ability of cross-entropy loss and solves the convergence problem of contrastive learning. Specifically, contrastive learning constructs positive and negative sample pairs, enabling the model to learn more discriminative feature representations. The cross-entropy loss function measures the difference between the model's predictions and the true labels, ensuring that the model can accurately predict the similarity of positive sample pairs. By combining contrastive learning and cross-entropy loss, the model not only learns discriminative feature representations but also accurately predicts the similarity of positive sample pairs, thereby significantly improving the performance of the retrieval module.
[0117] Furthermore, step S4, knowledge base construction and dynamic updating, includes the following steps:
[0118] Step S4.1 combines the knowledge graph with the RAG model to construct a knowledge base for the technology service field;
[0119] Step S4.2 enables dynamic updates to the knowledge base, including real-time access to new data and incremental updates to the knowledge graph;
[0120] Step S4.3 uses the RAG model to optimize the knowledge base, improving retrieval and generation efficiency.
[0121] The above steps ensure the timeliness and accuracy of the knowledge base, support real-time access to new data and incremental updates to the knowledge graph; improve the retrieval and generation efficiency of the knowledge base, enhance user experience, and reduce retrieval time and improve the accuracy and fluency of generated responses by optimizing the RAG model.
[0122] Furthermore, step S5, knowledge retrieval and generation, includes the following steps:
[0123] Step S5.1 Receive user queries and use the RAG model combined with the user's personal knowledge graph to retrieve relevant scientific and technological achievements from the science and technology knowledge graph;
[0124] Step S5.2 The generation module generates a response in natural language based on the search results;
[0125] Step S5.3 provides multimodal output (such as text and charts) to meet diverse user needs.
[0126] By combining the above steps with personalized user information, we can provide accurate search results and offer multimodal output (such as text, charts, and images) to enhance the readability and usability of the responses, meet users' needs for different forms of information, and improve the user experience.
[0127] Furthermore, step S5 is followed by step S6, which includes feedback and optimization, specifically the following steps:
[0128] Step S6.1 Collect user feedback, including query satisfaction and response accuracy;
[0129] Step S6.2: Iteratively optimize the RAG model and knowledge graph using feedback data;
[0130] Step S6.3 Regularly update the knowledge base to maintain the timeliness and accuracy of the knowledge.
[0131] By following the steps above, the RAG model and knowledge graph can be optimized based on user feedback, improving the system's accuracy and user experience. Iterative optimization enables the system to continuously adapt to new needs and scenarios, and ensures that the knowledge in the knowledge base is always up-to-date and accurate, avoiding the provision of outdated or incorrect information.
[0132] Example 2
[0133] A knowledge base construction system for the technology service field based on knowledge graphs and RAG is provided to implement the method described above.
[0134] The objectives of this invention have been fully and effectively achieved through the above embodiments. Those skilled in the art will understand that this invention includes, but is not limited to, the contents described in the accompanying drawings and the specific embodiments described above. Although the invention has been described with reference to what is currently considered the most practical and preferred embodiments, it should be understood that the invention is not limited to the disclosed embodiments, and any modifications that do not depart from the functional and structural principles of the invention will be included within the scope of the claims.
Claims
1. A method for constructing a knowledge base in a scientific and technological service field based on a knowledge graph and RAG, characterized in that, Comprise the following steps: Step S1 data collection and pretreatment, data cleaning, de-duplication, labeling and standardization processing; Step S2 knowledge graph construction, respectively construct science and technology knowledge graph and personal knowledge graph, wherein the science and technology knowledge graph contains entity-relation-entity-attribute four tuple information; Step S3 RAG model construction; Step S4 knowledge base construction and dynamic update; Step S5 knowledge retrieval and generation, according to user query information, using RAG model combined with user personal knowledge graph to retrieve related scientific and technological achievements from science and technology knowledge graph, and generating module generates natural language form reply according to retrieval result; Step S2 knowledge graph construction comprises the following steps: Step S2.1 extracting literature materials from science and technology service database, analyzing text and generating scientific and technological achievement text information; Step S2.2 adopting entity recognition to the corresponding text, extracting entity-relation-entity-attribute four tuple, and storing into science and technology knowledge graph, supporting intelligent matching of ontology object attribute and dataset field through ontology mapping, and determining dataset to graph data value conversion logic in the form of configuration mapping rule, creating unique identification information for data through knowledge graph, realizing fast positioning function, realizing that nodes in database have source and basis; Step S2.3 constructing personal knowledge graph according to user uploaded achievements, user demand, user label, user history question, user attention question, personal knowledge graph fuses each type of user personalized information, and through the knowledge graph system, the content directly related or indirectly related to the current user input content can be quickly obtained in the subsequent retrieval generation step; Step S3 RAG model construction comprises the following steps: Step S3.1 designing RAG model, including retrieval module and generation module; the retrieval module is responsible for retrieving knowledge fragments related to user question from the knowledge graph, and the input is user input text+user personal knowledge graph; based on user input text and user personal knowledge graph, user entity-relation-entity-attribute four tuple is generated, similarity matching with science and technology knowledge graph four tuple is carried out, and the output is the knowledge fragment related to the input; the generation module generates natural language form reply based on the retrieved knowledge fragment, the input is user input text+retrieved knowledge fragment, and the output is generated reply text; Step S3.2 initializing the generation module using a pre-trained language model; A pre-trained language model suitable for the generation task is selected, the weights of the pre-trained model are loaded, the parameters of the generation module are initialized, the input format is designed, the user input and the retrieved knowledge fragment are spliced as the input of the generation module, the output format is designed, and it is ensured that the generated reply meets the task requirements; Step S3.3 training the retrieval module to enable it to efficiently retrieve related knowledge from the knowledge graph; Step S3.4 using a joint training strategy to simultaneously optimize the retrieval module and the generation module, and using reinforcement learning to optimize the reply quality of the generation module. 2.The knowledge graph and RAG-based scientific and technological service field knowledge base construction method according to claim 1, characterized in that, Step S1 data collection and pretreatment comprises the following steps: Step S1.1 collects multi-source data in the field of scientific and technological services, including scientific and technological achievements, technical demands, technical documents, specifications and standards, scientific and technological policies, scientific and technological innovation, scientific and technological achievement evaluation, scientific and technological assessment, paper retrieval, high-tech enterprise cultivation, scientific and technological finance, technology contract registration, intellectual property, inspection and testing, business procedures and service content; Step S1.2 cleans, removes duplicates, labels and standardizes the collected data; Step S1.3 converts unstructured data into structured data. 3.The knowledge graph and RAG-based scientific and technological service field knowledge base construction method according to claim 1, characterized in that, Step S3.3 trains the retrieval module to enable efficient retrieval of relevant knowledge from the knowledge graph, including the following steps: Step S3.3.1 constructs a training data set, including user input, relevant knowledge fragments and their relevance labels, samples knowledge fragments from the scientific and technological knowledge graph, and labels their relevance to the question; Step S3.3.2 uses a dual-tower model based on Transformer to design model input and output, supporting retrieval of knowledge fragments from the scientific and technological knowledge graph; Step S3.3.3 uses contrastive learning combined with cross-entropy loss to train the retrieval module to maximize the retrieval probability of relevant knowledge fragments and minimize the retrieval probability of irrelevant knowledge fragments; Step S3.3.3 trains the retrieval module using contrastive learning combined with cross-entropy loss to maximize the retrieval probability of relevant knowledge fragments and minimize the retrieval probability of irrelevant knowledge fragments; the loss function is as follows: where N is the number of samples, z i is the feature representation of the anchor sample, z i + is the feature representation of the positive sample, z j is the feature representation of the negative sample, τ is a temperature parameter for controlling the sharpness of the distribution, K is the number of negative samples, C is the number of classes, y i,c is the true label of sample i, if sample i belongs to class c, then y i,c = 1, otherwise y i,c = 0, p i,c is the probability that the model predicts that sample i belongs to class c, C1 and C2 are loss weights, and C1 + C2 = 1, and C3 is an adjustment coefficient Step S3.3.4 designs an efficient query algorithm to support fast retrieval of relevant knowledge fragments from the knowledge graph, and uses the graph database Neo4j to optimize query performance. 4.The knowledge graph and RAG-based scientific and technological service field knowledge base construction method according to claim 1, characterized in that, Step S4 knowledge base construction and dynamic update includes the following steps: Step S4.1 combines the knowledge graph with the RAG model to construct the knowledge base in the field of scientific and technological services; Step S4.2 realizes dynamic updating of the knowledge base, including real-time access of new data and incremental updating of the knowledge graph; Step S4.3 uses the RAG model to optimize the knowledge base to improve retrieval and generation efficiency.
5. The knowledge graph and RAG-based scientific and technological service field knowledge base construction method according to claim 1, characterized in that, Step S5 knowledge retrieval and generation includes the following steps: Step S5.1 receives user queries and uses the RAG model combined with the user's personal knowledge graph to retrieve relevant scientific and technological achievements from the scientific and technological knowledge graph; Step S5.2 the generation module generates a reply in natural language form according to the retrieval results; Step S5.3 provides multi-modal output to meet the diverse needs of users.
6. The knowledge graph and RAG-based scientific service field knowledge base construction method according to claim 1, characterized in that, Step S5 is followed by step S6 feedback and optimization, which includes the following steps: Step S6.1 collects user feedback, including query satisfaction and reply accuracy; Step S6.2 uses feedback data to iteratively optimize the RAG model and the knowledge graph; Step S6.3 regularly updates the knowledge base to maintain the timeliness and accuracy of the knowledge.
7. A knowledge graph and RAG-based scientific and technological service field knowledge base construction system, characterized in that, for implementing the method as claimed in any one of claims 1-6.
Citation Information
Patent Citations
Psychological counseling dialogue generation method and device, equipment and storage medium
CN118553412A
Response enhancement method and device based on RAG technology
CN119005330A