An intelligent customer service question-answering method based on knowledge graph and large language model

By inputting customer questions and professional knowledge in the industry knowledge base into the large language model, and using the knowledge graph to verify the professionalism of the answers, the problem of traditional customer service systems being unable to cope with the diversity and complexity of user needs is solved, and the intelligent customer service system is realized. Accurate and personalized question and answer service improves user experience.

CN118312600BActive Publication Date: 2024-10-01HANGZHOU HAOQING TECH CO LTD +2
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410719068.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-10-01
Estimated Expiration
2044-06-05

AI Technical Summary

Technical Problem

Traditional customer service systems are difficult to cope with the diversity and complexity of user needs. Knowledge graphs and large language models each have problems of insufficient accuracy and static coverage, making it difficult to achieve accurate answers and personalized services for intelligent customer service systems.

Method used

By inputting customer questions and professional knowledge in the industry knowledge base into the large language model, preliminary answers are generated, and the knowledge graph is used to verify the professionalism of the answers, perform triple extraction and matching, and finally generate the final answer, achieving accurate and personalized Q&A service.

Benefits of technology

It improves the accuracy and professionalism of Q&A, ensures the natural fluency of interaction, realizes self-learning adaptability and personalized services, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312600B_ABST
    Figure CN118312600B_ABST
Patent Text Reader

Abstract

The present invention discloses an intelligent customer service question-and-answer method based on a knowledge graph and a large language model, comprising: step 1: using a customer question as a query text for intent recognition, and determining the industry corresponding to the customer question; step 2: searching for professional knowledge related to the customer query text in the knowledge base of the corresponding industry, and simultaneously inputting the professional knowledge and the customer query text into the large language model to generate a preliminary answer; step 3: using the large language model to extract triples from the generated preliminary answer, and matching the extracted triples with the constructed industry knowledge graph; step 4: inputting the relevant entity data matched in the knowledge graph into the large language model again, and performing a secondary answer based on the customer query text to obtain the final answer. The present invention realizes accurate answer extraction and automatic generation, greatly improving the accuracy, professionalism and natural fluency of the question-and-answer; and, through the secondary answer, the accuracy and professionalism of the answer are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and specifically relates to an intelligent customer service question-answering method based on a knowledge graph and a large language model. Background Art

[0002] As digital transformation accelerates, the customer service sector is facing unprecedented challenges and opportunities. Traditional customer service systems rely on preset scripts and limited knowledge bases, making it difficult to cope with the growing diversity and complexity of user needs. With the rapid development of artificial intelligence technology, especially natural language processing (NLP), knowledge graph construction technology, and the maturity of large-scale language models, new solutions have been provided for intelligent customer service systems, aiming to achieve a more accurate, efficient, and personalized customer service experience.

[0003] Although knowledge graphs and large-scale language models each have powerful capabilities, the combination of the two can further enhance the effectiveness of intelligent customer service systems. Knowledge graphs provide accurate factual information and structured knowledge, solving the problem of insufficient accuracy that language models may have; while large models make up for the limitations of knowledge graphs’ staticness and incomplete coverage, and can handle long-tail questions and fuzzy queries that are not included in knowledge graphs. The fusion of the two complements each other’s strengths: language models can understand the implicit meaning of users’ questions, while knowledge graphs help to accurately locate the entities and relationships referred to by the questions. Based on the empirical information of the knowledge graph, combined with the language model, fluent, natural and informative answers are generated. Large models can optimize themselves based on new data, while the dynamic update mechanism of the knowledge graph ensures the timeliness of knowledge, jointly promoting the continuous evolution of customer service systems. Summary of the invention

[0004] In order to solve the shortcomings of the prior art, avoid knowledge limitations, improve answer accuracy, ensure natural interaction, achieve self-learning adaptability, and provide personalized services, thereby improving user experience, the present invention adopts the following technical solutions:

[0005] An intelligent customer service question-answering method based on knowledge graph and large language model includes the following steps:

[0006] Step 1: Use the customer's question as a query text to identify the intent and determine the industry to which the customer's question corresponds;

[0007] Step 2: Search for expertise related to the customer query text in the knowledge base of the corresponding industry, and input the expertise and customer query text into the large language model at the same time to generate a preliminary answer;

[0008] Step 3: Use the large language model to extract triples from the generated preliminary answers, and match the extracted triples with the constructed industry knowledge graph to verify the professionalism of the answers;

