Urban greenway tourist emotion analysis method based on large language model

Through the DeepSeek model combined with the SEER emotion recognition model, the efficient real-time problem of greenway tourists' sentiment analysis is solved, and sentiment analysis with high accuracy and high throughput is achieved, which is suitable for real-time sentiment analysis of greenway scenes.

CN120470123APending Publication Date: 2025-08-12INST OF URBAN ENVIRONMENT CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510617165.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

The existing technology lacks efficient emotion analysis methods in greenway scenarios, especially methods based on large language models, which are difficult to adapt to the emotional changes of greenway tourists, and their computing resources are consumed, making it difficult to process massive social media data in real time.

Method used

The DeepSeek model is used to combine the SEER emotion recognition model, and through data collection and preprocessing, API calls, and emotion classification and calculation, a dynamic instruction template is constructed to realize sentiment analysis, including regularization processing, attention calculation, probability normalization and generation control, supporting real-time sentiment analysis.

Benefits of technology

It realizes efficient sentiment analysis, with an accuracy rate of 93%, throughput of 1200 docs/sec, end-to-end delay ≤2.3s, and supports real-time sentiment analysis of greenway scenes, improving the accuracy and efficiency of emotion classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470123A_ABST
    Figure CN120470123A_ABST
Patent Text Reader

Abstract

The invention discloses an urban greenway tourist emotion analysis method based on a large language model, and belongs to the technical field of natural language processing. The method comprises the following steps: step 1, acquiring emotional data of visitors visiting greenways and preprocessing the emotional data; 2, calling a DeepSeek model by using a dialogue completion function through an API interface of a third-party hosting platform, and requesting APIs in batches to execute sentiment analysis; and step 3, constructing a dynamic instruction template, combining an SEER emotion recognition model, carrying out emotion classification and calculation on the preprocessed emotional data of visitors visiting greenways, and outputting probability distribution of emotional polarity and fine-grained emotion tags. According to the method, directional optimization is performed on the DeepSeek model, and the sentiment analysis method is further optimized by using the dynamic cue words suitable for tourists to visit greenway scenes, so that the analysis efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of natural language processing, and in particular relates to a method for analyzing the sentiment of urban greenway tourists based on a large language model. Background Art

[0002] Text mining and sentiment analysis methods can be categorized into three types: rule-based, machine learning, and deep learning. Both rule-based and large language model methods are readily available tools. Rule-based methods include sentiment lexicons and text mining toolkits. Common machine learning methods include Naive Bayes and Maximum Entropy algorithms. Deep learning methods include the BERT model, Long Short-Term Memory (LSTM), XLNet, and large language models.

[0003] Rule-based methods rely on manually constructed sentiment lexicons, resulting in poor generalization and difficulty adapting to new online words and changing contexts. Some sentiments require manual annotation. Machine learning-based methods require manual feature design (e.g., word frequency and syntactic structure), resulting in low coverage of specific keywords in greenway scenarios (e.g., "shade" and "humidity"). Deep learning-based methods require fine-tuning for specific domains and consume significant computing resources, making them difficult to process massive amounts of social media data in real time.

[0004] In recent years, large language models have made significant progress in natural language processing. They are the most accurate tools among all automated programs capable of sentiment analysis, outperforming traditional lexicon methods and deep learning models in sentiment classification tasks. Despite the significant progress of large language models in natural language processing, there is still a lack of corpus to analyze the emotional changes of tourists visiting greenways. Therefore, a new sentiment analysis method is needed to address this shortcoming. Summary of the Invention

[0005] To address the above technical problems, this paper proposes a sentiment analysis method for urban greenway visitors based on a large language model. The DeepSeek model is used to perform sentiment classification and sentiment calculation tasks, achieving a data loading throughput ≥ 1200 docs / sec, end-to-end latency ≤ 2.3s (p95), and an abnormal interruption rate < 0.07%.

[0006] To achieve the above object, the present invention adopts the following technical solutions:

[0007] A method for analyzing the sentiment of urban greenway tourists based on a large language model includes the following steps:

[0008] Step 1: Data collection and preprocessing: Use crawler tools to collect sentiment data of tourists visiting the greenway from social media, and apply regularization to preprocess the data;

[0009] Step 2: API call: Use the third-party hosting platform's API interface, use the conversation completion function, call the DeepSeek model, and make batch API requests to perform sentiment analysis.

[0010] Step 3: Emotion classification and calculation: Build a dynamic instruction template, combine it with the SEER emotion recognition model, classify and calculate the preprocessed data, and output the probability distribution of emotion polarity and fine-grained emotion labels.

