Customs practice question and answer identification method based on knowledge graph and large-scale language model

By combining knowledge graphs and large-scale language models, the customs practical question and answer identification method solves the problems of low information acquisition efficiency, insufficient answer accuracy and weak multi-round dialogue support capabilities in the existing system, achieving efficient, accurate and personalized Q&A service.

CN119311821APending Publication Date: 2025-01-14JIANGSU SIYUAN INTEGRATED CIRCUIT & INTELLIGENT TECH RES INST CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411315996.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The existing customs practical question and answer system has problems such as inefficient information acquisition, insufficient accuracy of answers, insufficient timeliness and comprehensiveness of knowledge, lack of semantic understanding in professional fields, and weak ability to support multiple rounds of dialogue.

Method used

Adopt a customs practice question and answer identification method based on knowledge graphs and large-scale language models. By collecting and preprocessing customs-related text data, we generate question sets and corresponding entity sets, build entity detection modules and retrieval modules, and use knowledge graphs and pre-trained language models. Perform semantic reasoning and natural language generation to provide personalized and professional answers.

Benefits of technology

It achieves multi-round dialogue support and contextual understanding, significantly improves the accuracy and relevance of question and answer generation, ensures the timeliness and comprehensiveness of information, and improves user experience and system practicality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311821A_ABST
    Figure CN119311821A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of question and answer recognition, in particular to a customs practice question and answer recognition method based on a knowledge graph and a large-scale language model. Converting into a text set; generating a question set and a corresponding entity set; constructing an EDEM module comprising a word embedding layer, a first root mean square normalization, a multi-head attention mechanism, a second root mean square normalization, a feed-forward network, a third root mean square normalization, a linear layer and a classification layer, and outputting a prediction result of an entity set corresponding to the question; constructing a retrieval module, extracting an entity to be retrieved by utilizing an EDEM module according to a query input by a user, and searching triple information related to the entity in the knowledge graph; and the construction and generation module is used for generating natural language answers by utilizing the entity-related triple information and the query of the user. According to the method, the knowledge graph and the pre-trained large-scale language model are combined to improve the accuracy, correlation and efficiency of answer generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of question and answer recognition, and in particular to a customs practice question and answer recognition method based on a knowledge graph and a large-scale language model. Background Art

[0002] With the development of information technology and the acceleration of globalization, the challenges faced by customs practice are increasing day by day. Especially in international trade, the complexity and variability of customs regulations and processes have brought many difficulties to enterprises and individuals. Currently, many enterprises rely on manual customer service or automated question-and-answer systems based on simple rules to solve customs-related problems. However, these traditional methods have the following significant limitations:

[0003] 1. Inefficient information acquisition: Customs regulations and policy documents are usually complex and frequently updated. Manual customer service is prone to inefficiency when dealing with a large number of inquiries, and is unable to provide users with the required information in a timely and accurate manner;

[0004] 2. Insufficient answer accuracy: Rule-based automated question-answering systems often have difficulty providing accurate answers to complex professional questions. This is because these systems rely on predefined rules and templates and are difficult to cope with the ever-changing actual situation.

[0005] 3. Lack of timeliness and comprehensiveness of knowledge: Existing systems often rely on static knowledge bases, which make it difficult to quickly update the latest changes in customs regulations and policies, resulting in users obtaining answers that may not be the latest and most comprehensive;

[0006] 4. Lack of semantic understanding in professional fields: Traditional question-answering systems lack deep semantic understanding of professional fields and cannot accurately identify key entities and relationships in user questions, making it difficult to generate high-quality answers.

[0007] 5. Weak support for multi-round dialogues: In actual applications, questions and answers between users and systems often involve multiple rounds of interactions. When handling such multi-round dialogues, traditional systems often exhibit incoherent context understanding and inaccurate answers.

[0008] In view of the above problems, there is an urgent need for a technology that can combine knowledge graphs with pre-trained large-scale language models to improve the accuracy, relevance and efficiency of answer generation, thereby providing users with better services. Summary of the invention