[0009] Step 4: Input the relevant entity data matched in the knowledge graph into the large language model again, and give a secondary answer based on the customer query text to obtain the final answer.

[0010] Furthermore, the intention recognition in step 1 includes the following steps:

[0011] Step 1.1: Obtain customer service related question and answer data, preprocess and classify it to obtain training data;

[0012] Preprocessing includes data cleaning, removing special symbols, stop words and other information that is useless for model training, and then tokenizing and label encoding the data to convert the original data into a format suitable for BERT model training;

[0013] Step 1.2: Build an industry classification recognition model and add a classification layer after the BERT model to identify the customer's query intent to limit the range of questions that the large model can answer;

[0014] Step 1.3: Train the industry classification recognition model through training data. The model stacks multiple Transformer encoders for feature extraction. The core mechanism of Transformer is Self-Attention, and its calculation formula can be expressed as:

[0015]

[0016] In the formula, the vector , , The word vector X is respectively combined with three weight matrices W q , W k , W v Multiply them together to get d k Represents the dimension of the word vector;

[0017] The BERT model uses a multi-head attention mechanism when performing semantic encoding, that is, performing multiple (h) linear transformations to obtain multiple representation subspaces, so that the model can learn more features. The specific calculation method is as follows:

[0018]

[0019]

[0020] Then, based on the classification word vector H of the BERT model output result, a simple classifier is made using softmax to perform classification prediction, and the probability of the predicted category label L is:

[0021] P(L|H)= softmax(WH)

[0022] Where W represents the parameter matrix of the classification task. Finally, the BERT model and all parameters in W are fine-tuned by maximizing the log probability of the correct label, which is modified to use the fully connected layer to obtain the probability of each label:

[0023] P(L|H)= FC(H)

[0024] During training, the vector dimension of the input fully connected layer is 768. It has two hidden layers with dimensions of 384 and 768 respectively. The output dimension is the number of categories. This is a binary classification task, so it is 2. Finally, the label with a larger probability is selected as the predicted classification result.

[0025] Furthermore, the knowledge retrieval in step 2 includes the following steps:

[0026] Step 2.1: Divide the text in each file in the knowledge base into blocks;

[0027] Step 2.2: Create a vector index V for each piece of text i (i = 1,2,…,n×m), during retrieval, the query text is vectorized to obtain the question text vector Q, and multiple (k) vector indexes that are most similar to the question text vector Q are calculated through vector similarity, and the corresponding text blocks are returned;

[0028] The formula for vector similarity is:

[0029]

[0030] In the formula, Expressing words The term frequency and inverse document frequency index TF-IDF (TtermFrequency–Inverse Document Frequency) in the document, F i (i = 1,2,…,n) represents the i-th file in the knowledge base, D ij (i = 1,2,…,n; j = 1,2,…,m) represents the jth text block of the i-th file, represents the word frequency TF of the jth text block in the i-th file, Represents the inverse text frequency index of the i-th file;

[0031] Step 2.3: Combine the retrieved expertise text blocks with the customer query text to construct a prompt, and then input the prompt into the large language model to generate a preliminary answer.

[0032] Furthermore, in the construction of the industry knowledge graph in step 3, the process of named entity recognition includes the following steps:

[0033] Step 3.1: Preprocess industry data;

[0034] First, we cleaned the acquired financial industry data and used regular expressions to remove special characters and punctuation marks from the acquired financial industry data. Then, we performed Chinese word segmentation on the data and used the Jieba Chinese word segmentation method to segment the continuous financial industry text data into discrete words, so that the model can better understand the semantic features of the sentences.

[0035] Step 3.2: Encode the preprocessed data;

[0036] Step 3.3: Word2vec model font encoding; Since financial industry data is scattered and it is difficult to obtain relevant research data, font data is introduced to expand the data volume so that the entity recognition model can be fully trained. The problem of overfitting the model due to excessive attention to noise and details in the sample is likely to occur when the acquired financial industry data is integrated with the font data for training. Therefore, the original data and the font data are encoded separately, and finally the two character vectors are jointly encoded to achieve the best encoding effect;

