Tourism intelligent question and answer method and system based on large language model

By constructing a smart tourism question-and-answer system and utilizing knowledge graphs and embedded vector technology, the problem of low information retrieval efficiency in the tourism field has been solved, and more accurate and personalized answers have been achieved.

CN121979984APending Publication Date: 2026-05-05SONGCHENG DUMUQIAO NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SONGCHENG DUMUQIAO NETWORK CO LTD
Filing Date
2026-01-15
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In the tourism sector, user-generated text data may contain emotional and ambiguous words, leading to inefficient information retrieval and ambiguous responses. Existing methods struggle to utilize the common sense and contextual information behind the words.

Method used

By acquiring query text data input by tourists, preprocessing and extracting embedding vectors, constructing a candidate entity memory bank in conjunction with a tourism knowledge graph, performing contextual feature extraction and density clustering, generating query vectors, and fusing candidate entity vectors with query vectors to enrich semantic representation.

Benefits of technology

It improves the accuracy and efficiency of information retrieval, avoids semantic confusion and ambiguity, provides more context-appropriate responses, and enhances the understanding of user intent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121979984A_ABST
    Figure CN121979984A_ABST
Patent Text Reader

Abstract

The invention discloses a tourism intelligent question and answer method and system based on a large language model, and relates to the technical field of semantic analysis. The method comprises the following steps: preprocessing a query text to obtain an embedded vector, mapping a graph entity into a third vector, screening and building a candidate library, extracting context features and clustering to obtain a query vector, splicing candidate entities into a knowledge vector, fusing to obtain a knowledge semantic vector, generating semantic features in combination with the context features, and inputting a language model to output a prediction result. According to the method, context features are extracted, query vectors are generated through clustering, query vectors representing core query intentions are generated, semantic dispersion is avoided, knowledge semantic vectors of candidate entity vectors and the query vectors are fused, the defect that plain text semantics lack structured knowledge support is overcome, semantic feature vectors are generated in combination with the context features, and the query intentions are extracted. Inputting the language model to output a prediction result; the problem that ambiguity occurs to user reply due to the fact that common sense and context background information behind words are difficult to use is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of semantic analysis technology, specifically relating to a smart question-answering method and system for tourism based on a large language model. Background Technology

[0002] The intelligent question-and-answer system in the tourism sector is an intelligent interactive platform built upon technologies such as natural language processing, knowledge graphs, and big data analytics. Its core function is to enable precise, real-time, and personalized tourism consultation services through technological empowerment. This system integrates multi-dimensional tourism data, including scenic spot information, transportation ticketing, accommodation and dining, itinerary planning, and emergency assistance. It supports multi-channel interaction such as voice, text, and images, quickly understanding tourists' natural language needs and accurately answering frequently asked questions such as "attraction opening hours," "ticket booking process," and "route connection options." It can also generate customized suggestions based on user travel preferences and time budgets. Breaking the time and space limitations of traditional manual consultation and simplifying the information acquisition process, it not only enhances the tourist travel experience but also provides data support for tourism practitioners to optimize service layout and uncover user needs. It serves as a core interactive hub connecting tourists and service resources within the smart tourism ecosystem.

[0003] The existing publication number CN119621902A discloses a question-answering method and apparatus based on a large language model. The method includes obtaining query text input by the user corresponding to table data to be processed, and generating prompt text corresponding to the large language model based on the query text. The prompt text includes the query text and an instruction text indicating that the answer text may contain data processing instructions corresponding to the table data. The prompt text is input into the large language model, and the large language model generates an initial answer text corresponding to the query text under the guidance of the prompt text.

[0004] While the above solution optimizes the answer text generated by the large language model in the intelligent dialogue system based on the query text through the data processing results corresponding to the data processing instructions, in some scenarios such as the tourism industry, the text data output by users may contain user emotions and some words that are easy to cause ambiguity. This can lead to a lack of structured knowledge support in the pure text, making it difficult to utilize the common sense and contextual background information behind the words, resulting in low information retrieval efficiency and ambiguity in the responses to users. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of pure text semantics in the tourism field, which lacks structured knowledge support, making it difficult to utilize common sense and contextual background information behind words, resulting in low information retrieval efficiency and ambiguous responses to users. Therefore, this invention proposes a smart question-answering method and system for tourism based on a large language model.

