A multi-level social media review data structuring processing method based on a large language model (LLM)
Patent Information
- Application Number
- CN202610996166.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-06
- Publication Date
- 2026-09-18
AI Technical Summary
本发明旨在提供一种基于大语言模型(LLM)的多层级社交媒体评论数据结构化处理方法,以解决现有技术中未保留评论层级结构、未多维结构化分析入库、标签体系不可动态扩展、批量分析任务调度能力不足等技术问题
1. 将具有父子回复关系的评论构建为评论树,并以评论树而非单条评论为分析单元,保留了评论间的对话语境,使大语言模型能够理解讨论的完整语义,有助于提高分析结果的准确率;
Smart Images

Figure CN122777631A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing and computer application technology, and particularly relates to a method for automating the processing of comment data with hierarchical response relationships through comment tree construction, large language model (LLM) analysis, structured storage, and batch management mechanisms. Background Technology
[0002] With the continuous growth of user-generated content on social media platforms, comment data contains a wealth of information related to product usage experience, feature requirements, consumption preferences, and negative feedback. Extracting structured analysis results from this vast amount of comments is a crucial issue in data processing. Meanwhile, the development of large language models has demonstrated powerful capabilities in text understanding, information extraction, and natural language generation.
[0003] However, the existing technical solutions have the following main shortcomings: (i) The analysis focuses on individual comments without preserving the hierarchical relationship between replies, resulting in a fragmented discussion context, information loss, and insufficient accuracy of the analysis results; (ii) The results of Large Language Model (LLM) analysis are mostly in the form of one-time text reports, without forming multi-dimensional structured analysis or unstructured data storage, resulting in insufficient utilization efficiency of the results; (iii) Solutions based on traditional NLP (such as BiLSTM-CRF) require a large amount of labeled data for model training, resulting in high deployment costs and difficulty in quickly adapting to changes in the labeling system. (iv) When using Large Language Models (LLM) for large-scale data analysis, the lack of a batch management mechanism can easily lead to wasted model calls; (v) There is a lack of dedicated data models for brand and OEM scenarios, which cannot support cross-analysis across multiple categories, brands, and functions, nor can it quantify and evaluate the opportunity value at the post level; Summary of the Invention
[0004] The technical problem to be solved by the present invention This invention aims to provide a method for structuring multi-level social media comment data based on Large Language Model (LLM) to solve technical problems in existing technologies such as failure to retain comment hierarchy, lack of multi-dimensional structured analysis and data storage, inability to dynamically expand tag systems, and insufficient batch analysis task scheduling capabilities.
[0005] Technical solution A method for structuring multi-level social media comment data based on Large Language Model (LLM) includes the following steps: S1. Data Acquisition Steps: Receive social media comment collection data, which includes at least the following fields: post identifier field, post title field, post body field, comment identifier field, parent comment identifier field, comment text field, user identifier field, and comment time field; parse the social media comment collection data and write it into the business database, and create corresponding batch records; S2. Preprocessing step: Perform noise filtering on the comment data to filter out comment records that meet the preset invalid conditions; S3. Comment tree construction steps: Taking the same post as the scope, construct a comment tree according to the correspondence between the comment identifier field and the parent comment identifier field; wherein, the comments whose parent comment identifier is empty or points to the current comment identifier are determined as the root node, and child comment nodes are recursively attached from the root node to obtain a multi-level multi-branch comment tree structure; the comment tree structure is serialized and stored, and the maximum nesting depth and the total number of nodes of the comment tree are recorded; S4. Analysis Steps: Using the comment tree as the smallest analysis unit, read the title information, body information, and comment tree structure data of the corresponding posts in the comment tree to assemble the analysis payload; read the currently active Prompt template from the configuration storage; before each call to the large language model interface, read the current tag list from the tag definition storage in real time, and replace the tag library placeholders in the Prompt template with the current tag list to generate the target Prompt; send the analysis payload and the target Prompt to the large language model interface to obtain multi-dimensional structured analysis results; S5. Structured storage step: Write the multi-dimensional structured analysis results into the analysis result table in the business database, and establish a one-to-one association between the comment tree records and the analysis result records; establish a many-to-many association between the tag data in the multi-dimensional structured analysis results and the comment tree tag association table; The method also includes a batch status management mechanism: batch records have eight statuses: pending, importing, imported, tree built, analyzing, paused, completed, and failed; when a pause command is received, a pause flag is set and the batch status is switched to paused after the currently issued comment tree analysis task is completed; when a resume command is received, analysis is only performed on comment trees with an analysis status of pending or failed, and comment trees that have successfully completed analysis are not analyzed again.
[0006] Beneficial effects Compared with the prior art, the present invention has the following beneficial effects: 1. Comments with parent-child reply relationships are constructed as comment trees, and the comment tree, rather than individual comments, is used as the unit of analysis. This preserves the dialogue context between comments, enabling the large language model to understand the complete semantics of the discussion and helping to improve the accuracy of the analysis results. 2. By dynamically reading the label definition data and replacing the label library placeholders in the Prompt template before analysis, multidimensional structured analysis results can be obtained, and the label system can be adapted to changes without modifying the program code; 3. The batch status management mechanism can improve the schedulability of batch comment tree analysis tasks and reduce resource waste caused by repeated calls to model interfaces; 4. By performing unified structured storage and post-level aggregation processing on the comment tree analysis results, the efficiency of subsequent retrieval, statistics, and result reuse can be improved. Attached Figure Description
[0007] Figure 1 This is an overall flowchart of the method of the present invention; Figure 2 This is a schematic diagram of the comment tree construction algorithm of the present invention; Figure 3 This is a schematic diagram of the data flow for large language model analysis in this invention; Figure 4 This is a schematic diagram of batch state transition in this invention; Figure 5 This is a schematic diagram illustrating the post-level opportunity score calculation method of the present invention. Detailed Implementation The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments described herein are for illustration and explanation only and are not intended to limit the scope of this application. [Example 1: Basic Process Implementation] Step S1: Data Acquisition The system receives social media comment data. This comment data can be imported from a file (Excel or CSV format) or input via a data interface. The comment data includes at least the following fields: post identifier, post title, post body, comment identifier, parent comment identifier, comment text, user identifier, and comment time. The system parses the received data, identifies the field mapping relationship, writes the post data into the post table of the business database, writes the comment data into the original comment table, and creates an upload batch record. The initial status of the batch record is "pending processing". Step S2: Comment Preprocessing The system performs dual-mode noise filtering on the original comments. Forced filtering modes (always executed) include: (1) Pure symbol comment filtering: The number of valid Chinese characters matched by regular expression is filtered if the number is less than the preset threshold (default value is 2); (2) Verbal filter: Comments that match the preset invalid comment word list are filtered. The preset invalid comment word list includes, but is not limited to, single words or meaningless verbal tics such as "666", "received", "okay", "+1". Optional filtering modes (which users can choose to enable during upload) include: (3) Advertising water filtering: Filter comments containing e-commerce link keywords or account identifier formats; (4) Duplicate comment filtering: Duplicate comments that are exactly the same as the processed comment text after removing whitespace are filtered out. Step S3: Comment Tree Construction After the data import is complete, the system executes a comment tree construction algorithm on all valid comments under the same post, such as... Figure 2 As shown. The system first establishes a mapping relationship between "comment identifier and comment node object", generates a node object for each valid comment record, and then constructs the comment tree according to the following steps: (1) Identify the root node: The comment whose parent comment identifier is empty or points to the current comment identifier is the root node, that is, the first-level comment; (2) Recursive mounting: Starting from each root node, find comments whose parent comment identifier is equal to the current node's comment identifier as child nodes, and recursively execute until there are no child nodes, forming a multi-level multi-branch comment tree structure; (3) Serialization storage: Serialize each comment tree into JSON format and store it in the tree structure JSON field of the comment tree table, while recording the maximum nesting depth and the total number of nodes; (4) Each comment tree corresponds to one comment tree record, and the initial analysis status is "pending processing". Step S4: Large Language Model Analysis The system reads the currently active large language model configuration and Prompt template from the configuration storage, initiates a concurrent execution mechanism (the concurrency level is controlled by configurable parameters, ranging from 1 to 12), and concurrently performs large language model analysis on all pending comment trees within the batch, such as... Figure 3 As shown. For each comment tree, perform the following operations: (1) Assemble the analysis payload: Read the tree structure JSON data of the tree and the title field value and body field value of the post to which it belongs, and assemble it into an analysis payload object containing three fields: post title, post body, and comment tree JSON; (2) Dynamic Prompt Assembly: Read the active Prompt template in the configuration storage. Before calling the large language model interface, query the current tag list in real time from the tag definition storage, replace the tag library placeholder (i.e., "__TAG_LIBRARY__") in the Prompt template with the current tag list, and generate the target Prompt. This dynamic replacement mechanism ensures that the tag system used in each analysis is always consistent with the current state in the tag definition storage. (3) Call the large language model: Send the analysis payload and target prompt to the large language model interface through the Chat Completions compatible interface, and request the return of structured analysis results in JSON format; (4) Results parsing and storage: Parse the JSON returned by the large language model and extract structured analysis results containing at least the following ten dimensions: brand tags, category tags, efficacy tags, emotional polarity, usage scenario tags, user demand tags, audience signal tags, topic keywords, topic summary, and complaint summary; write the analysis results into the analysis results table, establish a many-to-many relationship between each dimension tag and the tag definition table, and update the analysis status of the comment tree record to "completed"; (5) Failure handling: If the large language model call returns an error due to interface timeout, network abnormality or other reasons, the system will update the analysis status of the comment tree to "failed", record the reason for failure (e.g. "API timeout: 30s exceeded"), and continue to execute the analysis of other pending comment trees in the batch without affecting the normal progress of other comment tree analysis tasks. Rule Analysis Backup Mode: When the user selects the rule analysis only mode, the system does not call the large language model interface. Instead, it performs sentiment polarity determination based on the sentiment dictionary and brand and category identification based on the pre-built brand and category thesaurus. The source marker field in the analysis result record is marked as the source of the rule analysis. The large language model analysis mode and the rule analysis backup mode can be switched independently at the batch level. Single Tree Reanalysis: For comment trees that have been analyzed, reanalysis can be triggered individually. During reanalysis, the system reads the currently active Prompt template from the configuration storage, reads the current tag list from the tag definition storage in real time and performs placeholder replacement, generates the target Prompt and then re-executes the analysis operations (1) to (4) above; the new analysis results overwrite the original analysis results, and the source tag field and analysis time field are updated at the same time. Step S5: Structured Storage The system persists the analysis results to the business database according to a predefined data table structure. A one-to-one relationship is established between the analysis results table and the comment tree table; a many-to-many relationship is established between the comment tree table and the tag definition table through the comment tree tag association table. In one implementation, the analysis results record can save information such as structured field values, original returned content, source markers (large language model analysis / rule analysis / reanalysis), and analysis time, supporting subsequent result traceability and quality auditing. Post-level aggregation and opportunity rating The system performs aggregation calculations on all analyzed comment trees under the same post, such as... Figure 5 As shown. The opportunity score is calculated based on the following four sub-indicators: (1) Sub-index of negative sentiment density: Number of negative comment trees under this post / Total number of comment trees under this post; (2) Sub-indicator of demand diversity: The number of unique user demand tags in all comment trees under this post / the total number of comment trees under this post; (3) Sub-indicator of population diversity: The number of unique population signal labels in all comment trees under this post / the total number of comment trees under this post; (4) Topic richness sub-indicator: The number of unique topic keywords in all comment trees under this post / the total number of comment trees under this post. Opportunity Score = Sub-index of Criticism Density × First Weight + Sub-index of Demand Diversity × Second Weight + Sub-index of Audience Diversity × Third Weight + Sub-index of Topic Richness × Fourth Weight; The sum of each weight is 1, and the default value is 0.25, which can be adjusted according to the analysis scenario. Calculation Example: Taking a post with 10 comment trees as an example, including 4 negative sentiment trees, 7 unique user need tags, 5 unique audience signal tags, and 10 unique topic keywords, then: Slot density = 4 / 10 = 0.40 Demand diversity = 7 / 10 = 0.70 Population diversity = 5 / 10 = 0.50 Topic richness = 10 / 10 = 1.0 Opportunity score = 0.40 × 0.25 + 0.70 × 0.25 + 0.50 × 0.25 + 1.0 × 0.25 = 0.65 The calculation results are written into a post summary table for subsequent retrieval, sorting, and display. [Example 2: Batch Status Management Implementation Method] Each data import creates a batch record, which has the following status: Pending, Importing, Imported, Tree Built, Analyzing, Paused, Completed, Failed in: 1. When data import begins, the batch status changes from pending to importing; 2. When the data writing is complete, the batch status switches to "Imported"; 3. When the comment tree is built, the batch status switches to "Tree Built"; 4. When the comment tree analysis begins, the batch status switches to "Analyzing". 5. When a pause command is received, the system sets a pause flag and stops assigning new comment tree analysis tasks to the execution queue; submitted and currently executing analysis tasks continue to complete; once the currently executing task is completed, the batch status switches to paused. 6. When a recovery command is received, the system queries the comment tree records in the batch whose analysis status is pending or failed, and adds them back to the analysis queue, switching the batch status to analysis in progress; 7. When all comment trees in this batch have been analyzed, the batch status will switch to "Completed". 8. When there are no pending comment trees but there are failed comment trees in this batch, the batch status is switched to "failed". In a failed state, the system can reset the analysis status of the failed comment tree to pending and re-execute the analysis. Example of graceful pause effect: Assume a batch contains comment data from 200 posts, generating approximately 800 comment trees, and an estimated 800 calls to the Large Language Model (LLM). When analyzing the 350th comment tree, the user triggers a pause—the system does not forcibly interrupt the current concurrent calls, but waits for all concurrent calls in the current batch to complete before entering a paused state (at this point, approximately 350 trees are completed, and approximately 450 are pending). Upon resumption the next day, only the approximately 450 incomplete comment trees are resubmitted; the 350 completed trees are not analyzed again. Compared to a forced interruption requiring re-execution of all 800 calls, the graceful pause strategy saves on the cost of repeated LLM calls. [Example 3: Comparative Experiment of Comment Tree Analysis and Single Comment Analysis] Experimental conditions: A test set containing 1200 social media comments was constructed, covering three thematic areas: beauty, food, and home appliances. The comments in the test set were structured into 326 comment trees based on reply relationships, and sentiment polarity and brand attribution were manually labeled as reference answers. Three control groups (A, B, and C) were set up: Group A used traditional NLP (Natural Language Processing) to analyze individual comments, Group B used Large Language Modeling (LLM) to analyze individual comments, and Group C used LLM to analyze the comment trees. The results are shown in the table below. The results above demonstrate that using comment trees as the smallest unit of analysis can significantly improve the accuracy of structured analysis, especially for response-type comment data with obvious contextual dependencies. [Example 4: Implementation of Dynamic Tag Expansion] This embodiment describes an implementation method for the system to support dynamic expansion of the tag system. The initial tag definition store contains 20 tags for the "Efficacy" type. Users add a new efficacy tag (e.g., "Soothing and Repairing") through the tag library management interface. Since step S4 reads the current tag list from the tag definition store in real time and replaces the tag library placeholders in the Prompt template before each call to the large language model interface, after the addition operation is completed, the target Prompt generated during the next large language model analysis will automatically include the "Soothing and Repairing" tag. This allows the large language model to recognize and extract the new tag without modifying the program code, achieving dynamic expansion of the tag system. For historical comment trees that have been analyzed using the old tag library, the single-tree reanalysis function can be used to re-execute the analysis using the latest target prompt (hint word) containing the newly added tags, so that the new results overwrite the original results. [Example 5: Implementation Method for Cross-Post Analysis Across Multiple Categories] This embodiment describes a scenario where the system supports cross-analysis of data from multiple brands and product categories. The operations team uploads comment data containing 100 posts from each of three skincare brands (Brand A, Brand B, and Brand C). After the system executes steps S1 to S5 above, the analysis results table contains structured analysis results for each brand and product category. Users can perform multi-dimensional queries: (1) Filter by brand: Query all comment trees of brand A, count the emotional distribution and main complaints of the brand, and make a horizontal comparison with brand B and brand C; (2) Filter by efficacy: Query all review trees related to a specific efficacy (such as "moisturizing") and compare user satisfaction and demographic signal distribution of different brands on this efficacy; (3) Opportunity score sorting: Sort all posts in descending order of opportunity score to quickly locate posts with high opportunity value. This embodiment illustrates that the data model design of the present invention can support cross-querying and comparative analysis across multiple brands, product categories, and efficacy dimensions. The above description is merely a preferred embodiment of this application and is not intended to limit this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for structuring multi-level social media comment data based on Large Language Model (LLM), characterized in that, Includes the following steps: S1. Data Acquisition Steps: Receive social media comment collection data, which includes at least the post identifier field, post title field, post body field, comment identifier field, parent comment identifier field, comment text field, user identifier field, and comment time field; After parsing the social media comment collection data, the post data is written into the post table of the business database, the comment data is written into the original comment table, and a batch record corresponding to the social media comment collection data is created; S2. Preprocessing step: Perform noise filtering on the comment data to filter out comment records that meet the preset invalid conditions; S3. Comment tree construction steps: Taking the same post as a scope, construct a comment tree according to the correspondence between the comment identifier field and the parent comment identifier field; wherein, comments whose parent comment identifier is empty or points to the current comment identifier are determined as the root node, and child comment nodes are recursively attached from the root node to obtain a multi-level multi-branch comment tree structure; the comment tree structure is serialized and stored in the comment tree table; S4. Analysis Steps: Using the comment tree as the smallest analysis unit, read the title information, body information, and comment tree structure data of the corresponding posts in the comment tree to assemble the analysis payload; read the currently active Prompt template from the configuration storage; before each call to the large language model interface, read the current tag list from the tag definition storage in real time, and replace the tag library placeholders in the Prompt template with the current tag list to generate the target Prompt; send the analysis payload and the target Prompt to the large language model interface to obtain multi-dimensional structured analysis results; S5. Structured storage step: Write the multi-dimensional structured analysis results into the analysis result table in the business database, and establish a one-to-one association between the comment tree records and the analysis result records; establish a many-to-many association between the tag data in the multi-dimensional structured analysis results and the comment tree tag association table.
2. The method according to claim 1, characterized in that, The noise filtering in step S2 includes a forced filtering mode and an optional filtering mode. The forced filtering mode is always executed and includes at least: filtering comments with fewer than a preset threshold number of valid Chinese characters, and filtering comments that match entries in a preset invalid comment vocabulary list; The optional filtering mode is determined by the user during the upload process. When enabled, at least additional filtering of advertising keywords and duplicate comments will be performed.
3. The method according to claim 1, characterized in that, In step S3, the comment tree structure is serialized and stored in the comment tree table in JSON format, and the comment tree table records the maximum nesting depth, the total number of nodes, and the root comment identifier corresponding to each comment tree.
4. The method according to claim 1, characterized in that, It also includes a batch status management mechanism; A batch record is created for each data import, and the batch record has multiple states such as pending, importing, imported, tree built, analyzing, paused, completed, and failed. Pause execution steps: Upon receiving a pause command, set a pause flag and stop assigning new comment tree analysis tasks to the execution queue. Wait for the currently issued comment tree analysis tasks to complete before switching the batch status to paused. Resumption of execution steps: Upon receiving the recovery command, comment trees that have already been successfully analyzed will not be analyzed again. The comment tree records in this batch that are in the pending or failed analysis status will be queried and added back to the analysis queue. The batch status will be switched to "in analysis" and the analysis will continue. Failure retry steps: In the case of failure, reset the analysis status of the comment tree records in the batch that were previously analyzed as failed to "pending processing", reset the batch status to "analyzing", and re-execute step S4.
5. The method according to claim 1, characterized in that, Step S4 is executed through a concurrent execution mechanism, with the number of concurrent processes controlled by configurable parameters. The analysis tasks of each comment tree within the same batch are executed independently, and the failure of a single comment tree analysis does not affect the continuation of the analysis tasks of other comment trees. When a single comment tree analysis fails, the reason for the failure is recorded for subsequent retry.
6. The method according to claim 1, characterized in that, Step S4 also includes a single comment tree reanalysis step: For comment trees that have been analyzed, reanalysis can be triggered individually. During reanalysis, the currently active Prompt template and tag library are read and step S4 is re-executed to overwrite the original analysis results and update the source tag field and analysis time field in the analysis results.
7. The method according to claim 1, characterized in that, The multi-dimensional structured analysis results include at least the analytical data from multiple dimensions, including brand tags, category tags, efficacy tags, emotional polarity, usage scenario tags, user demand tags, audience signal tags, topic keywords, topic summaries, and complaint summaries.
8. The method according to claim 1, characterized in that, It also includes post-level opportunity rating aggregation calculation, the calculation method is as follows: The sub-index for "criticism density" is calculated as: the number of comment trees with a negative sentiment polarity under this post / the total number of comment trees under this post. Demand diversity sub-metric = Number of unique user demand tags across all comment trees under this post / Total number of comment trees under this post; The population diversity sub-index = the number of unique population signal labels across all comment trees under this post / the total number of comment trees under this post; Topic richness sub-metric = Number of unique topic keywords across all comment trees under this post / Total number of comment trees under this post; Post-level opportunity score = Sub-index of density of complaints × First weight + Sub-index of demand diversity × Second weight + Sub-index of audience diversity × Third weight + Sub-index of topic richness × Fourth weight; The sum of all weights is 1, and each weight can be configured according to the analysis scenario.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.