Prompt word logic configuration method based on context semantic enhancement
By combining the dynamic generation of semantic anchor points with the semantic field strength modeling, a comprehensive prompt word logic configuration method is proposed to solve the problems in the existing technology that prompt word selection relies on static rules and semantic modeling lacks multidimensional factors. Dynamic priority sorting and logical dependency relationship construction of prompt words are realized, thereby improving the accuracy and consistency of generated content.
Patent Information
- Application Number
- CN202511251727.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-03
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-09-03
AI Technical Summary
The existing prompt word logic configuration method has the problem that the prompt word selection relies on static rules and cannot dynamically reflect the strength and timeliness changes of semantic relationships, resulting in the configuration results lacking context sensitivity and logical consistency; the semantic anchor point selection relies on word frequency or static keyword library, which makes it difficult to distinguish important terms from common terms; semantic modeling lacks comprehensive consideration of multi-dimensional factors, resulting in distorted or biased configuration results in complex scenarios.
A comprehensive prompt word logic configuration method combining dynamic generation of semantic anchor points and semantic field strength modeling is adopted. Semantic anchor points are dynamically generated through semantic network structure contribution calculation and time attenuation, and multi-dimensional attenuation-weighted semantic field strength quantitative modeling is performed to construct the logical dependency relationship of prompt words.
It realizes the priority sorting and logical dependency relationship construction of prompt words in the global semantic network, adapts to the dynamic changes of the dialogue context, improves the logical rigor and accuracy of the prompt word configuration, reflects the emotional orientation and source credibility, and enhances the relevance and completeness of the generated content.
Smart Images