[0037] Step 3.4: Joint encoding based on the gated recurrent unit GRU (Gated Recurrent Unit); Because the two character vectors trained by the Encoder module and the Word2vec model have different dimensions and representations, the two different vectors need to be merged when performing the subsequent decoding task as the input of the decoding task. When splicing, it is necessary to ensure that the dimensions of the two vectors are consistent; the present invention adopts joint encoding based on the GRU structure to unify the dimensions of the vectors encoded by the industry data and the vectors encoded by the font library to obtain the character representations of the two codes; during the joint encoding, the gated recurrent unit GRU is first used to perform fixed-length processing on the standardized vectors and horizontal splicing, and then the sequence data is processed, the key features are integrated and a joint coding representation is generated to provide a richer feature representation for subsequent tasks;

[0038] Step 3.5: Use the character sequence output by the gated recurrent unit GRU as the input sequence of the Lattice-LSTM (Lattice-Long Short-Term Memory) model to extract entities of the industry data.

[0039] Furthermore, in step 3.1, considering that financial industry data is often complex and diverse, in order to ensure the effectiveness and generalization of the training model, the BIOES five-gram labeling method is used to construct a label table D={B,I,E,S,O}, where B represents the starting word of the entity, I represents the middle word of the entity, E represents the ending word of the entity, S represents an entity composed of a single word, and O represents words other than the entity.

[0040] Furthermore, in step 3.2, four-layer embedding is used to encode the industry data text from different levels;

[0041] Through token embedding, discrete words in industry data are converted into continuous vector space, capturing the semantic similarity between words and providing a basic representation for each word.

[0042] Through token embedding, industry text x i Mapped to a real vector e i ;

[0043]

[0044] In the formula, represents a fixed-size word embedding matrix, is a one-hot encoding function, and the industry text sequence is x = {x1, x2, …, x n}, where n is the length of the input sequence, x i Represents the i-th word in the sequence, i=1, 2,···, n;

[0045] Position Embedding is used to encode the position information of words in sentences or texts, so that the model can distinguish words in different positions and capture the relative distance between words.

[0046] Position Embedding is the position embedding for each word x i The positional encoding of a fixed-size vector p i :

[0047]

[0048] In the formula, k represents the dimension index, and l represents the dimension of character embedding;

[0049] Through sentence embedding, word embedding or word-level representation is combined to capture the semantic and contextual information of the sentence;

[0050] Sentence Embedding performs a weighted average calculation on the outputs of Token Embedding and Position Embedding to obtain the vector representation s of the entire sentence:

[0051]

[0052] In the formula, , Respectively represent the weight matrices of Token Embedding and Position Embedding;

[0053] Through Task Embedding, task-related embedding vectors are introduced to focus the model’s attention and emphasis on the current task, allowing the model to learn task-specific information and patterns.

[0054] The task embedding is learned through gradient descent and input into the Transformer-Encoder encoder to calculate the attention score α between the input sequence and other positions i :

[0055]

[0056] Where d represents the dimension of the attention mechanism; represents the query vector obtained after linear transformation;

[0057] To α i Perform weighted averaging to calculate the input vector z at the corresponding position i :

[0058]

[0059] In the formula, represents the number of word vectors, Represents the linear transformation result of the j-th word vector;

[0060] Fully connected calculation: The output vector of each position is fully connected through the feedforward neural network to obtain the output vector T with a final vector dimension of 768 i :

[0061]

[0062] In the formula, ( ) represents the activation function; , represents the training weight, b1 and b2 represent the bias.

[0063] Furthermore, in step 3.3, the Skip-Gram model is used, and the weight matrix between the font input layer X and the hidden layer H is It is obtained through training and learning. V represents the vocabulary size, N represents the number of neurons in the hidden layer, and the output word vector is N×V dimensional. The hidden layer node input is calculated by weighted summation of the input layer. The input is a one-hot vector. Only non-zero elements in the input vector can generate the input of the hidden layer after calculation. The corresponding nodes of the hidden layer are weighted summed to obtain the output of the output layer, and finally the character vector of the font is obtained.

[0064] Furthermore, in step 3.4, since the two character vectors have different feature distributions, feature normalization is required before joint encoding. Normalization and standardization are commonly used feature normalization methods, among which normalization will scale the features to a smaller range and cause information loss, so standardization is used for feature normalization; the feature values ​​of the two character vectors are scaled to a normal distribution with a mean of 0 and a standard deviation of 1:

[0065]

