Bidirectional cue word collaborative optimization method and device, equipment and medium
By using a task configuration and feedback analysis-driven collaborative optimization method for prompt words, the problems of poor consistency and weak adaptability of prompt words in existing technologies are solved. This enables dynamic optimization and stability improvement of prompt words in fintech and healthcare business scenarios, thereby improving optimization efficiency and task processing capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2026-01-09
- Publication Date
- 2026-04-21
AI Technical Summary
Existing technologies lack a mechanism to collaboratively and dynamically optimize system prompts and user prompts based on task feedback and model uncertainty, resulting in poor consistency, weak adaptability, and low optimization efficiency, especially in fintech and healthcare business scenarios where performance is unstable.
By loading task configuration, initializing system prompts and user prompts, and inputting them into a language model to generate a set of dialogue responses, feedback analysis is performed based on preset analysis dimensions, and the type of optimization operation is determined by using output uncertainty indicators and change indicators. System and user prompts are updated respectively, and after optimization, they are stored in the prompts memory for new task processing.
It enables dynamic adjustment of system prompts and user prompts based on unified feedback analysis, improving semantic consistency, adaptability, and task collaboration capabilities. It also enhances the model's generalization performance in cross-task scenarios and improves optimization efficiency and task processing stability through the prompt word memory.
Smart Images