[0006] In a first aspect of this invention, a smart question-answering method for tourism based on a large language model is first proposed, the method comprising: The query text data input by the visitor is obtained, and the query text data is preprocessed to obtain a first embedding vector and a second embedding vector; the first embedding vector is the embedding vector of a single word in the context text of the target statement, and the second embedding vector is the embedding vector of a single word in the target statement; the target statement is a statement that does not contain preset sentiment words; Obtain the tourism knowledge graph, map each entity in the tourism knowledge graph to obtain the third embedding vector, filter the second and third embedding vectors and construct a candidate entity memory library; A context feature vector is obtained by extracting context semantic features from the first embedding vector, and a query vector is generated by density clustering of the context feature vector. The candidate entity vector in the candidate entity memory is concatenated with the query vector to obtain the knowledge vector, and the second embedding vector is fused with the knowledge vector to obtain the knowledge semantic vector; Based on the context feature vector and the knowledge semantic vector, a semantic feature vector is obtained by performing preset operations. The semantic feature vector is then input into the language model to output the semantic prediction result.

[0007] By extracting word embedding vectors from the context and the target sentence separately, fine-grained differentiation of semantic units is achieved, avoiding semantic confusion. Knowledge graph entities are mapped to embedding vectors and matched with second embedding vectors to construct an accurate candidate entity memory, effectively focusing on relevant knowledge and reducing interference. Density clustering of context feature vectors generates query vectors representing the overall query intent. By fusing query vectors and candidate entity vectors, a semantic representation rich in contextual guidance and structured knowledge is formed, improving the accuracy of semantic prediction for users.

[0008] Optionally, the second and third embedding vectors are filtered to construct a candidate entity memory, including: By mapping each entity in the knowledge graph to a low-dimensional real-valued vector using the TransE model, the embedding vector of a single entity in the knowledge graph is obtained and defined as the third embedding vector. By calculating the similarity between the second and third embedding vectors, the third embedding vectors that meet the conditions are selected as candidate entity embedding vectors based on the similarity and similarity threshold, and all candidate entity embedding vectors are combined into a candidate entity memory.

[0009] The TransE model transforms external knowledge graph entities into computable low-dimensional vectors, forming a candidate entity memory to provide pure external common sense support for the language model. It also avoids irrelevant noise introduced by knowledge graph triples and breaks through the limitation of traditional methods that can only model from the grammatical level.

[0010] Optionally, density clustering is performed on the context feature vector to generate a query vector, including: By using the bidirectional attention mechanism of Transformer, the semantic dependencies between text contexts are captured, and context feature vectors are generated. Calculate the density of the K nearest neighbor features around each context feature vector and the distance index of each context feature vector; The joint score of each context feature vector is calculated based on density and distance metrics. The joint scores are sorted in descending order, and the top M context feature vectors are selected as potential cluster centers. For each potential cluster center, the feature vectors of its K nearest neighbors with semantic similarity less than a threshold are grouped into the same cluster, and the average value of all context feature vectors in the cluster is calculated to obtain the cluster center, which is then used as the query vector.

[0011] Density clustering is used to screen potential centers with high local density and high separation. Then, the average value of the feature vectors within the cluster is taken to obtain the cluster center (query vector). The purpose is to generate a query that can adapt to the real-time semantic features of the input text, aggregate the core semantics of the same category and smooth local noise, and ensure the global representativeness and stability of the query. This avoids the defects of traditional learnable queries, such as overfitting and ignoring the discriminative features of the input text.

[0012] Optionally, the second embedding vector is fused with the knowledge vector to obtain a knowledge semantic vector, including: The first concatenated vector is obtained by concatenating each candidate entity vector in the candidate entity memory with the query vector. The first concatenated vector is input into two fully connected layers. After activation by the activation function, the attention weight of each candidate entity is calculated using the Softmax function. The knowledge vector is obtained by weighted summation of all the first concatenated vectors based on the attention weights. Each second embedding vector is concatenated with a knowledge vector to obtain an enhanced second embedding vector. The enhanced second embedding vector is then input into the BERT model to output a knowledge semantic vector.

[0013] The purpose of generating a query vector by weighting candidate entity embeddings and context representations through attention mechanisms to obtain a knowledge vector is to accurately filter out and integrate useful external knowledge that fits the context requirements. By concatenating the second embedding vector with the knowledge vector and inputting it into BERT to generate a knowledge semantic vector, the selected external common sense is deeply integrated into the semantics of the target statement, enriching its implicit semantic information.