[0009] In view of the shortcomings of existing methods, the present invention can not only dynamically update the customs-related knowledge base and provide timely and accurate information, but also better understand user needs and provide personalized and professional answers through semantic reasoning and natural language generation technology.

[0010] The technical solution adopted by the present invention is: a customs practice question and answer recognition method based on knowledge graph and large-scale language model includes the following steps:

[0011] Step 1: Collect customs-related text data and pre-process it;

[0012] As a preferred implementation of the present invention, the preprocessing includes: removing irrelevant characters, punctuation marks and HTML tags from the customs-related text data.

[0013] As a preferred implementation of the present invention, Selenium and Scrapy are used to collect customs-related text data.

[0014] Step 2: Convert the pre-processed customs-related text data into a text collection;

[0015] Step 3: Generate a question set and a corresponding entity set using the text set;

[0016] As a preferred implementation of the present invention, the llama3 model is used to generate a question set and a corresponding entity set from a text set.

[0017] Step 4: Construct an EDEM module including a word embedding layer, the first RMS normalization, a multi-head attention mechanism, a second RMS normalization, a feedforward network, a third RMS normalization, a linear layer, and a classification layer. Use text data and knowledge graph embedding to train the EDEM module and output the prediction results of the entity set corresponding to the question.

[0018] As a preferred embodiment of the present invention, step 4 specifically includes:

[0019] Step 41, the text input and knowledge graph embedding are converted into vector representation through the word embedding layer;

[0020] As a preferred implementation mode of the present invention, the construction of the knowledge graph is to perform relationship annotation on the entity set on the text set.

[0021] Step 42: Perform the first root mean square normalization on the word embedded data and then input it into the multi-head self-attention mechanism;

[0022] Step 43: Perform a first concat operation on the output of the multi-head attention mechanism and the output of the word embedding layer;

[0023] Step 44, input the eigenvalues ​​after the first concat operation into the second RMS normalization and then input into the feedforward network;

[0024] Step 45, input the second RMS normalized feature into the prompt word template and then into the feedforward network;

[0025] Step 46, the output value of the feedforward layer of the feedforward network and the eigenvalue after the first concat operation are subjected to a second concat operation and then input into a third RMS normalization;

[0026] Step 47, the third RMS normalized eigenvalue is input into the linear layer;

[0027] Step 48: Generate the probability distribution of the entity set corresponding to the output question through the classification layer.

[0028] Step 5: Build a retrieval module. According to the query input by the user, use the EDEM module to extract the entities to be retrieved and search for triple information related to the entities in the knowledge graph.

[0029] As a preferred embodiment of the present invention, step five includes:

[0030] Step 51, after the user inputs the query, the EDEM module extracts the entities to be retrieved;

[0031] Step 52: Search in the knowledge graph according to the entity to be retrieved;

[0032] Step 53, the retrieval module finds the triples directly related to the entity, and finds other triples associated with the entity through relational reasoning;

[0033] Step 54: Output relevant triples.

[0034] Step 6: Build a generation module to generate natural language answers using entity-related triple information and user queries.

[0035] As a preferred embodiment of the present invention, a customs practice question and answer recognition system based on a knowledge graph and a large-scale language model includes: a memory for storing instructions executable by a processor; a processor for executing instructions to implement a customs practice question and answer recognition method based on a knowledge graph and a large-scale language model.

[0036] As a preferred embodiment of the present invention, a computer-readable medium stores a computer program code, and when the computer program code is executed by a processor, it implements a customs practice question and answer recognition method based on a knowledge graph and a large-scale language model.

[0037] Beneficial effects of the present invention:

[0038] 1. Multi-round dialogue support and context understanding: The entity detection module uses the context understanding capability of the pre-trained language model to maintain semantic consistency in multi-round questions and answers, avoid context fragmentation, and improve user experience. The system can accurately identify the intent of user questions in multiple rounds of interactions and provide more coherent answers.

