A method for movie and television role playing based on sentiment retrieval and role consistency control

By constructing a structured character memory knowledge graph and user sentiment analysis, combined with semantic and emotion-related text fragment retrieval and consistency verification, the problems of logical conflict and emotional disconnect in existing role-playing systems are solved, and high-quality film and television character interaction is achieved.

CN121009185BActive Publication Date: 2026-02-13ARTIFICIAL INTELLIGENCE INNOVATION RES INST OF ZHEJIANG UNIV OF TECH BINJIANG DISTRICT HANGZHOU
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511536071.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-27
Publication Date
2026-02-13
Estimated Expiration
2045-10-27

AI Technical Summary

Technical Problem

Existing role-playing systems lack structured modeling of character knowledge, resulting in logical conflicts and emotional disconnects in the generated content, failing to provide high-quality interaction with film and television characters.

Method used

A film and television role-playing method based on sentiment retrieval and role consistency control is constructed. By building a structured role memory knowledge graph and combining it with user sentiment analysis, semantic and emotion-related text fragment retrieval is performed, and atomic fact parsing and role consistency verification are carried out to generate the final role response.

Benefits of technology

It effectively reduces deviations in character settings and logical conflicts, enhances the emotional resonance of generated content and consistency with character style, and improves the realism and immersion of the interaction process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121009185B_ABST
    Figure CN121009185B_ABST
Patent Text Reader

Abstract

The application discloses a film and television role playing method based on emotional retrieval and role consistency control, and relates to the technical field of artificial intelligence and natural language processing, which aims at the problems of role behavior deviating from the setting, lack of emotional response resonance and inconsistent retrieval content style in the prior art, constructs a role memory knowledge graph and calculates semantic and emotional vectors, carries out emotional retrieval according to user query, modifies the preliminary response after atomic fact analysis and consistency verification, and finally outputs a natural language reply conforming to the role setting and having emotional resonance, and is mainly used for improving the reality and immersion of film and television role interaction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence and natural language processing technology, and in particular relates to a film and television role-playing method based on emotion retrieval and role consistency control. Background Technology

[0002] In recent years, the rapid development of large language model technology has driven the widespread application of intelligent role-playing systems in fields such as virtual human interaction, immersive games, and the digitization of film and television IPs. The construction of digital humans for film and television IPs has become an important direction for the integration of digital entertainment and artificial intelligence. It not only needs to achieve natural language understanding and generation but also needs to strictly adhere to the character settings in terms of emotional expression, behavioral logic, and language style to provide a highly anthropomorphic and role-playing immersive experience. However, existing role-playing systems still have significant technical bottlenecks. First, these systems generally lack structured modeling of character knowledge, relying solely on prompting engineering to inject character personality descriptions or background information, and depending on the parametric memory of the language model to simulate character behavior. This approach easily leads to logical conflicts or setting errors in the generated content, i.e., the character illusion problem. For example, in a long dialogue, a reserved character might suddenly utter frivolous lines, severely damaging the user's immersion and trust. Second, existing methods ignore the user's emotional state and lack a mechanism for perceiving and resonating with the user's psychology, making it difficult to provide effective emotional support in companionship or emotional guidance scenarios. Furthermore, although some systems employ retrieval-enhanced generation techniques to incorporate external knowledge and reduce illusions, their retrieval mechanisms rely solely on semantic relevance, neglecting emotional consistency and character style consistency. This results in emotionally disjointed and stylistically chaotic generated content. For example, background information retrieved solely based on semantic matching may contain content inconsistent with the character's current emotional state, thus affecting the overall consistency of responses. These issues severely limit the realization of high-quality film and television character interactions, thus necessitating an intelligent role-playing method that integrates emotional perception, knowledge consistency control, and character style preservation. Summary of the Invention

[0003] To address the aforementioned technical problems, this invention proposes a film and television role-playing method based on emotion retrieval and role consistency control, thereby resolving the issues present in the prior art.

[0004] Firstly, to achieve the above objectives, this invention provides a film and television role-playing method based on emotion retrieval and role consistency control, comprising the following steps:

[0005] Receive natural language queries from users;

[0006] The query is parsed to obtain its semantic vector, sentiment vector, and key entities;

[0007] Based on the key entity and the emotion vector, at least one text fragment that is semantically and emotionally related is retrieved from the pre-constructed role memory knowledge graph;

[0008] The query, the at least one text fragment, and the role setting information are combined into prompt words and input into the language model to generate an initial role response.

[0009] The initial role response is parsed using atomic facts and verified for role consistency. If the verification fails, it is corrected to generate the final role response.

[0010] Output the final character response.

[0011] Optionally, the process of constructing the character memory knowledge graph includes:

[0012] The character's text data is divided into multiple semantic segments;

[0013] Extract entities and semantic relations from each semantic segment to construct triples, and calculate the semantic vector and sentiment vector for each semantic segment;