Figure CN121901294A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of semantic parsing technology, and in particular to a method, apparatus, device, and medium for bidirectional prompt word collaborative optimization. Background Technology
[0002] In the fintech sector, scenarios such as intelligent customer service, claims consultation, risk alerts, and product recommendations have gradually adopted automated interaction capabilities based on large-scale language models to replace traditional rule-matching systems. Existing technologies typically rely on manually configured system and user prompts to guide the model in outputting professional content within a financial context. However, these prompts often lack a coordinated update mechanism, leading to issues such as inconsistencies in logic, tone mismatches, or conflicting instructions between system and user prompts, impacting the professionalism, consistency, and comprehensibility of the generated content. Due to frequent updates to financial policies, compliance requirements, and product information, existing systems struggle to adapt in a timely manner through static prompt design, resulting in unstable prompt performance in dynamic business scenarios.
[0003] In the healthcare field, large-scale modeling technology is also used for tasks such as online consultations, health advice generation, and nursing process guidance. Existing systems typically optimize system prompts and user prompts separately based on scenario requirements. However, by ignoring the dependencies between the two, the model may exhibit inconsistent expression styles and incoherent contextual explanations when providing medical advice. Furthermore, healthcare scenarios have higher requirements for language consistency, information sufficiency, and compliance; existing prompt optimization methods struggle to maintain consistent dialogue quality while preserving standardized expression. Especially when addressing the diverse communication needs of different patients, optimized prompts often overfit in certain scenarios, resulting in insufficient generalization ability. Summary of the Invention
[0004] The main objective of this invention is to provide a method, apparatus, device, and storage medium for bidirectional prompt word collaborative optimization, aiming to solve the technical problems of the lack of a mechanism in the prior art to collaboratively and dynamically optimize system prompt words and user prompt words based on task feedback and model uncertainty, resulting in poor prompt word consistency, weak adaptability, and low optimization efficiency.
[0005] To achieve the above objectives, the present invention provides a bidirectional prompt word collaborative optimization method, comprising: Load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination; The prompt words are combined with the dialogue content and input into a language model to generate a dialogue response set. The dialogue response set is then analyzed based on a preset analysis dimension to obtain feedback analysis results. During the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index. Based on the optimization operation type, the execution process of system prompt word optimization processing and user prompt word optimization processing is controlled. Based on the user prompt words and the feedback analysis results, the system prompt words are optimized under the control of the optimized operation type to obtain the updated system prompt words. Under the condition that the updated system prompt words are fixed, user prompt word optimization processing is performed on the user prompt words based on the optimized operation type to obtain the updated prompt word combination; After the prompt word optimization is completed, the updated prompt word combination will be stored in the prompt word memory. When processing a new task, candidate combinations of prompt words are retrieved from the prompt word memory and used as prompt word combinations.
[0006] Furthermore, to achieve the above objectives, the present invention provides a bidirectional prompt word collaborative optimization device, comprising: The task configuration parsing module is used to load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination. The response analysis module is used to input the combination of the prompt words and the dialogue content into a language model to generate a dialogue response set, and to analyze the dialogue response set based on a preset analysis dimension to obtain feedback analysis results. The optimization strategy decision module is used to determine the optimization operation type based on the output uncertainty index and the output uncertainty change index during the prompt word optimization process, and to control the execution process of system prompt word optimization processing and user prompt word optimization processing based on the optimization operation type. The system prompt word optimization module is used to perform system prompt word optimization processing on the system prompt word based on the user prompt word and the feedback analysis result, under the control of the optimization operation type, to obtain the updated system prompt word; The user prompt word optimization module is used to perform user prompt word optimization processing on the user prompt words based on the optimization operation type, under the condition that the updated system prompt words are fixed, to obtain the updated prompt word combination; The prompt word storage module is used to store the updated prompt word combination into the prompt word memory after the prompt word optimization is completed; The prompt word retrieval module is used to retrieve candidate prompt word combinations from the prompt word memory when processing a new task, and use them as prompt word combinations.
[0007] Furthermore, to achieve the above objectives, the present invention also provides a computer device, the computer device including a memory, a processor, and a two-way prompt word co-optimization program stored in the memory and executable on the processor, wherein when the two-way prompt word co-optimization program is executed by the processor, it implements the steps of the two-way prompt word co-optimization method as described above.
[0008] Furthermore, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a two-way prompt word co-optimization program, wherein when the two-way prompt word co-optimization program is executed by a processor, it implements the steps of the two-way prompt word co-optimization method as described above.
[0009] Beneficial Effects: This invention relates to the field of semantic parsing technology and can be applied to business scenarios such as fintech and healthcare. It discloses a bidirectional prompt word collaborative optimization method, apparatus, device, and medium, comprising: initializing system prompt words and user prompt words based on task configuration to form a prompt word combination, and generating a dialogue response set by inputting the dialogue content into a language model; obtaining feedback analysis results through preset analysis dimensions, determining the optimization operation type based on uncertainty indicators, and updating the system prompt words and user prompt words respectively to obtain the updated prompt word combination; after the prompt word optimization is completed, storing the updated prompt word combination in a prompt word memory, and retrieving candidate prompt word combinations from the prompt word memory for use as the prompt word combination in new task processing. This invention, through an uncertainty-driven prompt word collaborative optimization mechanism, enables system prompt words and user prompt words to be dynamically adjusted based on unified feedback analysis, achieving improved semantic consistency, adaptability, and task collaboration capabilities among prompt words, strengthening the model's generalization performance in cross-task scenarios, and continuously accumulating and reusing optimization results through the prompt word memory, thereby improving overall optimization efficiency and task processing stability. Attached Figure Description
[0010] The present invention will be further described below with reference to the accompanying drawings and embodiments. In the accompanying drawings: Figure 1 This is a schematic diagram of an application environment for the bidirectional prompt word collaborative optimization method in one embodiment of the present invention; Figure 2 This is a flowchart illustrating an embodiment of the bidirectional prompt word collaborative optimization method of the present invention; Figure 3 This is a schematic diagram of the functional modules of a preferred embodiment of the bidirectional prompt word collaborative optimization device of the present invention; Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 5 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0011] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0012] The bidirectional prompt word collaborative optimization method provided in this embodiment of the invention can be applied to, for example... Figure 1 In this application environment, the client communicates with the server via a network. The server can initialize system prompts and user prompts based on task configuration through the client, forming a prompt word combination. This combination is then input into a language model along with the dialogue content to generate a dialogue response set. Feedback analysis results are obtained through preset analysis dimensions. Based on uncertainty indicators, the optimization operation type is determined, and the system prompts and user prompts are updated accordingly, resulting in an updated prompt word combination. After prompt word optimization, the updated prompt word combination is stored in a prompt word memory. In new task processing, candidate prompt word combinations are retrieved from the prompt word memory and used as the final prompt word combination. This invention, through an uncertainty-driven prompt word collaborative optimization mechanism, enables system prompts and user prompts to dynamically adjust based on unified feedback analysis. This improves semantic consistency, adaptability, and task collaboration capabilities among prompts, enhances the model's generalization performance in cross-task scenarios, and achieves continuous accumulation and reuse of optimization results through a prompt word memory, thereby improving overall optimization efficiency and task processing stability. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The present invention will now be described in detail through specific embodiments.
[0013] Please see Figure 2 , Figure 2 This is a flowchart illustrating an embodiment of the bidirectional prompt word collaborative optimization method provided by the present invention. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.
[0014] like Figure 2 As shown, the bidirectional prompt word collaborative optimization method proposed in this invention includes the following steps: S10, Load task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination; In this embodiment, the loading of task configuration is accomplished by parsing the task type identifier and task parameter set. The configuration content comes from the scheduling system, user requests, or business trigger records, and includes fields representing the task context. The parsing process performs a structured transformation on the type identifier and parameter items in the configuration, generating an internal representation that can directly participate in subsequent processing. Based on the type identifier, the corresponding system prompt word template and user prompt word template are selected from the template library. The template library is organized by task type and may include terminology requirements, expression specifications, and interaction style fragments.
[0015] The selected template typically contains parameter placeholders, so replacement needs to be performed based on the task parameter set, mapping the parameter fields to the template locations. During replacement, consistency must be maintained across multiple occurrences of the parameter, and basic security checks must be performed on the content. After replacement, system prompts and user prompts tailored to the current task are obtained. The combination of these two prompts relies on a preset format, concatenating the two segments in a structured manner to create a clear and well-defined input structure, and preventing structural conflicts through consistency checks.
[0016] Task configuration can use a parameter-rich structured format or a lightweight type-plus-summary format. The template library can be retrieved using rule-based matching or vectorized retrieval to adapt to more complex task structures. Parameter substitution can be based on field name matching or on tag or semantic embedding alignment. Hint word combinations can use simple concatenation or segmented or structured input formats to adapt to the input patterns of different language models.
[0017] This embodiment improves the stability and response quality of the model in different business scenarios by parsing the task configuration, selecting templates, and replacing parameters, so that the system prompts and user prompts have higher task relevance and expression consistency before being input into the model.
[0018] S20, the combination of the prompt words and the dialogue content are input into the language model to generate a dialogue response set, and the dialogue response set is analyzed based on a preset analysis dimension to obtain feedback analysis results; In this embodiment, the combination of prompt words and dialogue content are structurally concatenated to form the model input sequence. During the concatenation process, paragraph markers, semantic separators, or context markers can be added according to the task type to clearly distinguish the guidance information from the user content in the input sequence, facilitating the language model's understanding of the scope of the prompt words. After receiving the input sequence, the model generates a dialogue response set containing multiple responses to cover content under different temperatures, sampling strategies, or generation paths, thereby reflecting the model's diverse expressions in the semantic space. Preset analysis dimensions are used to systematically analyze the response set, including semantic consistency, information sufficiency, compliance and security, and user satisfaction. Each dimension can be calculated using methods such as word vector offset measurement, semantic coverage comparison, compliance rule checking, or sentiment preference modeling. The analysis results of each dimension can be integrated into feedback analysis results through weighted fusion, credibility reordering, and normalized convergence, providing quantifiable evidence for subsequent prompt word adjustments and maintaining a consistent optimization direction.
[0019] The concatenation of input sequences can employ a templated structure or adaptively adjust the concatenation format according to the task scenario. The generation of multiple response sets can be based on different sampling temperatures, different random seeds, or multi-channel decoding strategies to enhance output coverage. The implementation of analytical dimensions can utilize domain-specific dictionaries, text matching models, or content moderation models for scoring; the fusion method can be based on linear combination, weighted voting, or confidence interval-based decision-making strategies to adapt to the output quality requirements of different business environments.
[0020] This embodiment inputs the combination of prompt words and dialogue content into a language model to generate multiple responses. Then, by combining multi-dimensional analysis and fusion processing, more stable and controllable task feedback can be obtained, making the subsequent prompt word optimization process more targeted and interpretable, thereby significantly improving the adaptability in dynamic business environments.
[0021] S30, during the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index, and the execution process of the system prompt word optimization processing and the user prompt word optimization processing is controlled according to the optimization operation type; In this embodiment, the prompt word optimization process is based on the output distribution generated by the language model. The output uncertainty index characterizes the stability of the model's decision-making under the current input. The output uncertainty index can be obtained using the output entropy value, which originates from the probability distribution generated by the language model and measures the dispersion of the response distribution. A higher entropy value indicates a less focused understanding of the current prompt word combination by the model. The output uncertainty change index reflects the changing trend of uncertainty across multiple consecutive optimization cycles. It can be calculated by the difference in output entropy values between adjacent cycles; a larger difference indicates that the prompt word structure is still in a fluctuating phase. The optimization operation type is determined based on the above two indices combined with a threshold comparison. Different thresholds are used to distinguish whether the model is in an exploratory state, a convergent state, or exhibiting abnormal behavior, thereby selecting an exploratory operation, a convergent operation, or a reset operation. Once the optimization operation type is determined, it is used to control the execution process of system prompt word optimization and user prompt word optimization. During this process, the gradient update ratio, regularization term distribution, iteration frequency, or prompt word search range can be adjusted according to different operation types to ensure that the adjustments of the two prompt words are synchronized and consistent in direction. Through this uncertainty-driven control method, prompt word updates can achieve a balance between stability and divergence, thereby avoiding misleading optimization or over-adjustment.
[0022] Output uncertainty indicators can be statistically analyzed using the generation distribution at different sampling temperatures, or their stability can be enhanced by averaging multiple generation iterations. Change indicators can be smoothed using a sliding window to prevent single abnormal disturbances from affecting judgment. The determination of the optimization operation type can utilize linear thresholding or a state switching strategy based on time series prediction to further improve judgment accuracy in long-sequence tasks. The execution processes of system prompt word optimization and user prompt word optimization can employ a synchronous adjustment method to ensure coordinated updates of both prompts under the same optimization operation type, or a weighted balancing method can be used to allocate different update magnitudes to system and user prompt words to adapt to different application scenarios.
[0023] This embodiment dynamically determines the optimization operation type by utilizing output uncertainty index and output uncertainty change index, and adjusts the execution process of system prompt word optimization processing and user prompt word optimization processing accordingly, thereby achieving stable adjustment of the prompt word structure and enabling prompt word optimization to automatically switch between divergent exploration and convergent steady state, thereby improving the adaptability and generation consistency of prompt words.
[0024] S40, based on the user prompt words and the feedback analysis results, under the control of the optimized operation type, perform system prompt word optimization processing on the system prompt words to obtain updated system prompt words; In this embodiment, the system prompt word optimization process is driven by both user prompt words and feedback analysis results. User prompt words contain content instructions formed by user-side expressions, providing task context and preference direction. Feedback analysis results are derived from a comprehensive analysis of historically generated content by a language model, considering dimensions such as semantic consistency, information sufficiency, compliance and security, and satisfaction. This analysis characterizes whether the current prompt word combination meets business objectives. System prompt word optimization is performed under the control of optimization operation types. Different optimization operation types are derived from inferences about output uncertainty indicators and output uncertainty change indicators, and can be represented as three control modes: exploration, convergence, or reset. These modes are used to adjust the update magnitude and direction of the system prompt words. In specific execution, user prompt words and feedback analysis results are used to construct the adjustment direction of the system prompt words. The optimization gradient direction can be generated by extracting semantically contradictory parts, redundant information, or expression offsets from the feedback analysis results. The update magnitude of the system prompt words can be determined by the optimization operation type. In exploration mode, the update magnitude can be increased to expand the expression; in convergence mode, the update magnitude can be decreased to refine the expression; and in reset mode, some key expressions can be adjusted to restore stability. During the optimization process, vectorized encoding can be used to generate intermediate system prompts, ensuring their structure remains related to the original system prompts and guaranteeing the continuity of the optimization direction. These intermediate system prompts undergo semantic consistency and compliance verification. Verification can be based on rule sets, terminology databases, or structural comparison mechanisms. Once verification is passed, updated system prompts are generated, ensuring the reliability of the update results within semantic, logical, and industry-specific constraints.
[0025] This embodiment combines user prompts with feedback analysis results and adjusts system prompts under optimized operation type control, making the update direction task-oriented and semantically stable. This achieves round-by-round improvement of system prompts, resulting in better performance in terms of consistency, accuracy, and controllability of the final generated content.
[0026] S50, under the condition that the updated system prompt words are fixed, perform user prompt word optimization processing on the user prompt words based on the optimized operation type to obtain the updated prompt word combination; In this embodiment, the condition for fixing the updated system prompts describes that the global instruction content formed in the preceding optimization chain remains unchanged, serving as a stable semantic framework for language model parsing tasks. This condition ensures that the global constraint information will not shift due to local expression adjustments during subsequent processing. User prompt optimization based on optimization operation types refers to structural, semantic, or logical adjustments to user prompts under the guidance of operation types obtained from the preceding analysis chain. Optimization operation types can originate from output uncertainty fluctuations, content consistency deviations, or expression redundancy indicators, used to determine the direction of user prompt modification. For example, in the expression contraction direction, semantically repetitive phrases are deleted or long sentences are compressed to improve expression compactness; in the semantic enhancement direction, key qualifying words are added or weak instruction statements are rewritten to enhance the clarity of task expression. The implementation of user prompt optimization can be based on text vector representation, constructing a semantic mapping for user prompts, and guiding modifications through vector similarity or semantic weights to form a new expression structure. The updated prompt word combination is a structural reorganization between the fixed system prompt words and the adjusted user prompt words, so that the two form a compatible combination input at the semantic level, improving the stability of model parsing and the consistency of instructions.
[0027] Semantic segmentation can be used to divide user prompts into semantic units such as task descriptions, background information, and constraints. Then, based on different optimization operation types, these units can be added, deleted, replaced, or rearranged. Alternatively, vector search can be used to map user prompts to an embedding space, selecting the most suitable expression fragment for replacement based on the optimization operation type. Template-based rewriting can also be employed, guiding user prompts to form a unified logical order through structural templates to improve alignment with system prompts. For scenarios requiring higher stability, a rapid inference check can be performed after optimization to further correct any adjustments that may cause semantic errors.
[0028] This embodiment fixes the system prompts and performs targeted adjustments on the user prompts, making the combination of prompts more stable in semantic structure, reducing expression conflicts and meaning shifts, and improving the consistency and controllability of the model-generated content.
[0029] S60, After the prompt word optimization is completed, the updated prompt word combination is stored in the prompt word memory. In this embodiment, the process of storing the updated prompt word combination into the prompt word memory after prompt word optimization involves obtaining the optimization results, structuring them, and persistently storing them. The completion of prompt word optimization signifies that the preceding steps have completed the bidirectional adjustment of system prompt words and user prompt words, resulting in a final prompt word combination that can express task instructions, semantic associations, and domain limitations. Storing it in the prompt word memory allows for reuse of this combination in subsequent tasks, providing a reliable historical reference during cross-task migration. The prompt word memory can be constructed using a key-value structure or an embedded structure, where the key is a task-related feature vector or text index, and the value is the prompt word combination itself, used for fast retrieval. Before storage, the prompt word combination can be encoded, converting the text into a vector representation or a compressed structure to improve retrieval speed. In actual execution, a storage index can be generated based on task configuration, dialogue metrics, or optimization tags, and the updated prompt word combination and the index are written together into the corresponding partition of the memory to ensure that prompt word combinations from different sources are not confused during retrieval. Access counts, creation times, or tag information can also be added for subsequent scheduling strategies and update mechanisms.
[0030] This embodiment writes the updated prompt words into the prompt word memory, which can build reusable historical prompt word assets, reduce the overhead of repeated optimization, realize cross-task migration capability, and improve prompt word adaptation efficiency and task response speed.
[0031] S70, when processing a new task, retrieve candidate prompt word combinations from the prompt word memory and use them as prompt word combinations.
[0032] In this embodiment, when processing a new task, it is necessary to identify the information structure contained in the new task in order to establish comparability with the cue word combinations accumulated in the cue word memory. New tasks typically include task instructions, intent text, or user input fragments, and task vectors expressing semantic patterns can be generated through a text vectorization model. The task vectors describe the semantic features of the task, and their sources can include word embedding networks, context encoders, or task label encoding models. After the task vectors are generated, a similarity comparison is performed between them and the feature records in the cue word memory through a retrieval module. Each record stored in the cue word memory already contains vector information related to the task configuration when it is stored; these records are used to provide transferability support for historical cue word combinations when a new task arrives.
[0033] Similarity calculation can be based on cosine distance, vector dot product, or a hybrid weighted distance method to measure the semantic proximity between the new task and stored task records. The retrieval module sorts the prompt word memory based on similarity and selects a set of candidate prompt word combinations. The selected candidate prompt word combinations are similar to the new task in semantic expression, execution purpose, and dialogue structure, and can be directly used as candidate input for prompt word combinations. After obtaining the candidate prompt word combinations, a semantic consistency check can be performed to ensure that the selected prompt word combinations can naturally adapt to the language scenario of the new task. Finally, the retrieved candidate prompt word combinations are used as prompt word combinations in subsequent processing, ensuring that the initial prompt word quality of the new task is consistent with historical optimization experience.
[0034] Retrieval methods can be based on vector databases, generating task vectors upon the arrival of new tasks and filtering candidate suggestion word combinations through vector distance search; alternatively, task tag matching can be used to search for suggestion word combinations with the same semantic category in a tag-indexed database; or coarse-grained screening can be performed using keyword hash mapping, followed by fine-tuning based on semantic vectors. When the database memory is large, the stored content can be partitioned by task type, business scenario, or suggestion word style to accelerate retrieval efficiency. In environments with limited hardware resources or requiring rapid startup, only low-dimensional vector encoding can be enabled for fast retrieval, or the number of comparisons can be reduced by pruning the retrieval scope.
[0035] This embodiment allows new tasks to directly inherit the stable prompt word expressions of historical tasks by retrieving candidate prompt word combinations from the prompt word memory, so that the quality of prompt words does not depend on manual reconstruction, thereby improving the task adaptation speed and improving the consistency of prompt words and the coherence of contextual style.
[0036] In one embodiment, step S10 includes: S101, Load and parse the task configuration, and extract the task type identifier and task parameter set; S102, based on the task type identifier, load the corresponding system prompt word template and user prompt word template from the prompt word template library; S103, Based on the task parameter set, perform parameterized replacement processing on the system prompt word template and the user prompt word template; S104, use the system prompt word template after parameterized replacement as the system prompt word, and use the user prompt word template after parameterized replacement as the user prompt word; S105, the system prompts and user prompts are combined according to a preset format to form a prompt combination.
[0037] In this embodiment, loading the task configuration refers to reading the structured configuration data associated with the current task from the configuration storage medium. This type of configuration is typically stored in key-value or hierarchical form, including task type fields, business scenario fields, language preference fields, security level fields, and business-related parameter fields. When parsing the task configuration, the configuration parsing module can map the original configuration data into an internally unified data structure, extracting the task type identifier and task parameter set. The task type identifier indicates which type of dialogue scenario the current task belongs to, such as claims consultation, product recommendation, health assessment inquiry, or risk warning. During parsing, it can be identified using fixed field names, enumerated values, or business tags. The task parameter set carries specific parameters related to the task instance, including geographic information, user role, business object identifier, time interval parameters, compliance restriction level, etc. The parsing process can be achieved through field matching, default value completion, and type conversion, converting string parameters into numerical values, boolean values, or list structures to form a parameter set that is easy to populate later.
[0038] Based on the task type identifier, when loading the corresponding system prompt template and user prompt template from the prompt template library, the prompt template library can be designed as an indexed storage structure, mapping the task type identifier to a set of template records. System prompt templates typically define system roles, tone style, compliance boundaries, prohibited output content range, and domain terminology usage rules, while user prompt templates tend to describe the user's perspective on problem expression framework and interaction format. The loading process can be implemented through hash mapping, inverted index, or embedded vector retrieval. If multiple candidate templates exist, the template version that is closer to the scene tags and language preferences in the task parameter set can be prioritized, and the final template combination can be determined through multi-level priority rules.
[0039] Parameterized replacement processing targets placeholder fields in both system and user prompt templates. These templates can include placeholders during design, such as task variables enclosed in curly braces or dynamic fields marked with special symbols. The process iterates through the task parameter set, finding the corresponding parameter value for each placeholder and replacing it with the actual content. During replacement, type constraints and formatting rules can be set, such as formatting monetary parameters with thousands separators, standardizing date parameters to a standard time format, and adding country or region restrictions to regional parameters. To prevent the injection of abnormal content, parameter values can be validated and length-limited before replacement, using character filtering, keyword masking, and regular expression matching to control input quality. After parameterized replacement, the system prompt template is converted into system prompts containing specific business constraints, domain terminology, and compliance guidelines, while the user prompt template is converted into user prompts that fit the current task context.
[0040] When using the parameterized replacement system prompt template as system prompts and the parameterized replacement user prompt template as user prompts, the role information of both types of prompts needs to be marked in the internal structure. System prompts can be stored in a dedicated field to indicate the model's role and behavior boundaries in the dialogue context; user prompts can be used to construct a question framework or example question visible to the user. In implementation, system prompts and user prompts can be stored separately using a structure or dictionary structure, with attached task type identifiers and summary information of the task parameter set for subsequent tracking and optimization.
[0041] When combining system prompts and user prompts into a word combination according to a preset format, a stable set of concatenation rules needs to be defined to ensure that the text input to the language model is clear and repeatable. The preset format can include a fixed paragraph order, such as placing system prompts first, then adding separators, and finally concatenating user prompts. Task metadata or environment descriptions can also be inserted between the two. The format can define uniform separators, line break rules, and marker phrases to ensure that the word combination generated under different tasks maintains structural consistency. This can be implemented through string concatenation, template engine rendering, or a structured-to-text conversion module to generate the final word combination from system prompts and user prompts according to the preset format, and output it as an input unit that can be directly used by the subsequent dialogue generation module.
[0042] This embodiment loads and parses the task configuration, selects system prompt word templates and user prompt word templates based on the task type identifier, completes parameterized replacement processing using the task parameter set, and then combines the system prompt words and user prompt words into a prompt word combination according to a preset format. This allows the prompt word construction process to be directly bound to the business configuration, enabling automatic adaptation to different business scenarios, reducing the instability caused by manually writing and adjusting prompt words, and ensuring that system prompt words and user prompt words are consistent in semantics, parameters, and structure, thereby improving the professionalism, consistency, and controllability of dialogue generation.
[0043] In one embodiment, step S20 above includes: S201, The prompt words are combined with the dialogue content to form a model input sequence; S202, Input the model input sequence into the language model to generate a dialogue response set; S203, based on preset analysis dimensions, perform multi-dimensional analysis on the dialogue response set to obtain semantic consistency analysis results, information sufficiency analysis results, compliance and security analysis results, and user satisfaction analysis results; S204, the semantic consistency analysis results, the information sufficiency analysis results, the compliance and security analysis results, and the user satisfaction analysis results are weighted and fused to obtain the feedback analysis results.
[0044] In this embodiment, when concatenating the cue word combination with the dialogue content to form the model input sequence, the cue word combination comes from the configuration and optimization results of the previous stage, and the dialogue content comes from the actual user input of the current round or a summary of historical multi-round dialogues. The system simultaneously acquires the cue word combination and the dialogue content in memory and generates the model input sequence through a concatenation strategy. The concatenation strategy can be controlled in terms of the text order, delimiter style, and metadata insertion position. For example, the string can be organized in the order of "system cue area + delimiter + user cue area + delimiter + current dialogue content," and different functional segments can be distinguished by explicitly separating phrases, special symbols, or line breaks, so that the language model can distinguish between system constraint information, user intent expression, and contextual content. After generation, the model input sequence can also undergo length pruning, character encoding conversion, and sensitive symbol normalization to ensure a unified character set, length control within the context window supported by the language model, and avoid parsing errors caused by inconsistent encoding.
[0045] When inputting the model input sequence into the language model to generate a dialogue response set, the input sequence is first converted into a discrete token sequence required by the model through a word segmenter or sub-word unit encoder. This sequence is then mapped to an integer sequence using a vocabulary index before being fed into the forward computation graph of the language model. The language model can be a decoder network based on a self-attention structure, predicting the next token position-by-position through multi-layer attention computation and a feedforward network. During the sampling phase, sampling hyperparameters such as temperature, top-k, and top-p can be set to control the diversity and stability of the generated responses. To obtain the dialogue response set, multiple sampling trajectories can be executed on the same model input sequence, generating multiple candidate responses using different random seeds or sampling strategies. Each response retains information such as the generated text, generation probability score, and length statistics, which are then aggregated to form the dialogue response set. The set structure can be in the form of a list or batch tensor for easy subsequent analysis.
[0046] When performing multi-dimensional analysis on the dialogue response set based on preset analysis dimensions, these dimensions are jointly configured by the business team and the model development team before system deployment. These dimensions include semantic consistency, information sufficiency, compliance and security, and user satisfaction. Each dimension corresponds to a type of quantitative or quasi-quantitative evaluation indicator. Semantic consistency analysis results measure the semantic matching degree between generated content and prompt word combinations, as well as between dialogue content and the overall dialogue. Specifically, this can be achieved by encoding prompt word combinations, dialogue content, and each response, calculating the cosine similarity between embedded vectors, or using an additional semantic discrimination model to determine whether the response accurately reproduces the task constraints and key points of the problem. The similarity of multiple responses is then statistically analyzed as the mean, variance, or minimum. Information sufficiency analysis results characterize whether the response covers key information points, such as whether it answers multiple sub-items of the question, or provides necessary explanation steps or option hints. This can be achieved through key phrase matching, slot filling checks, or question-and-answer matching models, counting missing information and converting it into a score. The compliance and security analysis results are used to screen responses for content that violates financial regulatory requirements, medical compliance requirements, or security policies. Potential violations can be detected using a sensitive word rule base, compliance classification model, or risk filter, generating a compliance score or risk level for each response. The user satisfaction analysis results, simulating a user's perspective, assess whether the response is easy to understand, whether the language is polite, and whether the interaction is smooth. This can be achieved using a trained quality assessment model, a question-and-answer pair-based preference scorer, or a scoring network trained based on user feedback from historical interactions, outputting a predicted satisfaction value for each response.
[0047] After completing the analysis on each dimension, the results of semantic consistency analysis, information sufficiency analysis, compliance and security analysis, and user satisfaction analysis are weighted and fused to generate feedback analysis results. During weighted fusion, the four types of analysis results can be uniformly mapped to a standardized score space, for example, through interval scaling or z-score standardization, to normalize indicators of different dimensions to the same range. Then, weight parameters are configured for each analysis dimension. Weights can be preset based on task type, business importance, and compliance level, or adjusted through online update strategies based on historical performance. In the specific calculation, the system multiplies each dimension's score by its corresponding weight and sums the results to obtain a comprehensive score. Simultaneously, the vector formed by the scores of each dimension can be retained as structured feedback for subsequent optimization of system and user prompts for different dimensions. The feedback analysis results are finally returned to the upstream optimization control module in the form of a data structure, including the overall score, scores for each dimension, and possible intermediate statistics, enabling the optimization control module to identify weaknesses in the current prompt combination based on the feedback analysis results.
[0048] This embodiment organizes prompt word combinations and dialogue content into a model input sequence and inputs it into a language model to generate a dialogue response set. Then, based on preset analysis dimensions, it performs semantic consistency analysis, information sufficiency analysis, compliance and security analysis, and user satisfaction analysis on the responses. The results of each dimension are weighted and fused to obtain feedback analysis results. This provides structured, multi-dimensional quantitative feedback for the prompt word optimization process without relying on manual review of each prompt word. The system can simultaneously perceive the degree of semantic matching, information coverage, compliance risks, and interactive experience, thereby providing a clear optimization direction for subsequent prompt word adjustments and improving the pertinence and efficiency of collaborative prompt word optimization.
[0049] In one embodiment, step S30 above includes: S301, monitor the output entropy value when the language model generates a dialogue response as an output uncertainty indicator; S302, determine the change in output entropy value over multiple consecutive optimization cycles as an index of output uncertainty change; S303, compare the output uncertainty index with a first preset threshold, compare the output uncertainty change index with a second preset threshold, and determine the optimization operation type from the exploration operation type, convergence operation type and reset operation type according to the comparison result; S304, Based on the optimization operation type, set the parameter configuration and iterative control strategy for system prompt word optimization processing and user prompt word optimization processing; S305, the parameter configuration and iterative control strategy are applied to the execution process of the system prompt word optimization processing and the user prompt word optimization processing.
[0050] In this embodiment, during the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index, ultimately addressing the balance between dialogue generation stability and exploration efficiency. The prompt word optimization process can be understood as continuously adjusting system and user prompt words through multiple iterations to improve dialogue quality and business relevance. In this process, without quantitative feedback and control signals, optimization is prone to excessive oscillations or premature convergence, thus weakening its adaptability to complex financial and medical scenarios. Therefore, after each round of dialogue generation, a calculable metric needs to be introduced to characterize the uncertainty of the current output and its trend over time, and different adjustment strategies should be formulated accordingly.
[0051] Output uncertainty is measured by monitoring the output entropy of the language model as it generates dialogue responses. The output entropy is calculated based on the probability distribution given by the model at each marker position. The probability of each candidate marker is multiplied by its logarithmic probability, and the sum is obtained to get the entropy at a single position. This is then averaged or weighted across the entire response sequence. A higher entropy indicates more dispersed internal judgments by the model under that input, resulting in greater output uncertainty; a lower entropy indicates a more focused generation tendency under the current prompt word combination and dialogue content, leading to more stable output. In practical implementation, the predicted probability distribution at each step can be retained during decoding, and entropy values can be calculated in batches using tensor operations, avoiding the overhead of repeated forward inference.
[0052] The output uncertainty variation index is obtained by determining the change in output entropy over multiple consecutive optimization cycles. The optimization cycle can correspond to the prompt word update cycle; for example, each joint adjustment of the system prompt word and the user prompt word is considered a cycle. The system can save the output entropy value sequence of the most recent several cycles and calculate the entropy difference, average rate of change, or variance between adjacent cycles through differencing or sliding window statistics. If the change remains large, it indicates that the model behavior is still fluctuating wildly after the prompt word update; if the change gradually decreases, it indicates that the generation behavior is stabilizing. To improve robustness, the change can be smoothed, for example, by using an exponentially weighted average to reduce the impact of random anomalies.
[0053] After obtaining the output uncertainty index and the output uncertainty change index, these two quantities need to be compared with preset thresholds. The first preset threshold is used to constrain the output uncertainty index and can be pre-set according to the target business's requirements for response stability. For example, for financial contract interpretation scenarios with extremely high compliance requirements, the first preset threshold can be set lower; for more exploratory user guidance scenarios, the threshold can be slightly higher. The second preset threshold is used to constrain the output uncertainty change index and can be obtained based on historical optimization records. For example, by analyzing the entropy change level during stable convergence on a large number of tasks, an empirical range can be determined. During runtime, the system compares the output uncertainty index of the current period with the first preset threshold and the output uncertainty change index with the second preset threshold to determine whether the current generation state belongs to a region of high uncertainty and drastic change, low uncertainty but slow change, or something in between.
[0054] Based on the above comparison results, the optimization operation type is determined from the exploration, convergence, and reset operation types. The exploration operation type corresponds to situations with high output uncertainty or large variations. In this case, the system tends to encourage larger adjustments to search for more suitable prompt word configurations, such as increasing perturbation intensity or trying new prompt structures. The convergence operation type is suitable for states where output uncertainty has decreased and variations are small. In this case, small-step corrections are more appropriate, finely adjusting key expressions in the prompt words to prevent deviation from the existing optimal solution. The reset operation type corresponds to situations where both output uncertainty and variations are in unfavorable ranges, such as prolonged high uncertainty without significant improvement. The system can trigger a reset, reverting the prompt words to a historically better-performing version or re-enabling the standard template as a new starting point. The determination of the optimization operation type can be implemented through a simple rule tree or by encoding the mapping relationship between different regions and operation types using a state machine structure.
[0055] For example, after sampling a large number of financial and medical dialogue tasks, the average output entropy of a single-turn dialogue response can be normalized to the range of 0 to 1. Further analysis shows that when the business quality is acceptable, the entropy value is roughly concentrated in the range of 0.2 to 0.5, and the entropy change is concentrated in the range of 0.02 to 0.08. Based on this, a first preset threshold H1 can be set to 0.5, and a second preset threshold H2 to 0.08. When the output entropy of the current optimization cycle is less than or equal to H1 and the entropy change over several consecutive cycles is also less than or equal to H2, the uncertainty is considered to be at a low level with small fluctuations, corresponding to a convergence operation type, which is more suitable for fine-tuning the prompt word expression with small steps. When the output entropy is greater than H1 and the entropy change is greater than H2, it is considered to have high uncertainty and active changes, corresponding to an exploration operation type, which can increase the learning rate, relax regularization constraints, and allow for a greater adjustment of the prompt word structure. When the output entropy is greater than H1 for a long period of time and the entropy change remains close to zero or a minimum value over multiple periods, for example, the entropy is always above 0.7 while the change is below 0.01, it indicates that the system is in a state of high uncertainty that is difficult to improve. At this time, the operation type can be reset, the prompt words can be rolled back to a version with better historical performance, or the template prompts can be reintroduced as a new starting point.
[0056] After determining the optimization operation type, it is necessary to configure the parameter settings and iteration control strategies for system prompt word optimization and user prompt word optimization based on that type. Parameter settings may include the learning rate, regularization weight, allowed text range for modification, and maximum change length per update. Iteration control strategies may include which side of the prompt words to update in each round, whether to alternate between system and user prompt words, the number of iteration rounds in a single optimization, and whether to enable historical prompt version comparison. For exploratory operation types, a larger learning rate and lower regularization weight can be used, allowing for simultaneous structural adjustments to both system and user prompt words. For convergence operation types, the learning rate can be reduced, regularization constraints strengthened, and fine-tuning limited to local statement levels. For reset operation types, the learning rate can be readjusted to a moderate level, and historical version retrieval can be enabled to bring the current prompt words back to near verified and reliable configurations.
[0057] Finally, the parameter configuration and iterative control strategy are applied to the execution process of system prompt word optimization and user prompt word optimization. Specifically, the optimization engine maintains independent but coordinated update modules for the two types of prompt words. The parameter configuration obtained from the optimization operation type mapping is injected into the update module, and the iterative control strategy is converted into a specific update order and stopping condition. During execution, the system first selects one or both sides of the prompt word that needs adjustment in the current round according to the control strategy. Then, it calculates the gradient approximation or preference feedback direction of the objective function based on the parameter configuration, generates text-level update candidates, performs quality screening on the candidates, and writes them back to the prompt word storage area. After each round of adjustment, the system re-enters the output uncertainty monitoring and analysis stage, realizing a closed-loop control process driven by indicators.
[0058] This embodiment introduces output entropy as an output uncertainty index during the prompt word optimization process, and constructs an output uncertainty change index using the entropy change over a continuous optimization cycle. Then, it combines a first preset threshold and a second preset threshold to determine the exploration operation type, convergence operation type, and reset operation type. Based on different operation types, it sets parameter configurations and iterative control strategies for system prompt word optimization and user prompt word optimization, and applies these configurations and strategies to the specific execution process. This allows the prompt word optimization process to be transformed from a single static update into a dynamic control process adjusted by state variables.
[0059] In one embodiment, step S40 above includes: S401, Based on the user prompt words and the feedback analysis results, determine the direction of the system prompt word optimization gradient; S402, determine the optimization step size and regularization strength parameters of the system prompt words according to the optimization operation type; S403, Based on the system prompt word optimization gradient direction, the optimization step size, and the regularization strength parameter, generate the system prompt word update amount; S404, apply the system prompt word update amount to the system prompt word to generate an intermediate system prompt word; S405, perform semantic consistency and compliance verification on the intermediate system prompt words. After the semantic consistency and compliance verification is passed, the updated system prompt words are obtained.
[0060] In this embodiment, an optimization objective for the system prompts is first constructed using user prompts and feedback analysis results. User prompts reflect user expression habits, question structure, and interaction tone during the dialogue. Feedback analysis results summarize multi-dimensional evaluation data, including semantic consistency analysis, information sufficiency analysis, compliance and security analysis, and user satisfaction analysis. The system constructs an evaluation function by mapping the dialogue responses generated by combining system prompts and user prompts to the feedback analysis results. Responses with high semantic consistency, high information sufficiency, high compliance and security, and high user satisfaction are mapped to lower loss values, while responses deviating from business expectations are mapped to higher loss values. Based on this evaluation function, gradient calculation is performed on the parameter representation of the system prompts to obtain the optimization gradient direction. System prompts can be represented as a set of adjustable parameters in vector space. The optimization gradient direction corresponds to the direction in which the evaluation function decreases within this space. The calculation can be achieved through an automatic differentiation mechanism or by constructing a numerical difference approximation by comparing the feedback analysis results generated by different versions of system prompts to obtain an estimate of the adjustment direction of the system prompts.
[0061] After obtaining the optimization gradient direction of the system prompt, the optimization step size and regularization strength parameters of the system prompt need to be determined based on the optimization operation type. The optimization operation type originates from the decision results of the previous stage based on the output uncertainty index and the output uncertainty change index, and is used to distinguish different situations such as needing to enhance exploration, perform fine convergence, or trigger a reset. The optimization step size is used to control the scale of advancement along the optimization gradient direction of the system prompt. Under the exploration operation type, a larger optimization step size can be set to quickly jump out of the current prompt configuration. Under the convergence operation type, the optimization step size can be reduced to limit the adjustment range to avoid disrupting the established stable performance. After the reset operation type occurs, a smaller optimization step size can be used to perform gentle fine-tuning after reverting to a historical system prompt version. The regularization strength parameter is used to constrain the deviation range of the system prompt during the optimization process, preventing a single optimization from causing the system prompt to deviate from the business context or exceed the existing safety boundaries. This parameter can be applied to the vector norm of the system prompt words or the distance metric between them and the preset template. Under the exploration operation type, the regularization strength is appropriately reduced to give the system prompt words more adjustable space within the safe region. Under the convergence operation type, the regularization strength is increased to emphasize keeping close to historically effective expressions. Under the reset operation type, the change rate is controlled by combining a rollback strategy.
[0062] After determining the optimization gradient direction, optimization step size, and regularization strength parameters for the system prompt words, the system prompt word update quantity is generated by combining these three parameters. The system prompt word update quantity can be viewed as a vector with the same dimension as the system prompt word parameter space, its direction being the same as or near the optimization gradient direction of the system prompt word. It is scaled by the optimization step size and superimposed with the constraint component generated by the regularization term. The generation process can employ a simple gradient descent approach, multiplying the optimization step size by the optimization gradient direction of the system prompt word and then subtracting the correction component corresponding to the regularization term. Alternatively, it can combine momentum factor or adaptive learning rate algorithms to construct a smoother update quantity, making continuous multi-round system prompt word updates more stable. After the system prompt word update quantity is generated, it is added to the current system prompt word at the parameter level to obtain the intermediate system prompt word. The intermediate system prompt word semantically corresponds to an update result that has not yet been finalized, retaining the original system prompt word's business framework while introducing adjustments based on feedback analysis results.
[0063] For intermediate system prompts, semantic consistency and compliance verification are required. Only after both types of verification pass can the intermediate system prompts be promoted to updated system prompts. Semantic consistency verification involves constructing a set of representative task configurations and corresponding user prompts, combining the intermediate system prompts with these user prompts, and feeding them into a language model to generate a set of dialogue responses. Then, semantic consistency analysis is performed again on these responses to assess whether the intermediate system prompts remain consistent with the user prompts in the same business context, and to check the consistency of important terminology explanations, reasoning chains, and business rule references. If the semantic consistency analysis result is below a predetermined threshold, the update can be rejected or the system prompt update volume can be reduced to generate new intermediate system prompts. Compliance verification focuses on financial and insurance business rules, healthcare service standards, and general content security requirements. It uses rule matching engines, sensitive word detection models, and discriminative models trained on compliance tags to screen dialogue responses driven by intermediate system prompts, verifying whether the language model outputs content containing illegal expressions, misleading suggestions, or content exceeding professional boundaries. When the compliance and security analysis results meet the preset threshold, and the semantic consistency analysis results also meet the preset threshold, the intermediate system prompt words are recorded as the updated system prompt words. Subsequent periodic prompt word optimization processing will continue to be executed with the updated system prompt words as the new basic configuration, thereby gradually improving the adaptability to user prompt words and feedback analysis results while ensuring business security.
[0064] This embodiment constructs the system prompt word optimization gradient direction based on user prompt words and feedback analysis results, and jointly adjusts the optimization step size and regularization intensity parameters of the system prompt words under the control of the optimization operation type. It can adaptively generate system prompt word update amounts for different uncertainty states, so that the movement of system prompt words in the vector space can respond to semantic deviations and insufficient information reflected in the feedback analysis results, and will not produce uncontrolled offsets in a single update.
[0065] In one embodiment, step S50 above includes: S501, Based on the user prompt words, the updated system prompt words, and the user interaction history, generate a set of candidate user prompt words; S502, combine each candidate user prompt word in the candidate user prompt word set with the updated system prompt word, and input the combination results into the language model to generate the corresponding candidate dialogue response set; S503, analyze each candidate dialogue response set based on preset analysis dimensions to obtain candidate feedback analysis results; S504, determine the output entropy value of each candidate dialogue response set as the candidate output uncertainty index; S505, Determine the user prompt word selection strategy based on the optimized operation type; S506, Based on the candidate output uncertainty index, the candidate feedback analysis results and the user prompt word selection strategy, the candidate user prompt word set is scored and ranked. S507, Based on the rating ranking results, select target user prompt words from the candidate user prompt word set; S508, combine the updated system prompt word with the target user prompt word to form an updated prompt word combination.
[0066] In this embodiment, under the condition that the updated system prompts are fixed, when optimizing user prompts, a candidate user prompt set is first constructed using the currently used user prompts, the stabilized updated system prompts, and the user interaction history accumulated over a period of time. User prompts reflect the structure of user question expressions, preferred tone, and commonly used contextual phrases. Updated system prompts provide unified role settings, domain boundaries, and compliance constraints. User interaction history includes question texts from historical sessions, model answers, and previously obtained feedback analysis results. In implementation, user interaction history can be clustered, grouping similar question types and similar feedback results together. Representative user question templates are extracted from each group, and then combined with the sentence structure and vocabulary of the current user prompts. These historical templates are then integrated with the current expression to form multiple candidate user prompt versions. For example, key business fields and constraint terms can be retained, while the question structure, preceding context, and example phrases in the prompts can be replaced or rearranged to generate a candidate user prompt set covering different question styles and information granularities.
[0067] After obtaining the set of candidate user prompts, to evaluate the effectiveness of their combination with the updated system prompts, each candidate user prompt needs to be combined with the updated system prompt, and then input into a language model to generate a corresponding set of candidate dialogue responses. The combination can use a fixed format, placing the updated system prompt in the system position within the dialogue context and the candidate user prompt in the user position. Several test inputs are repeatedly constructed under the same business task configuration to observe the output behavior of the same candidate user prompt under different implicit sampling conditions. The language model can be a large-scale language model deployed on a server, performing inference on multiple combinations at once through a batch inference interface to generate multiple candidate responses, thus forming a set of candidate dialogue responses for each candidate user prompt. These responses provide the data foundation for subsequent analysis.
[0068] To compare different candidate user prompts from a business quality perspective, each candidate dialogue response set needs to be analyzed based on preset analysis dimensions to obtain candidate feedback analysis results. The preset analysis dimensions are consistent with the feedback analysis described earlier and typically include metrics such as semantic consistency, information sufficiency, compliance and security, and user satisfaction. In implementation, a corresponding evaluation model or rule set can be configured for each dimension. For example, a semantic similarity model can be used to determine the degree of consistency between the answer and the task objective; an information extraction model can be used to check whether key fields are covered; a compliance rule engine or compliance model can be used to determine whether inappropriate expressions occur; and a user satisfaction prediction model can be used to give scores based on answer structure, politeness, and problem-solving effectiveness. For each candidate dialogue response set, statistics such as the average score, minimum score, and variance on each dimension can be calculated, and then summarized to form the candidate feedback analysis results, which characterize the stable performance of the candidate user prompt across multiple rounds of output.
[0069] Beyond feedback dimension analysis, it's also necessary to quantify the uncertainty of the language model's output under each candidate user prompt. Therefore, the output entropy value is calculated for each candidate dialogue response set, serving as an indicator of candidate output uncertainty. The output entropy value can be calculated based on the probability distribution at various points in the model's generation process, averaging the entropy of word-level or token-level probability distributions over time to obtain the overall output entropy. Alternatively, it can focus only on the output entropy at key business locations, such as tokens involving fields like amount, insurance type, or treatment suggestions. A higher output entropy value indicates lower model confidence in the candidate expression under the current prompt configuration, making the answer more prone to wavering or instability. Recording the output entropy value of each candidate dialogue response set allows for simultaneous consideration of answer quality and uncertainty in subsequent user prompt word selection processes.
[0070] User prompt selection strategies rely on the optimization operation type for configuration. Optimization operation types are derived from the previous stage's assessment of global output uncertainty and change indicators, generally including exploration, convergence, and reset operation types. The user prompt selection strategy can define the weighted combination of different dimension scores and candidate output uncertainty indicators in the overall score. For example, under the exploration operation type, it tends to select candidate user prompts with moderate output entropy but high diversity to expand the language model's response space. Under the convergence operation type, it prioritizes compliance security and semantic consistency scores to solidify existing high-quality dialogue patterns. The strategy can also incorporate a preference for successful cases in user interaction history, such as assigning bonus points to prompt formats that have received high satisfaction feedback in similar tasks.
[0071] After determining the user suggestion selection strategy, the candidate user suggestion set is scored and ranked. Scoring can be achieved by constructing a comprehensive scoring function, which weights the scores from each dimension of the candidate feedback analysis results with the candidate output uncertainty index. The weights are given by the user suggestion selection strategy. For example, the comprehensive score can be set as a weighted score of semantic consistency plus information sufficiency, with a penalty proportional to the output entropy value deducted and a reward for compliance and security exceeding a threshold added. For exploratory operations, the output entropy penalty weight can be reduced to encourage more divergent questioning; for convergent operations, the output entropy penalty weight can be increased to prioritize candidate user suggestions with stable output and high response concentration. This comprehensive score is then used to rank the candidate user suggestion set from highest to lowest.
[0072] Based on the scoring ranking results, target user prompts are selected from the candidate user prompt set. The selection method can be to directly choose the highest-scoring candidate user prompt, or to introduce a small amount of randomness among multiple candidates with similar scores to avoid the system prematurely falling into local optima. In long-term operation, diversity constraints can be added to avoid selecting target user prompts with the exact same structure in multiple consecutive rounds, thereby improving adaptability to different user expression habits. After the target user prompts are determined, the updated system prompts are combined with the target user prompts to form an updated prompt combination. The combination format remains consistent with the previous steps: the updated system prompts are placed in the system position controlling the model's behavior, and the target user prompts are placed in the user position expressing the specific business request. This yields the prompt configuration used in subsequent dialogue rounds or the next task cycle, achieving coordinated adjustment of system prompts and user prompts under the same optimization operation type constraint.
[0073] This embodiment constructs a candidate user prompt word set by utilizing user prompt words, updated system prompt words, and user interaction history, under the premise that the updated system prompt words are fixed. It combines the candidate dialogue response set generated by the language model, the candidate feedback analysis results obtained under the preset analysis dimensions, and the candidate output uncertainty index formed based on the output entropy value. Under the constraint of optimizing the operation type, it formulates a user prompt word selection strategy and completes the scoring ranking and target user prompt word selection. It can finely adjust the user-side expression without destroying the stability of the system prompt words, so that the updated prompt word combination can simultaneously take into account business consistency, response quality, and output stability.
[0074] In one embodiment, step S60 above includes: S601, After the prompt word optimization is completed, extract the task configuration information and optimization process indicators of the current optimization task; S602, the task configuration information, the optimization process indicators and the updated prompt words are associated and encoded to generate a memory storage entry; S603, Based on the feature vector of the task configuration information, determine the storage location index of the memory bank storage entry; S604, the memory bank storage entries are stored in the corresponding storage partition of the prompt word memory bank according to the storage location index; S605, add timestamps and access frequency metadata to the entries stored in the memory bank, and update the metadata index of the prompt word memory bank.
[0075] In this embodiment, the premise is that the prompt word optimization has been completed, meaning that the system prompt words and user prompt words have completed one or more rounds of joint updates. The currently obtained updated prompt word combination can be considered a better result under a specific task configuration and data environment. At this point, it is first necessary to clarify which optimization task the update corresponds to. To this end, the task configuration information of the current optimization task is read from the scheduling module or task management module, such as task type identifier, business scenario identifier, target language model version, financial or healthcare business domain label, constraint policy identifier, evaluation indicator configuration, etc. Simultaneously, optimization process indicators are extracted from the optimization control module, such as the uncertainty indicator trajectory in each round of dialogue, feedback analysis score trajectory, entropy control operation type sequence, whether a reset operation is triggered, and the final comprehensive score. The task configuration information reflects "under what conditions optimization is performed," while the optimization process indicators reflect "how the optimization process evolves." Together, they define the applicable boundaries and reliability level of the updated prompt word combination.
[0076] Task configuration information, optimization process indicators, and updated prompt word combinations need to be associated and encoded using a unified data structure to form entries stored in the memory. This association encoding can employ a key-value record structure, using information such as task type, business scenario, and model version as key fields, and optimization process indicators and updated prompt word combinations as value fields. Alternatively, a retrieval-oriented composite vector can be constructed, mapping the discrete identifiers in the task configuration information into a dense vector through embedding, and statistically reducing the numerical sequences in the optimization process indicators to obtain several stable features, such as the mean of uncertainty, the extreme value of uncertainty, the slope of uncertainty change, and the average feedback score. These features are then concatenated with the prompt word text encoding vector to form a high-dimensional representation. Regardless of the structure used, the goal of association encoding is to ensure that the task configuration information, optimization process indicators, and updated prompt word combinations are always located and accessed as a whole during storage and retrieval.
[0077] To enable rapid searching based on task similarity when processing new tasks, feature vectors need to be constructed from the task configuration information. Feature vectors can contain multiple dimensions, such as one-hot encoding of task type, embedding of business scenario labels, embedding of labels from financial or healthcare sub-domains, model version number mapping values, and mapping values of key constraint policy identifiers. Construction methods can include rule-based mapping, mapping discrete labels to predefined numerical ranges; or using a trained encoding network to encode the task configuration information text or structured fields. After obtaining the feature vectors, a storage location index can be generated using hash functions, cluster center mapping, or hierarchical index trees. The storage location index indicates which storage partition in the cue word memory an entry should fall into, such as a hash bucket, a vector index cluster, a disk partition, or a segmented region in memory.
[0078] When writing entries to the prompt word memory, they are written to the corresponding storage partition according to the storage location index. The prompt word memory can be organized into a multi-level structure, such as a top-level partition for task type, a middle-level partition for business scenario, and a bottom-level partition for vector similarity index. Alternatively, a one-dimensional partitioning method based on hash can be used, directly mapping hash values to physical locations. During the writing process, it is necessary to ensure that the stored entries contain the updated prompt word combination text or its vector representation, while retaining structured fields of task configuration information and optimization process indicators to support subsequent retrieval, filtering, and statistical analysis. The write operation can support append mode, and can also overwrite or migrate versions of old entries under the same task configuration to reduce redundancy.
[0079] To support dynamic management across time and usage frequency dimensions, timestamps and access frequency metadata are appended to entries stored in the memory. Timestamps can record write time, last access time, etc., typically using system time or logical timestamps accurate to milliseconds. Access frequency metadata can include access counts, access window counts over a recent period, and time-decay-based weight values. This metadata is used to construct metadata indexes, such as ordered indexes based on time, priority queues based on access frequency, and multidimensional indexes based on a combination of time and frequency. It also drives eviction and preloading strategies in the memory, such as prioritizing the retention of high-frequency and latest suggestion word combinations, and downgrading or cleaning up entries that have not been accessed for a long time and have poor feedback metrics. Metadata indexes can be implemented by jointly encoding metadata with inverted tables, B+ trees, skip lists, or vector indexes, allowing for the retrieval of updated suggestion word combinations based on task similarity, as well as filtering and sorting by time or usage frequency when processing new tasks.
[0080] This embodiment encodes the updated prompt word combination, along with task configuration information and optimization process indicators, into a prompt word memory storage entry after prompt word optimization. This entry is then organized into the prompt word memory based on feature vectors and storage location indexes. Simultaneously, it maintains timestamps, access frequency metadata, and corresponding metadata indexes. This enables the accumulation and structured management of prompt word experience for fintech and healthcare business sectors. When processing subsequent tasks, the system can quickly locate updated prompt word combinations highly similar to the current task configuration, reducing redundant optimization overhead and improving the accuracy and stability of prompt word migration. Furthermore, by managing time and access frequency dimensions, the system achieves dynamic optimization and eviction of prompt word content, thereby improving responsiveness to business changes and long-term resource utilization efficiency while maintaining generation quality.
[0081] In one embodiment, a two-way prompt word collaborative optimization device is provided, which corresponds one-to-one with the two-way prompt word collaborative optimization method in the above embodiments. (Refer to...) Figure 3 , Figure 3 This is a schematic diagram of the functional modules of a preferred embodiment of the bidirectional prompt word collaborative optimization device of the present invention. The modules include a task configuration parsing module 10, a response analysis module 20, an optimization strategy decision module 30, a system prompt word optimization module 40, a user prompt word optimization module 50, a prompt word storage module 60, and a prompt word retrieval module 70. Detailed descriptions of each functional module are as follows: The task configuration parsing module 10 is used to load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination. The response analysis module 20 is used to input the combination of prompt words and dialogue content into a language model to generate a dialogue response set, and to analyze the dialogue response set based on a preset analysis dimension to obtain feedback analysis results. The optimization strategy decision module 30 is used to determine the optimization operation type based on the output uncertainty index and the output uncertainty change index during the prompt word optimization process, and to control the execution process of system prompt word optimization processing and user prompt word optimization processing based on the optimization operation type. The system prompt word optimization module 40 is used to perform system prompt word optimization processing on the system prompt word based on the user prompt word and the feedback analysis result, under the control of the optimization operation type, to obtain the updated system prompt word; The user prompt word optimization module 50 is used to perform user prompt word optimization processing on the user prompt words based on the optimization operation type, under the condition that the updated system prompt words are fixed, to obtain the updated prompt word combination; The prompt word storage module 60 is used to store the updated prompt word combination into the prompt word memory after the prompt word optimization is completed; The prompt word retrieval module 70 is used to retrieve candidate prompt word combinations from the prompt word memory when processing a new task, and use them as prompt word combinations.
[0082] In one embodiment, the task configuration parsing module 10 is specifically used for: Load and parse the task configuration, extracting the task type identifier and task parameter set; Based on the task type identifier, load the corresponding system prompt template and user prompt template from the prompt template library; Based on the task parameter set, parameterized replacement processing is performed on the system prompt word template and the user prompt word template; The system prompt word template after parameterized replacement is used as the system prompt word, and the user prompt word template after parameterized replacement is used as the user prompt word; The system prompts and user prompts are combined according to a preset format to form a prompt combination.
[0083] In one embodiment, the response analysis module 20 is specifically used for: The prompt words are combined with the dialogue content to form the model input sequence; The input sequence of the model is input into the language model to generate a set of dialogue responses; Based on preset analysis dimensions, the dialogue response set is analyzed in multiple dimensions to obtain semantic consistency analysis results, information sufficiency analysis results, compliance and security analysis results, and user satisfaction analysis results. The semantic consistency analysis results, information sufficiency analysis results, compliance and security analysis results, and user satisfaction analysis results are weighted and fused to obtain feedback analysis results.
[0084] In one embodiment, the optimization strategy decision module 30 is specifically used for: The output entropy value of the language model when generating dialogue responses is used as an indicator of output uncertainty. The change in output entropy over multiple consecutive optimization cycles is determined as an indicator of output uncertainty. The output uncertainty index is compared with a first preset threshold, and the output uncertainty change index is compared with a second preset threshold. Based on the comparison results, the optimization operation type is determined from the exploration operation type, the convergence operation type, and the reset operation type. Based on the optimization operation type, set the parameter configuration and iterative control strategy for system prompt word optimization processing and user prompt word optimization processing; The parameter configuration and iterative control strategy are applied to the execution process of the system prompt word optimization processing and the user prompt word optimization processing.
[0085] In one embodiment, the system prompt word optimization module 40 is specifically used for: Based on the user prompts and the feedback analysis results, determine the direction of the system prompt optimization gradient; Based on the optimization operation type, determine the optimization step size and regularization strength parameters of the system prompt words; Based on the system prompt word optimization gradient direction, the optimization step size, and the regularization strength parameter, the system prompt word update amount is generated; The system prompt word update amount is applied to the system prompt word to generate intermediate system prompt words; The intermediate system prompt words are subjected to semantic consistency and compliance verification. After the semantic consistency and compliance verification is passed, the updated system prompt words are obtained.
[0086] In one embodiment, the user suggestion optimization module 50 is specifically used for: Based on the user prompt words, the updated system prompt words, and the user interaction history, a set of candidate user prompt words is generated. Each candidate user prompt word in the candidate user prompt word set is combined with the updated system prompt word, and the combination results are input into the language model to generate the corresponding candidate dialogue response set. Each candidate dialogue response set is analyzed based on preset analysis dimensions to obtain candidate feedback analysis results; The output entropy value of each candidate dialogue response set is determined as an indicator of candidate output uncertainty. Based on the optimized operation type, determine the user prompt word selection strategy; Based on the candidate output uncertainty index, the candidate feedback analysis results, and the user prompt word selection strategy, the candidate user prompt word set is scored and ranked. Based on the rating ranking results, select target user prompts from the candidate user prompt word set; The updated system prompt word is combined with the target user prompt word to form an updated prompt word combination.
[0087] In one embodiment, the prompt word storage module 60 is specifically used for: After the prompt word optimization is completed, extract the task configuration information and optimization process indicators of the current optimization task; The task configuration information, the optimization process indicators, and the updated prompt words are combined and encoded to generate a memory storage entry. Based on the feature vector of the task configuration information, the storage location index of the memory storage entry is determined; The memory entries are stored in the corresponding storage partitions of the prompt word memory according to the storage location index; Add timestamps and access frequency metadata to the entries stored in the memory, and update the metadata index of the prompt word memory.
[0088] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides determination and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a two-way prompt word collaborative optimization method on the server side.
[0089] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 5 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides determination and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements the client-side functions or steps of a bidirectional prompt word collaborative optimization method.
[0090] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination; The prompt words are combined with the dialogue content and input into a language model to generate a dialogue response set. The dialogue response set is then analyzed based on a preset analysis dimension to obtain feedback analysis results. During the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index. Based on the optimization operation type, the execution process of system prompt word optimization processing and user prompt word optimization processing is controlled. Based on the user prompt words and the feedback analysis results, the system prompt words are optimized under the control of the optimized operation type to obtain the updated system prompt words. Under the condition that the updated system prompt words are fixed, user prompt word optimization processing is performed on the user prompt words based on the optimized operation type to obtain the updated prompt word combination; After the prompt word optimization is completed, the updated prompt word combination will be stored in the prompt word memory. When processing a new task, candidate combinations of prompt words are retrieved from the prompt word memory and used as prompt word combinations.
[0091] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, and a computer program is stored thereon, which, when executed by a processor, performs the following steps: Load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination; The prompt words are combined with the dialogue content and input into a language model to generate a dialogue response set. The dialogue response set is then analyzed based on a preset analysis dimension to obtain feedback analysis results. During the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index. Based on the optimization operation type, the execution process of system prompt word optimization processing and user prompt word optimization processing is controlled. Based on the user prompt words and the feedback analysis results, the system prompt words are optimized under the control of the optimized operation type to obtain the updated system prompt words. Under the condition that the updated system prompt words are fixed, user prompt word optimization processing is performed on the user prompt words based on the optimized operation type to obtain the updated prompt word combination; After the prompt word optimization is completed, the updated prompt word combination will be stored in the prompt word memory. When processing a new task, candidate combinations of prompt words are retrieved from the prompt word memory and used as prompt word combinations.
[0092] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0093] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0094] It should be noted that if any software tools or components not belonging to this company appear in the embodiments of this application, they are merely illustrative examples and do not represent actual use. The embodiments described above are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
[0095] The user personal information involved in this application embodiment is all authorized (knowing and consenting) by the relevant parties or fully authorized by all parties, and the executing entity can obtain it through various open, legal and compliant means. The collection, storage, use, processing, transmission, provision and disclosure of the information, data and signals involved all comply with the relevant laws and regulations of the relevant countries and regions, and do not violate public order and good morals.
Claims
1. A two-way prompt word collaborative optimization method, characterized in that, Includes the following steps: Load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination; The prompt words are combined with the dialogue content and input into a language model to generate a dialogue response set. The dialogue response set is then analyzed based on a preset analysis dimension to obtain feedback analysis results. During the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index. Based on the optimization operation type, the execution process of system prompt word optimization processing and user prompt word optimization processing is controlled. Based on the user prompt words and the feedback analysis results, the system prompt words are optimized under the control of the optimized operation type to obtain the updated system prompt words. Under the condition that the updated system prompt words are fixed, user prompt word optimization processing is performed on the user prompt words based on the optimized operation type to obtain the updated prompt word combination; After the prompt word optimization is completed, the updated prompt word combination will be stored in the prompt word memory. When processing a new task, candidate prompt word combinations are retrieved from the prompt word memory and used as prompt word combinations.
2. The bidirectional prompt word collaborative optimization method as described in claim 1, characterized in that, Load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination, including: Load and parse the task configuration, extracting the task type identifier and task parameter set; Based on the task type identifier, load the corresponding system prompt template and user prompt template from the prompt template library; Based on the task parameter set, parameterized replacement processing is performed on the system prompt word template and the user prompt word template; The system prompt word template after parameterized replacement is used as the system prompt word, and the user prompt word template after parameterized replacement is used as the user prompt word; The system prompts and user prompts are combined according to a preset format to form a prompt combination.
3. The bidirectional prompt word collaborative optimization method as described in claim 1, characterized in that, The combination of the prompt words and the dialogue content are input into a language model to generate a dialogue response set. This dialogue response set is then analyzed based on preset analysis dimensions to obtain feedback analysis results, including: The prompt words are combined with the dialogue content to form the model input sequence; The input sequence of the model is input into the language model to generate a set of dialogue responses; Based on preset analysis dimensions, the dialogue response set is analyzed in multiple dimensions to obtain semantic consistency analysis results, information sufficiency analysis results, compliance and security analysis results, and user satisfaction analysis results. The semantic consistency analysis results, information sufficiency analysis results, compliance and security analysis results, and user satisfaction analysis results are weighted and fused to obtain feedback analysis results.
4. The bidirectional prompt word collaborative optimization method as described in claim 1, characterized in that, During the prompt word optimization process, the optimization operation type is determined based on the output uncertainty index and the output uncertainty change index. Based on the optimization operation type, the execution process of the system prompt word optimization processing and the user prompt word optimization processing is controlled, including: The output entropy value of the language model when generating dialogue responses is used as an indicator of output uncertainty. The change in output entropy over multiple consecutive optimization cycles is determined as an indicator of output uncertainty. The output uncertainty index is compared with a first preset threshold, and the output uncertainty change index is compared with a second preset threshold. Based on the comparison results, the optimization operation type is determined from the exploration operation type, convergence operation type, and reset operation type. Based on the optimization operation type, set the parameter configuration and iterative control strategy for system prompt word optimization processing and user prompt word optimization processing; The parameter configuration and iterative control strategy are applied to the execution process of the system prompt word optimization processing and the user prompt word optimization processing.
5. The bidirectional prompt word collaborative optimization method as described in claim 1, characterized in that, Based on the user prompt words and the feedback analysis results, under the control of the optimized operation type, system prompt words are optimized to obtain updated system prompt words, including: Based on the user prompts and the feedback analysis results, determine the direction of the system prompt optimization gradient; Based on the optimization operation type, determine the optimization step size and regularization strength parameters of the system prompt words; Based on the system prompt word optimization gradient direction, the optimization step size, and the regularization strength parameter, the system prompt word update amount is generated; The system prompt word update amount is applied to the system prompt word to generate intermediate system prompt words; The intermediate system prompt words are subjected to semantic consistency and compliance verification. After the semantic consistency and compliance verification is passed, the updated system prompt words are obtained.
6. The bidirectional prompt word collaborative optimization method as described in claim 1, characterized in that, Under the condition that the updated system prompt words are fixed, user prompt word optimization processing is performed on the user prompt words based on the optimized operation type to obtain the updated prompt word combination, including: Based on the user prompt words, the updated system prompt words, and the user interaction history, a set of candidate user prompt words is generated. Each candidate user prompt word in the candidate user prompt word set is combined with the updated system prompt word, and the combination results are input into the language model to generate the corresponding candidate dialogue response set. Each candidate dialogue response set is analyzed based on preset analysis dimensions to obtain candidate feedback analysis results; The output entropy value of each candidate dialogue response set is determined as an indicator of candidate output uncertainty. Based on the optimized operation type, determine the user prompt word selection strategy; Based on the candidate output uncertainty index, the candidate feedback analysis results, and the user prompt word selection strategy, the candidate user prompt word set is scored and ranked. Based on the rating ranking results, select target user prompts from the candidate user prompt word set; The updated system prompt word is combined with the target user prompt word to form an updated prompt word combination.
7. The bidirectional prompt word collaborative optimization method as described in claim 1, characterized in that, After the prompt word optimization is completed, the updated prompt word combination will be stored in the prompt word memory, including: After the prompt word optimization is completed, extract the task configuration information and optimization process indicators of the current optimization task; The task configuration information, the optimization process indicators, and the updated prompt words are combined and encoded to generate a memory storage entry. Based on the feature vector of the task configuration information, the storage location index of the memory storage entry is determined; The memory entries are stored in the corresponding storage partitions of the prompt word memory according to the storage location index; Add timestamps and access frequency metadata to the entries stored in the memory, and update the metadata index of the prompt word memory.
8. A two-way prompt word collaborative optimization device, characterized in that, The bidirectional prompt word collaborative optimization device includes: The task configuration parsing module is used to load the task configuration, initialize system prompts and user prompts based on the task configuration, and combine the system prompts and user prompts into a prompt combination. The response analysis module is used to input the combination of the prompt words and the dialogue content into a language model to generate a dialogue response set, and to analyze the dialogue response set based on a preset analysis dimension to obtain feedback analysis results. The optimization strategy decision module is used to determine the optimization operation type based on the output uncertainty index and the output uncertainty change index during the prompt word optimization process, and to control the execution process of system prompt word optimization processing and user prompt word optimization processing based on the optimization operation type. The system prompt word optimization module is used to perform system prompt word optimization processing on the system prompt word based on the user prompt word and the feedback analysis result, under the control of the optimization operation type, to obtain the updated system prompt word; The user prompt word optimization module is used to perform user prompt word optimization processing on the user prompt words based on the optimization operation type, under the condition that the updated system prompt words are fixed, to obtain the updated prompt word combination; The prompt word storage module is used to store the updated prompt word combination into the prompt word memory after the prompt word optimization is completed; The prompt word retrieval module is used to retrieve candidate prompt word combinations from the prompt word memory when processing a new task, and use them as prompt word combinations.
9. A computer device, characterized in that, The computer device includes a memory, a processor, and a two-way prompt word co-optimization program stored in the memory and executable on the processor, wherein when the two-way prompt word co-optimization program is executed by the processor, it implements the steps of the two-way prompt word co-optimization method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a two-way prompt word collaborative optimization program, which, when executed by a processor, implements the steps of the two-way prompt word collaborative optimization method as described in any one of claims 1-7.
Citation Information
Cited By
Question answering methods, model training methods, equipment and storage media
CN122311471A