[0039] 2. Efficient and accurate question and answer generation: The entity detection module, through the combination with the knowledge graph and prompt word template, can generate high-quality questions and answers that meet user needs, significantly improving the practicality and accuracy of the question and answer system in customs practice;

[0040] 3. Improve the accuracy of entity recognition: By introducing knowledge graphs and pre-trained language models, the entity detection module can effectively identify and process specific entities in customs practices, such as regulatory names, tariff rates, commodity categories, etc. This deep combination not only improves the accuracy of entity detection for complex issues, but also copes with the ever-changing content of regulations and improves the accuracy of entity recognition;

[0041] 4. Seamless integration of knowledge graph and large-scale language model: By combining the entities in the knowledge graph with the output of large-scale pre-trained models, dynamic updating and management of knowledge is achieved, ensuring that the system can provide the latest and most complete customs regulations information at any time. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a flow chart of the customs practice question and answer recognition method based on knowledge graph and large-scale language model of the present invention;

[0043] Figure 2 It is a schematic diagram of the structure of the entity detection module of the present invention. DETAILED DESCRIPTION

[0044] The present invention is further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore it only shows the components related to the present invention.

[0045] like Figure 1 As shown in the figure, the customs practice question and answer recognition method based on knowledge graph and large-scale language model includes the following steps:

[0046] Step 1: Data collection and preprocessing: Use crawler technologies such as Selenium and Scrapy to collect customs-related text data from a customs website, including notices, regulatory documents, news, etc.; and preprocess the original text data, including removing irrelevant characters, punctuation marks, HTML tags, etc. to ensure the purity of the data;

[0047] Step 2: Convert the collected files into text to obtain a text set T = {t1, t2, t3...};

[0048] For example: T = {

[0049] t1:"According to the Tariff Regulations of the People's Republic of China, all imported goods are subject to tariffs in accordance with the law. Tariffs are calculated based on the type and quantity of goods, and certain goods may enjoy tariff reductions or exemptions.",

[0050] t2:"The 2024 import commodity list has been updated, including consumer electronics, mechanical equipment, auto parts and other categories of goods. Importers should pay attention to the tariff policy adjustments for some commodities.",

[0051] t3: "The customs declaration process includes filling out the declaration form, submitting the goods list, paying relevant fees, etc. When declaring, you must ensure the legality and completeness of all documents and certificates. Any false declaration will be punished."

[0052] }.

[0053] Step 3: Use the large-scale pre-trained language model llama3 to generate a question set Q = {q1, q2, q3....} and an entity set D = {d1, d2, d3......} corresponding to Q from the collected text set T;

[0054] Suppose the following text is extracted from the text collection T:

[0055] t1: "According to the Tariff Regulations of the People's Republic of China, all imported goods are subject to tariffs in accordance with the law. Tariffs are calculated based on the type and quantity of goods, and certain goods may enjoy tariff reductions or exemptions."

[0056] The generated question set Q and entity set D:

[0057] Q = {

[0058] q1: "Do all imported goods need to pay customs duties?",

[0059] q2: "How are tariffs calculated?"

[0060] q3: "Which products can enjoy tariff reductions and exemptions?"

[0061] }

[0062] D={

[0063] d1:["Import goods","Pay customs duties"],

[0064] d2:["Tariff","Commodity Type","Commodity Quantity"],

[0065] d3:["Specific commodities","Tariff reduction"]

[0066] }

[0067] Among them, Q is a set of questions automatically generated based on text t1:

[0068] Q1: "Do all imported goods need to pay customs duties?" - This is a question generated based on "All imported goods need to pay customs duties according to law."

[0069] Q2: "How are tariffs calculated?" - This is a question generated based on "Tariffs are calculated based on the type and quantity of goods."

[0070] Q3: "Which goods can enjoy tariff reductions?" - This is a question generated based on "Specific goods may enjoy tariff reductions."

[0071] D is the set of entities corresponding to each question:

[0072] d1: "Imported goods" and "Payment of customs duties" are entities related to the first question q1.

[0073] d2: "Tariff", "Commodity Type", and "Commodity Quantity" are entities related to q2.

[0074] d3: "Specified Goods" and "Tariff Reductions" are entities relevant to q3.

[0075] The formula is as follows:

[0076] (q i ,d i )=LLM(prompt|t i ) (1)

[0077] Among them, q i is the i-th question; d i is the entity corresponding to the i-th question; LLM() is the llama3 model, prompt is the prompt word template input to the llama3 model, which is used to guide the model to generate specific output; t i is the i-th input text.

[0078] Step 4: Construct entity detection module (EDEM, Entity Detection and Extraction Module);

[0079] like Figure 2 As shown, the EDEM module includes a word embedding layer, a first RMS normalization, a multi-head attention mechanism, a second RMS normalization, a feedforward network, a third RMS normalization, a linear layer, and a classification layer;

[0080] First, Q is used as text input and D is used as output to form an entity extraction dataset NER_Data = {<q1,d1> ,<q2,d2> ,.....};

[0081] Secondly, each question q is annotated with BIO to form training data;

[0082] The output of the classification layer is the result of entity detection; the output of the classification layer can be understood as the result of each input question q i The corresponding entity set d i The output of the classification layer will include the prediction of whether each word in the text belongs to a certain entity, usually using the BIO annotation method, such as "B-Entity", "I-Entity" and "O"; these annotation prediction values ​​are the entity set D. For example, if "customs tariff rate" is annotated as an entity, it will exist as d in NER_Data.

[0083] Secondly, the dataset is divided into training set, validation set and test set, and the pre-trained BERT model is selected for fine-tuning. During fine-tuning, each question q is converted into the input format of BERT, and entity recognition is performed through the classification layer output.

[0084] When using the BERT model, the model has been trained on a large amount of general text data and has a wide range of language understanding capabilities; but in order to achieve the best performance on specific tasks, the model needs to be fine-tuned; specific tasks such as entity detection.

[0085] The version of the BERT model is BERT-large-NER; Figure 2 As shown in the figure, the BERT model includes: a multi-head self-attention mechanism and a feedforward network, and the BERT model is used to perform entity recognition on the input text.

[0086] During the training process, the entity detection module is trained using the cross entropy loss function and the Adam optimizer, with the learning rate set to 2e-5 to 5e-5, the batch size to 16 or 32, and the training rounds to 3 epochs; after each epoch, the model performance is evaluated on the validation set and the best model is saved; and the model is evaluated using the test set, and the precision, recall, and F1 score are reported; after the training is completed, the trained entity recognition model, vocabulary, and configuration file are saved.

[0087] Among them, the BIO annotation format is as follows:

[0088]

[0089] The EDEM model specifically includes:

[0090] Step 41: The text input and knowledge graph embedding are converted into vector representations through the word embedding layer, so that the model not only understands the text content, but also incorporates entity information related to the question into the input;

[0091] Knowledge graph embedding is to embed triples in the knowledge graph into the EDEM module to represent the entities and relations in the knowledge graph in the form of vectors;

[0092] The knowledge graph construction is to annotate the relationship between the entity set D on the text set T;

[0093] For example, in a text "customs duty rate" there may be a customs duty rate REGULATED_BY electronic goods with "electronic goods";

[0094] Store the annotated triples in neo4j and save an entity list in the file Elist.txt, with one line for each entity. The insert statement cypher is as follows:

[0095] CREATE(a:Entity{name:'customs dutyrate'})

[0096] CREATE(b:Entity{name:'electronic goods'})

[0097] CREATE(a)-[:REGULATED_BY]->(b).

[0098] The output of the word embedding layer is passed to the subsequent multiple layers, and the multi-head attention and feedforward network are repeated 16 times; then the first root mean square normalization is used for normalization to ensure the stability of the model and the efficiency of training;