[0066] In the formula, is the normalized character vector eigenvalue; represents a character vector eigenvalue; represents the mean of the eigenvalues; The standard deviation of the marker eigenvalues.

[0067] The advantage of standardization is that it can handle situations where different features have different value ranges, and at the same time map the feature values ​​to the same scale, making the contribution weights of different features to the model more balanced. This article maps the character vector dimension of the font library to 768, which is consistent with the character vector dimension of the original data.

[0068] Furthermore, in step 3.4, the gated recurrent unit GRU introduces a gating mechanism to control the flow of information through two gating units, an update gate and a reset gate;

[0069] When the input sequence is {y1, y2, ..., y T}, T represents the current moment, and the hidden state is {h1, h2, ... h T}, calculate the reset gate of GRU:

[0070]

[0071] In the formula, ( ) represents the sigmoid activation function; represents the weight matrix of the reset gate; Indicates the previous time Hidden state and current input To splice;

[0072] Update the gate to:

[0073]

[0074] In the formula, represents the weight matrix of the update gate;

[0075] The candidate hidden states are:

[0076]

[0077] In the formula, A weight matrix representing candidate hidden states; Indicates the symbol for matrix element multiplication;

[0078] The updated hidden state is:

[0079] .

[0080] Furthermore, in step 3.5, the character sequence In The word vector is:

[0081]

[0082] In the formula, Represents the characters, M represents the number of characters, represents the word-to-vector mapping function;

[0083] The hidden state of the long short-term memory LSTM model at this moment is:

[0084]

[0085] In the formula, Represents the parameters learned during the training of the LSTM model. Represents the hyperparameters of the long short-term memory LSTM model;

[0086] In hidden state Use the Conditional Random Fields (CRF) model to get the label sequence The probability is:

[0087]

[0088] In the formula, Represents the unique parameters of the conditional random field CRF model, Represents the conditional random field CRF model bias;

[0089] Based on the character sequence and its corresponding label sequence, the extraction of industry data entities is completed.

[0090] The advantages and beneficial effects of the present invention are:

[0091] The present invention achieves accurate answer extraction and automatic generation by integrating the deep structured information of the knowledge graph and the advanced natural language processing capabilities of the large language model, greatly improving the accuracy, professionalism and natural fluency of the Q&A. The present invention provides a second answer to the question raised, using the preliminary answer generated by the first large language model to search the knowledge graph of the corresponding industry, retrieve more relevant knowledge, and thus improve the accuracy and professionalism of the answer. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] Figure 1 It is a flow chart of the method of the present invention.

[0093] Figure 2 It is a structural diagram of the customer intention recognition module in the present invention.

[0094] Figure 3 It is a structural diagram of the named entity recognition module in the present invention. DETAILED DESCRIPTION

[0095] The specific implementation of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the present invention, and is not used to limit the present invention.

[0096] like Figure 1 As shown, an intelligent customer service question-answering method based on a knowledge graph and a large language model of the present invention comprises the following steps:

[0097] Step 1: Input the customer's query text into the intention recognition module to determine whether the customer's query is a question related to an industry; in the embodiment of the present invention, the relevant industry is the financial industry, such as Figure 2 As shown, the intent recognition module includes the following steps:

[0098] Step 1.1: Data preparation: We used the bank customer service Q&A data accumulated by the company, including daily conversations, financial business consultations and other topics, to ensure the richness and diversity of the Q&A content. We then cleaned the collected data, removed special symbols, stop words and other information that was useless for model training, and then tokenized and labeled the data, thus converting the original data into a format suitable for BERT model training.

[0099] Step 1.2: Model structure design: The intent recognition module mainly uses the BERT model, and adds a classification layer after the model. This allows the customer's query intent to be recognized to limit the range of questions that the large model can answer.

[0100] Step 1.3: Model training: Input the training data set preprocessed in step 1.1 into the BERT model. The BERT model stacks multiple Transformer encoders for feature extraction. The core mechanism of Transformer is Self-Attention, and its calculation formula can be expressed as:

[0101]

[0102] In the formula, the vector , , The word vector X is respectively combined with three weight matrices W q , W k , W v Multiply them together to get d k is the dimension of the word vector.

[0103] When BERT performs semantic encoding, it uses the Multi-head Attention mechanism, which performs h linear transformations to obtain multiple representation subspaces, so that the model can learn more features. The specific calculation method is as follows:

[0104]

[0105]

[0106] Then, we use the classification word vector H of the BERT result to make a simple classifier based on softmax, and predict the probability of the label L of the category as follows:

[0107] P(L|H)= softmax(WH)

[0108] Where W is the parameter matrix of the classification task, and finally all parameters in BERT and W are fine-tuned by maximizing the log probability of the correct label. Modify it to use a fully connected layer to get the probability of each label:

[0109] P(L|H)= FC(H)

[0110] During training, the vector dimension of the input fully connected layer is 768, and there are two hidden layers with dimensions of 384 and 768 respectively. The output dimension is the number of categories. This is a binary classification task, so it is 2. Finally, the label with a larger probability is selected as the result of the predicted classification.

[0111] Step 2: Preprocess the acquired data to make the original data more standardized, accurate and usable. Then, through knowledge retrieval, search the knowledge base for professional knowledge related to the user's query text, input the acquired professional knowledge and the customer's query text into the big model at the same time, and generate a preliminary answer. Among them, knowledge retrieval includes the following steps:

[0112] Step 2.1: Assume that the i-th document in the knowledge base is F i (i = 1,2,…,n), the search based on LangChain will divide the text in each file into blocks, D ij (i = 1,2,…,n; j = 1,2,…,m) represents the jth text block in the i-th file.

[0113] Step 2.2: Create a vector index V for each piece of text i (i = 1,2,…,n×m), the question text is vectorized during retrieval to obtain the question text vector Q, and finally the k vector indexes most similar to Q are calculated through vector similarity, and the corresponding text blocks are returned; the formula for vector similarity is:

[0114]

[0115] In the formula, Expressing words TF-IDF in the document.

[0116] Step 2.3: Combine the retrieved professional knowledge text block and the customer query text to form a prompt, for example: "Now you are an expert in {a certain field such as: financial industry}, please refer to the following data: {professional knowledge text}, answer the question: {customer query question}"; finally, input the prompt into the large language model to generate a preliminary answer; the knowledge base here includes banking data, insurance data, securities data, trust data and leasing data.

[0117] Step 3: Use the large language model to extract triples from the generated preliminary answers, and match the extracted triples with the constructed financial industry knowledge graph to verify the professionalism of the answers; Figure 3 As shown in the figure, the named entity recognition process in the construction of the financial industry knowledge graph includes the following steps:

[0118] Step 3.1: Data preprocessing; First, clean the acquired financial industry data, use regular expressions to remove special characters and punctuation marks in the acquired financial industry data, and then perform Chinese word segmentation on it. The jieba Chinese word segmentation method is used to segment the continuous financial industry text data into discrete words, so that the model can better understand the semantic characteristics of the sentence. Considering that financial industry data is often complex and diverse, in order to ensure the effectiveness and generalization of the training model, the BIOES five-element annotation method is used to construct the label table D={B,I,E,S,O}. Among them, B is the entity start word, I is the entity middle word, E is the entity end word, S is the entity composed of a single word, and O is the word other than the entity.

[0119] Step 3.2: Data encoding: Encode the data preprocessed in step 3.1, and use 4 layers of Embedding to encode the financial industry data text from different levels.

[0120] Token Embedding is mainly used to convert discrete words in financial industry data into continuous vector space, capture the semantic similarity between words, and provide a basic representation for each word. Suppose the financial industry text sequence is x = {x1, x2, ..., x n}, where n is the length of the input sequence, x i is a sequence of i characters, i=1, 2, ···, n. i Mapped to a real vector e i .

[0121]

[0122] In the formula, is a fixed-size word embedding matrix, is the one-hot encoding function.

[0123] Position Embedding is used to encode the position information of words in a sentence or text, so that the model can distinguish words at different positions and capture the relative distance between words. i The positional encoding of a fixed-size vector p i .

[0124]

[0125] Where k is the dimension index and l is the dimension of character embedding.

[0126] Sentence Embedding captures the semantic and contextual information of a sentence by combining word embeddings or word-level representations. Sentence Embedding performs a weighted average calculation on the outputs of Token Embedding and Position Embedding to obtain the vector representation s of the entire sentence.

[0127]

[0128] In the formula, , They are the weight matrices of Token Embedding and Position Embedding respectively.