Figure CN120725027A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of artificial intelligence and natural language processing, and in particular to a method for logically configuring prompt words based on contextual semantic enhancement. Background Art
[0002] The context-enhanced prompt word logic configuration method is an advanced strategy designed to improve the interaction effect with generative artificial intelligence (such as large language models). Its core definition is that this method does not send the short prompt word input by the user directly to the model, but instead uses a systematic process to first conduct in-depth semantic analysis and expansion of the original instruction and its dialogue history, related background information, etc., and then construct an enhanced prompt word with rich connotation, clear structure, and rich contextual information. Its main function is to solve the pain points of traditional simple prompt words due to lack of context, such as the generated content deviating from expectations, unstable quality, and lack of depth. It can significantly improve the accuracy, relevance and completeness of AI-generated content, and ultimately enable users to obtain higher-quality output results at a lower communication cost.
[0003] However, existing methods for intelligent logical configuration of prompt words have technical problems: prompt word selection relies on static rules and cannot dynamically reflect the strength and timeliness of semantic relationships, resulting in a lack of contextual sensitivity and logical consistency in the prompt word configuration results.
[0004] Existing methods for dynamically generating semantic anchors have technical issues such as over-reliance on word frequency or static keyword libraries for anchor selection, difficulty distinguishing important terms from common terms, and ignoring the dynamic contribution of terms at different time points.
[0005] In existing semantic modeling methods, there are technical problems such as single-dimensional evaluation of semantic weight and lack of comprehensive consideration of multi-dimensional factors such as sentiment polarity and knowledge credibility, which leads to distortion or deviation of prompt word configuration results in complex scenarios. Summary of the Invention
[0006] In view of the above situation, in order to overcome the defects of the existing technology, the present invention provides a prompt word logic configuration method based on contextual semantic enhancement. In view of the technical problem that the prompt word selection in the existing prompt word logic intelligent configuration method relies on static rules and cannot dynamically reflect the strength and timeliness changes of semantic relationships, resulting in the prompt word configuration results lacking context sensitivity and logical consistency, this solution creatively adopts a comprehensive prompt word logic configuration idea that combines dynamic generation of semantic anchor points and semantic field strength modeling, and realizes the priority sorting and logical dependency relationship construction of prompt words in the global semantic network. By setting high-priority anchor points as core nodes and low-priority anchor points as supplementary nodes, and combining time-weighted components with the timeliness intensity component, not only the logical rigor of the prompt word configuration is guaranteed, but also it can adapt to the dynamic changes of the dialogue context over time; in the existing dynamic generation methods of semantic anchor points, there are technical problems such as over-reliance on word frequency or static keyword library for anchor point selection, difficulty in distinguishing important terms from common terms, and ignoring the dynamic contribution of terms at different time points. This scheme creatively adopts a dynamic anchor point extraction method based on semantic network structure contribution calculation and time attenuation to generate dynamic semantic anchor points, achieving accurate coverage of core semantics by the anchor point set. Specifically, the structural contribution formula comprehensively considers node degree, semantic similarity and relationship strength, and introduces a time decay factor to correct the historical frequency of occurrence, so that recent high-value terms can be highlighted, while noise terms that have not appeared for a long time are automatically weakened; in view of the technical problems in existing semantic modeling methods, there is a single dimension to evaluate semantic weight, lacks comprehensive consideration of multidimensional factors such as emotional polarity and knowledge credibility, which leads to distortion or deviation of prompt word configuration results in complex scenarios. This scheme creatively adopts a semantic field strength quantification model that integrates multidimensional attenuation weighting and credibility improvement to perform semantic field strength quantitative modeling, and realizes a comprehensive evaluation of timeliness, emotional weight and knowledge credibility. This method uses three-dimensional field strength vectors and comprehensive field strength formulas for quantitative modeling to ensure that prompt words not only reflect semantic strength, but also reflect emotional orientation and source credibility.
[0007] The technical solution adopted by the present invention is as follows: The present invention provides a method for logically configuring prompt words based on contextual semantic enhancement, which includes the following steps:
[0008] Step S1: data collection;
[0009] Step S2: data preprocessing;
[0010] Step S3: Dynamic semantic anchor generation;
[0011] Step S4: Semantic field strength quantitative modeling;
[0012] Step S5: logical configuration of prompt words.
[0013] Furthermore, in step S1, the data collection is used to collect original information related to the construction of the prompt word, specifically by constructing a data collection module to perform multi-dimensional data collection to obtain an original data set;
[0014] The original data set specifically includes user input text data, context history data and text semantic tags;
[0015] The multi-dimensional data collection specifically includes user interaction data collection, corpus data collection and label data collection.
[0016] Furthermore, in step S2, the data preprocessing is used to clean and unify the original data format, specifically, data cleaning, context alignment and semantic annotation are performed on the original data set in sequence to obtain a prompt word configuration enhanced data set;
[0017] The prompt word configuration enhanced data set specifically includes optimized text data, entity term annotation data and semantic relationship structure data.
[0018] Furthermore, in step S3, the dynamic semantic anchor point generation is used to extract keywords or phrases that can represent the core meaning. Specifically, the enhanced dataset is configured according to the prompt word, and a dynamic anchor point extraction method based on semantic network structure contribution calculation and time decay is adopted to generate dynamic semantic anchor points to obtain a semantic anchor point set, including the following steps:
[0019] Step S31: constructing a temporal semantic network, specifically, configuring the entity term annotation data and semantic relationship structure data in the enhanced dataset according to the prompt word, and constructing a contextual temporal semantic network through node modeling, edge modeling, and node attribute definition;
[0020] The node modeling is specifically to define each marked entity term as a node;
[0021] The edge modeling specifically defines the relationship between two arbitrary terms defined in the semantic relationship structure data as an edge;
[0022] The node attribute definition specifically includes appending a timestamp list to each node to record all the occurrences of the term in the context history;
[0023] Step S32: Structural contribution modeling, specifically, constructing a basic structural contribution calculation equation, calculating the structural contribution of the candidate term corresponding to each node, and obtaining basic structural contribution data;
[0024] Step S33: Calculate the time-attenuation of the structural contribution, specifically, based on the timestamp list in the node attributes, perform time-attenuation coefficient modeling on the candidate terms corresponding to each node, and introduce the time-attenuation coefficient modeling to perform improved calculation on the basic calculation equation of the structural contribution to obtain time-attenuated structural contribution data;
[0025] Step S34: Semantic anchor point set generation, specifically by constructing the context temporal semantic network, taking all nodes in the context temporal semantic network as a candidate term set, and calculating the corresponding time-attenuated structural contribution data for each candidate term, and obtaining the semantic anchor point set through dynamic threshold filtering and structural contribution sorting.
[0026] Furthermore, in step S4, the semantic field strength quantification modeling is used to quantify the influence of each semantic anchor point in the context based on the concept of physical field strength, and comprehensively evaluate its timeliness, emotional weight and knowledge credibility through a three-dimensional semantic field model. Specifically, based on the prompt word configuration enhanced dataset and the semantic anchor point set, the semantic field strength quantification modeling is performed using a fusion of multi-dimensional attenuation weighting and credibility improvement to obtain semantic field quantification modeling data, including the following steps:
[0027] Step S41: Initializing the three-dimensional semantic field strength vector, specifically by defining the initial structure of the three-dimensional semantic field model to obtain a three-dimensional semantic field initialization vector; the initial structure includes a timeliness strength component, an emotion strength component, and a credibility strength component;
[0028] Step S42: constructing a timeliness strength component, specifically by performing an exponential time decay calculation based on the time distance between the number of occurrences of terms in the semantic anchor point set in the historical context, to construct a timeliness strength component;
[0029] Step S43: constructing the sentiment intensity component, specifically, performing sentiment polarity analysis based on the optimized text data corresponding to the semantic anchor point set using a pre-trained sentiment analysis model, calculating the sentiment intensity value based on the probability distribution entropy output by the pre-trained sentiment analysis model, performing separate calculations of sentiment polarity and intensity, and constructing a sentiment intensity component by merging the sentiment polarity and the sentiment intensity;
[0030] Step S44: Constructing a credibility improvement strength component, specifically constructing a fixed data source scoring table to optimize the basic source credibility rating of the text data, and constructing a credibility improvement strength component by constructing a time span weighted correction method based on the basic source credibility to obtain a credibility strength component;
[0031] Step S45: comprehensive field strength calculation, specifically, performing comprehensive semantic field strength calculation through the timeliness strength component construction, the emotion strength component construction, and the credibility improvement strength component construction to obtain comprehensive semantic field strength data;
[0032] Step S46: semantic field strength quantitative modeling, specifically, performing semantic field quantitative modeling based on the comprehensive semantic field strength data to obtain semantic field quantitative modeling data;
[0033] The semantic field quantitative modeling data is in the form of a triple list, including a semantic anchor point, a three-dimensional field strength vector, and a comprehensive field strength value;
[0034] The semantic anchor point specifically refers to the semantic anchor point of the corresponding node in the semantic anchor point set; the three-dimensional field strength vector specifically refers to the timeliness strength component, the emotion strength component and the credibility strength component; the comprehensive field strength value specifically refers to the comprehensive semantic field strength data.
[0035] Furthermore, in step S5, the prompt word logic configuration is used to generate a final prompt word configuration scheme, specifically based on the semantic field quantitative modeling data and the semantic anchor point set, by prioritizing the semantic anchor points in the semantic field quantitative modeling data according to the comprehensive field strength value, and based on the semantic relationship between the semantic anchor points and the corresponding three-dimensional field strength vector, establishing a prompt word logical dependency relationship, using high-priority semantic anchor points as core prompt word nodes, and low-priority semantic anchor points as supplementary prompt word nodes, and combining the timeliness intensity component for time weighting, outputting a prompt word configuration scheme including a prompt word sequence, prompt word logical dependency relationship and prompt word priority weight.
[0036] The beneficial effects achieved by the present invention using the above scheme are as follows:
[0037] (1) In view of the technical problem in the existing intelligent logical configuration method of prompt words that the selection of prompt words depends on static rules and cannot dynamically reflect the strength of semantic relationships and changes in timeliness, resulting in the prompt word configuration results lacking context sensitivity and logical consistency, this solution creatively adopts a comprehensive prompt word logical configuration idea that combines the dynamic generation of semantic anchor points and semantic field strength modeling, and realizes the priority sorting and logical dependency relationship construction of prompt words in the global semantic network. By setting high-priority anchor points as core nodes and low-priority anchor points as supplementary nodes, and combining time-weighted components with time-effectiveness strength, it not only ensures the logical rigor of prompt word configuration, but also can adapt to the dynamic changes of dialogue context over time;
[0038] (2) In view of the technical problems in existing dynamic semantic anchor generation methods, such as excessive reliance on word frequency or static keyword libraries for anchor selection, difficulty in distinguishing important terms from common terms, and neglect of the dynamic contribution of terms at different time points, this solution creatively adopts a dynamic anchor extraction method based on semantic network structure contribution calculation and time decay to generate dynamic semantic anchors, thus achieving accurate coverage of core semantics by the anchor set. Specifically, the structural contribution formula comprehensively considers node degree, semantic similarity and relationship strength, and introduces a time decay factor to correct the historical frequency of occurrence, so that recent high-value terms can be highlighted, while noise terms that have not appeared for a long time are automatically weakened;
[0039] (3) In view of the technical problems in existing semantic modeling methods, such as single-dimensional evaluation of semantic weight and lack of comprehensive consideration of multi-dimensional factors such as emotional polarity and knowledge credibility, which leads to distortion or deviation of prompt word configuration results in complex scenarios, this solution creatively adopts a semantic field strength quantification model that integrates multi-dimensional attenuation weighting and credibility improvement to perform semantic field strength quantification modeling, realizing a comprehensive evaluation of timeliness, emotional weight and knowledge credibility. This method uses three-dimensional field strength vectors and comprehensive field strength formulas for quantitative modeling, ensuring that prompt words not only reflect semantic strength, but also reflect emotional orientation and source credibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A flowchart of a method for configuring prompt word logic based on contextual semantic enhancement provided by the present invention;
[0041] Figure 2 Schematic diagram of the process of generating dynamic semantic anchors in step S3;
[0042] Figure 3 Schematic diagram of the process of semantic field strength quantization modeling in step S4.
[0043] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0045] In the description of the present invention, it should be understood that terms such as "upper", "lower", "front", "back", "left", "right", "top", "bottom", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the accompanying drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction. Therefore, they should not be understood as limiting the present invention.
[0046] Example 1, see Figure 1 The present invention provides a method for configuring prompt word logic based on contextual semantic enhancement, which includes the following steps:
[0047] Step S1: data collection;
[0048] Step S2: data preprocessing;
[0049] Step S3: Dynamic semantic anchor generation;
[0050] Step S4: Semantic field strength quantitative modeling;
[0051] Step S5: logical configuration of prompt words.
[0052] By performing the above operations, we address the technical issues in existing prompt word logic intelligent configuration methods, where prompt word selection relies on static rules and cannot dynamically reflect changes in the strength of semantic relationships and timeliness, resulting in a lack of contextual sensitivity and logical consistency in the prompt word configuration results. This solution creatively adopts a comprehensive prompt word logic configuration approach that combines dynamic semantic anchor point generation and semantic field strength modeling, achieving the priority sorting and logical dependency relationship construction of prompt words in the global semantic network. By setting high-priority anchor points as core nodes and low-priority anchor points as supplementary nodes, and combining time-weighted time with the timeliness strength component, we not only ensure the logical rigor of the prompt word configuration, but also adapt to the dynamic changes of the conversation context over time.
[0053] Specifically, for example, in long conversation scenarios, core concepts that have appeared frequently recently (such as "model") can automatically increase their weights, while secondary concepts that have not appeared for a long time (such as "optimization") are weakened to ensure that the prompt word output is closely aligned with the user context.
[0054] Example 2, see Figure 1 This embodiment is based on the above embodiment. In step S1, the data collection is used to collect original information related to the construction of the prompt word. Specifically, a data collection module is constructed to perform multi-dimensional data collection to obtain an original data set.
[0055] The original data set specifically includes user input text data, context history data and text semantic tags;
[0056] The multi-dimensional data collection specifically includes user interaction data collection, corpus data collection and label data collection;
[0057] Preferably, the user interaction data collection specifically collects the log data of the question-answering system of the natural language interaction platform; during the user interaction data collection process, the data collection module automatically captures the log data of the question-answering system through the collection component deployed on the natural language interaction platform, including the user's original input text, response content, timestamp and session number;
[0058] The corpus data collection specifically collects general and domain corpus datasets. During the corpus data collection process, the data collection module acquires data from two levels: general corpus and domain corpus. General corpus can be derived from open source natural language corpora, such as encyclopedia corpus or news corpus, while domain corpus can be derived from professional industry documents, FAQs, and industry specification texts.
[0059] The tag data collection specifically collects the existing term base, entity relationships, term definitions, upper and lower hierarchies, and synonymous relationship tag data in the tag system.
[0060] Example 3, see Figure 1 This embodiment is based on the above embodiment. In step S2, the data preprocessing is used to clean and unify the original data format. Specifically, the original data set is sequentially cleaned, contextually aligned, and semantically annotated to obtain a prompt word configuration enhanced data set.
[0061] The prompt word configuration enhanced dataset specifically includes optimized text data, entity term annotation data, and semantic relationship structure data;
[0062] Preferably, the data cleaning specifically includes noise text removal, sensitive word desensitization and duplicate data merging operations;
[0063] The context alignment is specifically performed through dialogue turn alignment and input-output alignment operations to align conversation semantics. In long dialogue scenarios, topic lines can also be aggregated through keyword extraction or clustering methods.
[0064] The semantic annotation is specifically performed through word segmentation, part-of-speech tagging and entity recognition to perform semantic feature tagging. The text is segmented by using word segmentation technology, and grammatical attributes are assigned to words in combination with the part-of-speech tagging model. The names of people, institutions, places or professional terms therein are identified through the named entity recognition method.
[0065] Example 4, see Figure 1 、 Figure 2This embodiment is based on the above embodiment. In step S3, the dynamic semantic anchor point generation is used to extract keywords or phrases that can represent the core meaning. Specifically, the enhanced dataset is configured according to the prompt word, and a dynamic anchor point extraction method based on semantic network structure contribution calculation and time decay is used to generate dynamic semantic anchor points to obtain a semantic anchor point set. The method includes the following steps:
[0066] Step S31: constructing a temporal semantic network, specifically, configuring the entity term annotation data and semantic relationship structure data in the enhanced dataset according to the prompt word, and constructing a contextual temporal semantic network through node modeling, edge modeling, and node attribute definition;
[0067] The node modeling is specifically to define each marked entity term as a node;
[0068] The edge modeling specifically defines the relationship between two arbitrary terms defined in the semantic relationship structure data as an edge;
[0069] The node attribute definition specifically includes appending a timestamp list to each node to record all the occurrences of the term in the context history;
[0070] Step S32: Structural contribution modeling, specifically, constructing a basic structural contribution calculation equation, calculating the structural contribution of the candidate term corresponding to each node, and obtaining basic structural contribution data;
[0071] The calculation formula of the structural contribution basic calculation equation is:
[0072] ;
[0073] Where, SCD(v i ) is the infrastructure contribution data, v i is the i-th node, used to represent the candidate term, i is the node index, and Degree is the node v i The degree, E(v i ) is the node v i The set of all connected edges, e ij is the edge connecting the i-th node and the j-th node, j is the neighbor node index, Sim is the semantic similarity calculation function, which is specifically calculated using the cosine similarity of word vectors, and RelStrength is the preset strength weight data, which is specifically calculated and set by the statistical co-occurrence frequency;
[0074] Step S33: Calculate the time-attenuation of the structural contribution, specifically, based on the timestamp list in the node attributes, perform time-attenuation coefficient modeling on the candidate terms corresponding to each node, and introduce the time-attenuation coefficient modeling to perform improved calculation on the basic calculation equation of the structural contribution to obtain time-attenuated structural contribution data;
[0075] The calculation formula for the aging attenuation structure contribution data is:
[0076] ;
[0077] Where, is the time-dependent decay structure contribution data, t is the time interval index, T i is node v i A list of timestamps, is a time decay factor, which is used to control the influence of the term's appearance in the context history on the structural contribution;
[0078] Step S34: generating a semantic anchor point set, specifically by constructing the contextual temporal semantic network, taking all nodes in the contextual temporal semantic network as a candidate term set, and calculating the corresponding time-attenuated structural contribution data for each candidate term, and obtaining the semantic anchor point set through dynamic threshold filtering and structural contribution sorting;
[0079] Preferably, the dynamic threshold filtering adopts a quantile-based dynamic threshold filtering method to calculate the mean and standard deviation of the time decay structure contribution of all candidate term nodes, and perform dynamic threshold calculation based on the sum of half the mean and the standard deviation.
[0080] By performing the above operations, this solution addresses the technical issues in existing dynamic semantic anchor generation methods, which rely too much on word frequency or static keyword libraries for anchor selection, making it difficult to distinguish important terms from common terms, and ignoring the dynamic contribution of terms at different time points. This solution creatively adopts a dynamic anchor extraction method based on semantic network structure contribution calculation and time decay to generate dynamic semantic anchors, achieving accurate coverage of core semantics by the anchor set. Specifically, the structural contribution formula comprehensively considers node degree, semantic similarity, and relationship strength, and introduces a time decay factor to correct historical occurrence frequency, so that recent high-value terms can be highlighted, while noise terms that have not appeared for a long time are automatically weakened;
[0081] Specifically, for example, in technical document analysis, "data" and "model" can be selected as semantic anchors due to their high connectivity and frequent recent appearances, while "one-time test" can be automatically eliminated due to its long history and lack of important relationship edges, thereby improving the accuracy and timeliness of the anchor set.
[0082] Example 5, see Figure 1 、 Figure 3 This embodiment is based on the above embodiment. In step S4, the semantic field strength quantification modeling is used to quantify the influence of each semantic anchor point in the context based on the concept of physical field strength, and comprehensively evaluate its timeliness, emotional weight and knowledge credibility through a three-dimensional semantic field model. Specifically, based on the prompt word configuration enhanced dataset and the semantic anchor point set, the semantic field strength quantification model that integrates multi-dimensional attenuation weighting and credibility improvement is used to perform semantic field strength quantification modeling to obtain semantic field quantification modeling data, including the following steps:
[0083] Step S41: Initializing the three-dimensional semantic field strength vector, specifically by defining the initial structure of the three-dimensional semantic field model to obtain a three-dimensional semantic field initialization vector; the initial structure includes a timeliness strength component, an emotion strength component, and a credibility strength component;
[0084] The calculation formula of the three-dimensional semantic field initialization vector is:
[0085] ;
[0086] Where, is the initialization vector of the three-dimensional semantic field, a i is the anchor point in the semantic anchor point set corresponding to the i-th node, a i The whole is the anchor index, F t is the temporal intensity component, F s is the emotional intensity component, F c is the credibility strength component;
[0087] Step S42: constructing a timeliness strength component, specifically by performing an exponential time decay calculation based on the time distance between the number of occurrences of terms in the semantic anchor point set in the historical context, to construct a timeliness strength component;
[0088] The calculation formula of the timeliness intensity component is:
[0089] ;
[0090] Where N i It is a i The total number of times the term corresponding to the anchor point appears in the context, k is the term occurrence index, is the time decay factor, is the time difference between the time point of the kth occurrence and the current moment;
[0091] Step S43: constructing the sentiment intensity component, specifically, performing sentiment polarity analysis based on the optimized text data corresponding to the semantic anchor point set using a pre-trained sentiment analysis model, calculating the sentiment intensity value based on the probability distribution entropy output by the pre-trained sentiment analysis model, performing separate calculations of sentiment polarity and intensity, and constructing a sentiment intensity component by merging the sentiment polarity and the sentiment intensity;
[0092] The separate calculation of emotion polarity and intensity is used to optimize the detail distinguishability of emotion polarity. The calculation formula of the emotion intensity component is:
[0093] ;
[0094] Where Polarity is the sentiment polarity value, which is obtained through analysis of the pre-trained sentiment analysis model, and Intensity is the sentiment intensity;
[0095] Preferably, Table 1 is an example table of model parameters of the pre-trained sentiment analysis model. The pre-trained sentiment analysis model specifically adopts the SKEP (Sentiment Knowledge Enhanced Pre-training) model. In a specific implementation, the skep_ernie_1.0_large_ch model disclosed by the PaddleNLP platform can be used. The model has been fine-tuned on the Chinese sentiment classification task and can output multi-class sentiment polarity probability distribution for information entropy calculation and sentiment intensity component construction;
[0096] Table 1 Example of model parameters of pre-trained sentiment analysis model
[0097]
[0098] The calculation formula of the emotion intensity is:
[0099] ;
[0100] Where H is the information entropy function, ProbDist is the probability distribution entropy output by the pre-trained sentiment analysis model, and NumClasses is the total number of sentiment classes;
[0101] Step S44: Constructing a credibility improvement strength component, specifically constructing a fixed data source scoring table to optimize the basic source credibility rating of the text data, and constructing a credibility improvement strength component by constructing a time span weighted correction method based on the basic source credibility to obtain a credibility strength component;
[0102] The calculation formula of the credibility strength component is:
[0103] ;
[0104] Where M is the total number of sources of anchor terms in the semantic relationship structure data, m is the source index of the anchor term, Source is the source basic credibility function, which is specifically defined by the data source fixed score table, and e m It is a i The source of the term corresponding to each anchor point, Credibility is a credibility mapping function constructed based on the time span weighted correction method of the basic source credibility;
[0105] Preferably, Table 2 is a reference example table of fixed scoring of the data source, such as Table 2, which manually evaluates and assigns values for the basic source categories and credibility values of the optimized text data;
[0106] Table 2 Data source fixed score reference example table
[0107]
[0108] The calculation formula for constructing the credibility improvement intensity component based on the time span weighted correction method of the basic source credibility is:
[0109] ;
[0110] Where, is the credibility time decay coefficient, which is used to adjust the effect of time decay on the overall credibility. Its value range is set to [0,1]. It is a time scale parameter used to control the speed of aging decay. Age is the i The time span value from the source of the term corresponding to the anchor point to the current moment;
[0111] Step S45: comprehensive field strength calculation, specifically, performing comprehensive semantic field strength calculation through the timeliness strength component construction, the emotion strength component construction, and the credibility improvement strength component construction to obtain comprehensive semantic field strength data;
[0112] The calculation formula of the comprehensive semantic field strength data is:
[0113] ;
[0114] Where FieldStrength is the comprehensive semantic field strength data, Overall is the emotion enhancement factor, which is used to numerically amplify the field strength of the emotion intensity component regardless of the positive or negative emotion polarity. Sign is the sign function, which is used to preserve the polarity information of the emotion.
[0115] Step S46: semantic field strength quantitative modeling, specifically, performing semantic field quantitative modeling based on the comprehensive semantic field strength data to obtain semantic field quantitative modeling data;
[0116] The semantic field quantitative modeling data is in the form of a triple list, including a semantic anchor point, a three-dimensional field strength vector, and a comprehensive field strength value;
[0117] The semantic anchor point specifically refers to the semantic anchor point of the corresponding node in the semantic anchor point set; the three-dimensional field strength vector specifically refers to the timeliness strength component, the emotion strength component and the credibility strength component; the comprehensive field strength value specifically refers to the comprehensive semantic field strength data.
[0118] By performing the above operations, we address the technical issues in existing semantic modeling methods, such as single-dimensional evaluation of semantic weight and lack of comprehensive consideration of multi-dimensional factors such as sentiment polarity and knowledge credibility, which leads to distortion or deviation of prompt word configuration results in complex scenarios. This solution creatively adopts a semantic field strength quantification model that integrates multi-dimensional attenuation weighting and credibility improvement to perform semantic field strength quantification modeling, achieving a comprehensive assessment of timeliness, sentiment weight, and knowledge credibility. This method uses three-dimensional field strength vectors and a comprehensive field strength formula for quantitative modeling, ensuring that prompt words reflect not only semantic strength but also sentiment orientation and source credibility.
[0119] Specifically, for example, in a medical consultation scenario, the anchor point "diagnosis" will have its comprehensive field strength value amplified because it comes from authoritative guidelines (high credibility) and carries negative emotions (such as "serious"), thereby appearing first in the prompt word configuration scheme, thereby improving the matching degree of the prompt word logic configuration with the user's true intention.
[0120] Example 6, see Figure 1 and Figure 2 This embodiment is based on the above embodiment. In step S5, the prompt word logic configuration is used to generate a final prompt word configuration scheme. Specifically, based on the semantic field quantitative modeling data and the semantic anchor point set, the semantic anchor points in the semantic field quantitative modeling data are prioritized according to the comprehensive field strength value, and based on the semantic relationship between the semantic anchor points and the corresponding three-dimensional field strength vector, a prompt word logical dependency relationship is established, and the high-priority semantic anchor point is used as the core prompt word node, and the low-priority semantic anchor point is used as the supplementary prompt word node. The timeliness intensity component is combined for time weighting, and a prompt word configuration scheme including a prompt word sequence, a prompt word logical dependency relationship and a prompt word priority weight is output.
[0121] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus.
[0122] While the embodiments of the present invention have been shown and described, it will be apparent to those skilled in the art that various changes, modifications, substitutions, and alterations can be made to the embodiments without departing from the principles and spirit of the invention.
[0123] The present invention and its embodiments are described above. This description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if a person skilled in the art is inspired by this and, without departing from the purpose of the present invention, designs structures and embodiments similar to this technical solution without inventiveness, they shall fall within the scope of protection of the present invention.
Claims
1. A method for logically configuring prompt words based on contextual semantic enhancement, characterized by: The method comprises the following steps: Step S1: Data collection, multi-dimensional data collection to obtain the original data set; Step S2: Data preprocessing, performing data cleaning, context alignment, and semantic annotation on the original data set in sequence to obtain a prompt word configuration enhanced data set; Step S3: Dynamic semantic anchor point generation: Based on the prompt word configuration and enhanced dataset, dynamic semantic anchor point generation is performed using a dynamic anchor point extraction method based on semantic network structure contribution calculation and time decay to obtain a semantic anchor point set, including the following steps: temporal semantic network construction; structural contribution modeling; structural contribution time decay calculation; semantic anchor point set generation; Step S4: Semantic field strength quantitative modeling, based on the prompt word configuration enhanced dataset and the semantic anchor point set, adopts a semantic field strength quantitative model that integrates multi-dimensional attenuation weighting and credibility improvement to perform semantic field strength quantitative modeling, and obtains semantic field quantitative modeling data, including the following steps: initialization of a three-dimensional semantic field strength vector; construction of a timeliness strength component; construction of an emotional strength component; construction of a credibility improvement strength component; calculation of comprehensive field strength; and semantic field strength quantitative modeling; Step S5: Prompt word logic configuration, outputting a prompt word configuration scheme including a prompt word sequence, prompt word logical dependency, and prompt word priority weights based on the semantic field quantification modeling data and the semantic anchor point set.
2. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 1, characterized in that: In step S1, the original data set specifically includes user input text data, context history data and text semantic tags; The multi-dimensional data collection specifically includes user interaction data collection, corpus data collection and label data collection.
3. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 2, characterized in that: In step S2, the data preprocessing is used to clean and unify the original data format, specifically, the original data set is sequentially subjected to data cleaning, context alignment and semantic annotation to obtain a prompt word configuration enhanced data set; The prompt word configuration enhanced data set specifically includes optimized text data, entity term annotation data and semantic relationship structure data.
4. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 3, characterized in that: In step S3, the dynamic semantic anchor point generation is used to extract keywords or phrases that can represent the core meaning. Specifically, the enhanced dataset is configured according to the prompt word, and a dynamic anchor point extraction method based on semantic network structure contribution calculation and time decay is used to generate dynamic semantic anchor points to obtain a semantic anchor point set. The method includes the following steps: Step S31: constructing a temporal semantic network, specifically, configuring the entity term annotation data and semantic relationship structure data in the enhanced dataset according to the prompt word, and constructing a contextual temporal semantic network through node modeling, edge modeling, and node attribute definition; Step S32: Structural contribution modeling, specifically, constructing a basic structural contribution calculation equation, calculating the structural contribution of the candidate term corresponding to each node, and obtaining basic structural contribution data; Step S33: Calculate the time-attenuation of the structural contribution, specifically, based on the timestamp list in the node attributes, perform time-attenuation coefficient modeling on the candidate terms corresponding to each node, and introduce the time-attenuation coefficient modeling to perform improved calculation on the basic calculation equation of the structural contribution to obtain time-attenuated structural contribution data; Step S34: Semantic anchor point set generation, specifically by constructing the context temporal semantic network, taking all nodes in the context temporal semantic network as a candidate term set, and calculating the corresponding time-attenuated structural contribution data for each candidate term, and obtaining the semantic anchor point set through dynamic threshold filtering and structural contribution sorting.
5. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 4, characterized in that: In step S31, the node modeling is specifically to define each marked entity term as a node; The edge modeling specifically defines the relationship between two arbitrary terms defined in the semantic relationship structure data as an edge; The node attribute definition is specifically to add a timestamp list to each node to record all the occurrence times of the term in the context history.
6. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 5, characterized in that: In step S4, the semantic field strength quantification modeling is used to quantify the influence of each semantic anchor point in the context based on the concept of physical field strength, and comprehensively evaluate its timeliness, emotional weight and knowledge credibility through a three-dimensional semantic field model. Specifically, the following steps are included: Step S41: Initializing the three-dimensional semantic field strength vector, specifically by defining the initial structure of the three-dimensional semantic field model to obtain a three-dimensional semantic field initialization vector; the initial structure includes a timeliness strength component, an emotion strength component, and a credibility strength component; Step S42: constructing a timeliness strength component, specifically by performing an exponential time decay calculation based on the time distance between the number of occurrences of terms in the semantic anchor point set in the historical context, to construct a timeliness strength component; Step S43: constructing the sentiment intensity component, specifically, performing sentiment polarity analysis based on the optimized text data corresponding to the semantic anchor point set using a pre-trained sentiment analysis model, calculating the sentiment intensity value based on the probability distribution entropy output by the pre-trained sentiment analysis model, performing separate calculations of sentiment polarity and intensity, and constructing a sentiment intensity component by merging the sentiment polarity and the sentiment intensity; Step S44: Constructing a credibility improvement strength component, specifically constructing a fixed data source scoring table to optimize the basic source credibility rating of the text data, and constructing a credibility improvement strength component by constructing a time span weighted correction method based on the basic source credibility to obtain a credibility strength component; Step S45: comprehensive field strength calculation, specifically, performing comprehensive semantic field strength calculation through the timeliness strength component construction, the emotion strength component construction, and the credibility improvement strength component construction to obtain comprehensive semantic field strength data; Step S46: Semantic field strength quantitative modeling, specifically performing semantic field quantitative modeling based on the comprehensive semantic field strength data to obtain semantic field quantitative modeling data.
7. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 6, characterized in that: In step S46, the semantic field quantitative modeling data is in the form of a triple list, including a semantic anchor point, a three-dimensional field strength vector and a comprehensive field strength value; the semantic anchor point specifically refers to the semantic anchor point of the corresponding node in the semantic anchor point set; the three-dimensional field strength vector specifically refers to the timeliness strength component, the emotional strength component and the credibility strength component; the comprehensive field strength value specifically refers to the comprehensive semantic field strength data.
8. The method for configuring prompt word logic based on contextual semantic enhancement according to claim 7, characterized in that: In step S5, the prompt word logic configuration is used to generate a final prompt word configuration scheme, specifically based on the semantic field quantitative modeling data and the semantic anchor point set, by prioritizing the semantic anchor points in the semantic field quantitative modeling data according to the comprehensive field strength value, and based on the semantic relationship between the semantic anchor points and the corresponding three-dimensional field strength vector, establishing a prompt word logical dependency relationship, using high-priority semantic anchor points as core prompt word nodes, and low-priority semantic anchor points as supplementary prompt word nodes, and combining the timeliness intensity component for time weighting, outputting a prompt word configuration scheme including a prompt word sequence, prompt word logical dependency relationship and prompt word priority weight.
Citation Information
Patent Citations
Intelligent operation and maintenance report generation system based on hybrid expert language model
CN118709677A
Prompt word optimization method in combination with expert evaluation rule and large language model
CN118886427A
Storage type XSS attack detection method and device based on large language model
CN120337215A
Intelligent financial cue word generation and optimization system based on knowledge graph
CN120542400A
Method and system for generating document, computing device, and medium
WO2025107896A1
Cited By
Distributed database operation and maintenance method and device and related equipment
CN121350004A
Data security risk automatic assessment method and system based on bipolar semantic anchor points
CN122310551A
Data security risk automatic evaluation method and system based on bipolar semantic anchor point
CN122310551B