[0014] Optionally, a semantic feature vector is obtained by performing preset operations on the context feature vector and the knowledge semantic vector, including: The context feature vector and knowledge semantic vector are respectively input into the fully connected layer, and the enhanced context feature vector and enhanced knowledge semantic vector are obtained by activating the tanh function respectively. The semantic matrix of the enhanced context feature vector and the enhanced knowledge semantic vector is calculated by matrix multiplication. The semantic matrix and its transpose are respectively processed by the Softmax function to output the first attention score matrix and the second attention score matrix. The first correction vector is obtained by weighting the enhanced knowledge semantic vector according to the first attention score matrix, and the first correction vector is concatenated with the enhanced context feature vector to obtain the second concatenated vector. The second correction vector is obtained by weighting the second concatenation vector according to the second attention score matrix. The second correction vector is then concatenated with the enhanced knowledge semantic vector and input into the BiLSTM module to obtain the semantic feature vector.

[0015] The semantic relevance of contextual feature vectors and knowledge semantic vectors calculated by dynamic mechanism and combined with BILSTM fusion is to deeply integrate contextual information and external common sense, and achieve bidirectional semantic complementarity.

[0016] In a second aspect of this invention, a smart tourism question-answering system based on a large language model is proposed. The system includes a preprocessing module, a filtering module, a clustering module, a fusion module, and a prediction module, wherein: The preprocessing module is used to acquire query text data input by tourists, and preprocess the query text data to obtain a first embedding vector and a second embedding vector; the first embedding vector is the embedding vector of a single word in the context text of the target statement, and the second embedding vector is the embedding vector of a single word in the target statement; the target statement is a statement that does not contain preset sentiment words; The filtering module is used to obtain a tourism knowledge graph, map each entity in the tourism knowledge graph to obtain a third embedding vector, filter the second and third embedding vectors, and construct a candidate entity memory library. The clustering module is used to extract contextual semantic features from the first embedding vector to obtain a contextual feature vector, and to perform density clustering on the contextual feature vector to generate a query vector. The fusion module is used to concatenate the candidate entity vector in the candidate entity memory with the query vector to obtain a knowledge vector, and to fuse the second embedding vector with the knowledge vector to obtain a knowledge semantic vector. The prediction module is used to perform preset operations based on the context feature vector and the knowledge semantic vector to obtain a semantic feature vector, and input the semantic feature vector into the language model to output the semantic prediction result.

[0017] Optionally, the filtering includes a mapping module and a combination module, wherein: The mapping module is used to map each entity in the knowledge graph to a low-dimensional real-valued vector through the TransE model to obtain the embedding vector of a single entity in the knowledge graph, and define it as the third embedding vector. The combination module is used to calculate the similarity between the second embedding vector and the third embedding vector, select the third embedding vector that meets the conditions as candidate entity embedding vectors based on the similarity and similarity threshold, and combine all candidate entity embedding vectors into a candidate entity memory.

[0018] Optionally, the clustering module includes a capture module, a first calculation module, a second calculation module, and a cluster generation module, wherein: The capturing module is used to capture the semantic dependencies between text and generate context feature vectors through the bidirectional attention mechanism of Transformer. The first calculation module is used to calculate the density of the K nearest neighbor features around each context feature vector and the distance index of each context feature vector; The second calculation module is used to calculate the joint score of each context feature vector based on density and distance indicators, and to sort the joint scores in descending order to select the top M context feature vectors as potential cluster centers. The clustering generation module is used to group the feature vectors with semantic similarity less than a threshold among the K nearest neighbors of each potential cluster center into the same cluster, calculate the average value of all context feature vectors in the cluster to obtain the cluster center, and use the cluster center as the query vector.

[0019] Optionally, the fusion module includes a first stitching module, a third calculation module, and an enhancement module, wherein: The first concatenation module is used to concatenate each candidate entity vector in the candidate entity memory with the query vector to obtain the first concatenation vector; The third calculation module is used to input the first concatenated vector into two fully connected layers, activate it through an activation function, calculate the attention weight of each candidate entity using the Softmax function, and obtain the knowledge vector by weighted summation of all the first concatenated vectors based on the attention weights. The enhancement module is used to concatenate each second embedding vector with a knowledge vector to obtain an enhanced second embedding vector, and input the enhanced second embedding vector into the BERT model to output a knowledge semantic vector.