[0014] A graph structure is constructed from the entities and semantic relationships, and synonymous entity nodes are disambiguated and merged.

[0015] An inverted index of entity-semantic fragments is constructed for the graph structure, and a community detection algorithm is used to cluster the graph to generate multiple entity communities.

[0016] Optionally, the process of retrieving data based on the key entity and the sentiment vector includes:

[0017] Based on the key entities, the corresponding entity communities are located using the inverted index;

[0018] Calculate the similarity between the semantic vector of the query and the aggregate vector of the entity community, and filter out at least one candidate community;

[0019] Calculate the distance between the sentiment vector of the query and the sentiment vectors of each semantic segment in the candidate community, and filter out the semantic segments that match the sentiment.

[0020] Optionally, the process of parsing the query includes:

[0021] The query is processed by word segmentation and noise reduction.

[0022] The semantic embedding model is used to encode the processed query to obtain the semantic vector;

[0023] The query is analyzed using an emotion recognition model to obtain the emotion vector;

[0024] Identify the key entities in the query.

[0025] Optionally, the process of performing atomic fact parsing and role consistency verification on the initial role response includes:

[0026] The initial role response is parsed into multiple atomic facts expressed in the third person;

[0027] The atomic facts, the query, the at least one text fragment, and the role knowledge are input into the evaluation model for consistency judgment.

[0028] Optionally, the process of correcting the verification if it fails includes:

[0029] If the atomic facts have a setting conflict or semantic deviation, the language model is invoked to rewrite the conflicting parts;

[0030] The rewritten atomic facts are used to regenerate a natural language response that conforms to the role's logic as the final role response.

[0031] Secondly, the present invention also provides a film and television role-playing system based on emotion retrieval and role consistency control, for implementing a film and television role-playing method based on emotion retrieval and role consistency control, the system comprising:

[0032] The query parsing module is used to receive and parse the natural language query input by the user to obtain its semantic vector, sentiment vector and key entities;

[0033] The emotion knowledge retrieval module is used to retrieve at least one text fragment that is semantically and emotionally related from a pre-constructed role memory knowledge graph based on the key entity and the emotion vector.

[0034] The response generation module is used to combine the query, the at least one text fragment, and the role setting information into prompt words, and call the language model to generate an initial role response;

[0035] The consistency verification module is used to perform atomic fact parsing and role consistency verification on the preliminary role response, and to correct it to generate the final role response if the verification fails.

[0036] The response output module is used to output the final role response.

[0037] Thirdly, the present invention also provides a computer terminal device, comprising:

[0038] One or more processors;

[0039] A memory, coupled to the processor, for storing one or more programs;

[0040] When the one or more programs are executed by the one or more processors, the one or more processors implement the steps of the film and television role-playing method based on emotion retrieval and role consistency control in the first aspect described above.

[0041] Fourthly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, it implements the steps of the film and television role-playing method based on emotion retrieval and role consistency control described in the first aspect above.

[0042] Fifthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the film and television role-playing method based on emotion retrieval and role consistency control described in the first aspect above.

[0043] Compared with the prior art, the present invention has the following advantages and technical effects:

[0044] This invention provides a film and television role-playing method based on emotion retrieval and character consistency control. By constructing a structured character memory knowledge graph and integrating user emotion analysis, this invention achieves character response generation with emotional perception and knowledge consistency. This method effectively reduces character setting deviations and logical conflicts, enhances the emotional resonance of the generated content and the consistency of character style, thereby significantly improving the realism, immersion, and user experience of the interaction process. Attached Figure Description

[0045] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:

[0046] Figure 1 This is a flowchart of an embodiment of the present invention. Detailed Implementation

[0047] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0048] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0049] Example 1

[0050] like Figure 1As shown, this embodiment provides a film and television role-playing method based on emotion retrieval and role consistency control, including:

[0051] Receive natural language queries from users;

[0052] The query is parsed to obtain its semantic vector, sentiment vector, and key entities;

[0053] Based on the key entity and the emotion vector, at least one text fragment that is semantically and emotionally related is retrieved from the pre-constructed role memory knowledge graph;

[0054] The query, the at least one text fragment, and the role setting information are combined into prompt words and input into the language model to generate an initial role response.

[0055] The initial role response is parsed using atomic facts and verified for role consistency. If the verification fails, it is corrected to generate the final role response.

[0056] Output the final character response.

[0057] S1: Constructing and Encoding Character Memories. The system constructs a structured memory knowledge graph based on textual data of film and television characters, including script excerpts and character settings. Specific steps include:

[0058] S1.1: Divide the original text into multiple TextChunks (semantic segments), each segment being controlled within 100–300 characters;

[0059] S1.2: Extract entities and semantic relationships from each TextChunk to form triples; calculate the semantic vector and sentiment vector for each segment respectively;