[0011] Furthermore, the regularization processing includes denoising, word segmentation and stop removal, and the cleaned text is converted into JSON format for storage.

[0012] Furthermore, the API call in step 2 automatically reads the stored JSON file through Python's json library script during the data loading phase; automatically traverses the data list during the model calling phase, and batch requests the API to perform sentiment analysis; during the result parsing phase, the JSON parsing library is used to directly extract the probability value corresponding to each predefined sentiment category. The probability value represents the possibility of the input sentence being judged as a specific sentiment category (such as positive, neutral, negative), and is used to achieve quantitative analysis of the sentence sentiment.

[0013] Furthermore, the SEER emotion recognition model in step 3 includes an attention calculation module, a probability normalization module, a generation control module, and an emotion quantification module.

[0014] Furthermore, the attention calculation module adopts an improved multi-head attention mechanism, and the attention weight calculation is realized through the scaled dot product operation. After the attention calculation module performs context association analysis on the input JSON format text data, it generates an intermediate feature vector with semantic representation ability. The intermediate feature vector is transmitted to the probability normalization module through the residual connection function for numerical regularization processing; the probability normalization module adds a maximum value shift step before the traditional Softmax function, and calculates the probability with Softmax by adjusting the numerical distribution of the neural network output to obtain the possibility of the text belonging to different emotion categories (such as positive, neutral, and negative).

[0015] Furthermore, the generation control module is used to optimize the probability distribution of emotion categories to generate a final probability distribution, and a mixed sampling strategy is used to generate diversified sentiment analysis texts, which includes temperature parameter adjustment, Top-k truncation and Top-p kernel sampling; the sentiment quantification module is used to perform sentiment classification, and the possibility of the text belonging to a specific emotion category (such as positive, neutral, negative) is judged based on the final probability distribution, and the sentiment polarity and fine-grained sentiment labels are output.

[0016] Furthermore, the Top-k truncation and Top-p kernel sampling are used as two parallel paths to screen high-probability candidate words and reduce the probability of repeated words, respectively. The results of the two paths are output and weighted summed to obtain the final probability distribution.

[0017] The beneficial effects of the present invention are:

[0018] 1. Improved accuracy: DeepSeek-V3 achieves 93% accuracy in sentiment classification for greenway scenes (compared to BERT’s 86%).

[0019] 2. It is real-time, supporting a throughput of 1200 docs / sec and an end-to-end latency of ≤2.3s (p95), meeting the needs of real-time analysis of social media data streams.

[0020] 3. Scenario adaptation: Through dynamic prompt words, the general model is optimized into a sentiment analysis tool for the greenway vertical field.

[0021] The present invention can be applied to fields such as tourist greenway tour experience evaluation and tourism product development. By comparing the differences in emotion scores of different scenarios, an optimization strategy for greenway planning can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] To further illustrate various embodiments, the present invention provides accompanying drawings. These drawings form part of the present disclosure and are primarily used to illustrate the embodiments and, in conjunction with the relevant description in the specification, to explain the operating principles of the embodiments. By referring to these drawings, those skilled in the art will be able to understand other possible implementations and the advantages of the present invention.

[0023] Figure 1 This is a logic flow chart of a method for analyzing the sentiment of urban greenway tourists based on a large language model according to the present invention;

[0024] Figure 2 This is a data processing flow chart of the SEER emotion recognition model of the present invention. DETAILED DESCRIPTION

[0025] The present invention will be further described below with reference to the accompanying drawings and examples.

[0026] like Figure 1 FIG. 1 is a logic flow chart of a method for analyzing the sentiment of urban greenway tourists based on a large language model according to the present invention, which specifically includes the following steps:

[0027] Step 1: Data Collection and Preprocessing. Greenway tour-related text was collected from social media platforms (such as Weibo) and then regularized. Regularization included: denoising, using regular expressions to remove advertisements, web links, usernames, phone models, and hashtags; word segmentation and stop-word removal, using the "Jieba" word segmentation tool, following the "Specifications for Limited Chinese Word Segmentation for Information Processing" for semantic segmentation, and using a stop-word list to filter out irrelevant words such as degree adverbs and function words; and structured storage: the cleaned text was converted to JSON format for storage.