[0129] Task Embedding is used to introduce task-related embedding vectors, focusing the model’s attention and focus on the current task, so that the model can learn task-specific information and patterns. Transformer-Encoder encoding. Task Embedding is learned through gradient descent and input into Transformer-Encoder to calculate the attention score α between the input sequence and other positions i .

[0130]

[0131] Where d is the dimension of the attention mechanism; Represents the query vector obtained after linear transformation.

[0132] To α i Perform weighted averaging to calculate the input vector z at the corresponding position i .

[0133]

[0134] In the formula, is the number of word vectors, is the linear transformation result of the j-th word vector.

[0135] Fully connected calculation: The output vector of each position is fully connected through the feedforward neural network to obtain the output vector T with a final vector dimension of 768 i .

[0136]

[0137] In the formula, ( ) is the activation function; , is the training weight, b1 and b2 are the biases.

[0138] Step 3.3: Word2vec model font encoding; Due to the scattered data in the financial industry, it is difficult to obtain relevant research data. Therefore, font data is introduced to expand the data volume so that the entity recognition model can be fully trained. The fusion training of the acquired financial industry data and font data is prone to the problem that the model pays too much attention to the noise and details in the sample, resulting in overfitting of the model. Therefore, the original data and the font data are encoded separately, and finally the two character vectors are jointly encoded to achieve the best encoding effect. The present invention adopts the Skip-Gram model, and the weight matrix between the font input layer X and the hidden layer H is the parameter that needs to be learned through training, is the vocabulary size, and N is the number of hidden layer neurons. The output word vector is N×V dimensional The input of the hidden layer nodes is calculated by weighted summation of the input layer. Since the input is a one-hot vector, only non-zero elements in the input vector can generate the input of the hidden layer after calculation. The corresponding nodes of the hidden layer are weighted summed to obtain the output of the output layer. Finally, a font character vector with a vector dimension of 300 is obtained.

[0139] Step 3.4: GRU joint encoding: Because the two character vectors trained by the Encoder module and the Word2vec model have different dimensions and representations, the two different vectors need to be merged as the input of the decoding task in the subsequent decoding task. When splicing, it is necessary to ensure that the dimensions of the two vectors are consistent.

[0140] The present invention adopts joint encoding based on GRU structure to unify the vector dimension to obtain two encoded character representations. Since the two character vectors have different feature distributions, feature normalization is required before joint encoding. Normalization and standardization are commonly used feature normalization methods, among which normalization will scale the features to a smaller range and cause information loss, so the standardization method is selected for feature normalization.

[0141] The eigenvalues ​​of the two character vectors are scaled to a normal distribution with a mean of 0 and a standard deviation of 1 according to the following formula.

[0142]

[0143] In the formula, is the normalized character vector eigenvalue; is the character vector eigenvalue; is the mean of the eigenvalues; is the standard deviation of the eigenvalues.

[0144] The advantage of standardization is that it can handle situations where different features have different value ranges, and at the same time map the feature values ​​to the same scale, making the contribution weights of different features to the model more balanced. In this paper, the character vector dimension of the font library is mapped to 768, which is consistent with the original data character vector dimension.

[0145] GRU introduces a gating mechanism to control the flow of information through gating units. It has two gating units: update gate and reset gate.

[0146] When the input sequence is {y1, y2, ..., y T} (T is the current time), the hidden state is {h1, h2, ... h T}, calculate the reset gate of GRU:

[0147]

[0148] In the formula, ( ) is the sigmoid activation function; is the weight matrix of the reset gate; Indicates the previous time Hidden state and current input Make stitching.

[0149] Update the gate to:

[0150]

[0151] In the formula, is the weight matrix of the update gate.

[0152] The candidate hidden states are:

[0153]

[0154] In the formula, is the weight matrix of the candidate hidden state; is the matrix element multiplication sign.

[0155] The updated hidden state is:

[0156]

[0157] During joint encoding, GRU is first used to perform fixed-length processing on the standardized vectors and perform horizontal splicing, and then the sequence data is processed by GRU to fuse key features and generate a joint encoding representation, providing richer feature representations for subsequent tasks.

[0158] Step 3.5: Use the character sequence output by the GRU model as the input sequence of the Lattice-LSTM model is the number of characters. The word vector is:

[0159]

[0160] In the formula, is the word-to-vector mapping function.

[0161] The hidden state of the LSTM model at this moment is:

[0162]

[0163] In the formula, are the parameters learned during the LSTM model training process, is the hyperparameter of the LSTM model.

[0164] exist Use CRF to get the label sequence The probability of

[0165]

[0166] In the formula, It is a parameter specific to the CRF model; is the CRF model bias.

[0167] This completes the extraction of data entities in the financial industry.

[0168] Step 4: Input the relevant entity data matched in the knowledge graph into the large language model for secondary answering to form the final answer. In the embodiment of the present invention, by using the preliminary answer generated by the large language model for the first time, more relevant information is retrieved from the financial industry knowledge graph, and the retrieved information and the customer query text are used as prompts and input into the large model again to generate the final answer.

[0169] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An intelligent customer service question-answering method based on knowledge graph and large language model, characterized in that The steps include: Step 1: Use the customer's question as a query text to identify the intent and determine the industry to which the customer's question corresponds; Step 2: Search for expertise related to the customer’s query text in the knowledge base of the corresponding industry, and input the expertise and the customer’s query text into the large language model at the same time to generate a preliminary answer; Step 3: Use the large language model to extract triples from the generated preliminary answers, and match the extracted triples with the constructed industry knowledge graph. In the construction of the industry knowledge graph, the process of named entity recognition includes the following steps: Step 3.1: Preprocess industry data; Step 3.2: Encode the preprocessed data; use four-layer embedding to encode the industry data text from different levels; Through token embedding, discrete words in industry data are converted into a continuous vector space, capturing the semantic similarity between words and providing a basic representation for each word; Embedding industry text into i Mapped to a real vector e i ; e i =Q token one hot (x i ) In the formula, Q token represents a fixed-size word embedding matrix, one hot (.) is the one-hot encoding function, and the industry text sequence is x = {x1, x2, ..., x n }, where n is the length of the input sequence, x i Represents the i-th word in the sequence, i=1,2,···,n; Through position embedding, the position information of words in sentences or texts is encoded, so that the model can distinguish words in different positions and capture the relative distance between words. The position embedding is for each word x i The position encoding of a fixed-size vector p i : In the formula, k represents the dimension index, and l represents the dimension of character embedding; Through sentence embedding, word embeddings or word-level representations are combined to capture the semantic and contextual information of the sentence; Sentence embedding performs a weighted average calculation on the token embedding and position embedding outputs to obtain the vector representation s of the entire sentence: Where W1 and W2 represent the weight matrices of tag embedding and position embedding respectively; Through task embedding, task-related embedding vectors are introduced to focus the model’s attention and emphasis on the current task, allowing the model to learn task-specific information and patterns; The task embedding is learned through gradient descent and input into the encoder, and the attention score α between the input sequence and other positions is calculated. i : Where d represents the dimension of the attention mechanism; q i represents the query vector obtained after linear transformation; To α i Perform weighted averaging to calculate the input vector z at the corresponding position i : In the formula, u represents the number of word vectors, v j Represents the linear transformation result of the j-th word vector; Fully connected calculation: The output vector of each position is fully connected through the feedforward neural network to obtain the final output vector T i : T i =ReLU(from i w1+b1)w2+b2 In the formula, ReLU() represents the activation function; w1 and w2 represent the training weights, and b1 and b2 represent the biases; Step 3.3: Import the font data and encode it; Step 3.4: Joint encoding based on gated recurrent units; unify the dimensions of the vectors after industry data encoding and the vectors after font encoding to obtain the character representations of the two encodings. When performing joint encoding, first use gated recurrent units to perform fixed-length processing on the standardized vectors and horizontally splice them, then process the sequence data, fuse the key features and generate a joint encoding representation; Step 3.5: Use the character sequence output by the gated recurrent unit as the input sequence of the long short-term memory model to extract the entities of the industry data; Step 4: Input the relevant entity data matched in the knowledge graph into the large language model again, and give a secondary answer based on the customer query text to obtain the final answer.

2. According to claim 1, an intelligent customer service question-answering method based on knowledge graph and large language model is characterized in that: The intention recognition in step 1 includes the following steps: Step 1.1: Obtain customer service related question and answer data, preprocess and classify it to obtain training data; Step 1.2: Construct an industry classification identification model; Step 1.3: Train the industry classification recognition model through training data. The model stacks multiple Transformer encoders for feature extraction. When performing semantic encoding, it adopts a multi-head attention mechanism. Then, it performs classification prediction based on the classification word vector of the model output result to obtain the predicted category label.