[0099] Step 42: Input the word-embedded data into a multi-head self-attention mechanism; the multi-head self-attention mechanism includes Q' (query vector), K (key vector) and V (value vector); the mechanism calculates the relationship between each word in the input and other words to determine the correlation between them;

[0100]

[0101] Among them, Q' is the query vector converted from the input embedding or word vector; the query vector is used to find the relationship with other word vectors, that is, the correlation; K is the key vector generated from the input embedding, which represents the characteristics of the input. The key vector is used to perform dot product calculation with the query vector to measure the similarity between them; V is also the value vector generated from the input, which represents the actual content of the input; it is used to generate the final output after weighted calculation; K T : The transpose of the key vector, used to perform dot product calculation with Q' to obtain the similarity between the query and the key; d kis the dimension of the key vector, which is used to scale the dot product result to prevent gradient problems caused by values ​​that are too large or too small; softmax is used to normalize the dot product result and generate a weight distribution; the weight determines the influence of each word in the final output; V generates the final self-attention output by weighted averaging.

[0102] Step 43: Perform a first concat operation on the output of the multi-head attention mechanism and the output of the word embedding layer;

[0103] h concat1 =Concat(h multihead ,h embedding ) (3)

[0104] Among them, h concat1 is the result after the first concatenation operation, which concatenates the output of the multi-head self-attention mechanism with the output of the original word embedding layer to form a new feature vector; h multihead is the output of the multi-head self-attention mechanism, which is the context information of each word vector weighted by the attention mechanism; h embedding is the input word embedding vector, which represents the basic semantic information of each word.

[0105] Step 44, input the feature values ​​after the first concat operation into the second RMS normalized feed-forward network to help capture more complex patterns and features; that is, through the deeper processing capabilities of the model, to understand the high-order semantic relationships and subtle features that are difficult to capture directly in the input data;

[0106] Step 45, input the second RMS normalized feature into the prompt word template and then into the feedforward network;

[0107]

[0108] Among them, h norm2 is the eigenvalue after the second normalization, ensuring that the concatenated eigenvalue is stable within the numerical range to prevent the gradient from disappearing or exploding; n is the dimension of the vector, indicating how many elements need to be normalized; h concat1,i is the i-th element of the feature vector after the first concatenation operation; ∈ is a very small constant used to prevent division by zero errors.

[0109] The formula for the feedforward network is as follows:

[0110] h ffn1 =ReLU(W1h norm2 +b1) (5)

[0111] h out1 =W2h ffn1 +b2 (6)

[0112] Among them, h ffn1 is the output of the first layer of the feedforward network, the result after being processed by the activation function ReLU; W1 is the weight matrix of the first layer in the feedforward network, which is used to linearly transform the input features; b1 is the bias term of the first layer in the feedforward network; h out1 is the final output of the feedforward network; W2 is the second layer weight matrix of the feedforward network, which is used for further linear transformation; b2 is the bias term of the second layer of the feedforward network.

[0113] Prompt word templates, such as answering Q based on the content in T, llama3 will generate answers based on the input question and entity information embedded in the knowledge graph; ensure that the generated output conforms to specific formats and requirements.

[0114] Step 46: The output value of the feedforward layer of the feedforward network is subjected to a second concat operation with the eigenvalue after the first concat operation and then input into the third root mean square normalization to ensure the stability of the output and reduce the risk of gradient disappearance or explosion. The formula is as follows:

[0115] h concat2 =Concat(h out1 ,h concat1 ) (7)

[0116] Among them, h concat2 is the vector after the second concatenation, and the output h of the feedforward network is out1 With h concat1 Combined together to form a higher dimensional feature representation.

[0117] Step 47, the third RMS normalized eigenvalue is input into the linear layer, and the output of the feed-forward layer is converted into a fixed-dimensional representation;

[0118]

[0119] h linear =W3h norm3 +b3 (9)

