Intelligent terminal chat dialogue assistant implementation method and device, terminal and medium
By building a collaborative architecture on smart terminals and utilizing role management, security alignment, and emotion generation technologies, the problems of role consistency, security compliance, and insufficient emotional expression in the interaction of smart TV voice assistants with children have been solved, providing a personalized, safe, and emotionally rich interactive experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN COOCAA NETWORK TECH CO LTD
- Filing Date
- 2026-04-01
- Publication Date
- 2026-07-31
AI Technical Summary
Existing smart TV voice assistants suffer from issues such as a lack of role consistency, safety and compliance risks, and insufficient emotional expression when interacting with child users, resulting in an unattractive and unsafe interactive experience.
By constructing a collaborative architecture, including a role management module, a secure alignment filter, and an emotional generator, the system is automatically activated after obtaining user voice input, loads a preset role package, generates candidate responses using a large language model, performs multi-dimensional evaluation through the secure alignment filter, adds emotional tags before outputting, and uses personal voice timbre for speech synthesis.
It achieves a reliable, secure, and emotionally resonant interactive experience, ensuring that responses are consistent with roles, safe and compliant with regulations, and express emotions, thereby enhancing user engagement and satisfaction.
Smart Images

Figure CN122491472A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent terminal dialogue technology, and more specifically, to a method, apparatus, intelligent terminal, and computer-readable storage medium for implementing an intelligent terminal chat dialogue assistant based on role awareness and security alignment. Background Technology
[0002] In current smart TV applications, users, especially children, often face challenges in their interaction with voice assistants. Existing TV voice assistants may appear mechanical and impersonal in their responses, lacking an appealing personality, and in some cases, may even output inappropriate content, posing compliance risks. For example, when a child asks a question to a smart assistant, if the assistant simply provides a rigid, standard answer without considering the child's comprehension and emotional needs, the interaction may lack fun and engagement.
[0003] Therefore, existing technologies still need improvement and development. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a method, device, smart terminal and storage medium for implementing a smart terminal chat dialogue assistant based on role perception and security alignment, which addresses the problems and defects of the prior art. It has the advantages of solving the problems of lack of role consistency, security and compliance risks and insufficient emotional expression ability, and achieving a reliable, safe and emotionally rich interactive experience.
[0005] This application provides a method for implementing a smart terminal chat assistant based on role awareness and security alignment. The technical solution is as follows: A method for implementing a smart terminal chat assistant based on role awareness and security alignment, comprising: Acquire user voice input and convert it into text content through speech recognition; When a user's voice input is recognized as a chat conversation, a preset collaborative architecture is automatically activated. Based on the context of the recognized voice conversation or the user's selection, a preset role package is loaded to determine the role in the current conversation. Based on the determined roles, candidate responses corresponding to the text content are generated collaboratively by a preset content agent and a large language model. The candidate responses are evaluated for security in multiple dimensions using a preset security alignment filter, and a risk score is output. For candidate responses whose risk scores meet the security check, add emotional tags that match the character's tone; Using a personal voice associated with the character, candidate responses with emotional tags are output and played through speech synthesis technology.
[0006] The method for implementing a smart terminal chat assistant based on role awareness and security alignment includes the following steps prior to obtaining the user's voice input and performing voice recognition: A collaborative architecture is pre-built, including a role management module, a security alignment filter, and an emotional generator. It works collaboratively and outputs text-to-speech technology. The role management module is used to load family role packages, the security alignment filter is used to perform multi-dimensional security assessments on the generated candidate responses, and the emotional generator is used to add emotional tags that match the tone of the roles.
[0007] The method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment includes the following steps: when user voice input is recognized as a chat dialogue, automatically activating a preset collaborative architecture, loading a preset role package based on the recognized voice dialogue context or user selection, and determining the role of the current dialogue. The text content obtained from speech recognition is acquired and analyzed to determine whether it is chat dialogue content. When a user's voice input is recognized as a chat conversation, a preset collaborative architecture is automatically activated. Based on the context of the recognized voice conversation or the user's selection, a preset family role package and role knowledge base are loaded to determine the roles in the current conversation.
[0008] The method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment includes the step of generating candidate responses corresponding to the text content through a preset content intelligence agent and a large language model, based on a determined role. Obtain the current role and the user intent determined based on the text content; Based on the user intent, a search is performed in the corresponding role knowledge base to extract knowledge points, factual data and dialogue style examples related to the text content; The content agent dynamically and structurally organizes the extracted knowledge points, factual data, and dialogue style examples related to the text content into a detailed prompt word instruction, which is then passed to the AI big model. The AI big model generates candidate responses corresponding to the text content. The role knowledge base is also introduced as raw material and instructions into the generation process, guiding and constraining the output of the AI big model from the source, and generating candidate responses that conform to the knowledge background, style, and tone of the current role.
[0009] The method for implementing a smart terminal chat assistant based on role awareness and security alignment, wherein the step of performing a multi-dimensional security assessment of the candidate responses using a preset security alignment filter and outputting a risk score includes: The candidate responses are subjected to a multi-dimensional security assessment using a preset security alignment filter, including: In terms of explicit content security, explicit violations are filtered out through a sensitive word dictionary and regular expression matching algorithms. Semantic and intent risk dimensions: By analyzing the deep semantics of response content through a text classification model, we can identify content that promotes inappropriate behavior or misleads users. In terms of logic and factuality, for knowledge-based roles, the core knowledge points in the response are compared with internal knowledge graphs or authoritative databases to check for obvious scientific errors or logical contradictions. In terms of values and ethics, a value alignment model is established for children's scenarios to assess whether the responses conform to mainstream and positive children's values. In terms of sentiment risk, sentiment analysis is performed on the response text to identify sentiment tags and compare them with the current role's preset sentiment whitelist; if sentiments outside the whitelist that have a negative impact on children are found, sentiment compliance filtering is performed. A total risk score is obtained by weighted summation of the risk scores from the above dimensions; when the total risk score is lower than the set safety threshold, the candidate response is allowed to pass. When the total risk score is higher than or equal to the set security threshold, it is judged as high-risk content, blocked, and a rejection signal with a risk label is returned to the content agent, triggering the content to be regenerated. When regenerating candidate responses, additional avoidance instruction prompts are added to achieve a dynamic and adaptive correction cycle.
[0010] The method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment includes the step of adding emotional tags that match the character's tone to candidate replies whose risk scores meet security checks. A sentiment fitting model is pre-built. During the training phase, a predetermined amount of manually labeled data is used to learn appropriate sentiment expressions in the context of specified roles, user emotions, and response content, thereby achieving role-emotion alignment and obtaining the trained sentiment fitting model. The trained sentiment fitting model is input into the candidate responses that meet the security check for risk scores, the determined roles in the current dialogue, the user's emotional state obtained through sentiment analysis of user input, and the identified voice dialogue context. The trained sentiment fitting model encodes and fuses multiple inputs and interacts with them through an attention mechanism, outputting a single, clear sentiment label from a predefined sentiment label library.
[0011] The method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment, wherein the step of using a personal voice bound to the role to output and play candidate replies with emotional tags through speech synthesis technology includes: Using a personal voice associated with the character, the system identifies and analyzes candidate responses with emotional tags through speech synthesis technology, and automatically adjusts a series of preset prosodic parameters to achieve the corresponding emotional effect.
[0012] A device for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment, wherein the device includes: The dialogue acquisition module is used to acquire the user's voice input and convert the speech into text content through speech recognition; The role package loading module is used to automatically activate the preset collaborative architecture when the user's voice input is recognized as a chat dialogue. Based on the recognized voice dialogue context or the user's selection, the preset role package is loaded to determine the role of the current dialogue. The candidate response generation module is used to generate candidate responses corresponding to the text content based on the determined role, through a preset content agent and a large language model in collaboration. The security assessment module is used to perform multi-dimensional security assessments on the candidate responses using a preset security alignment filter and output a risk score. The sentiment tag addition module is used to add sentiment tags that match the tone of the character to candidate responses whose risk scores meet the security check. The synthesis playback module is used to output and play candidate responses with emotional tags using a personal voice tone bound to the character through speech synthesis technology.
[0013] A smart terminal includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs comprising the method for performing any one of the methods.
[0014] A computer-readable storage medium wherein, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform any of the methods described herein.
[0015] The beneficial effects of this invention are as follows: This invention provides a method, apparatus, smart terminal, and storage medium for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment. It constructs a collaborative architecture comprising three main modules: a "role management module," a "security alignment filter," and an "emotional generator," and outputs the content through text-to-speech (TTS) technology. This architecture does not simply connect the three modules in series, but rather allows them to work organically together, aiming to solve the problem that existing single-technology approaches may not be able to simultaneously address the issues of "role consistency," "content security," and "emotional richness."
[0016] The collaborative architecture constructed in this invention is activated when the user's voice input is recognized as a chat dialogue. It loads a family role package through a role management module, and the content agent and the large language model collaboratively generate candidate responses. Subsequently, a security alignment filter performs multi-dimensional risk scoring, and the verified responses are then given emotional tags that match the tone of the role by an emotion generator. Finally, the responses are broadcast to the user using personalized voice TTS technology.
[0017] This invention addresses the issues of lack of role consistency, security and compliance risks, and insufficient emotional expression by acquiring voice input, activating a collaborative architecture, generating candidate responses, conducting security assessments, adding emotional tags, and outputting playback. It has the advantage of achieving a reliable, secure, and emotionally rich interactive experience. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating the implementation method of a smart terminal chat dialogue assistant based on role awareness and security alignment provided in Embodiment 1 of the present invention.
[0020] Figure 2 This is a schematic diagram illustrating the specific implementation process of the intelligent terminal chat dialogue assistant implementation method based on role awareness and security alignment provided in Embodiment 2 of the present invention.
[0021] Figure 3 This is a schematic diagram of an embodiment of the intelligent terminal chat dialogue assistant implementation device based on role perception and security alignment provided by the present invention.
[0022] Figure 4 This is a block diagram illustrating the internal structure of a smart terminal provided in an embodiment of the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0024] It should be noted that if the embodiments of the present invention involve directional indicators (such as up, down, left, right, front, back, etc.), the directional indicators are only used to explain the relative positional relationship and movement of the components in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indicators will also change accordingly.
[0025] Traditional smart TV dialogue systems suffer from deficiencies in role awareness and safety alignment technologies. Specifically, existing solutions cannot simultaneously ensure role consistency, emotional expression, and content safety compliance. Rule-based and template-based methods offer controllable content safety but suffer from mechanical interactions and struggle to handle open-ended questions; retrieval-based methods provide natural responses but lack personality consistency and may contain unsafe content in their corpora; and purely generative large-scale models offer fluent language but are prone to model illusions and safety compliance risks. These issues prevent the system from meeting requirements in terms of role consistency, emotional expression, and content safety, thus impacting the realism, appeal, and compliance of the user interaction experience, making it difficult for users, especially children, to obtain a sustained and safe dialogue experience.
[0026] For example, in a home environment, a child asks a smart TV voice assistant, "Why is the sky blue?" Existing systems might respond with a rule-based template, "Because of Rayleigh scattering," but this is a technical statement that a child cannot understand and lacks emotional engagement. Alternatively, a retrieval-based model might respond with "The sky is blue, just like your eyes," but subsequent conversations might include statements like "The sky is gray," leading to inconsistency in the role. A generative model might respond with "Because of magic," but this could introduce unscientific content or inappropriate suggestions. In this scenario, the lack of role consistency reduces the child's trust in the assistant, insufficient emotional expression makes the interaction uninteresting, and security risks mean that responses may contain content unsuitable for children, thus impacting educational effectiveness and user experience.
[0027] If the aforementioned issues are not addressed, smart TV dialogue systems will struggle to maintain long-term user engagement. Inconsistent roles and insufficient emotional expression will reduce user stickiness and satisfaction. Security and compliance risks may lead to inappropriate content output, raising parental concerns and regulatory issues, thus impacting market acceptance and commercial sustainability. In the home setting, dialogue assistants serve as tools for children's education and entertainment; their content security and role credibility directly affect children's mental health and cognitive development.
[0028] In response, this application proposes a method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment.
[0029] like Figure 1 As shown in Embodiment 1 of the present invention, a method for implementing a smart terminal chat assistant based on role awareness and security alignment includes the following steps: Step S100: Obtain the user's voice input and convert it into text content through voice recognition; Step S200: When the user's voice input is recognized as a chat dialogue, the preset collaborative architecture is automatically activated. Based on the recognized voice dialogue context or the user's selection, the preset role package is loaded to determine the role of the current dialogue. Step S300: Based on the determined role, generate candidate responses corresponding to the text content through a preset content agent and a large language model. Step S400: Perform a multi-dimensional security assessment on the candidate responses using a preset security alignment filter and output a risk score; Step S500: For candidate responses whose risk scores meet the security check, add emotional tags that match the character's tone; Step S600: Using the personal voice tone bound to the character, output and play candidate responses with emotional tags through speech synthesis technology.
[0030] For ease of understanding, the following explains some key terms in this embodiment: This embodiment of the intelligent terminal chat dialogue assistant implementation method aims to provide intelligent terminal devices with an interactive dialogue function. By simulating human dialogue, it responds to the user's voice input and provides personalized, secure, and emotionally resonant responses. The core of this invention lies in combining role perception, secure alignment, and emotional generation technologies to enhance the user experience.
[0031] Role perception refers to the system's ability to identify and understand the specific role it should play in the current dialogue (such as "storyteller" or "teacher"). By loading a preset role package, this invention can adjust the knowledge background, dialogue style, and emotional expression of the role, thereby achieving consistency and personalization in the dialogue.
[0032] The aforementioned security alignment refers to the system's multi-dimensional evaluation of generated content to ensure it complies with preset security standards and ethical norms. Through the security alignment filter, the system can identify and filter out inappropriate, harmful, or value-incompatible content, thereby ensuring the security of the conversation.
[0033] The collaborative architecture in this embodiment is an integrated working framework that includes multiple modules, such as a role management module, a security alignment filter, and an emotion generator. These modules work together to complete the various functions of the dialogue assistant. The activation and operation of this architecture is the foundation for realizing the entire dialogue process.
[0034] The role package in this embodiment is a data set that contains all the necessary information to define a specific role, such as the role's knowledge base, dialogue style examples, tone characteristics, associated personal voice, and a preset emotional whitelist. By loading different role packages, the system can quickly switch between and play different roles.
[0035] The content agent is responsible for coordinating the work of the large language model, organizing and optimizing the prompt words input to the large language model according to the determined role and user intent, and guiding the large language model to generate candidate responses that meet the role requirements and security specifications.
[0036] The large language model in this embodiment is a deep learning-based artificial intelligence model trained on massive amounts of text data, possessing powerful text understanding, generation, and reasoning capabilities. In the dialogue assistant, it is used to generate natural, fluent, and creative responses.
[0037] The security alignment filter in this embodiment is a key component of the collaborative architecture, specifically designed for multi-dimensional security assessment of candidate responses generated by large language models. It identifies potentially risky content through various detection mechanisms and outputs a quantified risk score.
[0038] The risk score is a quantitative indicator given by the security alignment filter after performing a security assessment on candidate responses. It measures the likelihood that the response contains inappropriate content. The lower the risk score, the safer the response.
[0039] The emotion tag refers to metadata attached to candidate responses to indicate the emotional tone that the response should express (e.g., "happy," "comforting," "encouraging," etc.). This tag guides speech synthesis technology to express emotions in a manner consistent with the character's tone.
[0040] The personal voice is a voice model with unique vocal characteristics that is bound to a specific character. By using this personal voice for speech synthesis, the personalization and immersion of the character can be enhanced, allowing users to experience a more realistic interactive experience.
[0041] The speech synthesis technology in this embodiment is used to convert text content into audible speech output. In the dialogue assistant, it not only converts text with emotion tags into speech, but also adjusts the rhythm, intonation, and speed of the speech according to the emotion tags to achieve emotional expression.
[0042] In this specific implementation, various methods can be used to acquire user voice input and convert it into text. For example, a speech recognition system based on traditional acoustic and language models can be used to convert speech into text by matching a preset phoneme sequence and vocabulary. Another approach is to use a rule-based speech recognition engine, which analyzes the spectral characteristics of the speech signal and compares it with a predefined set of rules to generate text. Alternatively, the user's voice input can be manually recorded word by word and converted into text content. For example, a child might ask, "Why do stars shine?"
[0043] When a user's voice input is recognized as a chat conversation, a pre-defined collaborative framework is automatically activated. Based on the context of the recognized voice conversation or the user's selection, a pre-defined role package is loaded to determine the roles in the current conversation. Specifically, keyword matching can be used to determine if the voice input is a chat conversation; if a match is successful, the collaborative framework is activated. Regarding role loading, a default role package can be pre-defined and loaded upon the user's first interaction, such as loading a family role package like "Science Dad" or "Storytelling Mom." Alternatively, a simple text classifier can be used to categorize the text content after voice recognition as either "chat" or "command"; if it's "chat," the collaborative framework is activated. For role determination, a fixed list can be provided for the user to manually select roles.
[0044] In this embodiment, based on the determined role, a pre-defined content agent and a large language model collaboratively generate candidate responses corresponding to the text content. Specifically, the content agent can directly input the user's text content as prompt words into the large language model, which then generates a response based on its general knowledge. Role information can be added to the prompt words as a simple prefix instruction. As another implementation, the content agent can select a template from a pre-defined, role-related response template library, fill the template with keywords from the user's text content, and then input the filled template as prompt words into the large language model for refinement.
[0045] The candidate response undergoes a multi-dimensional security assessment using a pre-defined security alignment filter, and outputs a risk score. For example, the security alignment filter could simply match a candidate response to a list of sensitive words, marking it as high-risk if any sensitive words are present. The risk score could be simply set to 0 (safe) or 1 (unsafe). Alternatively, the security alignment filter could employ rule-based text analysis, such as checking for specific sentence structures or phrases in the response that might suggest inappropriate content. The risk score could then be accumulated based on the number of matched rules.
[0046] In this embodiment, candidate responses whose risk scores meet the security check are given an emotional tag that matches the character's tone. Specifically, the emotional tendency of the candidate responses can be determined by simple keyword matching based on the text content, and one of several preset general emotional tags (such as "happy" or "calm") can be selected for inclusion. As another implementation method, the emotional tag can be manually preset, for example, a default emotional tag can be preset for each character, and all responses can include that tag.
[0047] Then, using a personal voice associated with the character, candidate responses with emotional tags are output and played through speech synthesis technology. For example, speech synthesis technology can use a general, emotionless voice library for synthesis, where emotional tags are only displayed as text information and do not affect the speech output. As another implementation, speech synthesis technology can preset a fixed voice for each character, but this voice does not have emotional expression capabilities, and emotional tags are ignored during synthesis.
[0048] The following example will provide a more detailed explanation of the above technical solution: For example, when User A interacts with a chat assistant at home via a smart terminal, User A's voice input is: "I learned something new at school today, did you know?". In this embodiment, the smart terminal's voice recognition module receives User A's voice input and accurately converts it into the text content: "I learned something new at school today, did you know?".
[0049] Next, the system in this embodiment analyzes the text content and determines that it falls within the scope of a chat conversation. Therefore, the preset collaborative architecture is automatically activated. Based on the text content and the context of the conversation, the system analyzes that user A's question is most likely to be answered by the character "Story Mom," thus identifying that user A expects to converse with the "Story Mom" character. Therefore, the system in this embodiment loads the preset "Story Mom" character package, thereby determining that the character in the current conversation is "Story Mom."
[0050] Subsequently, the content agent receives the identified "Story Mom" role and user A's text content. Based on the "Story Mom" role's settings and user A's expressed intention to "learn new knowledge," the content agent constructs a detailed prompt instruction. This instruction not only includes user A's question but also incorporates information such as the "Story Mom's" background knowledge, caring tone, and encouraging style. This prompt instruction is passed to the large language model, which generates a candidate response based on the instruction, such as: "Really? That's great, baby! Tell Story Mom what new knowledge you learned!"
[0051] Next, the candidate response is fed into a pre-defined security alignment filter for a multi-dimensional security assessment. The security alignment filter comprehensively examines the response's explicit content, semantic intent, logical facts, values, and sentiment. In this example, the response is positive and does not contain any sensitive words or inappropriate information; therefore, the security alignment filter outputs a low-risk score that meets security checks.
[0052] Since the risk score meets the security check, the candidate response is passed to the sentiment tagging module. This module adds sentiment tags that match the tone of the "storytelling mom" based on the determined "storytelling mom" role, user A's positive emotions (obtained through sentiment analysis of voice input), and the content of the response itself. These tags include "encouragement," "curiosity," and "care."
[0053] Finally, candidate responses tagged with "encouragement," "curiosity," and "care" are sent to the speech synthesis module. This module uses a personal voice associated with the "Story Mom" character, employing speech synthesis technology to identify and analyze these emotional tags. It automatically adjusts the rhythm, intonation, and speed of the speech, outputting the response "Really? That's great, baby! Tell Story Mom what new knowledge you learned?" to user A in an encouraging, curious, and caring "Story Mom" voice.
[0054] The implementation method in this embodiment effectively solves the technical problem of providing a "professional + warm" interactive experience in smart terminal chat assistants through the synergistic effect of the above steps.
[0055] The implementation method of this embodiment has significant advantages over existing technologies. While rule-based and template-based methods in existing technologies can ensure role consistency and content security, their responses are mechanical, lack engagement, and struggle to address open-ended questions. This method, by introducing a large language model and content intelligence, combined with dynamic loading of role packages, makes the responses more natural and creative. Simultaneously, role awareness ensures role consistency, overcoming the limitations of traditional methods.
[0056] Compared to retrieval-based methods, this invention avoids the potential for inconsistencies in personality and security risks that may arise from retrieving data from large-scale dialogue databases. This method employs a generative model, supplemented by guidance from content agents and strict control through a security alignment filter, ensuring the originality, role consistency, and content compliance of responses from the outset.
[0057] To address the potential "model illusion" and uncontrollable security and compliance risks associated with purely generative large-scale models, this method injects refined instructions into the large language model through a pre-defined content agent and introduces a role knowledge base as constraints to effectively guide the model's output. Furthermore, a security alignment filter performs multi-dimensional evaluation of candidate responses, forming a dynamic and adaptive correction loop that significantly reduces the risk of inappropriate content generation. The addition of emotional tags and the use of personalized voice further enhances the "warmth" of the conversation, making the interactive experience more human and immersive. Therefore, this invention significantly improves the role consistency and emotional expression capabilities of the chat assistant while ensuring the security and compliance of the response content, thus providing a "professional and warm" interactive experience.
[0058] In some other embodiments, this application proposes a method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment. It further proposes that before the steps of obtaining user voice input and performing voice recognition, the method includes: pre-constructing a collaborative architecture, which includes a role management module, a security alignment filter, and an emotion generator. These modules work collaboratively and output data through text-to-speech technology. Specifically, the role management module is used to load a family role package, the security alignment filter is used to perform multi-dimensional security assessments on the generated candidate responses, and the emotion generator is used to add emotion tags that match the tone of the role.
[0059] The pre-construction of a collaborative architecture refers to the pre-design, development, and integration of the various modules constituting the core functions of the smart terminal chat assistant before the system runs, forming a unified and coordinated overall framework. This architecture can be implemented using microservice architecture, modular design, or component-based development, aiming to provide stable, efficient, and scalable foundational support for subsequent dialogue processing. This collaborative architecture includes a role management module, a security alignment filter, and an emotion generator. The role management module is responsible for managing and maintaining all pre-set role information in the system, including role attributes, knowledge base, and dialogue style. Its implementation can be as a standalone software service, storing role data in a database and providing API interfaces for other modules to call; or as a component embedded in the main program, responsible for loading and parsing pre-set role configuration files.
[0060] The security alignment filter is used to perform content security reviews on system-generated dialogue responses, ensuring that the responses comply with preset security standards and ethical norms. It can be implemented as a standalone text processing engine integrating algorithms for sensitive word detection, semantic risk analysis, and value assessment; or as a machine learning-based model trained to identify and filter inappropriate content.
[0061] The aforementioned sentiment generator adds appropriate sentiment tags to generated responses based on the dialogue context, character settings, and user emotions, making the responses more human and engaging. It can be implemented as a rule-based system that matches preset sentiments based on keywords or sentence structures; or as a deep learning model that generates sentiment tags through sentiment analysis and sentiment synthesis techniques.
[0062] The role management module, security alignment filter, and emotion generator work collaboratively, exchanging data and cooperating on tasks through explicit interfaces and communication protocols to jointly complete the various functions of the dialogue assistant. This collaboration can be sequential, where the output of one module serves as the input of another; or parallel, where multiple modules process different tasks simultaneously and the final results are integrated. Finally, text-to-speech (TTS) technology is used for output. This final output stage is responsible for presenting the text responses, after security assessment and emotion tagging, to the user in a natural and emotionally resonant voice format. This can be achieved using a mature TTS engine, such as a speech synthesis system based on deep neural networks, or by integrating third-party TTS services. Specifically, the role management module loads preset data packages containing specific dialogue styles, knowledge backgrounds, and emotional tendencies of family members (such as "Science Dad," "Storytelling Mom," "Grandpa," "Grandma," etc.). This ensures that the dialogue assistant can interact in a manner consistent with specific family roles in a family setting. The security alignment filter performs a comprehensive security check on candidate responses generated by the large language model, not only filtering for sensitive words but also assessing semantic risks, values, ethics, and other dimensions to ensure the security of the response content. The affective generator adds tags that reflect the unique tone and emotional expression of the current dialogue role to candidate responses, such as "gentle," "encouraging," and "serious," making the voice output more immersive.
[0063] This application's solution lays a solid foundation for the entire chat dialogue assistant method by pre-constructing a collaborative architecture comprising a role management module, a secure alignment filter, and an emotion generator before acquiring and performing speech recognition of user voice input. When user voice input is recognized as a chat dialogue and the collaborative architecture is activated, the role management module is ready to quickly load a pre-defined family role package based on the dialogue context or user selection, thus efficiently determining the roles in the current dialogue. Simultaneously, the secure alignment filter and emotion generator are on standby, ensuring that after generating candidate responses, they can be immediately subjected to multi-dimensional security assessments, and that responses meeting security checks are tagged with emotion labels appropriate to the role's tone. This pre-constructed and modular collaborative working mode allows the entire dialogue processing flow to proceed smoothly and efficiently, avoiding delays and resource consumption caused by ad-hoc construction or dynamic scheduling. Finally, through text-to-speech technology, responses with emotion tags are output in speech form, providing users with a coherent, secure, and emotionally resonant interactive experience.
[0064] The following concrete example illustrates this: Smart terminals pre-build this collaborative architecture at their operating system or application layers upon factory release or initial startup. For instance, this architecture could be implemented as a background service process. The role management module could be a JSON or XML-based configuration file loader used to parse pre-defined "family role packages" that define the specific vocabulary, tone preferences, and knowledge scope of roles such as "Science Dad" and "Storytelling Mom." The security alignment filter could be a service integrating multiple pre-trained models; for example, a BERT model for semantic risk identification and a rule-based regular expression engine for sensitive word filtering. The sentiment generator could be a lightweight neural network model that selects the most appropriate label from a predefined set of sentiment labels based on the input text and role information. These modules communicate via internal message queues or shared memory to ensure real-time data flow. When a user says, "Story Mom, how's the weather today?", the collaborative architecture is activated after the voice recognition is completed. The role management module quickly identifies and loads the "Story Mom" role package. Subsequent response generation, security assessment, and emotional tag addition will be efficiently completed under this preset architecture. Finally, the voice response in the "Story Mom" voice is output through the TTS engine built into the smart terminal.
[0065] By employing the aforementioned technical solution, a collaborative architecture comprising a role management module, a security alignment filter, and an emotion generator is pre-built before the execution of the intelligent terminal chat assistant method. The responsibilities of each module are clearly defined, significantly improving the operational efficiency and stability of the entire chat assistant system. This pre-planned systematic planning and modular design ensures seamless integration and efficient collaboration among functional components during actual operation, avoiding performance bottlenecks and compatibility issues that may arise from dynamic loading or temporary configuration. Specifically, the role management module can quickly load family role packages, the security alignment filter performs multi-dimensional security assessments, and the emotion generator adds emotional tags that match the character's tone. These pre-defined specialized modules ensure that every step of the dialogue process is optimized, providing users with a responsive, content-secure, and emotionally rich intelligent dialogue experience, effectively solving the problems of complex system integration and low operational efficiency.
[0066] The present invention will be further described in detail below through another specific application embodiment: like Figure 2 As shown in the illustration, a method for implementing a smart terminal chat assistant based on role awareness and security alignment in this specific application embodiment includes the following steps: S11, User voice input: Obtain user's voice and proceed to S12; S12, Perform automatic speech recognition (ASR) on the user's voice; and proceed to S13; S13. Perform sensitive word filtering, then proceed to S14; S14. Perform intent recognition and proceed to S15; S15. Determine if it is (chatting) casual conversation. If it is, proceed to S16. S16. Extract roles using the role extractor, load the family role package (e.g., "Science Dad" and "Storytelling Mom") into the role management module, and proceed to S17. S17. The content agent (intelligent agent) and the large language model (LLM) work together to generate candidate responses corresponding to the text content, that is, generate answer content, and then proceed to S18; S18. Align the role and emotion using the emotion fitting model, add emotion tags that match the role's tone using the emotion generator, and then proceed to S19. S19. Conduct security filtering, which involves multi-dimensional risk scoring through a security alignment filter; including sensitive word filtering and sentiment compliance filtering, and proceed to S20. S20, TTS, refers to the playback of a person's voice through text-to-speech (TTS) technology.
[0067] The specific timing of this embodiment is as follows: For example, a child asks "Why do stars light up?" → Role = "Science Dad" → Output "Because stars are like big light bulbs, but they are very far away from us..." → Security check passed → Play.
[0068] In other embodiments, this application proposes a method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment. It further proposes a step-by-step approach to automatically activate a preset collaborative architecture when user voice input is recognized as a chat dialogue, and to load a preset role package based on the recognized voice dialogue context or user selection to determine the role of the current dialogue. This step includes: acquiring the text content of the voice recognition and analyzing the text content to determine whether it is chat dialogue content; automatically activating the preset collaborative architecture when user voice input is recognized as a chat dialogue, and loading a preset family role package and role knowledge base based on the recognized voice dialogue context or user selection to determine the role of the current dialogue.
[0069] Specifically, after the smart terminal chat assistant receives the user's voice input and recognizes it as text, to ensure the accuracy and personalization of subsequent dialogue, the system first performs in-depth analysis of the text content to determine whether it falls within the scope of a chat conversation. This judgment process is crucial, as it avoids unnecessary role-based processing of non-chat commands or queries. For example, natural language processing (NLP) techniques, such as text classification models, can be used to perform semantic analysis on the text content. These models can be pre-trained on a large corpus of chat and non-chat conversations to learn the features that distinguish between the two. Alternatively, keyword matching and a rule engine can be combined to set a set of common opening lines, greetings, or specific sentence structures in chat conversations as trigger words or rules. When the text content matches these rules, it is judged as a chat conversation. Once it is confirmed that the user's intention is to engage in a chat conversation, the system will immediately and automatically activate the preset collaborative architecture, thus preparing for the generation of subsequent responses. This activation process can be implemented through a state machine or event listener. When the judgment result is "yes," a signal is triggered or an interface is called, thereby starting the various modules in the collaborative architecture. Based on this, the system of this invention will accurately load the family role package and corresponding role knowledge base that best match the current dialogue scenario from a preset role library, according to the currently recognized voice dialogue context information or the user's explicit selection. The family role package refers to predefined role settings related to family members (such as science dad, story mom, grandpa, grandma, brother, sister, etc.), including but not limited to the role's personality traits, speaking style, commonly used vocabulary, and emotional tendencies. The role knowledge base is a collection of knowledge associated with a specific role. For example, for the "story mom" role, the knowledge base may include parenting knowledge, daily family affairs, children's stories, etc.; for the "grandpa" role, it may include historical stories, traditional cultural knowledge, etc. This information can be loaded by storing different family role packages and corresponding role knowledge bases in a database or file system. Once the current dialogue role is determined, the system retrieves and loads the corresponding role package and knowledge base from storage into memory for use in subsequent content generation. The role in the current conversation can be inferred from the context of the voice conversation. For example, if the phrase "Story Mom, I'm hungry" appears frequently in the conversation, it can be inferred that the current role is "Story Mom". Alternatively, it can be determined by the user's explicit choice. For example, before or during the conversation, the user can select "Please chat with me as Story Mom" through voice commands or the interface.
[0070] The proposed solution involves a smart terminal chat assistant receiving and recognizing user voice input as text. The system first performs in-depth analysis of the text to determine if it falls within the scope of a chat conversation. This judgment is crucial, as it avoids unnecessary role-based processing of non-chat commands or queries. Once the user's intent is confirmed as a chat conversation, the system automatically activates a pre-set collaborative architecture to prepare for subsequent response generation. Based on this, the system precisely loads the most suitable family role package and corresponding role knowledge base from a pre-set role library, according to the currently recognized voice conversation context or the user's explicit selection. The family role package provides the role's personality and conversational style, while the role knowledge base provides rich background knowledge and factual data. In this way, the system ensures that subsequent candidate responses not only conform to the nature of a chat conversation but also deeply align with the identified role, providing users with a more natural, personalized, and knowledge-rich interactive experience. This mechanism effectively solves the problem of accurately identifying chat intent and finely loading role information, enabling the chat assistant to respond to user needs more intelligently.
[0071] The following is a concrete example. When a child user says to a smart device, "Story Mom, tell me a story," the smart device first recognizes the speech as the text "Story Mom, tell me a story." The system then analyzes this text. Through its built-in natural language understanding module, the system recognizes the intent to "tell a story" and the title "Story Mom," thus determining that the input is a chat conversation. Based on this judgment, the system automatically activates its preset collaborative architecture. Next, based on the conversation context (e.g., recognizing the title "Story Mom") or preset user preferences, the system loads a preset "Story Mom" family role package and a children's story knowledge base related to the "Story Mom" role. For example, the "Story Mom" role package might include a gentle, patient, and educational dialogue style, while the children's story knowledge base contains a large number of bedtime stories, fables, etc., suitable for children. In this way, subsequent responses will strictly adhere to the "Story Mom" role's settings and knowledge background, ensuring the coherence and appropriateness of the responses.
[0072] Through the aforementioned technical solutions, smart terminal chat assistants can more intelligently identify users' chat intentions, avoiding unnecessary role-based processing of non-chat commands, thereby improving system response efficiency and accuracy. Simultaneously, by accurately loading preset family role packages and role knowledge bases based on dialogue context or user selection, the chat assistant can interact in a specific role that better matches user expectations, greatly enhancing the personalization, naturalness, and knowledge depth of the conversation. This not only improves the user experience but also makes the application of smart terminals in home scenarios more aligned with actual needs, effectively solving the problem of how to accurately determine chat intentions and finely load role information to ensure dialogue accuracy and personalization.
[0073] In some of the embodiments described above in this application, a candidate response corresponding to the text content is generated collaboratively by a preset content agent and a large language model based on a determined role. However, in its implementation, if only the general capabilities of the large language model are relied upon, the generated response may be insufficient in terms of knowledge accuracy, factual basis, and consistency of role style, making it difficult to ensure that the response content can accurately reflect the knowledge background and tone of conversation of a specific role.
[0074] To address this, this application further proposes a step-by-step approach to generate candidate responses corresponding to the text content through a pre-defined content agent and a large language model, based on a determined role. This step includes: obtaining the determined current role and the user intent determined based on the text content; retrieving relevant knowledge points, factual data, and dialogue style examples from the corresponding role knowledge base based on the user intent; dynamically and structurally organizing the extracted relevant knowledge points, factual data, and dialogue style examples into a detailed prompt instruction, which is then passed to the large AI model to generate candidate responses corresponding to the text content; and introducing the role knowledge base as raw material and instruction into the generation process to guide and constrain the output of the large AI model from the source, generating candidate responses that conform to the knowledge background, style, and tone of the current role.
[0075] This embodiment first obtains the determined current role and the user intent determined based on the text content. The current role refers to the specific identity activated during the dialogue and used to guide the generation of responses, such as "father," "mother," "teacher," or "storyteller." User intent refers to the deeper purpose or need expressed by the user's voice input. Its determination can be made through semantic analysis of the text content using a Natural Language Understanding (NLU) model, identifying keywords, entities, and semantic relationships to infer whether the user is asking a question, requesting information, or expressing emotion. Alternatively, a rule-based system combined with keyword matching can be used to map predefined patterns or keywords to specific user intents.
[0076] Subsequently, based on the user's intent, a search is performed in the corresponding role knowledge base to extract knowledge points, factual data, and dialogue style examples related to the text content. The role knowledge base is an information repository tailored to a specific role, containing far more information than the general knowledge of a large language model. This knowledge base can exist in the form of a structured database (e.g., relational database, graph database), storing domain-specific knowledge, facts, and data related to the role; for example, the role of "father" might include family history, specific hobbies, or common phrases. Alternatively, it can be an indexed collection of unstructured text, such as documents, books, or dialogue logs, providing contextual information and dialogue style examples. The retrieval process can employ semantic search techniques, utilizing embedding models to find semantically similar knowledge points, facts, and style examples based on user intent and text content. Alternatively, keyword-based search algorithms (e.g., TF-IDF, BM25) can be used, combined with filtering based on metadata related to the knowledge entries. The extracted knowledge points are conceptual information relevant to the query, factual data are verifiable information fragments, and dialogue style examples include the role's typical tone, vocabulary, sentence structure, and common expressions.
[0077] Next, the content agent dynamically and structurally organizes the extracted knowledge points, factual data, and dialogue style examples related to the text content into a detailed prompt word instruction, which is then passed to the large AI model. As an intermediate component, the content agent coordinates the interaction between the knowledge base and the large language model; its core function is prompt word engineering. It dynamically constructs prompt words, rather than using static templates, allowing them to adaptively adjust based on the retrieved information and be presented in a structured format that the large language model can effectively process. This can be achieved through a template-based approach, where placeholders in the prompt word template are filled with extracted knowledge points, facts, and style examples. Alternatively, more sophisticated prompt word engineering techniques can be used to dynamically generate prompt word components based on the complexity of the query and the richness of the retrieved information, even including a small number of examples selected from dialogue style paradigms. This detailed prompt word instruction is then sent to the large AI model.
[0078] Finally, the AI model generates candidate responses corresponding to the text content. This AI model can be based on the Transformer architecture, such as the GPT series, LLaMA, or other large language models, or it can be a model fine-tuned for conversational AI tasks. During this process, the role knowledge base is injected into the generation process as raw material and instructions, guiding and constraining the output of the AI model from the source, generating candidate responses that match the current role's knowledge background, style, and tone. This means that knowledge points, facts, and style examples can be directly embedded as context into prompt words, guiding the large language model to use this information. Alternatively, a Retrieval-Enhanced Generation (RAG) framework can be used, where the large language model first retrieves relevant information from the knowledge base and then uses this information to generate responses, ensuring the factual basis of the responses. This guidance and constraint mechanism ensures the accuracy of the generated responses in terms of knowledge, consistency of style, and tone matching, enabling them to accurately reflect the characteristics of a specific role.
[0079] This application's solution, through refined information retrieval and prompt word engineering, ensures that the large language model can generate candidate responses highly consistent with the requirements of a specific role. Specifically, upon receiving the identified current role and the user intent parsed from the user's text content, the system proactively uses this user intent as the basis for a deep search within a pre-built role knowledge base closely related to the current role. This search process aims to accurately locate and extract knowledge points highly relevant to the user input, solid factual data, and examples that reflect the unique dialogue style of the role. This filtered and extracted specific information, rather than relying solely on the general knowledge of the large language model, forms the foundation for subsequent response generation. Subsequently, a dedicated content agent plays a crucial coordinating role. It receives this fragmented information extracted from the role knowledge base and dynamically and structurally organizes and integrates it, carefully constructing a detailed and instructive prompt word instruction. This prompt word instruction is not merely a simple accumulation of information, but a carefully designed one that cleverly encodes the extracted knowledge points, factual data, and dialogue style examples, enabling it to be effectively transmitted to the large artificial intelligence model as explicit context and behavioral guidelines. In this way, the content of the character knowledge base is directly and purposefully injected into the generation process of the large language model, fundamentally changing its output generation logic. Upon receiving the prompt word rich in character-specific information and instructions, the AI large model's generation process is no longer a free-form creation, but rather strictly guided and constrained. It is explicitly instructed to ensure the accuracy of the response based on the provided knowledge points, guarantee the authenticity of the content based on factual data, and shape the tone, vocabulary, and sentence structure of the response by referring to dialogue style examples. This guidance and constraint mechanism from the source enables the large language model to generate candidate responses corresponding to the text content, and these responses accurately match the current character's knowledge background, unique dialogue style, and tone. Therefore, this solution effectively solves the problem of inaccurate responses and inconsistent styles that may result from relying solely on the general capabilities of the large language model, ensuring that the intelligent terminal chat assistant can provide a high-quality, personalized, and highly character-fitting dialogue experience in specific character scenarios.
[0080] The following is a concrete example to illustrate this. Suppose the smart terminal chat assistant is currently set to the role of a "children's storyteller." When a child user inputs the question "Why do birds sing?", this invention first identifies the current role as "children's storyteller" and, based on text content analysis, determines that the user's intent is "to inquire about the explanation of a natural phenomenon." Next, the system searches a pre-set knowledge base for the "children's storyteller" role based on this user intent. This knowledge base may contain simplified scientific knowledge about how birds produce sound (e.g., birds produce sound through the syrinx, where muscle vibrations create sound), factual data about the purposes of birds singing (e.g., attracting mates, marking territory, warning predators), and examples of dialogue styles suitable for children's understanding (e.g., using metaphors, personification, simple sentence structures, and a curious and encouraging tone). The content agent then dynamically organizes these retrieved knowledge points, factual data, and dialogue style examples into a detailed prompt instruction. For example, the prompt instruction might be structured as follows: "You are a loving and imaginative children's storyteller. Please explain to a child why birds sing, using simple, vivid, and childlike language. Please refer to the following information: Birds produce sound through their syrinxes, which vibrate to generate sound; they sing to attract mates, mark territory, and warn predators. Please use personification and metaphor, and maintain a curious and encouraging tone." This prompt instruction is then passed to the AI model. Upon receiving this instruction, the AI model will strictly adhere to the included role setting, knowledge background, and style requirements to generate candidate responses corresponding to the user's question. For example, a large model might generate a response like this: "Oh, my little explorer, what a wonderful question you've asked! Birds sing as if they're using a magical little flute hidden in their tiny throats—that's their syrinx! When their little muscles tremble slightly, it's like playing this flute, and beautiful songs fly out. Sometimes they sing to tell other birds, 'Hey, I'm here, come and play with me!' Sometimes it's to say, 'This is my little twig, please don't come any closer!' And sometimes it's to warn everyone, 'Watch out, a big cat is coming!' Isn't that interesting?" Through the aforementioned technical solution, this application significantly improves the dialogue quality and user experience of smart terminal chat assistants in specific role scenarios. By obtaining the current role and user intent, and based on this, accurately retrieving and extracting relevant knowledge points, factual data, and dialogue style examples from the corresponding role knowledge base, this application ensures that the subsequent response generation process has a solid and highly relevant knowledge foundation. The content agent dynamically and structurally organizes this information into detailed prompt instructions, and injects them as raw materials and instructions into the generation process of the large artificial intelligence model, thereby providing strong guidance and constraints on the output of the large model from the source. This mechanism effectively avoids the problems of generalized response content, inaccurate knowledge, or inconsistent style that may result from relying solely on the general capabilities of the large language model. Ultimately, the generated candidate responses accurately match the current role's knowledge background, unique dialogue style, and tone, enabling the smart terminal to provide a highly personalized, professional, and emotionally resonant dialogue experience. This makes users feel that they are communicating with a truly understanding and specific intelligent agent, rather than a general AI, thereby greatly improving user satisfaction and trust in the smart terminal chat assistant.
[0081] In some of the embodiments described above in this application, a preset security alignment filter is used to perform a multi-dimensional security assessment of candidate responses and output a risk score. However, in practical applications, especially when faced with complex and varied user input and generated content, a single or limited-dimensional security assessment may be insufficient to fully identify and mitigate all potential risks, such as implicit semantic risks, factual errors, inappropriate values, or negative emotional biases. This could lead to unexpected responses being output, affecting user experience and system reliability.
[0082] To address this, this application further proposes a step of performing a multi-dimensional security assessment of the candidate responses using a preset security alignment filter and outputting a risk score. This includes: performing a multi-dimensional security assessment of the candidate responses using a preset security alignment filter, including explicit content security dimension, semantic and intent risk dimension, logical and factual dimension, value and ethical dimension, and sentiment risk dimension. A weighted sum of the risk scores for each dimension is then obtained to obtain a total risk score. When the total risk score is lower than a set security threshold, the candidate response is allowed to pass. When the total risk score is higher than or equal to the set security threshold, it is determined to be high-risk content, blocked, and a rejection signal with a risk label is returned to the content agent, triggering content regeneration. During the regeneration of the candidate response, additional avoidance instruction prompts are added to achieve a dynamic and adaptive correction cycle.
[0083] The explicit content security dimension refers to filtering explicitly prohibited content through sensitive word dictionaries and regular expression matching algorithms. For example, a sensitive word dictionary containing keywords such as "sensitive" and "abuse" can be constructed, and string matching algorithms (such as AC automata and BM algorithm) can be used to quickly detect the presence of these words in candidate replies. Furthermore, regular expressions can be used to define specific patterns, such as identifying personal privacy information like phone numbers, ID card numbers, and bank card numbers, or prohibited links in specific formats, for pattern matching filtering. The semantic and intent risk dimension refers to analyzing the deep semantics of reply content through text classification models to identify content that promotes inappropriate behavior or induces users. For example, a deep learning-based text classification model (such as BERT or RoBERTa) can be trained using a large amount of labeled data (including normal, inappropriate, and inducement content) to understand the deep semantics of the text and determine its risk intent. Alternatively, keyword embedding and topic models (such as LDA) can be combined to map text into a semantic space, and potential risks can be assessed by calculating similarity with known risky topics. The logical and factual dimension refers to comparing the core knowledge points in a response with an internal knowledge graph or authoritative database for knowledge-based roles, checking for obvious scientific errors or logical contradictions. For example, an internal knowledge graph can be constructed, containing entities, relationships, and attributes within a specific domain. When a candidate response involves a knowledge point, its consistency with the facts in the graph can be verified through knowledge graph queries and reasoning. Alternatively, authoritative external databases (such as Wikipedia or specialized academic databases) can be integrated to perform real-time queries and cross-validation of key information in the response to uncover factual errors.
[0084] The values and ethics dimension refers to establishing a value alignment model for children's scenarios to assess whether the response content conforms to mainstream, positive, and uplifting children's values. For example, a value alignment model can be trained to learn from a large amount of text data that aligns with children's values, enabling it to identify and evaluate the value orientation contained in the response content, such as whether it encourages positive qualities like friendliness, cooperation, and exploration. Alternatively, a set of rules for children's values can be defined, including positive guiding words, negative avoidance words, and behavioral guidelines, and a rule engine can be used to match and evaluate responses. The sentiment risk dimension refers to performing sentiment analysis on the response text, identifying sentiment tags, and comparing them with a pre-defined sentiment whitelist for the current role; if emotions outside the whitelist that have a negative impact on children are found, sentiment compliance filtering is performed. For example, a sentiment analysis model (such as a sentiment classification model based on recurrent neural networks (RNN) or Transformers) can be used to identify the sentiment polarity (positive, negative, neutral) and sentiment category (joy, anger, sadness, etc.) of candidate responses and compare them with a pre-defined sentiment whitelist. Alternatively, by combining an emotional dictionary and rules, the emotional words in the response can be scored, and the overall emotional tendency can be judged based on the context to ensure that it is within the emotional range allowed by the role.
[0085] This application's solution ensures the comprehensiveness and depth of the security assessment by conducting multi-dimensional security evaluations of candidate responses. First, when the smart terminal receives the user's voice input and identifies it as a chat dialogue, the content agent and the large language model collaboratively generate candidate responses based on the determined role. Subsequently, the candidate response is sent to a preset security alignment filter. This filter does not perform a single check but simultaneously or sequentially conducts a detailed risk assessment across multiple dimensions, including explicit content security, semantic and intent risk, logic and factuality, values and ethics, and emotional bias. Each dimension generates a risk score, and these scores are weighted and summed to form a total risk score. This total score is then compared to a preset security threshold. If the total score is below the security threshold, the candidate response is considered safe, and subsequent steps of adding sentiment tags and voice output can proceed. However, once the total score reaches or exceeds the security threshold, the candidate response is judged as high-risk content and immediately blocked. At this point, the system returns a rejection signal with a specific risk tag to the content agent. Upon receiving this signal, the content agent triggers the large language model to regenerate the response. During this regeneration process, additional avoidance prompts are dynamically added, such as "avoid mentioning violence" and "ensure information accuracy," to guide the large language model in generating a safer and more compliant response. This multi-dimensional evaluation and dynamic feedback correction mechanism enables the system to comprehensively identify and effectively avoid potential risks, thereby significantly improving the security and reliability of the chat assistant.
[0086] The following example illustrates this. Suppose a child user asks a smart terminal's chat assistant (currently designated as a "parent"), "How can I make my puppy fly?" First, the user's voice input is recognized and converted into text. The system determines the current role as "parent" based on the dialogue context. The content agent, in collaboration with a large language model, generates a candidate response, such as: "It's impossible to make the puppy fly, and doing so might hurt it." Next, the candidate response undergoes a multi-dimensional evaluation using a safety alignment filter: In the explicit content safety dimension, no explicit prohibited words were found; in the semantic and intent risk dimension, the text classification model analysis indicates the response's intent is persuasion and protection, resulting in low risk; in the logic and factual dimension, the system compares its internal knowledge graph to confirm that "puppies cannot fly" is a fact, and that "harming puppies" presents a logical risk, but the response itself avoids this risk, thus this dimension has low risk; in the values and ethics dimension (for children's scenarios), the values alignment model assesses that the response aligns with positive children's values such as animal protection and respect for life, resulting in low risk; in the emotional tendency risk dimension, sentiment analysis identifies the response's emotion as neutral to serious persuasion, consistent with the "parent's" pre-set emotional whitelist, with no negative impact. The risk scores from each dimension are weighted and summed to obtain a total risk score below the safety threshold. Therefore, the candidate response is allowed to pass, and emotional tags consistent with the "parent's" tone are added, ultimately outputting and playing the response through speech synthesis technology.
[0087] Through the aforementioned technical solution, this application enables a comprehensive and in-depth security assessment of the content generated by smart terminal chat assistants, effectively identifying and mitigating various potential risks such as explicit violations, semantic risks, factual errors, inappropriate values, and negative emotions. This multi-dimensional assessment combined with dynamic feedback correction allows the system to continuously optimize its response quality and security, especially when dealing with sensitive user groups (such as children), ensuring that the output content always adheres to the principles of safety, positivity, and health. This significantly improves the reliability and user trust of smart terminal chat assistants, avoiding potential negative impacts caused by inappropriate content.
[0088] In some of the embodiments described above in this application, when processing candidate responses whose risk scores meet security checks, it is necessary to add emotional tags that match the tone of the character. However, if the way emotional tags are added lacks consideration of multi-dimensional contextual information, it may lead to emotional expression that is inconsistent with the current dialogue scenario, user emotions, or character settings, thereby affecting the naturalness of the dialogue assistant and the user experience.
[0089] In response, this application further proposes a step of adding an emotional tag that matches the role's tone to candidate responses whose risk scores meet the security check. This step includes: pre-constructing an emotional fitting model; during the training phase, using a predetermined amount of manually labeled data, learning appropriate emotional expressions in a specified role, user emotion, and response content scenario to achieve role and emotion alignment, resulting in a trained emotional fitting model; inputting candidate responses whose risk scores meet the security check, the determined role in the current dialogue, the user's emotional state obtained through emotion analysis of user input, and the identified voice dialogue context into the trained emotional fitting model; encoding and fusing multiple inputs through the trained emotional fitting model, and interacting through an attention mechanism to output a single, clear emotional tag from a predefined emotional tag library.
[0090] The sentiment fitting model is a machine learning model designed to predict or generate the most suitable sentiment labels based on multiple inputs (such as text content, roles, user emotions, and dialogue context). This model can be built on a deep learning sequence-to-sequence model, such as using a Transformer or LSTM network, processing multimodal inputs through an encoder-decoder structure; alternatively, it can be a hybrid model based on rules and statistical methods, combining a predefined sentiment dictionary, syntactic analysis, and a machine learning classifier for sentiment judgment. During the training phase, a predetermined amount of manually labeled data is used to learn appropriate sentiment expressions for specified roles, user emotions, and response content scenarios, achieving role-sentiment alignment. This aims to ensure the model accurately understands the emotional needs in different contexts and generates expected sentiment labels. Manually labeled data can include dialogue text, corresponding roles, user emotions (such as happiness, sadness, questioning, etc.), and appropriate response sentiment labels judged by experts. The training process can employ supervised learning, optimizing the loss function to ensure the model output matches the labeled data; alternatively, semi-supervised learning can be used, combining a small amount of manually labeled data with a large amount of unlabeled data for pre-training, followed by fine-tuning to improve model performance. The trained sentiment fitting model receives multi-dimensional input and outputs a single, clear sentiment label. This model can be a trained neural network whose output layer is designed as a multi-classifier, corresponding to various labels in a predefined sentiment label library; alternatively, it can be an ensemble model that combines the outputs of multiple sub-models (such as a text sentiment analysis model and a character style recognition model), deriving the final sentiment label through weighted voting or a meta-learner. The trained sentiment fitting model is input with candidate responses that meet safety checks based on risk scores, the identified character in the current dialogue, the user's emotional state obtained through sentiment analysis of user input, and the identified voice dialogue context. This aims to provide the sentiment fitting model with comprehensive contextual information, enabling it to make more accurate sentiment judgments. These inputs can be encoded into vector representations; for example, candidate responses can be represented through word embeddings and sentence embeddings, character and user emotions through one-hot encoding or embedding layers, and voice dialogue context through encoding of historical dialogues. Alternatively, all text information can be concatenated as a single text input to the model, supplemented with additional feature vectors to represent character and user emotions. The trained sentiment fitting model encodes and fuses multiple inputs, interacting through an attention mechanism. This aims to ensure the model effectively processes and integrates information from different sources, focusing on the most important information fragments. Encoding and fusion can be achieved through a multi-head self-attention mechanism, allowing the model to capture complex relationships between input features in different representation spaces; alternatively, gated recurrent units (GRUs) or long short-term memory networks (LSTMs) can be used to process sequential inputs, fusing information from different modalities through a cross-attention mechanism.The model outputs a single, clear emotion tag from a predefined emotion tag library, aiming to provide standardized and controllable emotion expression for subsequent speech synthesis. The emotion tag library can contain discrete tags such as "happy," "surprised," "sad," "calm," and "encouraging," selecting the tag with the highest probability from the probability distribution output by the model; alternatively, it can contain more granular emotion dimensions, such as "positive," "negative," and "neutral," combined with intensity levels.
[0091] This application's solution pre-constructs an emotion fitting model and, during the training phase, utilizes a predetermined amount of manually labeled data to enable it to learn appropriate emotion expressions for specific roles, user emotions, and response content scenarios, thereby achieving deep alignment between roles and emotions. In actual operation, when the system obtains a candidate response whose risk score meets safety checks, it simultaneously collects the determined role in the current dialogue, the user's emotional state obtained through emotion analysis of user input, and the identified voice dialogue context. This multi-dimensional information is fed into the trained emotion fitting model. Internally, the model encodes and fuses these heterogeneous inputs and interacts using an attention mechanism. This means the model can intelligently identify and focus on the most critical information points for emotion label decisions; for example, certain words or user emotions may be more decisive under a specific role. Finally, the model outputs a single, clear emotion label from a predefined emotion label library. This mechanism ensures that the added emotion label not only conforms to the semantics of the candidate response but also highly matches the role setting of the current dialogue, the user's real-time emotion, and the historical dialogue context, thus solving the unnatural and inaccurate problems that may arise from simple emotion labels.
[0092] The following example illustrates this. Suppose a smart terminal chat assistant is set up as a "storytelling mom," and the user is a child. When the child, with a slightly frustrated expression, asks, "Storytelling mom, is my drawing today not good?" the system first recognizes the speech and converts it to text, then generates a candidate response, such as, "Honey, your drawing is very creative! Storytelling mom thinks it's great!" After performing a security check on this candidate response, the system inputs the candidate response, the current "storytelling mom" role, the user's "frustrated" emotional state obtained through sentiment analysis, and the dialogue context of "the child asking about the drawing" into a pre-trained sentiment fitting model. This sentiment fitting model can be a deep learning model based on the Transformer architecture, with its input layer designed as a multimodal encoder, processing the text sequence (candidate response, dialogue context) and discrete features (role ID, user emotion category). The encoder inside the model converts this information into vector representations and interacts through a multi-head self-attention mechanism, paying particular attention to the user's "frustrated" emotion, the gentle and encouraging attributes of the "storytelling mom" role, and positive words such as "very creative" and "great" in the response. Ultimately, the model outputs a single, clear emotion label, such as "encouragement," from a predefined emotion label library (containing labels like "gentle," "encouraging," "patient," and "comforting"). This "encouraging" label is then used in speech synthesis, resulting in a final speech output with a gentle and encouraging tone, thus better responding to the child's emotions.
[0093] The above technical solution involves pre-constructing and training an emotion fitting model to learn appropriate emotional expression within a given role, user emotion, and response context, achieving role-emotion alignment. In practical applications, multiple inputs, including candidate responses, the determined role in the current conversation, the user's emotional state, and the voice dialogue context, are encoded and fused, and interacted with through an attention mechanism. This results in a single, clear emotion tag being output from a predefined emotion tag library. This method ensures that the added emotion tag is more accurate, natural, and highly matched to the role, user emotion, and dialogue context of the current conversation. This significantly improves the emotional expression capabilities and user experience of smart terminal chat assistants, making the dialogue more human and engaging, and avoiding the stiffness or incongruity caused by inappropriate emotion tags.
[0094] In some implementations, this application proposes a method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment. The method includes acquiring user voice input and converting it into text content through speech recognition; automatically activating a preset collaborative architecture when the user's voice input is recognized as a chat dialogue, loading a preset role package based on the recognized voice dialogue context or user selection, and determining the role of the current dialogue; generating candidate responses corresponding to the text content through a preset content agent and a large language model based on the determined role; performing a multi-dimensional security assessment on the candidate responses through a preset security alignment filter and outputting a risk score; adding emotional tags that match the role's tone to candidate responses with risk scores that meet security checks; and outputting and playing the candidate responses with emotional tags using a personal voice bound to the role through speech synthesis technology. However, in the above solution, simply outputting and playing candidate responses with emotional tags through speech synthesis technology may not fully and naturally express the subtle emotions indicated by the emotional tags, resulting in synthesized speech that sounds stiff or lacks appeal, thus affecting the user's interaction experience with the smart terminal chat dialogue assistant.
[0095] In response, this application further proposes the following steps for using a personal voice tone bound to the character and outputting candidate responses with emotional tags through speech synthesis technology: using a personal voice tone bound to the character, identifying and parsing the candidate responses with emotional tags through speech synthesis technology, and automatically adjusting a series of preset prosodic parameters to achieve the corresponding emotional effect.
[0096] The phrase "using a personal timbre bound to the character" refers to a pre-configured or trained voice model with unique timbre, pitch, speech rate, and pronunciation habits for a specific character. This timbre aims to simulate the speaking style of a real person to enhance the user's sense of immersion and intimacy with the character. This can be achieved by extensively collecting and training voice data from a specific person to construct a dedicated voice model for that person, thereby reproducing their unique timbre characteristics during speech synthesis; or by selecting a pre-set timbre library with specific styles (e.g., children's voices, elderly voices, cartoon voices, etc.) and binding it to the character to meet the timbre requirements of different characters. The "speech synthesis technology" is a technology that converts text information into audible speech. It involves multiple stages such as text analysis, acoustic model construction, and prosody generation, aiming to generate natural, fluent, and expressive speech. This technology can employ end-to-end speech synthesis models based on deep learning, such as Tacotron, WaveNet, and TransformerTTS. These models can directly generate high-quality speech waveforms from text and support fine-grained control over prosody and emotion. Alternatively, it can use parametric speech synthesis technology, which generates speech by extracting and controlling acoustic parameters such as fundamental frequency, formants, and energy. This method has advantages on resource-constrained devices. The "identification and parsing of the candidate responses with emotion tags" aims to accurately extract the text content itself and the attached emotion tag information from candidate responses that have undergone security verification and have been attached with emotion tags. This is a crucial preliminary step in transforming abstract emotion tags into concrete speech expressions. This can be achieved by parsing the data structure of the candidate responses. For example, if the emotion tags are embedded in the text in a specific format (such as XML tags, JSON fields, or specific prefixes / suffixes), the corresponding parser or regular expression can be used for extraction. Alternatively, it can be achieved by directly receiving structured data containing text and emotion tags through a preset interface or function, thereby avoiding additional recognition and parsing work during the speech synthesis stage. The "automatic adjustment of a series of preset prosodic parameters" refers to the dynamic adjustment of key parameters such as speech rate, pitch (fundamental frequency), volume, and pauses based on emotion tags. Prosodic parameters are key factors affecting the naturalness of speech and emotional expression. This can be achieved by pre-setting a set of corresponding prosodic parameter adjustment rules or models based on emotion tags (e.g., "happy," "sad," "surprised"). For example, "happy" might correspond to a faster speech rate, a rising pitch, and a moderate volume; "sad" might correspond to a slower speech rate, a lower pitch, and a reduced volume. These rules can be implemented in the prosodic generation module of the speech synthesizer. Alternatively, an emotion-to-prosodic parameter mapping model can be trained. This model receives emotion tags as input, outputs a set of optimized prosodic parameters, and then inputs these parameters into the speech synthesizer for speech generation.The ultimate goal of the entire process is to "achieve the corresponding emotional effect." This means that through the aforementioned timbre selection, text parsing, and prosodic parameter adjustment, the final synthesized speech output can vividly and accurately express the emotional tags carried by the candidate responses, thereby enhancing the naturalness and immersion of the dialogue. This can be achieved by finely controlling acoustic features such as fundamental frequency (F0), duration, and energy, making the synthesized speech audibly consistent with the target emotion (such as joy, anger, or sadness); or by training with an emotional speech database, enabling the speech synthesis model to learn the acoustic feature distribution under different emotions, thus better simulating the subtleties of human emotional expression during synthesis.
[0097] This application's solution, during the speech synthesis stage, not only uses a personal voice bound to a character but also, more importantly, identifies and analyzes candidate responses with emotional tags using speech synthesis technology. Based on the analyzed emotional tags, it automatically adjusts a series of preset prosodic parameters. This mechanism ensures that the synthesized speech accurately conveys the emotions indicated by the emotional tags. For example, for the emotional tag of "happiness," the system adjusts the speech rate, tone, and volume to make the speech sound energetic and joyful; for the emotional tag of "comfort," it may slow down the speech rate and lower the tone to create a calm and supportive atmosphere. This dynamic, emotion-tag-based prosodic parameter adjustment makes the final output speech response not only accurate and compliant in content but also more vivid and natural in emotional expression, complementing the character's personalized voice, thereby greatly enhancing the naturalness and immersion of the user's interaction with the smart terminal chat assistant.
[0098] The following is a concrete example. When a smart terminal chat assistant needs to play a candidate reply with a "happy" emotion tag, such as "Great job, you did a great job!", the system first calls the personal voice model bound to the current character (e.g., the "Storytelling Mom" character). This voice model can be a deep learning-based speech synthesis model that was trained using a large amount of speech data from the "Storytelling Mom" character, thus synthesizing speech with the character's unique voice quality and pronunciation habits. Subsequently, the speech synthesis module receives the text "Great job, you did a great job!" and the "happy" emotion tag. The prosody generator inside the speech synthesis module recognizes the "happy" tag and automatically adjusts the prosodic parameters of the speech according to preset rules or an emotion-prosodic mapping model. Specifically, it may increase the average value of the fundamental frequency (F0) by about 10-20Hz, increase the range of fundamental frequency variation, increase the speech rate by about 10-15%, and introduce some light, rising intonation patterns. In addition, the volume may also be adjusted appropriately to match the emotional intensity of "happy". Through the coordinated adjustment of these parameters, the final synthesized voice not only has the timbre of "Story Mom," but also clearly expresses joy and praise in auditory perception, allowing users to clearly feel the positive emotions expressed by the assistant.
[0099] Through the aforementioned technical solution, intelligent terminal chat assistants can go beyond simple text-to-speech when outputting voice replies, achieving more refined and expressive emotional communication. Relying solely on emotion tags for speech synthesis can result in a lack of vividness in the voice expression, failing to fully reflect the character's emotional nuances and tone. This solution overcomes this limitation by identifying and parsing candidate replies with emotion tags and automatically adjusting a series of preset prosodic parameters, enabling the synthesized speech to accurately match the emotions indicated by the emotion tags. This not only enhances the naturalness and persuasiveness of the voice replies, allowing users to more intuitively perceive the assistant's "emotions," but also further strengthens character perception, making users feel as if they are communicating with a truly emotional and individual character. This refined emotional expression greatly enhances the immersiveness and satisfaction of the user experience, elevating intelligent terminal chat assistants to a higher level in human-computer interaction.
[0100] Exemplary device like Figure 3 As shown, this embodiment of the invention provides a device for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment. The device includes: The dialogue acquisition module 310 is used to acquire the user's voice input and perform speech recognition to convert it into text content; The role package loading module 320 is used to automatically activate the preset collaborative architecture when the user's voice input is recognized as a chat dialogue. Based on the recognized voice dialogue context or the user's selection, the preset role package is loaded to determine the role of the current dialogue. The candidate response generation module 330 is used to generate candidate responses corresponding to the text content by means of a preset content agent and a large language model, based on a determined role. The security assessment module 340 is used to perform a multi-dimensional security assessment on the candidate responses through a preset security alignment filter and output a risk score; The sentiment tag module 350 is used to add sentiment tags that match the tone of the character to candidate responses whose risk scores meet the security check. The synthesis playback module 360 is used to output and play candidate responses with emotional tags using a personal voice tone bound to the character through speech synthesis technology, as described above.
[0101] This application's solution, through the collaborative work of the aforementioned modules, addresses the technical challenge of balancing content security and compliance with role consistency in smart TV chat assistant applications. Specifically, the role package loading module ensures long-term consistency in knowledge background, style, and tone among dialogue roles, avoiding the "model illusion" and inconsistencies that may occur with purely generative large models. The security assessment module evaluates candidate responses across multiple dimensions, including explicit content security, semantic and intent risks, logical and factual accuracy, value and ethical considerations, and emotional bias risks, filtering inappropriate content at the source and effectively mitigating security vulnerabilities of the original corpus in retrieval-based model methods. The emotion tagging module dynamically generates emotion tags that match the role's tone, combining role settings with the user's emotional state, enabling speech synthesis technology to precisely adjust prosodic parameters and achieve emotional expression. Compared to the mechanical rigidity of rule-based and template-based methods, the inconsistency of personality in retrieval-based model methods, and the security risks of purely generative large models in existing technologies, this solution achieves a balance between security and natural fluency through the injection of instructions into the large language model by the content intelligent agent and the constraint of the role knowledge base.
[0102] Through the above technical solutions, smart terminal chat assistants can provide an interactive experience that aligns with mainstream values and is emotionally resonant in family settings, such as those with children. For example, when a child user expresses interest in learning new knowledge, the role-packaging module automatically activates the "Mom" role pack, the safety assessment module ensures that the response is free of scientific errors and conforms to children's values, the emotional tagging module adds "encouragement" and "care" tags, and finally, the synthesis and playback module outputs a response in a warm and friendly personal voice, significantly enhancing the attractiveness of the conversation and user satisfaction.
[0103] Based on the above embodiments, the present invention also provides a smart terminal, the principle block diagram of which can be as follows: Figure 4 As shown, the smart terminal includes a processor, memory, network interface, display screen, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium 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 medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for creating a role-aware and security-aligned smart terminal chat assistant. The database stores the implementation program for the role-aware and security-aligned smart terminal chat assistant.
[0104] Those skilled in the art will understand that Figure 4 The block diagram shown is merely a partial structural diagram related to the present invention and does not constitute a limitation on the smart terminal to which the present invention is applied. A specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0105] In one embodiment, a smart terminal is provided, including a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors, the one or more programs containing the method described above. This embodiment, by configuring a memory and programs in the smart terminal to execute a dialogue method based on role awareness and security alignment, effectively improves the role consistency and emotional expression capabilities of the chat assistant while ensuring the security and compliance of the response content, achieving the effect of providing a "professional + warm" interactive experience. Specifically, since the smart terminal can execute the above method, after obtaining user voice input, the system automatically activates a collaborative architecture when it is recognized as a chat dialogue, and determines the current dialogue role by loading a role package based on the voice dialogue context or user selection; the content agent combines a role knowledge base and a large language model to collaboratively generate candidate responses, and performs a multi-dimensional security assessment of explicit content security, semantic and intent risks, logical and factual risks, value and ethical risks, and emotional tendency risks through a security alignment filter; emotional tags that conform to the role's tone are added to the candidate responses that pass the security verification, and finally, the personal voice bound to the role is output and played through speech synthesis technology. Given the rigidity of rule-based and template-based methods, the inconsistency in personality portrayal in retrieval-based models, and the security and compliance risks of purely generative large models in existing technologies, this embodiment integrates a role management module, a security alignment filter, and an emotional generator into a collaborative architecture. This achieves a complete technical system that guides the output of a large language model from the source, dynamically adapts and corrects loops, and provides emotional speech expression. In other words, this smart terminal ensures consistency between role knowledge background and dialogue style through role package loading, effectively avoids inappropriate content output through the multi-dimensional evaluation mechanism of the security alignment filter, and enhances the accuracy of emotional expression by combining the emotional fitting model with the role-bound voice timbre. Thus, in the context of smart TV applications, this comprehensively solves the technical problems of lack of role consistency in casual conversation, compliance risks in responses, and insufficient emotional expression, providing a safe interactive experience that combines professionalism and emotional warmth for users such as children.
[0106] In the field of smart TV dialogue system technology, user interactions, especially with children, often face problems such as mechanical responses, lack of personalization, and potential compliance risks when interacting with voice assistants. To address these challenges, embodiments of this application provide an innovative implementation solution. Specifically, embodiments of this application also disclose a computer-readable storage medium, which, when executed by the processor of an electronic device, enables the electronic device to perform the aforementioned method. This method, through the synergistic application of role awareness and security alignment technologies, effectively enhances the role consistency and emotional expression capabilities of the chat assistant while ensuring the security and compliance of the response content.
[0107] This embodiment implements role perception and security alignment technology in the form of a computer-readable storage medium, thereby effectively improving the role consistency and emotional expression capabilities of the chat assistant while ensuring the security and compliance of the response content, achieving the effect of providing a "professional + warm" interactive experience. During implementation, the electronic device executes instructions in the storage medium. First, the dialogue acquisition module acquires the user's voice input and converts it into text content through speech recognition. When a chat dialogue is identified, the role package loading module automatically activates a preset collaborative architecture, loads a role package based on context or user selection, and determines the role in the current dialogue. Subsequently, the candidate response generation module generates candidate responses collaboratively with a content intelligence agent and a large language model based on the determined role. Next, the security assessment module performs a multi-dimensional security assessment of the candidate responses through a security alignment filter, including explicit content security, semantic and intent risk, logic and factuality, values and ethics, and emotional tendency risk. For candidate responses whose risk scores meet the security verification, the emotional tagging module adds emotional tags that match the role's tone. Finally, the synthesis and playback module uses a personal voice bound to the role and outputs the candidate responses with emotional tags through speech synthesis technology.
[0108] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for implementing a smart terminal chat assistant based on role awareness and security alignment, characterized in that, include: Acquire user voice input and convert it into text content through speech recognition; When a user's voice input is recognized as a chat conversation, a preset collaborative architecture is automatically activated. Based on the context of the recognized voice conversation or the user's selection, a preset role package is loaded to determine the role in the current conversation. Based on the determined roles, candidate responses corresponding to the text content are generated collaboratively by a preset content agent and a large language model. The candidate responses are evaluated for security in multiple dimensions using a preset security alignment filter, and a risk score is output. For candidate responses whose risk scores meet the security check, add emotional tags that match the character's tone; Using a personal voice associated with the character, candidate responses with emotional tags are output and played through speech synthesis technology.
2. The method for implementing a smart terminal chat assistant based on role awareness and security alignment according to claim 1, characterized in that, Prior to the step of obtaining the user's voice input and performing voice recognition, the following steps are included: A collaborative architecture is pre-built, including a role management module, a security alignment filter, and an emotional generator. It works collaboratively and outputs text-to-speech technology. The role management module is used to load family role packages, the security alignment filter is used to perform multi-dimensional security assessments on the generated candidate responses, and the emotional generator is used to add emotional tags that match the tone of the roles.
3. The method for implementing a smart terminal chat assistant based on role awareness and security alignment according to claim 1, characterized in that, The steps of automatically activating a preset collaborative architecture when user voice input is recognized as a chat conversation, loading a preset role package based on the recognized voice conversation context or user selection, and determining the role of the current conversation include: The text content obtained from speech recognition is acquired and analyzed to determine whether it is chat dialogue content. When a user's voice input is recognized as a chat conversation, a preset collaborative architecture is automatically activated. Based on the context of the recognized voice conversation or the user's selection, a preset family role package and role knowledge base are loaded to determine the roles in the current conversation.
4. The method for implementing a smart terminal chat assistant based on role awareness and security alignment according to claim 1, characterized in that, The step of generating candidate responses corresponding to the text content through a preset content agent and a large language model based on a determined role includes: Obtain the current role and the user intent determined based on the text content; Based on the user intent, a search is performed in the corresponding role knowledge base to extract knowledge points, factual data and dialogue style examples related to the text content; The content agent dynamically and structurally organizes the extracted knowledge points, factual data, and dialogue style examples related to the text content into a detailed prompt word instruction, which is then passed to the AI big model. The AI big model generates candidate responses corresponding to the text content. The role knowledge base is also introduced as raw material and instructions into the generation process, guiding and constraining the output of the AI big model from the source, and generating candidate responses that conform to the knowledge background, style, and tone of the current role.
5. The method for implementing a smart terminal chat assistant based on role awareness and security alignment according to claim 1, characterized in that, The step of performing a multi-dimensional security assessment of the candidate responses using a preset security alignment filter and outputting a risk score includes: The candidate responses are subjected to a multi-dimensional security assessment using a preset security alignment filter, including: In terms of explicit content security, explicit violations are filtered out through a sensitive word dictionary and regular expression matching algorithms. Semantic and intent risk dimensions: By analyzing the deep semantics of response content through a text classification model, we can identify content that promotes inappropriate behavior or misleads users. In terms of logic and factuality, for knowledge-based roles, the core knowledge points in the response are compared with internal knowledge graphs or authoritative databases to check for obvious scientific errors or logical contradictions. In terms of values and ethics, a value alignment model is established for children's scenarios to assess whether the responses conform to mainstream and positive children's values. In terms of sentiment risk, sentiment analysis is performed on the response text to identify sentiment tags and compare them with the current role's preset sentiment whitelist; if sentiments outside the whitelist that have a negative impact on children are found, sentiment compliance filtering is performed. A total risk score is obtained by weighted summation of the risk scores from the above dimensions; when the total risk score is lower than the set safety threshold, the candidate response is allowed to pass. When the total risk score is higher than or equal to the set security threshold, it is judged as high-risk content, blocked, and a rejection signal with a risk label is returned to the content agent, triggering the content to be regenerated. When regenerating candidate responses, additional avoidance instruction prompts are added to achieve a dynamic and adaptive correction cycle.
6. The method for implementing a smart terminal chat assistant based on role awareness and security alignment according to claim 1, characterized in that, The step of adding emotional tags that match the tone of voice to candidate responses whose risk scores meet the security check includes: A sentiment fitting model is pre-built. During the training phase, a predetermined amount of manually labeled data is used to learn appropriate sentiment expressions in the context of specified roles, user emotions, and response content, thereby achieving role-emotion alignment and obtaining the trained sentiment fitting model. The trained sentiment fitting model is input into the candidate responses that meet the security check for risk scores, the determined roles in the current dialogue, the user's emotional state obtained through sentiment analysis of user input, and the identified voice dialogue context. The trained sentiment fitting model encodes and fuses multiple inputs and interacts with them through an attention mechanism, outputting a single, clear sentiment label from a predefined sentiment label library.
7. The method for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment according to claim 1, characterized in that, The step of using a personal voice tone bound to the character to output and play candidate responses with emotional tags through speech synthesis technology includes: Using a personal voice associated with the character, the system identifies and analyzes candidate responses with emotional tags through speech synthesis technology, and automatically adjusts a series of preset prosodic parameters to achieve the corresponding emotional effect.
8. A device for implementing a smart terminal chat dialogue assistant based on role awareness and security alignment, characterized in that, The device includes: The dialogue acquisition module is used to acquire the user's voice input and convert the speech into text content through speech recognition; The role package loading module is used to automatically activate the preset collaborative architecture when the user's voice input is recognized as a chat dialogue. Based on the recognized voice dialogue context or the user's selection, the preset role package is loaded to determine the role of the current dialogue. The candidate response generation module is used to generate candidate responses corresponding to the text content based on the determined role, through a preset content agent and a large language model in collaboration. The security assessment module is used to perform multi-dimensional security assessments on the candidate responses using a preset security alignment filter and output a risk score. The sentiment tag addition module is used to add sentiment tags that match the tone of the character to candidate responses whose risk scores meet the security check. The synthesis playback module is used to output and play candidate responses with emotional tags using a personal voice tone bound to the character through speech synthesis technology.
9. A smart terminal, characterized in that, It includes a memory and one or more programs, wherein one or more programs are stored in the memory and configured to be executed by one or more processors, wherein the one or more programs include methods for performing any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method as described in any one of claims 1-7.