[0020] Optionally, the prediction module includes an activation module, a fourth calculation module, a correction module, and a weighting module, wherein: The activation module is used to input the context feature vector and the knowledge semantic vector into the fully connected layer respectively, and obtain the enhanced context feature vector and the enhanced knowledge semantic vector by activating the tanh function respectively; The fourth calculation module is used to calculate the semantic matrix of the enhanced context feature vector and the enhanced knowledge semantic vector through matrix multiplication, and output the first attention score matrix and the second attention score matrix by passing the Softmax function through the semantic matrix and its transpose matrix respectively. The correction module is used to weight the enhanced knowledge semantic vector according to the first attention score matrix to obtain a first correction vector, and to concatenate the first correction vector with the enhanced context feature vector to obtain a second concatenation vector. The weighting module is used to weight the second concatenation vector according to the second attention score matrix to obtain the second modified vector, and then concatenate the second modified vector with the enhanced knowledge semantic vector and input it into the BiLSTM module to obtain the semantic feature vector.

[0021] The beneficial effects of this invention are: This invention proposes a smart question-answering method for tourism based on a large language model. It constructs a candidate entity memory bank through knowledge graph entity mapping and target sentence word embedding filtering, establishing a precise association between text and structured knowledge, reducing computational complexity. Features are extracted from contextual feature vectors and density clustered to generate query vectors representing the core query intent, avoiding semantic dispersion and providing clear semantic anchors for subsequent matching. The candidate entity vectors, query vectors, and second embedding vectors are fused and concatenated to enrich the depth and breadth of semantic representation, compensating for the lack of structured knowledge support in pure text semantics. This addresses the problem that existing methods struggle to utilize the common sense and contextual background information behind words, leading to low information retrieval efficiency and ambiguous responses to users. Attached Figure Description

[0022] The invention will now be further described with reference to the accompanying drawings.

[0023] Figure 1 A flowchart illustrating a smart tourism question-answering method based on a large language model, provided as an embodiment of the present invention; Figure 2 This is a data flow diagram of a smart tourism question-answering system based on a large language model, provided as an embodiment of the present invention. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and B can represent: A alone, A and B simultaneously, and B alone. Furthermore, descriptions involving "first," "second," etc., in this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" can explicitly or implicitly include at least one of those features. Additionally, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by the present invention.

[0025] Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this invention.

[0026] This invention provides a smart question-answering method for tourism based on a large language model. See also... Figure 1 , Figure 1 A flowchart illustrating a smart tourism question-answering method based on a large language model, provided as an embodiment of the present invention. The method includes the following steps: S101, Obtain the query text data input by the tourist, and preprocess the query text data to obtain the first embedding vector and the second embedding vector; S102, obtain the tourism knowledge graph, map each entity in the tourism knowledge graph to obtain the third embedding vector, filter the second embedding vector and the third embedding vector and construct the candidate entity memory library; S103, extract context semantic features from the first embedding vector to obtain a context feature vector, and perform density clustering on the context feature vector to generate a query vector; S104, concatenate the candidate entity vector in the candidate entity memory with the query vector to obtain the knowledge vector, and fuse the second embedding vector with the knowledge vector to obtain the knowledge semantic vector; S105: Based on the context feature vector and the knowledge semantic vector, perform preset operations to obtain the semantic feature vector, input the semantic feature vector into the language model, and output the semantic prediction result.

[0027] The first embedding vector is the embedding vector of a single word in the context text of the target statement, and the second embedding vector is the embedding vector of a single word in the target statement; the target statement is a statement that does not contain preset sentiment words; This invention provides a tourism-focused intelligent question-answering method based on a large language model. It constructs a candidate entity memory bank through knowledge graph entity mapping and target sentence word embedding filtering, establishing a precise association between text and structured knowledge, reducing computational complexity. It extracts features from contextual feature vectors and performs density clustering to generate query vectors representing the core query intent, avoiding semantic dispersion and providing clear semantic anchors for subsequent matching. The method merges and concatenates candidate entity vectors, query vectors, and second embedding vectors, enriching the depth and breadth of semantic representation. This compensates for the lack of structured knowledge support in pure text semantics and solves the problems of low information retrieval efficiency and ambiguous responses to users caused by existing methods' difficulty in utilizing common sense and contextual background information behind words.

[0028] In one implementation, preprocessing of the raw text data includes: After segmenting the original text data, the segmented text data is input into the ELMo context-related word embedding model. This model maps each word in the text to a low-dimensional real-valued vector, obtaining the embedding vector of a single word in the context text and the embedding vector of a single word in the target sentence. The embedding vector of a single word in the context text is defined as the first embedding vector, and the embedding vector of a single word in the target sentence is defined as the second embedding vector. Contextual text refers to the related text surrounding the target statement that provides contextual support for implicit sentiment judgment. Its function is to supplement the usage scenario of the target statement and help distinguish the emotional differences of the same target statement in different contexts. The target statement refers to a statement that does not contain explicit sentiment words (such as "good / bad / dislike / like"), but can express human-perceptible emotions. It is the core analysis object of implicit sentiment analysis. For example: statements implying negative emotions such as "How many more minutes will it take to walk from Bright Summit to Welcoming Pine?", statements implying positive emotions such as "The proportion of shady spots along this route is very high", and statements implying neutral emotions such as "Are there very few people walking this route?"