[0120] where h norm3 is the output after the third RMS normalization, ensuring that the new concatenated vector remains numerically stable; m is the dimension of the vector after the second concatenation; h concat2,j is the jth element of the feature vector after the second concatenation; h linear is the output of the linear layer, the feature representation after linear transformation; W3 is the weight matrix of the linear layer, which is used to map the normalized vector to the new dimensional space; b3 is the bias term of the linear layer.

[0121] Step 48: Generate the probability distribution of the entity set corresponding to the output question through the classification layer; the classification layer is Softmax; it represents the confidence and probability when the model generates the answer based on the input question, and the formula is:

[0122] P(y|input)=Softmax(W4h linear +b4) (10)

[0123] Among them, P(y|input) is the probability distribution of the output, which indicates the confidence of the model in each type of answer; Softmax is used to convert the output of the linear layer into a probability distribution to ensure that the sum of the probabilities of all categories is 1; W4 is the weight matrix of the classification layer; b4 is the bias term of the classification layer.

[0124] Step 5: Construct a retrieval module;

[0125] The task of the retrieval module is to find the triple information related to the entity in the knowledge graph based on the user input query Q and the entity to be retrieved extracted from the entity detection module, and return it to the generation module for reply generation;

[0126] The specific steps of the retrieval module are as follows:

[0127] Step 51, entity input:

[0128] After the user enters the query Q, the entity detection module first extracts the entities to be retrieved; for example, the user's query is "What is the tariff for electronic products?", the entity detection module may identify "electronic products" and "tariffs" as entities to be retrieved.

[0129] Step 52: Entity query and matching:

[0130] The retrieval module searches the knowledge graph based on the entity to be retrieved; the knowledge graph consists of a large number of triplets (entity-relationship-entity) representing various relationships between entities; the task of the retrieval module is to find the triplets related to the input entity; for example, the knowledge graph may contain the following triplets: (electronic goods, regulated, tariffs);

[0131] Step 53: Relational reasoning and extension:

[0132] During the matching process, the retrieval module will not only find triples directly related to the entities, but also find other triples associated with these entities through relational reasoning; for example, if the user's query involves "tariffs", the retrieval module can infer other regulations or policy information related to "tariffs" through the relationships in the knowledge graph.

[0133] Step 54, return triples: the search module outputs the found related triples as results, and the related triples include triples directly related to the entity and other triples associated with the entity; for example, for the query of "electronic goods", the search module may return multiple triples, such as: (electronic goods, regulated, tariffs), (electronic goods, classification, consumer electronics), (tariffs, scope of application, specific goods);

[0134] Step 6: Build the generation module;

[0135] Finally, the retrieved triples are passed to the generation module, which combines the triples with the user's query to generate a natural language answer; the generated replies are not only based on keyword matching, but also build accurate and logically reasonable answers through the entities and relationships in the knowledge graph.

[0136] That is, when a user uses it, a new query Q first passes through the entity detection module to obtain the entity to be retrieved; then passes through the retrieval module to obtain the relevant triples; and then passes through the generation module to generate a reply;

[0137] The generation module is composed of llama3 and a prompt word template. The prompt word template prompt2 is to answer: Q according to the content in T.

[0138] Suppose the user inputs a new query Q: What is the customs duty rate for electronic goods?

[0139] The function of the prompt word template is: In the generation module, the structure of the prompt word template prompt2 is: answer Q: {question} according to the content in T: {content};

[0140] {content}: represents the structured information retrieved from the knowledge graph; for example, the following triples are found through the retrieval module:

[0141] (customs duty rate,REGULATED_BY,electronic goods)

[0142] This information can be embedded into {content} and become the basis for generating answers.

[0143] {question}: The user's query question, such as "What is the tariff rate for electronic products?"

[0144] llama3 generation process:

[0145] The llama3 model receives the prompt word template prompt2 and generates a natural language answer through the following steps:

[0146] Input: Based on the content in (customs duty rate REGULATED_BY electronic goods), answer: What is the customs duty rate for electronic goods?