[0060] S1.3: Construct a graph structure with entities as nodes and semantic relationships as edges, with edge weights weighted by co-occurrence frequency; disambiguate and merge synonymous entity nodes to improve the semantic consistency of the graph;

[0061] S1.4: Construct an inverted index to record entities and their associated TextChunks; use the Leiden community detection algorithm to cluster the knowledge graph, generate entity communities with sentiment and semantic consistency, and calculate an aggregation vector for each community.

[0062] S2: Receiving and parsing user queries. The system first receives the natural language text input by the user through the front end and performs semantic and sentiment analysis on it. This mainly includes:

[0063] S2.1: Perform preprocessing on the original query text, including word segmentation, noise reduction, and stop word filtering;

[0064] S2.2: Use the semantic embedding model bge-base-zh-v1.5 to encode the cleaned text and generate semantic vectors; use ChatGPT-4o as an emotion recognition model to map the query emotion into a vector containing eight basic emotion dimensions with a numerical range of [1,10], where the emotions specifically include: joy, acceptance, fear, surprise, sadness, disgust, anger, and expectation;

[0065] S2.3: Call the language model to identify key entities, such as character names, events, and items, to provide recall conditions for subsequent emotional memory retrieval.

[0066] S3: Emotion-based Knowledge Graph Retrieval. The system locates the entity keywords in the user's query within the inverted index of the knowledge graph, retrieving candidate memory fragments. The process is as follows:

[0067] S3.1: Quickly locate the graph node containing the entity and its adjacent nodes to determine candidate communities;

[0068] S3.2: Calculate the cosine similarity between the user's semantic vector and the aggregated vector of each candidate community, and select the Top-N communities;

[0069] S3.3: Further sort the TextChunks in the candidate communities by the similarity between the sentiment vector and the query sentiment;

[0070] S3.4: Merge and remove duplicates of all related TextChunks, and finally determine the Top-K text chunks based on semantic and sentiment scores, which are used as input for the generation module.

[0071] S4: Generate Initial Role Response. The system concatenates user queries, Top-K search results, and role profile information into prompts, and calls a language model to generate an initial natural language response, ensuring that the tone and style match the target role's profile. The process includes:

[0072] S4.1: Construct a comprehensive prompt that includes user input, emotional features, memory fragments, and character background;

[0073] S4.2: Use the large language model ChatGPT-4o to generate natural language responses with consistent character styles; output the response text and submit it to the next module for character consistency verification.

[0074] S5: Role Consistency Verification. To ensure that the initial response is highly consistent with the role settings, the system performs the following consistency verification operations:

[0075] S5.1: Parse the response into multiple atomic facts and express them uniformly in the third person;

[0076] S5.2: Submit atomic facts, user queries, retrieved TextChunks, and role knowledge together to the evaluation model for consistency judgment;

[0077] S5.3: If there are settings conflicts, semantic errors, or behavioral deviations, the system triggers a correction mechanism, calls the language model to delete or rewrite the conflicting parts, and uses the corrected atomic facts to regenerate a natural language response that conforms to the role's logic.

[0078] S6: Output the final response text:

[0079] S6.1: The system will return the final reply to the user after consistency verification and correction, ensuring consistency and credibility in semantics, emotion and role behavior logic, so as to achieve emotional resonance and immersive interaction in role-playing.

[0080] As one implementation method in this embodiment, the process of constructing the role memory knowledge graph includes:

[0081] The character's text data is divided into multiple semantic segments;

[0082] Extract entities and semantic relations from each semantic segment to construct triples, and calculate the semantic vector and sentiment vector for each semantic segment;

[0083] A graph structure is constructed from the entities and semantic relationships, and synonymous entity nodes are disambiguated and merged.

[0084] An inverted index of entity-semantic fragments is constructed for the graph structure, and a community detection algorithm is used to cluster the graph to generate multiple entity communities.

[0085] S1: Constructing and Encoding Character Memories. The character memory mapping system constructs a structured memory knowledge graph based on textual data of film and television characters, including script excerpts, character settings, etc.

[0086] S1.1: The system collects character-related memory data from specified knowledge sources, including script excerpts, dialogue records between characters, character setting documents, etc. The system segments this raw text data according to semantic boundaries or a length of 100–300 characters per segment, generating multiple TextChunks as the basic units for subsequent retrieval. For example, the original text can be used as input, segmented according to semantic boundaries.

[0087] The following excerpt is from *Dream of the Red Chamber*, TextChunk_1: "Baoyu saw fallen flowers scattered on the ground and was about to sweep them into the water when Lin Daiyu said, 'It's not good to leave them in the water… I have a flower mound in that corner; if we sweep them up now, put them in this silk bag, and bury them there, they'll eventually decompose with the soil. Wouldn't that be cleaner?'"