[0029] In one implementation, the third embedding vector is the embedding vector of a single entity in the tourism knowledge graph; the knowledge graph is essentially a structured common sense / background knowledge base with entity-relationship as its core, used to store and organize objectively existing concepts, things and their related information in the real world, providing common sense support beyond the literal text for implicit sentiment analysis.

[0030] In one implementation, the semantic prediction result is the user's desired intention predicted based on the user's input statement; The training process of a language model is as follows: Obtain the training dataset, input the training dataset into the preset model to train and obtain the model update parameters, and update the model parameters in the preset model according to the model update parameters to obtain the language model; Obtain the validation dataset, input the validation data into the language model to obtain the validation results, and compare the validation results with the true results; If the verification results are inconsistent with the actual results, the language model training is deemed unqualified and iterative training is re-executed until the preset conditions are met; otherwise, the language model training is deemed qualified. The verification dataset contains both verification results and actual results, and the verification data corresponds one-to-one with the actual results.

[0031] In one implementation, see [link to implementation details]. Figure 2 , Figure 2 This invention provides a data flow diagram for a smart tourism question-answering system based on a large language model. It captures multi-layered semantics of text through dual embedding preprocessing, constructs a candidate memory bank by combining knowledge graph entity mapping, retains the core information of the original text, and supplements it with structured knowledge. Contextual clustering generates accurate query vectors, and vector concatenation and fusion achieve deep coupling between text semantics and knowledge, effectively compensating for the knowledge gap in pure text processing. Through the collaborative computation of contextual features and knowledge semantics, it significantly improves the accuracy, richness, and logic of the language model's understanding of text semantics, making semantic prediction results more context-aware and supported by professional knowledge. Screening and clustering optimize data processing efficiency.

[0032] In one embodiment, the second and third embedding vectors are filtered to construct a candidate entity memory, including: By mapping each entity in the knowledge graph to a low-dimensional real-valued vector using the TransE model, the embedding vector of a single entity in the knowledge graph is obtained and defined as the third embedding vector. By calculating the similarity between the second and third embedding vectors, the third embedding vectors that meet the conditions are selected as candidate entity embedding vectors based on the similarity and similarity threshold, and all candidate entity embedding vectors are combined into a candidate entity memory.

[0033] In one implementation, the similarity calculation formula is: , This represents the t-th second embedding vector. This represents the i-th third embedding vector. The similarity is used as the threshold; if the similarity is greater than the similarity threshold, then the third embedding vector is used as the candidate entity embedding vector.

[0034] In one embodiment, density clustering of the context feature vector to generate a query vector includes: By using the bidirectional attention mechanism of Transformer, the semantic dependencies between text contexts are captured, and context feature vectors are generated. Calculate the density of the K nearest neighbor features around each context feature vector and the distance index of each context feature vector; The joint score of each context feature vector is calculated based on density and distance metrics. The joint scores are sorted in descending order, and the top M context feature vectors are selected as potential cluster centers. For each potential cluster center, the feature vectors of its K nearest neighbors with semantic similarity less than a threshold are grouped into the same cluster, and the average value of all context feature vectors in the cluster is calculated to obtain the cluster center. The cluster center is then used as the query vector.

[0035] In one implementation, the calculation process for density and distance indices is as follows:

[0036]

[0037]

[0038] in, Represents the i-th context feature vector The density, the higher the value, the more... The denser the surrounding similar features; This represents the Euclidean distance between the i-th and j-th context feature vectors; the smaller the distance, the closer the semantics. This represents the specific value of the i-th context feature vector in the r-th feature dimension, where K is a hyperparameter used to limit the range of K nearest neighbors; express The set of K-nearest neighbor feature vectors is used to control the range of density calculation; R represents the feature dimension of the context feature vector. The distance index represents the i-th context feature vector. The larger the value, the greater the semantic difference between the feature and the high-density features, and the more likely it is to be a cluster center. This indicates that if there exists a context feature vector with index j such that the subsequent conditions are true; The distance metric formula means: if there exists at least one contextual feature eigenvector... , making density Greater than the current context feature vector density If the condition is met, the distance index is calculated according to the former case; otherwise, the distance index is calculated according to the latter case.