[0147] Model processing: llama3 combines {content} and {question} in the prompt word template, first understands the entities and relationships in the knowledge graph, recognizes that "customs duty rate" is a regulated entity related to "electronic goods", and infers the tariff-related answer.

[0148] Output: llama3 generates an answer such as: The customs duty rate for electronic goods is regulated and may vary depending on the specific type of electronic goods.

[0149] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. A customs practice question and answer recognition method based on knowledge graph and large-scale language model, characterized by: The following steps are involved: Step 1: Collect customs-related text data and pre-process it; Step 2: Convert the pre-processed customs-related text data into a text collection; Step 3: Generate a question set and a corresponding entity set using the text set; Step 4: Construct an EDEM module including a word embedding layer, the first RMS normalization, a multi-head attention mechanism, a second RMS normalization, a feedforward network, a third RMS normalization, a linear layer, and a classification layer. Use text data and knowledge graph embedding to train the EDEM module and output the prediction results of the entity set corresponding to the question. Step 5: Build a retrieval module. According to the user query, use the EDEM module to extract the entities to be retrieved and search for triple information related to the entities in the knowledge graph. Step 6: Build a generation module to generate natural language answers using entity-related triple information and user queries.

2. The customs practice question and answer recognition method based on knowledge graph and large-scale language model according to claim 1 is characterized in that: Step 4 specifically includes: Step 41, the text input and knowledge graph embedding are converted into vector representation through the word embedding layer; As a preferred implementation mode of the present invention, the construction of the knowledge graph is to perform relationship annotation on the entity set on the text set. Step 42: Perform the first root mean square normalization on the word embedded data and then input it into the multi-head self-attention mechanism; Step 43: Perform a first concat operation on the output of the multi-head attention mechanism and the output of the word embedding layer; Step 44, input the eigenvalues ​​after the first concat operation into the second RMS normalization and then into the feedforward network; Step 45, input the second RMS normalized feature into the prompt word template and then into the feedforward network; Step 46, the output value of the feedforward layer of the feedforward network and the eigenvalue after the first concat operation are subjected to a second concat operation and then input into a third RMS normalization; Step 47, the third RMS normalized eigenvalue is input into the linear layer; Step 48: Generate the probability distribution of the entity set corresponding to the output question through the classification layer.

3. The customs practice question and answer recognition method based on knowledge graph and large-scale language model according to claim 2 is characterized in that: The construction of a knowledge graph is to annotate the relationships between entity sets on a text collection.

4. The customs practice question and answer recognition method based on knowledge graph and large-scale language model according to claim 2 is characterized in that: Step five includes: Step 51, after the user inputs the query, the EDEM module extracts the entities to be retrieved; Step 52: Search in the knowledge graph according to the entity to be retrieved; Step 53: Find the triples directly related to the entity, and find other triples associated with the entity through relational reasoning; Step 54: Output relevant triples.

5. The customs practice question and answer recognition method based on knowledge graph and large-scale language model according to claim 1 is characterized in that: Preprocessing includes: removing irrelevant characters, punctuation marks and HTML tags from customs-related text data.

6. The customs practice question and answer recognition method based on knowledge graph and large-scale language model according to claim 1 is characterized in that: Use Selenium and Scrapy to collect customs-related text data.

7. The customs practice question and answer recognition method based on knowledge graph and large-scale language model according to claim 1 is characterized in that: Use the llama3 model to generate a question set and a corresponding entity set from a text set.

8. A customs practice question and answer recognition system based on knowledge graph and large-scale language model, characterized by: include: a memory for storing instructions executable by a processor; A processor, configured to execute instructions to implement the customs practice question and answer recognition method based on knowledge graph and large-scale language model as described in any one of claims 1 to 7.

9. A computer readable medium storing a computer program code, characterized in that: When the computer program code is executed by a processor, it implements the customs practice question and answer recognition method based on knowledge graph and large-scale language model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Method for enhancing large language model by knowledge graph during testing

    CN120492637A