[0088] TextChunk_2: "When Lin Daiyu heard the phrases 'beautiful women like flowers, fleeting years like water,' she was moved and her mind was shaken. She savored the meaning of the phrases and thought of the lines about the sorrow of spring in ancient poems. These lines came together and she pondered them carefully. She felt heartbroken and lost in thought, and tears welled up in her eyes."

[0089] TextChunk_3: "He was frail and sickly from childhood, but possessed a delicate and sensitive mind and was exceptionally talented. Living in the Jia family mansion, he often felt like a dependent and was deeply saddened by the passing of beautiful things. His writing style was elegant and subtle."

[0090] S1.2: For each TextChunk, a large language model is invoked to extract the entities involved, such as people, places, and objects, as well as their semantic relationships (cooperation, causality, adversarial relationships, etc.), and organize them into structured triplet information, such as (Lin Daiyu, inquiry, Baoyu). An embedding model is executed for each TextChunk to calculate its semantic vector, and an emotion recognition model is used to generate its corresponding 8-dimensional emotion vector. These results are cached to accelerate subsequent retrieval.

[0091] For example, the semantic vectors of TextChunk_1, TextChunk_2, and TextChunk_3 are calculated by bge-base-zh-v1.5, and the emotion vectors are generated by ChatGPT-4o. The hypothetical model output is: TextChunk_1: [Joy: 1, Acceptance: 2, Fear: 1, Surprise: 2, Sadness: 6, Disgust: 1, Anger: 1, Expectation: 1]; TextChunk_2: [Joy: 1, Acceptance: 1, Fear: 2, Surprise: 1, Sadness: 8, Disgust: 1, Anger: 1, Expectation: 2]; TextChunk_3: [Joy: 1, Acceptance: 2, Fear: 3, Surprise: 1, Sadness: 5, Disgust: 1, Anger: 1, Expectation: 1].

[0092] S1.3: A knowledge graph is constructed based on all extracted entities. Nodes in the graph represent entities, and edges represent semantic relationships between entities. Edge weights are calculated based on the frequency of their co-occurrence across multiple TextChunks. To achieve semantic consistency and entity disambiguation, the system merges synonymous entity nodes and aggregates their descriptive information. Nodes include "Lin Daiyu," "Baoyu," "Peach Blossom," etc.

[0093] S1.4: Build an inverted index structure to establish the corresponding relationship between each entity and the TextChunk where it appears, improving the entity recall efficiency. Finally, use the Leiden community detection algorithm to perform graph clustering on the knowledge graph to obtain multiple graph communities. Each community contains several entities and their associated TextChunks, and calculate the semantic aggregation vector of the community. For example, "Lin Daiyu: TextChunk_1, TextChunk_2, TextChunk_3". Community A (burying flowers / pitying flowers): Nodes Lin Daiyu, Baoyu, peach blossoms, sentiment; associated TextChunk_1, TextChunk_3. Calculate the aggregation vector of TextChunk_1, TextChunk_3. Community B (feeling sad while listening to music): Nodes Lin Daiyu, The Peony Pavilion, ancient poems, sentiment, beautiful ladies like flowers, fleeting years like water; associated TextChunk_2. Calculate the aggregation vector of TextChunk_2. Community C (life experience and talent): Nodes Lin Daiyu, poems, living under another's roof, weak and sickly; associated TextChunk_3. Calculate the aggregation vector of TextChunk_3.

[0094] As an implementation manner in this embodiment, the process of parsing the query includes:

[0095] Perform word segmentation and denoising processing on the query;

[0096] Use a semantic embedding model to encode the processed query to obtain the semantic vector;

[0097] Use an emotion recognition model to analyze the query to obtain the emotion vector;

[0098] Identify the key entity in the query.

[0099] S2: Receive and parse the user query. The system first receives the natural language text input by the user through the front end and performs semantic and emotion parsing on it.

[0100] S2.1: The user inputs a natural language query through the system front-end interface. After the system receives the input text, it triggers the query processing flow. The system first performs preprocessing operations on the query text, including Chinese word segmentation, removing noise characters, and removing stop words, to improve the subsequent semantic analysis effect. Input: "When Lin Daiyu saw the fallen flowers in the garden, she felt very sad. Have you ever felt so sentimental?" Output: "Lin Daiyu saw the garden fallen flowers, felt very sad. Have you ever felt so sentimental?" (Word segmentation, removing the stop word 'de').

[0101] S2.2: The cleaned text is encoded using a pre-trained semantic embedding model to generate a fixed-dimensional semantic vector representing the semantic meaning of the query. The system uses ChatGPT-4o as the emotion recognition model to perform emotion analysis on the original query text and outputs an integer vector containing 8 emotion dimensions, representing joy, acceptance, fear, surprise, sadness, disgust, anger, and expectation, with each dimension ranging from [1, 10]. [Joy: 1, Acceptance: 2, Fear: 2, Surprise: 1, Sadness: 8, Disgust: 1, Anger: 1, Expectation: 4] (Strong sadness is the dominant tone, expecting the other party to resonate).