[0028] Step 2: API Call. Using the dialogue completion feature through the API of a third-party hosting platform (Silicon Flow), the DeepSeek v3 model is retrieved to perform sentiment classification and sentiment calculation tasks. End-to-end automation is achieved through a program. During the data loading phase, a Python json library script automatically reads JSON files stored in the cloud. During the model call phase, the program automatically iterates through the data list and makes batch API (application programming interface) requests to perform sentiment analysis. During the result parsing phase, a JSON parsing library is used to extract sentiment scores. These scores represent the probability values corresponding to each predefined sentiment category. These probability values represent the likelihood that the input sentence will be classified as belonging to a specific sentiment category (e.g., positive, neutral, negative), and are used to quantitatively analyze the sentence sentiment.

[0029] The score returned by the API interface is the probability value of the sentiment category to which the sentence belongs.

[0030] Step 3: Emotion classification and calculation. Build a dynamic instruction template and combine it with the SEER emotion recognition model (Sentiment-Emotion Encoder-Reader) to generate a structured prompt based on the input text features. The input format is the JSON format text collected in step 1. The prompt template example is:

[0031] json

[0032] {

[0033] "text": "The temperature in Xiamen isn't high, but it's really hard to get out in the sun without sunscreen.",

[0034] "instruction": "Analyze the sentiment score of this sentence and return a value between (0,1). Output anger score: sadness score: joy score: surprise score: disgust score: fear score."

[0035] }

[0036] like Figure 2As shown in the figure, the SEER emotion recognition model consists of four cascaded network modules: attention calculation module → probability normalization module → generation control module → emotion quantification module. Each module transfers parameters through the intermediate feature vector h∈R^d and probability distribution P∈R^C, forming an end-to-end emotion analysis pipeline.

[0037] The attention calculation module uses an improved multi-head attention mechanism. The calculation of attention weights is achieved through scaled dot product operations, effectively alleviating the vanishing gradient problem and improving computational efficiency by approximately 62% compared to traditional recurrent neural networks. The attention calculation module performs contextual analysis on the JSON-formatted text data collected in step 1, generating an intermediate feature vector with semantic representation capabilities. This intermediate feature vector is then transmitted to the probability normalization module via a residual connection channel for numerical regularization.

[0038] The probability normalization module converts the intermediate feature vector into the probability distribution of the emotion category based on the improved softmax function with maximum shift.

[0039] The generation control module is used to optimize the probability distribution of emotion categories. A hybrid sampling strategy is used to generate diversified sentiment analysis texts, which includes temperature parameter adjustment, Top-k truncation and Top-p kernel sampling. The temperature coefficient τ is set to 0.6, and the maximum generation length is set to 512 tokens to ensure output stability. A dual-path processing architecture is set. Path 1 uses `top_p=0.7` to limit the cumulative distribution range of candidate word probabilities, screen high-probability candidate words, and enhance the relevance of the generated diversified sentiment analysis texts. Path 2 applies `frequency_penalty=0.5` to reduce the probability of repeated words, dynamically adjust the word list size, and improve the diversity of sentiment analysis text generation. The results of the two paths are output and the final probability distribution is obtained through weighted summation.

[0040] A two-tiered exception handling mechanism, combining format checking and data repair, is also designed. This includes validation of API return data and a default value fallback strategy. If the API doesn't return a field, the code assigns a default value of 0, which can be considered a data interpolation strategy for exception handling. For API request failures or data parsing errors, the `Error` field is marked to ensure data integrity.

[0041] The emotion quantification module performs emotion classification, predicting emotion categories based on the final probability distribution and outputting emotion polarity (positive, neutral, negative) and fine-grained emotion labels (six categories, including anger and happiness). Sentences containing six emotions are extracted, and the average score for each emotion is calculated to analyze the emotional impact of different scenarios on tourists.

[0042] This invention optimizes sentiment analysis by performing targeted optimization on the DeepSeek model and using dynamic prompt words suitable for tourists visiting greenways. It can not only accurately analyze tourists' emotions, but also generate detailed sentiment scores (such as anger, sadness, joy, etc.). It supports processing more than 1,200 text data per second, with latency controlled within 2.3 seconds, ensuring efficient and real-time sentiment analysis.

[0043] Leveraging an efficient API calling mechanism, this method can meet the real-time analysis needs of social media platform data streams, maximizing the use of computing resources. Based on the DeepSeek-V3 model, sentiment classification accuracy reaches 93%, a significant improvement over the 86% accuracy of the traditional BERT model. This method is particularly effective in greenway sentiment classification, accurately identifying visitors' emotional preferences. By adapting templated instructions to different text inputs, the standardization of API return data is improved. Compared to traditional fixed template methods, this solution improves the standardization of API return data by approximately 41%.