[0039] In one implementation, a joint score for each context feature vector is calculated based on density and distance metrics, including: The distance index is normalized to obtain a normalized distance index. The normalized distance index is then weighted and summed with the density to obtain a joint score.

[0040] in, This represents the joint score of the i-th context feature vector. To avoid scale differences between distance and density metrics, a normalized distance metric is used. In one implementation, this method breaks away from the existing paradigm of relying on training sets to learn fixed query templates, shifting to input-driven dynamic query generation. Furthermore, it adapts to the irregular distribution of category features in semantic segmentation through density clustering, accurately aggregating semantically similar features without pre-setting the number of clusters. Compared to traditional K-means clustering or predefined grid queries, it more efficiently captures semantic affinity. Simultaneously, queries generated by averaging within clusters possess both semantic purity and global representativeness, adapting to query functionality requirements.

[0041] In one embodiment, fusing the second embedding vector with the knowledge vector yields a knowledge semantic vector, including: The first concatenated vector is obtained by concatenating each candidate entity vector in the candidate entity memory with the query vector. The first concatenated vector is input into two fully connected layers. After activation by the activation function, the attention weight of each candidate entity is calculated using the Softmax function. The knowledge vector is obtained by weighted summation of all the first concatenated vectors based on the attention weights. Each second embedding vector is concatenated with a knowledge vector to obtain an enhanced second embedding vector. The enhanced second embedding vector is then input into the BERT model to output a knowledge semantic vector.

[0042] In one implementation, the calculation process for attention weights and knowledge vectors is as follows:

[0043]

[0044]

[0045] in, For the i-th first concatenated vector, Let q represent the i-th candidate entity vector, and q be the query vector. This is a vector concatenation operation; This represents the attention weight of the i-th candidate entity vector. This is the weight matrix of the first fully connected layer. This is the weight matrix for the second fully connected layer; For the bias term of the first fully connected layer, This is the bias term for the second fully connected layer; Let N be the knowledge vector, and N be the total number of candidate entities.

[0046] In one implementation, the attention first scores the candidate entities, retaining only the knowledge fragments most relevant to the context to form a high-purity knowledge vector; then the attention and the target sentence embedding are input into BERT together, allowing the model to complete the cross-mapping of "external common sense × original semantics" in the self-attention layer, so that structured information such as entity relationships and attribute constraints are transformed into hidden states, filling semantic gaps.

[0047] In one implementation, compared with existing technologies, the problem of external knowledge being disconnected from the current context is solved. While further filtering noise, the introduced common sense is made more targeted, improving the accuracy of subsequent semantic understanding. This avoids the separation between knowledge vectors and target sentence semantics, allowing the target sentence representation to simultaneously cover literal meaning and common sense background, providing a better feature foundation for the subsequent fusion of knowledge semantic vectors and context.

[0048] In one embodiment, a semantic feature vector is obtained by performing preset operations based on the context feature vector and the knowledge semantic vector, including: The context feature vector and knowledge semantic vector are respectively input into the fully connected layer, and the enhanced context feature vector and enhanced knowledge semantic vector are obtained by activating the tanh function respectively. The semantic matrix of the enhanced context feature vector and the enhanced knowledge semantic vector is calculated by matrix multiplication. The semantic matrix and its transpose are respectively processed by the Softmax function to output the first attention score matrix and the second attention score matrix. The first correction vector is obtained by weighting the enhanced knowledge semantic vector according to the first attention score matrix, and the first correction vector is concatenated with the enhanced context feature vector to obtain the second concatenated vector. The second correction vector is obtained by weighting the second concatenation vector according to the second attention score matrix. The second correction vector is then concatenated with the enhanced knowledge semantic vector and input into the BiLSTM module to obtain the semantic feature vector.

[0049] In one implementation, the process of enhancing the context feature vector and knowledge semantic vector, and calculating the semantic matrix, is as follows:

[0050]

[0051]

[0052] in, and These are the context feature vector and the knowledge semantic vector after enhancing semantic representation, respectively; The weight matrix of the fully connected layer is the context feature vector. This is the bias term of the fully connected layer for the context feature vector; The weight matrix of the fully connected layer for the knowledge semantic vector. The bias term of the fully connected layer of the knowledge semantic vector; L is the semantic matrix.

[0053] In one implementation, the attention score and correction vector are calculated as follows:

[0054]

[0055]

[0056]