3. According to claim 1, an intelligent customer service question-answering method based on knowledge graph and large language model is characterized in that: The knowledge retrieval in step 2 includes the following steps: Step 2.1: Divide the text in each file in the knowledge base into blocks; Step 2.2: Create a vector index for each block of text, vectorize the query text during retrieval, obtain the question text vector, calculate multiple vector indexes that are most similar to the question text vector through vector similarity, and return the corresponding text block; Step 2.3: Combine the retrieved expertise text blocks with the customer query text to construct a prompt, and then input the prompt into the large language model to generate a preliminary answer.

4. The intelligent customer service question-answering method based on knowledge graph and large language model according to claim 1, characterized in that: In step 3.1, the BIOES five-element annotation method is used to construct a label table D = {B, I, E, S, O}, where B represents the starting character of the entity, I represents the middle character of the entity, E represents the ending character of the entity, S represents an entity composed of a single character, and O represents a character other than the entity.

5. According to claim 1, an intelligent customer service question-answering method based on knowledge graph and large language model is characterized in that: In step 3.3, the weight matrix W between the font input layer X and the hidden layer H N×V It is obtained through training and learning. V represents the vocabulary size, N represents the number of neurons in the hidden layer, and the output word vector is N×V dimension W′ N×V The hidden layer node input is obtained by weighted summation of the input layer. The input is a one-hot vector. Only non-zero elements in the input vector can generate the input of the hidden layer after calculation. The corresponding nodes of the hidden layer are weighted summed to obtain the output of the output layer, and finally the character vector of the font is obtained.

6. The intelligent customer service question-answering method based on knowledge graph and large language model according to claim 1, characterized in that: In step 3.4, the eigenvalues ​​of the two character vectors are scaled to a normal distribution with a mean of 0 and a standard deviation of 1: Where Z′ is the standardized character vector eigenvalue; Z represents the character vector eigenvalue; μ represents the mean of the eigenvalue; ξ represents the standard deviation of the eigenvalue.

7. The intelligent customer service question-answering method based on knowledge graph and large language model according to claim 1, characterized in that: In step 3.4, the gated recurrent unit introduces a gated mechanism to control the flow of information through two gated units, an update gate and a reset gate; When the input sequence is {y1, y2, ..., y T }, T represents the current moment, and the hidden state is {h1, h2, ... h T }, calculate the reset gate of GRU: r T =σ(W r ,h T-1 ,y T -) Where σ() represents the activation function; W r Represents the weight matrix of the reset gate; [h T-1 ,y T ] indicates that the previous h T-1 The hidden state and the current input y T To splice; Update the gate to: g T =σ(W z ,h T-1 ,y T -) Where W z represents the weight matrix of the update gate; The candidate hidden states are: Where W represents the weight matrix of the candidate hidden state; ⊙ represents the matrix element multiplication symbol; The updated hidden state is:

8. The intelligent customer service question-answering method based on knowledge graph and large language model according to claim 1, characterized in that: In step 3.5, the character sequence *φ1,φ2,…,φ M +, the Jth (J=1,2,…,M) word vector is: a J =L(φ J ) In the formula, φ J represents the character, M represents the number of characters, and L(·) represents the word vector mapping function; The hidden state of the long short-term memory model at time T is: In the formula, Λ represents the parameters learned during the training of the long short-term memory model, and θ represents the hyperparameters of the long short-term memory LSTM model; In hidden state Using the conditional random field model, the probability of obtaining the label sequence o is: In the formula, K represents the unique parameters of the conditional random field CRF model, and γ represents the conditional random field CRF model deviation; Based on the character sequence and its corresponding label sequence, the extraction of industry data entities is completed.

Citation Information

Patent Citations

  • Question text answer searching method and device, computer equipment and storage medium

    CN116975212A

  • Knowledge graph-based method for enhancing dual-carbon domain service of large language model

    CN117370580A

  • Policy question and answer method and system based on large language model and knowledge graph technology

    CN117725170A

  • Question answering method and device based on artificial intelligence, electronic equipment and storage medium

    CN117725188A

  • Intelligent trademark law question and answer method for enhancing big language model reasoning through knowledge graph

    CN117807202A