[0044] A two-stage error interception design establishes a two-tiered exception handling mechanism for format checking and data repair. Robustness design: Combining default value assignment with an exception handling mechanism ensures process stability even when some data is missing. Primary validation verifies HTTP status codes and JSON format integrity, while secondary validation injects default values for missing fields. An automated pipeline design implements an end-to-end automated analysis pipeline, encompassing data loading, model inference, and persistent storage of results, reducing manual intervention. This achieves data loading throughput ≥ 1200 docs / sec, end-to-end latency ≤ 2.3s (p95), and an abnormal interruption rate < 0.07%.

[0045] The present invention provides a sentiment analysis method for urban greenway tourists based on a large language model. The method utilizes the DeepSeek model for sentiment classification and sentiment calculation, which can effectively address the shortcomings of traditional methods, improve the accuracy and efficiency of sentiment analysis, and has broad application prospects.

[0046] The present invention provides an electronic device, comprising: a memory and a processor; the memory is used to store executable instructions; the processor is used to implement the urban greenway visitor sentiment analysis method based on a large language model as described in any one of claims 1 to 9 when executing the executable instructions.

[0047] The present invention provides a computer-readable storage medium having executable instructions thereon. When the instructions are executed by a processor, the processor can implement the method for analyzing the sentiment of urban greenway tourists based on a large language model as described in any one of claims 1 to 9.

[0048] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific embodiments of the present invention and do not limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A sentiment analysis method for urban greenway tourists based on a large language model, characterized by: The following steps are involved: Step 1: Collect sentiment data of tourists visiting the greenway from social media using crawler tools and preprocess the data using regularization. Step 2: Use the conversation completion function through the API interface of the third-party hosting platform to call the DeepSeek model and make batch requests to the API to perform sentiment analysis; Step 3: Build a dynamic instruction template, combine it with the SEER emotion recognition model, classify and calculate the preprocessed data, and output the probability distribution of emotion polarity and fine-grained emotion labels.

2. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 1 is characterized in that: The regularization process in step 1 includes the following steps: denoising, word segmentation, and stop removal, and the cleaned text is converted into JSON format for storage.

3. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 1 is characterized in that: The batch request API execution sentiment analysis in step 2 includes the following steps: Step 2.1: During the data loading phase, the stored JSON file is automatically read by the Python json library script; Step 2.2: During the model call phase, automatically traverse the data list and make batch requests to the API. Step 2.3: During the result parsing phase, use the JSON parsing library to directly extract the probability values corresponding to each predefined sentiment category. This probability value represents the likelihood that the input sentence will be judged as belonging to a specific sentiment category and is used to achieve quantitative analysis of the sentence sentiment.

4. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 1 is characterized in that: In step 3, the SEER emotion recognition model includes an attention calculation module, a probability normalization module, a generation control module, and an emotion quantification module.

5. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 4 is characterized in that: The attention calculation module adopts an improved multi-head attention mechanism, and the attention weight calculation is realized through the scaled dot product operation. After the attention calculation module performs context association analysis on the input JSON format text data, it generates an intermediate feature vector with semantic representation capability. The intermediate feature vector is transmitted to the probability normalization module through the residual connection function for numerical regularization processing.

6. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 4 is characterized in that: The probability normalization module adds a maximum shift step before the traditional Softmax function. By adjusting the numerical distribution of the neural network output and calculating the probability with Softmax, the possibility of the text belonging to a specific emotion category is obtained.

7. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 4 is characterized in that: After optimizing the probability distribution of emotion categories using the generation control module, a hybrid sampling strategy combining temperature parameter adjustment, Top-k truncation, and Top-p kernel sampling techniques is adopted to regulate the generation process of sentiment analysis text.

8. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 4 is characterized in that: The sentiment quantification module is used to perform sentiment classification, and the possibility of the text belonging to a specific sentiment category is judged according to the final probability distribution, and the sentiment polarity and fine-grained sentiment labels are output.

9. The method for analyzing the sentiment of urban greenway tourists based on a large language model according to claim 7 is characterized in that: The Top-k truncation and Top-p kernel sampling are used as two parallel paths to screen high-probability candidate words and reduce the probability of repeated words respectively. The operation results of the two paths are output and weighted summed to obtain the final probability distribution.

10. An electronic device, characterized in that: It includes a memory and a processor, the memory is used to store executable instructions; the processor is used to implement the urban greenway tourist sentiment analysis method based on a large language model as described in any one of claims 1 to 9 when executing the executable instructions.

11. A computer-readable storage medium, characterized in that: The storage medium contains executable instructions, which, when executed by the processor, enable the processor to implement the urban greenway visitor sentiment analysis method based on a large language model as described in any one of claims 1 to 9.