[0057] in, and These are the first attention score matrix and the first attention score matrix, respectively; and These are the first correction vector and the second correction vector, respectively.

[0058] One implementation breaks through the limitations of the separation between context and knowledge in traditional fusion methods, making features more aligned with the needs of implicit sentiment inference and further improving the accuracy of sentiment analysis.

[0059] The foregoing has described one embodiment of the present invention in detail, but this content is merely a preferred embodiment and should not be considered as limiting the scope of the present invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the scope of the claims of this invention.

Claims

1. A smart question-answering method for tourism based on a large language model, characterized in that, The method includes: The query text data input by the visitor is obtained, and the query text data is preprocessed to obtain a first embedding vector and a second embedding vector; the first embedding vector is the embedding vector of a single word in the context text of the target statement, and the second embedding vector is the embedding vector of a single word in the target statement; the target statement is a statement that does not contain preset sentiment words; Obtain the tourism knowledge graph, map each entity in the tourism knowledge graph to obtain the third embedding vector, filter the second and third embedding vectors and construct a candidate entity memory library; A context feature vector is obtained by extracting context semantic features from the first embedding vector, and a query vector is generated by density clustering of the context feature vector. The candidate entity vector in the candidate entity memory is concatenated with the query vector to obtain the knowledge vector, and the second embedding vector is fused with the knowledge vector to obtain the knowledge semantic vector; Based on the context feature vector and the knowledge semantic vector, a semantic feature vector is obtained by performing preset operations. The semantic feature vector is then input into the language model to output the semantic prediction result.

2. The intelligent question-answering method for tourism based on a large language model according to claim 1, characterized in that, The second and third embedding vectors are filtered to construct a candidate entity memory bank, including: By mapping each entity in the knowledge graph to a low-dimensional real-valued vector using the TransE model, the embedding vector of a single entity in the knowledge graph is obtained and defined as the third embedding vector. By calculating the similarity between the second and third embedding vectors, the third embedding vectors that meet the conditions are selected as candidate entity embedding vectors based on the similarity and similarity threshold, and all candidate entity embedding vectors are combined into a candidate entity memory.

3. The intelligent question-answering method for tourism based on a large language model according to claim 1, characterized in that, The process of generating a query vector by performing density clustering on the context feature vector includes: By using the bidirectional attention mechanism of Transformer, the semantic dependencies between text contexts are captured, and context feature vectors are generated. Calculate the density of the K nearest neighbor features around each context feature vector and the distance index of each context feature vector; The joint score of each context feature vector is calculated based on density and distance metrics. The joint scores are sorted in descending order, and the top M context feature vectors are selected as potential cluster centers. For each potential cluster center, the feature vectors of its K nearest neighbors with semantic similarity less than a threshold are grouped into the same cluster, and the average value of all context feature vectors in the cluster is calculated to obtain the cluster center, which is then used as the query vector.

4. The intelligent question-answering method for tourism based on a large language model according to claim 1, characterized in that, The knowledge semantic vector is obtained by fusing the second embedding vector with the knowledge vector, including: The first concatenated vector is obtained by concatenating each candidate entity vector in the candidate entity memory with the query vector. The first concatenated vector is input into two fully connected layers. After activation by the activation function, the attention weight of each candidate entity is calculated using the Softmax function. The knowledge vector is obtained by weighted summation of all the first concatenated vectors based on the attention weights. Each second embedding vector is concatenated with a knowledge vector to obtain an enhanced second embedding vector. The enhanced second embedding vector is then input into the BERT model to output a knowledge semantic vector.

5. The intelligent question-answering method for tourism based on a large language model according to claim 1, characterized in that, The semantic feature vector is obtained by performing pre-defined operations on the context feature vector and the knowledge semantic vector, including: The context feature vector and knowledge semantic vector are respectively input into the fully connected layer, and the enhanced context feature vector and enhanced knowledge semantic vector are obtained by activating the tanh function respectively. The semantic matrix of the enhanced context feature vector and the enhanced knowledge semantic vector is calculated by matrix multiplication. The semantic matrix and its transpose are respectively processed by the Softmax function to output the first attention score matrix and the second attention score matrix. The first correction vector is obtained by weighting the enhanced knowledge semantic vector according to the first attention score matrix, and the first correction vector is concatenated with the enhanced context feature vector to obtain the second concatenated vector. The second correction vector is obtained by weighting the second concatenation vector according to the second attention score matrix. The second correction vector is then concatenated with the enhanced knowledge semantic vector and input into the BiLSTM module to obtain the semantic feature vector.