[0102] S2.3: Simultaneously, the language model is invoked to extract key entity terms from the query text, such as character names, events, and items, as entity recall conditions for subsequent graph retrieval. The extracted key entities are Lin Daiyu, fallen flowers, and sadness.

[0103] As one implementation method in this embodiment, the process of retrieving based on the key entity and the sentiment vector includes:

[0104] Based on the key entities, the corresponding entity communities are located using the inverted index;

[0105] Calculate the similarity between the semantic vector of the query and the aggregate vector of the entity community, and filter out at least one candidate community;

[0106] Calculate the distance between the sentiment vector of the query and the sentiment vectors of each semantic segment in the candidate community, and filter out the semantic segments that match the sentiment.

[0107] The specific process of retrieval based on the key entities and the sentiment vector includes:

[0108] S3: Emotion-based knowledge graph retrieval. The system locates the position of entity keywords in the inverted index within the knowledge graph based on the user's query, and retrieves candidate memory fragments.

[0109] S3.1: Based on the entity keywords identified in the first step, the system quickly locates the knowledge graph node containing the entity in the inverted index. It then obtains the graph community where the entity resides and its adjacent entities as preliminary search candidates. The input entities are Lin Daiyu, Fallen Flowers, and Sentimental Sorrow. Searching the inverted index based on Lin Daiyu, Fallen Flowers, and Sentimental Sorrow reveals that Lin Daiyu and Fallen Flowers are primarily in community A. Sentimental Sorrow is in both community A and community B.

[0110] S3.2: Calculate the relevance score by using the cosine similarity between the query semantic vector and the aggregate vector of each graph community, and select the Top-N most relevant communities.

[0111]

[0112] Where u is the semantic vector of the user query. c is the graph community aggregation vector or TextChunk semantic vector. Community A is highly relevant to the query semantics (Lin Daiyu + falling flowers + sentimentality). Community B is relatively relevant (listening to music and feeling sentimental). Therefore, the top-2 most relevant communities are Community A and Community B.

[0113] S3.3: In terms of emotion dimension, the system further compares the emotion vector of the user query with the emotion vector distribution of TextChunk in each community, and performs preliminary filtering through emotion distance to ensure that the recall results are emotionally consistent with the user's intent.

[0114]

[0115] in An 8-dimensional emotion vector for the numerical range of 1–10 queried by the user. Given an 8-dimensional sentiment vector for a TextChunk, calculate the sentiment distance between the query and every TextChunk within the community. Exclude segments with excessively large sentiment distances, retaining segments with high sadness values ​​such as [sad: 6, 7, 9].