6. A smart tourism question-answering system based on a large language model, characterized in that, The system includes a preprocessing module, a filtering module, a clustering module, a fusion module, and a prediction module, wherein: The preprocessing module is used to acquire query text data input by tourists, and preprocess the query text data to obtain a first embedding vector and a second embedding vector; the first embedding vector is the embedding vector of a single word in the context text of the target statement, and the second embedding vector is the embedding vector of a single word in the target statement; the target statement is a statement that does not contain preset sentiment words; The filtering module is used to obtain a tourism knowledge graph, map each entity in the tourism knowledge graph to obtain a third embedding vector, filter the second and third embedding vectors, and construct a candidate entity memory library. The clustering module is used to extract contextual semantic features from the first embedding vector to obtain a contextual feature vector, and to perform density clustering on the contextual feature vector to generate a query vector. The fusion module is used to concatenate the candidate entity vector in the candidate entity memory with the query vector to obtain a knowledge vector, and to fuse the second embedding vector with the knowledge vector to obtain a knowledge semantic vector. The prediction module is used to perform preset operations based on the context feature vector and the knowledge semantic vector to obtain a semantic feature vector, and input the semantic feature vector into the language model to output the semantic prediction result.

7. A smart tourism question-answering system based on a large language model according to claim 6, characterized in that, The filtering includes a mapping module and a combination module, wherein: The mapping module is used to map each entity in the knowledge graph to a low-dimensional real-valued vector through the TransE model to obtain the embedding vector of a single entity in the knowledge graph, and define it as the third embedding vector. The combination module is used to calculate the similarity between the second embedding vector and the third embedding vector, select the third embedding vector that meets the conditions as candidate entity embedding vectors based on the similarity and similarity threshold, and combine all candidate entity embedding vectors into a candidate entity memory.

8. A smart tourism question-answering system based on a large language model according to claim 6, characterized in that, The clustering module includes a capture module, a first calculation module, a second calculation module, and a cluster generation module, wherein: The capturing module is used to capture the semantic dependencies between text and generate context feature vectors through the bidirectional attention mechanism of Transformer. The first calculation module is used to calculate the density of the K nearest neighbor features around each context feature vector and the distance index of each context feature vector; The second calculation module is used to calculate the joint score of each context feature vector based on density and distance indicators, and to sort the joint scores in descending order to select the top M context feature vectors as potential cluster centers. The clustering generation module is used to group the feature vectors with semantic similarity less than a threshold among the K nearest neighbors of each potential cluster center into the same cluster, calculate the average value of all context feature vectors in the cluster to obtain the cluster center, and use the cluster center as the query vector.

9. A smart tourism question-answering system based on a large language model according to claim 6, characterized in that, The fusion module includes a first stitching module, a third calculation module, and an enhancement module, wherein: The first concatenation module is used to concatenate each candidate entity vector in the candidate entity memory with the query vector to obtain the first concatenation vector; The third calculation module is used to input the first concatenated vector into two fully connected layers, activate it through an activation function, calculate the attention weight of each candidate entity using the Softmax function, and obtain the knowledge vector by weighted summation of all the first concatenated vectors based on the attention weights. The enhancement module is used to concatenate each second embedding vector with a knowledge vector to obtain an enhanced second embedding vector, and input the enhanced second embedding vector into the BERT model to output a knowledge semantic vector.

10. A smart tourism question-answering system based on a large language model according to claim 6, characterized in that, The prediction module includes an activation module, a fourth calculation module, a correction module, and a weighting module, wherein: The activation module is used to input the context feature vector and the knowledge semantic vector into the fully connected layer respectively, and obtain the enhanced context feature vector and the enhanced knowledge semantic vector by activating the tanh function respectively; The fourth calculation module is used to calculate the semantic matrix of the enhanced context feature vector and the enhanced knowledge semantic vector through matrix multiplication, and output the first attention score matrix and the second attention score matrix by passing the Softmax function through the semantic matrix and its transpose matrix respectively. The correction module is used to weight the enhanced knowledge semantic vector according to the first attention score matrix to obtain a first correction vector, and to concatenate the first correction vector with the enhanced context feature vector to obtain a second concatenation vector. The weighting module is used to weight the second concatenation vector according to the second attention score matrix to obtain the second modified vector, and then concatenate the second modified vector with the enhanced knowledge semantic vector and input it into the BiLSTM module to obtain the semantic feature vector.

Citation Information

Patent Citations

  • Question and answer method and device based on large language model

    CN119621902A