[0116] S3.4: Summarize all TextChunks selected from the communities, perform deduplication, and form a preliminary candidate set. For each TextChunk in the candidate set, calculate the cosine similarity with the query semantic vector, and sort them from highest to lowest similarity. Select the Top-K text chunks as the final candidates. If the user has high requirements for sentiment matching, the system can further optimize the final candidate results by weighting the sorting based on the 8-dimensional sentiment vector on top of the Top-K. TextChunk_1 from community A (mainly high-sadness values ​​for descriptions like "burying flowers" and "pitying flowers"), and the high-sadness fragment from community B (TextChunk_2's [sadness: 8] matches). Top-K results: TextChunk_1, TextChunk_2.

[0117] Furthermore, S4: Initial Response Generation. The system combines the user query, Top-K search results, and character profile information into prompts, and calls the language model to generate an initial natural language response, ensuring that the tone and style match the target character's profile.

[0118] S4.1: The system combines user queries, Top-K text block content, basic character settings, user prompt descriptions, etc., to construct system prompt words.

[0119] For example: You are playing the role of Lin Daiyu. Please reply to the user in Lin Daiyu's voice based on the following character settings and your memory.

[0120] [Character Setting]:

[0121] {{TextChunk_3 Summary of Daiyu's Character, Talent, Circumstances, and Sentimentality Towards Falling Flowers}}

[0122] [Related Memories]:

[0123] 1. {{Top1 TextChunk: Summary of the Core Plot of Burying Flowers}} (Emotion: Intense Sadness)

[0124] 2. {{Top2 TextChunk: Excerpt from "Listening to The Peony Pavilion: Moved to Tears"}} (Emotion: Intense Sadness)

[0125] 3. {{Top3 TextChunk: "Sad Falling Flowers" Setting Summary}} (Emotion: Sadness)

[0126] [User Inquiry]:

[0127] "When Lin Daiyu saw the fallen flowers in the garden, she felt very sad. Have you ever felt this way?"

[0128] [Require]:

[0129] *The tone, wording, and emotions must be consistent with Lin Daiyu's identity and personality.

[0130] *Referencing or adapting related memories.

[0131] *Expresses deep sorrow and empathy.

[0132] Use polite language appropriate to the character.

[0133] S4.2: Call the large-scale language model ChatGPT-4o, input the constructed Prompt content, and the model generates a preliminary text response with a style that fits the target character based on its semantic and emotional features. Output the preliminary response result and pass it to the subsequent character consistency verification module to verify whether it conforms to the character's behavioral logic and settings. Suppose it is: "These fallen flowers...are most heartbreaking. I remember that day, when I saw the fallen petals piled up on the steps, I couldn't bear to let them flow away with the muddy water, so I collected them in a brocade pouch and buried them in a fragrant tomb. 'Today I bury flowers, people laugh at my foolishness; who will bury me in years to come?' These flowers bloom and fall, they are originally heartless things, yet they cause people to shed thousands of tears. My sister saw this scene today and was moved; how could I not know? In this world, only these fallen flowers and the ill-fated can truly pity and cherish each other."

[0134] As one implementation method in this embodiment, the process of performing atomic fact parsing and role consistency verification on the preliminary role response includes:

[0135] The initial role response is parsed into multiple atomic facts expressed in the third person;

[0136] The atomic facts, the query, the at least one text fragment, and the role knowledge are input into the evaluation model for consistency judgment.

[0137] The process of performing atomic fact parsing and role consistency verification on the preliminary role response specifically includes:

[0138] S5: Role Consistency Check. This checks and corrects role consistency to ensure the initial response is highly consistent with the role settings.

[0139] S5.1: The system records each character's background information, typical behavioral logic, emotional reaction patterns, value orientation, and language style. The initially generated response text is parsed into several atomic facts, each using a consistent third-person narrative to improve the accuracy of automatic analysis. Input: Initial response text. Output: Lin Daiyu feels deeply saddened by fallen flowers. Lin Daiyu once collected fallen flowers to bury. While burying the flowers, Lin Daiyu recited, "Today I bury flowers, people laugh at my folly; in years to come, who will bury me?" Lin Daiyu believes that the blooming and withering of flowers is heartless, yet it brings tears to one's eyes. Lin Daiyu understands and resonates with the user's sadness upon seeing fallen flowers. Lin Daiyu believes that fallen flowers and those with tragic fates share a mutual pity.

[0140] S5.2: Input these atomic facts, along with the user query, relevant TextChunks, and role knowledge, into the ChatGPT-4o model for semantic consistency verification to ensure that each fact has retrieval support or reasonable derivation. The prompt used is:

[0141] Please input the following atomic facts along with the user query, relevant TextChunk, and the personality and language habits of character XXX into ChatGPT-4o for multi-dimensional verification. Specific requirements are as follows:

[0142] Basic verification: Determine whether each fact can be reasonably deduced based on search support such as direct expression in TextChunk or logical inference based on user query and TextChunk. If all 1-5 items pass this verification, "Fact X verification passed" can be marked.

[0143] Role and Expression Suitability Verification: Focus on checking whether the expression of each fact is consistent with the personality traits and language habits of character XXX, paying particular attention to whether the following issues exist:

[0144] Semantic deviation (inconsistent with the core meaning reasonably expressed by the character);

[0145] The expression was not subtle enough (it did not conform to the character's usual language style).

[0146] Other situations where the character's personality or language habits do not match.

[0147] The output should be presented in bullet points:

[0148] For facts that have passed all verifications, mark them as "Fact X has passed verification";

[0149] For facts that have issues with character suitability or expression, clearly indicate "Fact X has semantic deviation / is not subtle enough and may not be consistent with the character XXX's personality and language habits".

[0150] The output is: Facts 1-5 are verified. Fact 6 (Lin Daiyu believes that fallen flowers and ill-fated people can pity and cherish each other) has semantic deviation / is not subtle enough and may not be consistent with the character's proud personality and language habits.

[0151] As one implementation method in this embodiment, the process of correcting the verification when it fails includes:

[0152] If the atomic facts have a setting conflict or semantic deviation, the language model is invoked to rewrite the conflicting parts;

[0153] The rewritten atomic facts are used to regenerate a natural language response that conforms to the role's logic as the final role response.

[0154] The process of correcting instances that fail verification specifically includes: S5.3: If logical conflicts, semantic deviations, or behavioral inconsistencies are detected in the facts, the system triggers a correction mechanism, calling the language model to delete, rewrite, or fine-tune them. The corrected atomic facts are then input back into the language model to generate the final text response, ensuring the logical rationality, consistency, and emotional immersion of the character's behavior.

[0155] Furthermore, S6: Final response output.

[0156] S6.1: The system will return the response content, after role consistency verification and correction, as the final output to the user. The response content maintains a consistent role style, natural tone, and alignment with the user's emotional state, achieving an immersive and highly credible role-playing dialogue experience.

[0157] Through the detailed steps described above, this invention realizes a multi-dimensional retrieval mechanism based on knowledge graphs and sentiment vectors, and integrates a role consistency control process. While ensuring semantic relevance and sentiment consistency, it improves the response quality, interactive immersion, and interpretability of the role-playing system.

[0158] Based on this, this invention provides a film and television role-playing method based on emotion retrieval and character consistency control. This invention achieves character response generation with emotional perception and knowledge consistency by constructing a structured character memory knowledge graph and integrating user emotion analysis. This method effectively reduces character setting deviations and logical conflicts, enhances the emotional resonance of the generated content and the consistency of character style, thereby significantly improving the realism, immersion, and user experience of the interaction process.

[0159] This invention is applicable to scenarios such as virtual character interaction, digital operation of film and television IPs, and immersive entertainment experiences. The system can understand the semantics and emotional state of user input, and combined with a constructed character memory knowledge graph, it can retrieve relevant text fragments driven by emotional resonance. Furthermore, it generates consistent natural language responses under the constraints of character settings, thereby enhancing the immersion, credibility, and interaction quality of role-playing.

[0160] Example 2

[0161] In this embodiment, a computer terminal device is provided, including:

[0162] One or more processors;

[0163] A memory, coupled to the processor, for storing one or more programs;

[0164] When the one or more programs are executed by the one or more processors, the one or more processors implement the steps of the above-described film and television role-playing method based on emotion retrieval and role consistency control.

[0165] In this embodiment, a computer-readable storage medium is also provided, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the above-described film and television role-playing method based on emotion retrieval and role consistency control.

[0166] In this embodiment, an electronic device is also provided, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to perform the steps of the above-described film and television role-playing method based on emotion retrieval and role consistency control.

[0167] In this embodiment, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of the above-described film and television role-playing method based on emotion retrieval and role consistency control.

[0168] The aforementioned program can run on a processor or be stored in memory (or a computer-readable medium). Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and information storage can be achieved by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random-access memory (SRAM), dynamic random-access memory (DRAM), other types of random-access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.

[0169] These computer programs may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes can be implemented by different modules for different steps.

[0170] This embodiment provides such a device or system. The system, referred to as a film and television role-playing system based on emotion retrieval and role consistency control, includes:

[0171] The query parsing module is used to receive and parse the natural language query input by the user to obtain its semantic vector, sentiment vector and key entities;

[0172] The emotion knowledge retrieval module is used to retrieve at least one text fragment that is semantically and emotionally related from a pre-constructed role memory knowledge graph based on the key entity and the emotion vector.

[0173] The response generation module is used to combine the query, the at least one text fragment, and the role setting information into prompt words, and call the language model to generate an initial role response;

[0174] The consistency verification module is used to perform atomic fact parsing and role consistency verification on the preliminary role response, and to correct it to generate the final role response if the verification fails.

[0175] The response output module is used to output the final role response.

[0176] As one implementation method in this embodiment, a knowledge graph management module is also included;

[0177] The knowledge graph management module includes:

[0178] The text processing unit is used to divide character text data into multiple semantic segments;

[0179] The vector computation unit is used to extract entities and semantic relations in each semantic segment to construct triples, and to compute the semantic vector and sentiment vector of each semantic segment;

[0180] The graph construction unit is used to construct a graph structure from the entities and semantic relationships, and to disambiguate and merge synonymous entity nodes;

[0181] An index clustering unit is used to construct an inverted index of entity-semantic fragments for the graph structure and to cluster the graph using a community detection algorithm to generate multiple entity communities.

[0182] As one implementation method in this embodiment, the emotion knowledge retrieval module includes:

[0183] The community positioning unit is used to locate the corresponding entity community based on the key entity through an inverted index.

[0184] A semantic filtering unit is used to calculate the similarity between the semantic vector of the query and the aggregate vector of the entity community, and filter out at least one candidate community.

[0185] The emotion filtering unit is used to calculate the distance between the queried emotion vector and the emotion vectors of each semantic segment in the candidate community, and to filter out semantic segments that match the emotion.

[0186] As one implementation method in this embodiment, the query parsing module includes:

[0187] A text preprocessing unit is used to perform word segmentation and noise reduction on the query.

[0188] A semantic encoding unit is used to encode the processed query using a semantic embedding model to obtain the semantic vector;

[0189] An emotion recognition unit is used to analyze the query using an emotion recognition model to obtain the emotion vector;

[0190] An entity extraction unit is used to identify the key entities in the query.

[0191] As one implementation method in this embodiment, the consistency verification module includes:

[0192] The fact parsing unit is used to parse the initial role response into multiple atomic facts expressed in the third person;

[0193] The consistency verification unit is used to input the atomic facts, the query, the at least one text fragment, and the role knowledge into the evaluation model for consistency judgment.

[0194] As one implementation method in this embodiment, the consistency verification module further includes:

[0195] The response correction unit is used to call the language model to rewrite the conflicting part when there is a setting conflict or semantic deviation in the atomic fact, and use the rewritten atomic fact to regenerate a natural language response that conforms to the role logic as the final role response.

[0196] The system or apparatus is used to implement the functions of the methods in the above embodiments. Each module in the system or apparatus corresponds to each step in the method, as has been described in the method and will not be repeated here.

[0197] The above implementation method solves the problem of film and television role-playing based on emotion retrieval and role consistency control in related technologies, thereby ensuring that the problems existing in the prior art are resolved.

[0198] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for movie role playing based on emotion retrieval and role consistency control, characterized in that, The method comprises the following steps: receiving a natural language query input by a user; parsing the query to obtain a semantic vector, an emotion vector, and a key entity thereof; retrieving at least one text segment related to both semantics and emotions from a pre-constructed role memory knowledge graph based on the key entity and the emotion vector; the process of constructing the role memory knowledge graph comprises: dividing role text materials into a plurality of semantic segments; extracting entities and semantic relationships in each semantic segment to construct triples, and calculating a semantic vector and an emotion vector of each semantic segment; constructing a graph structure from the entities and semantic relationships, and disambiguating and merging synonymous entity nodes; constructing an inverted index of entity-semantic segments for the graph structure, and clustering the graph using a community detection algorithm to generate a plurality of entity communities; combining the query, the at least one text segment, and role setting information into a prompt word, and inputting the prompt word into a language model to generate a preliminary role response; performing atomic fact parsing and role consistency verification on the preliminary role response, and modifying the preliminary role response when the verification fails to generate a final role response; outputting the final role response.

2. The method of claim 1, wherein, The process of retrieving based on the key entity and the emotion vector comprises: locating a corresponding entity community through the inverted index according to the key entity; calculating the similarity between the semantic vector of the query and the aggregated vector of the entity community, and screening at least one candidate community; calculating the distance between the emotion vector of the query and the emotion vectors of the semantic segments in the candidate community, and screening semantic segments with matching emotions.

3. The method of claim 1, wherein, The process of parsing the query comprises: performing word segmentation and noise removal processing on the query; encoding the processed query using a semantic embedding model to obtain the semantic vector; analyzing the query using an emotion recognition model to obtain the emotion vector; identifying the key entity in the query.

4. The method of claim 1, wherein, The process of performing atomic fact parsing and role consistency verification on the preliminary role response comprises: parsing the preliminary role response into a plurality of atomic facts of third-person expressions; inputting the atomic facts, the query, the at least one text segment, and role knowledge into a judgment model for consistency judgment.

5. The method of claim 4, wherein, The process of modifying the preliminary role response when the verification fails comprises: if the atomic facts have a set conflict or semantic deviation, invoking a language model to rewrite the conflict part; using the rewritten atomic facts to regenerate a natural language reply that conforms to the role logic as the final role response.

6. A movie role playing system based on emotion retrieval and role consistency control, characterized in that, The system comprises: a query parsing module configured to receive and parse a natural language query input by a user to obtain a semantic vector, an emotion vector, and a key entity thereof; an emotion knowledge retrieval module configured to retrieve at least one text segment related to both semantics and emotions from a pre-constructed role memory knowledge graph based on the key entity and the emotion vector; further comprising a knowledge graph management module; the knowledge graph management module comprises: a text processing unit configured to divide role text materials into a plurality of semantic segments; a vector calculation unit configured to extract entities and semantic relations in each of the semantic segments to construct triples and calculate semantic vectors and sentiment vectors of each of the semantic segments; a graph construction unit configured to construct a graph structure from the entities and semantic relations and to disambiguate and merge synonymous entity nodes; an index clustering unit configured to construct an inverted index of entity-semantic segment for the graph structure and to cluster the graph using a community detection algorithm to generate a plurality of entity communities; a response generation module configured to combine the query, the at least one text segment, and role setting information into a prompt word, and to call a language model to generate a preliminary role response; a consistency verification module configured to perform atomic fact parsing and role consistency verification on the preliminary role response, and to modify the preliminary role response to generate a final role response when the verification fails; a response output module configured to output the final role response.

7. A computer terminal device, characterized by comprising: one or more processors; a memory coupled to the processors, the memory storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more programs cause the one or more processors to implement the steps of the method according to any one of claims 1-5.

8. A computer readable storage medium having stored thereon a computer program, characterized in that, the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1-6.

9. A computer program product comprising a computer program, characterized in that, the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Man-machine conversation control method and device and terminal

    CN114238589A

  • Role playing model fusion system and method based on retrieval and reflection

    CN120562547A