An end-cloud collaborative layered memory injection, dynamic retrieval and conflict update method, system, device and equipment suitable for emotional companion toys
By constructing an edge-cloud collaborative hierarchical memory system and caching rules, the memory management and retrieval problems of the ESP32-S3 terminal in the existing technology are solved, realizing efficient memory management and emotional companionship, adapting to embedded hardware resources, and ensuring continuous interaction in weak network and low computing power scenarios.
Patent Information
- Application Number
- CN202611216320.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-12
- Publication Date
- 2026-11-10
AI Technical Summary
Existing companion devices have deficiencies in memory management, retrieval, terminal adaptation, and prompt word construction. They cannot be adapted to the ESP32-S3 terminal, resulting in low interaction accuracy, poor emotional memory lifecycle management, simplistic conflict handling methods, insufficient utilization of embedded hardware resources, and insufficient linkage between intimacy and memory recall weights, thus failing to achieve a sense of exclusivity in emotional companionship.
A six-layer hierarchical memory system with edge-cloud collaboration and edge-side caching rules is constructed. The system is divided into six basic memory layers, including user profiles, contextual events, and reassurance strategies. It is equipped with local fixed rules for network disconnection effectiveness. The terminal collects multimodal interaction data and uploads it to the cloud for parsing. The memory is written through seven-dimensional saliency scoring and conflict detection. The system is reordered based on intimacy and reassurance effectiveness, and structured encoding and dynamic injection are performed. A three-level conflict resolution and two-way version tracking mechanism is established to achieve system self-evolution.
It improves memory management efficiency, enhances the accuracy of memory retrieval, ensures content consistency after changes in user preferences, reduces token consumption, adapts to the hardware characteristics of ESP32-S3, and ensures continuous emotional support in weak network and low computing power scenarios.
Smart Images

Figure CN123068618A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of intelligent human-computer interaction, embedded systems and natural language processing, and in particular to a method, system, device and equipment for edge-cloud collaborative hierarchical memory injection, dynamic retrieval and conflict update suitable for emotional companion toys. Background Technology
[0002] Existing memory solutions for companionship devices have significant flaws and are unsuitable for the ESP32-S3 terminal and emotional companionship scenarios. At the memory management level, memories are not stored hierarchically, resulting in a mix of user preferences, temporary states, event experiences, and device information, leading to chaotic retrieval and injection logic. The writing mechanism lacks filtering, allowing short-lived, invalid, and erroneous information to accumulate into "dirty memories," reducing interaction accuracy. At the retrieval level, reliance on semantic similarity alone, lacking joint filtering based on keywords, time, confidence level, and category, results in significant false positives and false negatives. At the consistency level, memories are only appended without conflict identification and updates, easily leading to contradictory responses when user preferences and soothing strategies change. At the terminal adaptation level, the ESP32-S3's limited computing power and memory cannot handle complex retrieval and full historical storage, making interaction prone to interruption in weak or offline network scenarios. At the prompt word construction level, a one-time full concatenation method is used, failing to dynamically inject corresponding memories according to stages such as wake-up, understanding, soothing, and expression, causing contextual pollution and token waste; furthermore, memories are injected in raw natural language, lacking structured expression and resulting in poor model controllability.
[0003] Furthermore, existing solutions do not incorporate differentiated memory decay rules based on emotion types, thus failing to achieve emotional memory lifecycle management; they do not evaluate or self-evolve the actual effectiveness of soothing strategies, resulting in low strategy reuse efficiency; they do not establish a hierarchical judgment and graded resolution mechanism for memory conflicts, leading to simplistic and crude conflict handling methods; they do not achieve low-power wake-up and memory preloading on the device side, making them unfriendly to embedded hardware resources; and they do not deeply link intimacy with memory retrieval weights, resulting in insufficient exclusivity in emotional companionship. Summary of the Invention
[0004] To solve the above-mentioned technical problems, the present invention provides the following technical solution: A method for edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update applicable to emotional companion toys includes: constructing a six-layer edge-cloud collaborative hierarchical memory system and edge-side caching rules; dividing the memory into six basic layers: user profile, scenario events, soothing strategies, working memory, relationship status, and device status; and supporting two types of extended memories: locally solidified scenario silence rules that take effect when the network is disconnected and negative constraint-type system lessons; defining write triggering, retrieval priority, and time-effect decay rules for each layer; pre-setting ESP32-S3 edge-side Flash resident cache and RAM short-term cache, and solidifying offline constraints and low-power wake-up preloading logic; collecting multimodal interaction data from the terminal, including voice, touch, posture, button, and environmental data, and uploading it to the cloud, parsing and generating memory candidates; calculating the total saliency score from seven dimensions, and allocating data to edge-side short-term cache, session working memory, and cloud long-term memory according to a 30 / 60 threshold; and skipping scoring and thresholding for key events that meet the judgment conditions. Values are distributed and forcibly written to the corresponding memory layer after conflict detection; interaction themes, emotions, and scenarios are identified, with pre-existing metadata and time window hard filtering, parallel keyword inversion and relation graph adjacency coarse recall, followed by semantic vector fine matching; multi-dimensional weights and conflict risk penalties are superimposed, and the intimacy and soothing effectiveness are combined for re-ranking, and the candidate set is output by pruning according to the token budget; before writing, historical memories with the same subject and attributes are matched, and the conflicts are divided into three levels of minor, moderate, and severe according to semantic similarity, and in-situ update, pending confirmation guidance, and dual-version scenario adaptive strategies are executed respectively; the complete version traceability link is preserved, and the latest high-confidence memory is selected for secondary verification before injection; candidate memories are compressed, distilled, and structured encoded, and memory blocks are dynamically injected according to four stages: awakening, understanding, soothing, and expression; high-frequency memories are synchronized to the end side via network, offline degradation is triggered when the network is disconnected, and updates are made when the network is connected; the system self-evolves based on the soothing effect and multi-dimensional index iteration strategy.
[0005] An edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update system for emotional companion toys is provided. The system is used to execute executable instructions to perform the aforementioned edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys.
[0006] An end-to-end cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update device for emotional companion toys is characterized in that the device is used to execute executable instructions to perform the above-mentioned end-to-end cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys.
[0007] Its beneficial effects are as follows: It constructs a full-link emotional memory management system with end-to-end cloud collaboration for the ESP32-S3 low-power emotional companion toy. Architecturally, it adopts a layered storage design with six layers of basic memory and two types of extended memory, complemented by two levels of terminal storage: a persistent Flash cache and a short-term RAM cache, adapting to the limited computing power and storage resources of embedded hardware. In terms of process, it achieves memory writing gating through seven-dimensional saliency scoring and mandatory archiving of key events, establishing a four-level retrieval system of pre-processing hard filtering, dual-channel coarse recall, semantic fine matching, and refined reordering, and establishing a three-level conflict resolution and bidirectional version traceability mechanism. After compression and distillation, memories are structurally injected according to the four stages of companionship, complemented by end-to-cloud synchronization, offline degradation, and a closed-loop evaluation mechanism for soothing effects, achieving continuous and consistent personalized emotional companionship under weak network and low computing power constraints.
[0008] This application offers several key benefits. First, it employs layered storage and write gating to effectively intercept invalid information that creates "dirty memories," and differentiates access rules by level to improve memory management efficiency. Second, it utilizes multi-path hybrid retrieval combined with intimacy and soothing effectiveness weighted sorting for higher memory retrieval accuracy, better meeting the needs of emotional companionship scenarios. Third, it addresses memory inconsistencies caused by changes in user preferences through three-level conflict resolution and version tracking, ensuring consistent output content. Fourth, it reduces token consumption through structured compression and phased injection, and its two-level cache on the device side and low-power wake-up deeply adapt to the ESP32-S3 hardware characteristics. Fifth, it ensures continuity of companionship in weak network scenarios through offline degradation and backhaul transmission, and its closed-loop evaluation of soothing effects forms a positive data loop, supporting continuous system self-improvement. Attached Figure Description
[0009] Figure 1 A flowchart of an edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of a module for an end-to-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update system for emotional companion toys, provided as an embodiment of the present invention. Detailed Implementation
[0010] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention. Figure 1 This application describes an edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys, based on an exemplary embodiment of the present application.
[0011] In this application embodiment, an edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method suitable for emotional companion toys is provided, such as... Figure 1 As shown: The S101 constructs a six-layer hierarchical memory system for end-to-cloud collaboration and end-side caching rules. It divides the memory into six basic layers: user profile, scenario events, reassurance strategies, working memory, relationship status, and device status. It is equipped with two types of extended memory: locally fixed scenario silent rules that take effect when the network is disconnected and negative constraint system lessons. It defines the write trigger, retrieval priority, and time-lapse rules for each layer. It has a pre-configured ESP32-S3 end-side Flash resident cache and RAM short-term cache, and fixed offline constraints and low-power wake-up preloading logic.
[0012] In one implementation, constructing an edge-cloud collaborative hierarchical memory system and edge-side caching rules is the fundamental supporting component of the entire memory management method. The core objective is to isolate and store memory content with different lifecycles and functional attributes, adapting to the limited computing power and storage resources of the ESP32-S3 terminal, while ensuring the accuracy and continuity of memory retrieval in long-term emotional support scenarios. The entire system comprises six layers of basic memory, two types of extended memory, and two levels of terminal caching. Each type of memory is configured with independent write triggering logic, retrieval priority sorting rules, and time-limited decay logic, ensuring clear access logic and controllable hardware resource consumption.
[0013] The first layer is the user profile memory, used to store long-term stable features such as basic user information, preferences, taboos, and daily habits. Write triggering includes three rules: first, the user actively informs them of preferences, names, daily habits, or taboos via voice; second, similar features are consistently extracted through multiple rounds of interaction; and third, corresponding profile tags are added after reassurance strategies have been proven effective over a long period. This layer uses incremental write logic; newly extracted features do not directly overwrite existing content. Conflict checks are performed first, and only profile entries with higher confidence are replaced. This layer has the highest retrieval priority, loaded into the terminal cache once during session initialization, and participates in prompt word construction throughout, eliminating the need for repeated retrieval in each round of interaction. The time-limit decay logic uses 180 days as the default validity period. If no corresponding profile feature is triggered by interaction for 90 consecutive days, or the user explicitly requests modification or deletion, or a new preference with long-term contradictions is identified, the corresponding memory is marked as invalid. Invalid memories are not physically deleted but are archived and compressed in a cold path, only to be recalled when the user actively mentions the relevant content. For example, if a user repeatedly mentions their love of fairy tales in conversations, the system, after multiple rounds of feature verification, will write this preference for fairy tales into the user's profile memory. This profile will be automatically loaded each time a conversation starts, and fairy tale-related expressions will be prioritized when generating replies. If the user does not mention fairy tales for 90 consecutive days, this profile entry will be marked as invalid and archived, and will no longer be included in the suggestion word construction by default.
[0014] The second layer is for contextual event memories, used to store important interactive content, anniversary information, successful reassurance cases, and key dialogue records. Writing is triggered by significant emotional fluctuations during interactions, the appearance of anniversary-related content, the completion of a full reassurance loop, or the user mentioning a personal experience. Strong emotional events can skip regular gating and be written directly. Similar events are only merged into summary content; no new independent entries are created. This layer has the second-highest priority for memory retrieval and is not permanently loaded. It retrieves matching entries in real-time based on the current interaction's emotion, topic, and time period, defaulting to recalling highly relevant events from the last 90 days. Time-based decay uses a tiered calculation rule: memories created 0-30 days ago are stored in full and have the highest retrieval weight; memories created 30-90 days ago are automatically compressed into summary form, retaining only core emotions and key event points; memories created over 90 days ago are moved to a low-weight archive state and are only recalled when the semantic match is extremely high. If the user's associated preferences change completely, the corresponding event memory is directly marked as expired. For example, if a user confides about feeling down after failing an exam, and the system plays soothing music that calms them down, this comforting case will be added to the contextual event memory. If the user experiences a similar low mood again within 30 days, this case will be prioritized for recall. After 90 days, this case will be compressed into a summary entry demonstrating the effectiveness of soothing music during exam failures, and will only be invoked if the topic is highly relevant.
[0015] The third layer is the soothing strategy memory, used to store validated and effective soothing phrases, interaction rhythms, lighting patterns, and feedback methods. The writing trigger condition is that after an interaction, the user's emotions are detected to have calmed down, the soothing feedback is positive, and multiple rounds of similar soothing are effective, then it is refined into a standardized strategy. A personalized soothing template is generated after a severe emotional event. The update logic is to evaluate the effectiveness after a single soothing loop is completed. Effective strategies are added immediately and their weight is increased; ineffective strategies are automatically downgraded if not reused for 30 days. This layer's memory retrieval priority is level three, only being retrieved and loaded when negative, aggrieved, or anxious emotions are detected in the user; it is not used in neutral casual conversation scenarios to save token resources. The validity period is 90 days; if intimacy drops significantly, user preferences change, or similar soothing methods fail multiple times, it is considered invalid. Strategies that fail to be recalled for 30 consecutive days will have their retrieval weight reduced; strategies completely unused for 90 days will be archived and hidden. For example, if the system finds that using gentle short phrases paired with warm light to soothe a user when they are aggrieved has a high success rate, it will refine this combination into a standardized soothing strategy and write it into storage. When users subsequently experience feelings of grievance, the system will automatically retrieve and invoke this strategy. If this strategy is not recalled for 30 consecutive days, its search ranking weight will be automatically lowered.
[0016] The fourth layer is working memory, used to store temporary content such as the current session's temporary state, emotional tendency, pending confirmations, and the context of the current conversation. Writing is triggered by temporary emotions, temporary requests, and the context of the conversation, and is updated in real-time with each round of dialogue. This layer has the highest priority for retrieval within the session, is constantly loaded throughout, loads first when constructing prompts, and is cleared immediately after the session is destroyed, without being stored in long-term storage. The expiration rule is that it is immediately cleared when the session ends, the device is idle for more than 120 seconds, or the device goes to sleep; there is no archiving or history retention, it only survives in the memory cache of a single session. For example, if a user mentions wanting to chat later in the current session, this content will be written to working memory, and the system will automatically control the response pace in this round of dialogue, no longer proactively initiating new topics. 120 seconds after the session ends, this temporary memory will be cleared along with the entire working memory and will not be retained for the next interaction.
[0017] The fifth layer is the relationship state memory, used to maintain continuous relationship variables such as familiarity, trust, and activity between the user and the companion toy. The write trigger conditions are completing a full companionship interaction, the user providing positive feedback, prolonged companionship, or the user actively sharing their feelings. Values are updated asynchronously through a cold path after each interaction, and are not rewritten in real-time during the interaction to avoid blocking the hot path. This layer's memory retrieval priority is at the same level as the user profile, belonging to the persistent content loaded in the session. All memory retrievals incorporate intimacy weight in the scoring. A continuous decay mechanism is used for time-based decay: after 7 consecutive days without interaction, the intimacy value decreases slightly each day; after 30 consecutive days without interaction, the trust value drops significantly, but is not directly deleted. After a new interaction occurs, the relationship value resumes growth. For example, if a user interacts with the toy for half an hour every day for a week, the intimacy and activity values in the relationship state will gradually increase, and distant related events can be recalled during memory retrieval. If a user has not interacted for 30 consecutive days, the trust value will decrease significantly, and retrieval will be more biased towards recent memory content.
[0018] The sixth layer is the device status memory, used to store hardware-related information such as battery level, network status, volume, night mode, and synchronization time. Writes are triggered by detecting changes in hardware status; these changes are immediately synchronized to the terminal cache, and cloud-based status snapshots are periodically synchronized. This layer's memory retrieval priority is session-resident, loading with each wake-up and each prompt to constrain the output format. The expiration rule is that when the device restarts, restores factory settings, or is offline for an extended period, the old status snapshot is marked as expired, and the new status overwrites the original record upon restart. Device status snapshots that are offline for more than 48 hours are considered expired. For example, when night mode is enabled, the device status memory will update this status synchronously, automatically switching to a soft, short sentence output format when generating a reply to avoid disturbing the user's rest. After a device restart, the status memory will use the latest hardware parameters after the restart.
[0019] In addition to the six layers of basic memory, two types of extended memory are configured as supplementary functions. The first type is scene-based silent rule memory, which specifically stores user-defined do-not-disturb periods, light and volume limits, prohibited topics, and environmental constraints. The writing trigger condition is that the user actively sets the relevant constraints via voice. If there are no changes, the background will check and synchronize once every 30 days. This type of memory has the highest hardware constraint priority, is permanently stored in the terminal's local flash memory, is forcibly loaded during the wake-up phase, does not rely on cloud retrieval, and remains effective even when offline. If the user actively deletes or modifies the rules, the original content is immediately overwritten; rules that have not been triggered for more than 180 days are automatically archived. For example, if a user sets 10 pm to 7 am as the do-not-disturb period, this rule is written into the scene-based silent rule memory and fixed in the terminal's flash memory. Even when offline, the toy will automatically switch to the lowest volume and short response mode when woken up at night, and will not actively initiate interaction.
[0020] The second category is the system lesson memory, used to store historical errors, contradictory responses, failed attempts at appeasement, and samples of non-compliant output. Writing is triggered when content contradictions occur during interactions, appeasement fails, or users correct errors. It is written via a cold path, and similar lessons are merged monthly in batches. This type of memory is a low-priority fallback for retrieval; it is only loaded when the topic highly matches a historical error and is not continuously loaded. The storage limit is 100 entries. New content automatically discards the oldest lesson entry; the relevant lesson memory automatically expires after a complete change in the corresponding user profile or event. For example, if the system incorrectly stated a user's age during an interaction and the user corrected it, this error case will be written into the system lesson memory. It will then serve as a negative constraint during subsequent searches for similar topics, reducing the probability of similar errors occurring.
[0021] The terminal side is configured with a two-level cache to adapt to the hardware resource characteristics of the ESP32-S3. The first level is a resident flash cache, used to store four types of resident memory: user profile, relationship status, device status, and scene silencing rules, as well as high-frequency soothing strategy content. Data is not lost after power failure, and it is read directly from local memory during session initialization, reducing wake-up latency. The second level is a short-term memory cache, used to store working memory, temporary search results, and session state data. It has fast read and write speeds and is automatically released after the session ends or the device goes into sleep mode.
[0022] Simultaneously, it embeds low-power wake-up preloading logic. After the terminal is effectively woken up through local wake-up word recognition, it prioritizes loading high-frequency memories and basic soothing strategies from flash memory before connecting to the network. This allows for basic response preparation without waiting for a cloud response, significantly reducing wake-up latency and cloud dependency. For example, after the user speaks the wake-up word, the terminal first completes wake-up word recognition locally and preloads user address preferences, basic soothing phrases, etc., from flash memory. Basic responses can be provided during the time it takes to synchronize data to the cloud, avoiding user waiting. Even in offline states, basic soothing interactions can be completed using local caching.
[0023] S102: The terminal collects multimodal interaction data including voice, touch, posture, button, and environmental data and uploads it to the cloud. The data is then parsed to generate memory candidates. The total saliency score is calculated from seven dimensions and distributed to the terminal short-term cache, session working memory, and cloud long-term memory according to the 30 / 60 threshold. Key events that meet the judgment conditions skip the scoring and threshold distribution and are forcibly written to the corresponding memory layer after conflict detection.
[0024] In one implementation, combining the dirty memory interception and edge-cloud hierarchical storage requirements of the ESP32-S3 emotional companion toy, a multi-dimensional saliency scoring rule and a three-level threshold triage mechanism are introduced. This relies on multi-modal data acquisition from the terminal's voice, touch, posture, button operation, and environmental data, along with structured analysis and filtering in the cloud to generate a candidate set of memories. The system utilizes multiple sensors on the ESP32-S3 terminal to collect raw interactive data, covering five categories: voice content, touch state, posture changes, button operations, and environmental parameters. The terminal packages and uploads the collected raw data to the cloud. The cloud then sequentially performs speech transcription, semantic parsing, and event structured extraction processing, filtering out meaningless interjections, transient noise, and invalid interaction fragments, selecting content with potential memory value, and generating an initial candidate set of memories.
[0025] For example, if a user continuously strokes the surface of a toy for 12 seconds while simultaneously expressing their joy at receiving an award at school, the terminal simultaneously collects continuous trigger signals from the touch module, the voice content from the microphone, the stable posture data from the gyroscope, and the indoor ambient light parameters, packaging all the data and uploading it to the cloud. After the cloud completes speech-to-text transcription and semantic analysis, it extracts three core elements: receiving an award, positive emotion, and prolonged soothing touch. It filters out interjections and irrelevant environmental noise, generating a candidate memory entry corresponding to the positive emotional event.
[0026] Based on the criteria of long-term memory value, source credibility, and hardware resource compatibility, a comprehensive significance score is calculated using a weighted average of seven dimensions: proactive declaration, companionship value, repetition frequency, conflict risk, privacy sensitivity, emotional importance, and edge-cloud compatibility. A three-tiered value stratification is then established using a 30 / 60 threshold. Qualified long-term memories undergo conflict detection before being assigned to their corresponding memory tier. The system quantifies and scores each candidate memory across seven dimensions, combining the scores with fixed weights to obtain a comprehensive significance score. A three-tiered value stratification is then established based on two fixed thresholds of 30 and 60, matching the corresponding storage path. The seven scoring dimensions are proactive declaration, companionship value, repetition frequency, conflict risk, privacy sensitivity, emotional importance, and edge-cloud compatibility. Each dimension has a score range of 0 to 10, corresponding to different judgment criteria and fixed weights. The weightings for the following dimensions are as follows: proactive declaration (0.22), companionship value (0.18), repetition frequency (0.16), conflict risk (0.14), emotional importance (0.16), privacy sensitivity (0.08), and edge-cloud compatibility (0.06). All three dimensions—conflict risk, privacy sensitivity, and edge-cloud compatibility—are positively weighted; higher scores correspond to lower conflict risk, lower privacy leakage risk, and better edge storage compatibility. The overall significance score is obtained by multiplying each dimension's score by its corresponding weight and then summing the results. The total score ranges from 0 to 100.
[0027] Memory candidates with a total score below 30 are stored only in a short-term cache on the device, which is composed of the ESP32's local RAM. Their lifespan is limited to the current interaction segment. They are automatically cleared after the wake-up ends or the device is idle for 120 seconds, and are not transmitted to the cloud or involved in subsequent retrievals. Memory candidates with a total score between 30 and 60 are simultaneously stored in the cloud's dedicated temporary memory for the session and the device's working cache, forming the session's working memory. This memory is only valid within the current complete session period and is automatically cleared within 72 hours after the session ends. It is not migrated to the cloud's long-term memory system. Memory candidates with a total score above 60 are deemed to have long-term storage value. They first undergo a conflict detection process to complete consistency verification. After passing the verification, they are written to the corresponding level of the cloud's long-term memory database, and high-frequency entries are simultaneously synchronized to the device's resident flash cache.
[0028] For example, if a user casually mentions wanting to eat fruit for the first time, they score 2 points for proactive declaration, 2 points for companionship value, 0 points for repetition frequency, 10 points for conflict risk, 10 points for privacy sensitivity, 1 point for emotional importance, and 8 points for edge-cloud adaptation. The weighted average significance score is 24.36, below the 30-point threshold. This content is only stored in the short-term cache on the device and will be automatically cleared after the interaction ends. Another example is if a user mentions liking to draw in three consecutive conversations, scoring 8 points for proactive declaration, 9 points for companionship value, 10 points for repetition frequency, 10 points for conflict risk, 10 points for privacy sensitivity, 4 points for emotional importance, and 9 points for edge-cloud adaptation. The weighted average significance score is 84.34, above the 60-point threshold. The system first verifies that this preference does not conflict with the existing user profile, then writes the preference to the cloud user profile memory layer and simultaneously synchronizes it to the device's flash resident cache.
[0029] The system utilizes five key event-based mandatory archiving rules to bypass conventional scoring and threshold-based routing. Triggering scenarios include intense emotional fluctuations, significant positive commemorative events, prolonged touch-based soothing loops, and significant long-term user preference changes. Conflict detection and memory level matching are performed simultaneously before writing to the corresponding repository, ultimately outputting a three-tiered storage result: short-term cache on the device side, session working memory, and long-term cloud memory. The system sets five mandatory archiving triggering scenarios. Memory content meeting any one of these criteria bypasses the seven-dimensional saliency scoring and threshold-based routing, directly skipping the conventional gating process and entering the conflict detection stage for verification. After matching to the corresponding memory level, it is forcibly written to long-term storage. The five triggering scenarios are: intense emotional fluctuations, significant positive commemorative events, prolonged touch-based soothing loops, significant long-term user preference changes, and multiple rounds of negative emotion soothing interactions. The criteria for intense emotional fluctuations are: gyroscope detection of continuous violent shaking for at least 4 seconds, accompanied by voice recognition of continuous crying or depressed emotional words; the criteria for prolonged touch-based soothing loops are: continuous touch module triggering for at least 10 seconds, accompanied by user emotion easing feedback. Different types of events are automatically matched to their corresponding memory levels. Emotional events are categorized into contextual event memories, while preference change events are categorized into user profile memories. Content that triggers mandatory archiving is simultaneously marked with a unique tag, and operation logs are retained in the backend for subsequent strategy statistics and optimization. Only extreme, momentary, weak emotional fluctuations do not trigger mandatory archiving and proceed with the regular gating scoring process.
[0030] For example, if the gyroscope detects a toy shaking violently for 5 seconds, and the voice recognition system detects the user continuously using words related to low mood, the system determines that the trigger condition for a severe emotional fluctuation is met. It immediately marks the event as forcibly archived, bypassing the seven-dimensional scoring and threshold-based triage steps, and directly enters the conflict detection process. After automatically matching it to the contextual event memory level, it writes it to long-term cloud storage, while simultaneously synchronizing it to the local persistent cache on the device. Another example is when a user explicitly states via voice that they want to change how they are addressed, which constitutes a significant long-term preference change. The system directly triggers the forced archiving process, verifies the conflict, updates the corresponding entry in the user profile memory layer, and simultaneously refreshes the address preference data in the device's cache.
[0031] S103 identifies interaction themes, emotions, and scenarios, uses pre-existing metadata and time window hard filtering, parallel keyword inversion and relation graph adjacency coarse recall, and then performs semantic vector fine matching; it overlays multi-dimensional weights and conflict risk penalties, combines intimacy and soothing effectiveness for re-ranking, and outputs candidate sets by Token budget.
[0032] In one implementation, combining the precise memory retrieval requirements and token cost constraints of the ESP32-S3 emotional companion toy, a four-level retrieval system is constructed, incorporating multi-dimensional hybrid retrieval, cross-encoder correction, dynamic weighted sorting, and hierarchical pruning mechanisms. This system includes pre-processing hard filtering, dual-channel coarse retrieval, semantic fine matching, and refined re-sorting. Based on memory type, emotion tag, time period, and retrieval priority, metadata field matching and dynamically adjustable time window threshold filtering are performed to directly eliminate completely irrelevant memory entries, significantly reducing the scope of subsequent calculations and lowering computational costs. Metadata matching performs hard filtering based on memory classification, emotion attributes, and scene tags. For example, in neutral casual conversation scenarios, soothing strategy memories are directly excluded, retaining only basic profiles and casual conversation-related entries. The time window automatically adjusts its size according to the interaction scenario: immediate emotional soothing covers nearly 30 days by default, daily casual conversation covers nearly 90 days by default, and anniversary scenarios allow full-cycle retrieval. The window automatically widens when the same emotion appears repeatedly and automatically shrinks when there is no emotional dialogue. The freshness score is calculated using an exponential decay method. The longer the memory was created, the lower the score. The decay coefficient is 0.012 in the appeasement scenario and 0.025 in the ordinary chat scenario.
[0033] For example, when a user expresses their grievances at night, the system first filters and retains two types of memories—contextual events and soothing strategies—by using metadata, while removing irrelevant categories such as "system lessons." It then filters entries tagged with "grievance" or "depression," excluding memories with positive emotions. The initial time window is set to the last 30 days; after identifying two consecutive instances of a user expressing depression, the window is widened to the last 90 days to include more historical soothing cases, thus completing the initial simplification of the candidate set.
[0034] Based on memory type, emotion tag, time period, and retrieval priority specifications, metadata field matching and dynamically adjustable time window threshold filtering are performed to directly eliminate completely irrelevant memory entries, thus pre-simplifying the candidate set to reduce subsequent computational overhead. Relying on the balance between recall coverage and computational cost, a dual-channel parallel coarse-grained recall rule is set up, combining keyword inverted indexing and 2-hop adjacency range relation graph adjacency, achieving breadth recall from two dimensions. Keyword inverted indexing performs precise matching for entities such as names, hobbies, items, and exclusive titles; keyword matching weight is automatically amplified when users explicitly mention exclusive terms. The relation graph is centered on the user master node, associating with three types of nodes: attributes, events, and strategies. Users and basic attributes have permanent association edges, attributes and emotional events have time-sensitive association edges, and emotional events and soothing strategies have permanent association edges with validity weights. Retrieval is limited to the 2-hop range of the current emotion or hobby node, prohibiting infinite traversal. The weight of valid soothing association edges is multiplied by 1.5, ordinary event edges by 1.0, and invalid soothing edges by 0.4.
[0035] For example, if a user mentions that listening to music calmed them down after failing their last exam, the keyword inverted search channel directly hits historical events containing entities like "exam," "music," and "calm down." The relationship graph channel starts from the user node, extends through the "feeling down" node to the corresponding event and strategy node, and recalls all related comforting cases within a 2-hop range. These two channels together constitute the initial coarse recall candidate set. The maximum limit for the coarse recall candidate set is 120 items; if it exceeds this, low-scoring tail items are directly truncated.
[0036] Based on the constraint of balancing recall coverage and computing power, a coarse recall rule with dual channels of keyword inverted index and 2-hop adjacency range relation graph adjacency is set. Then, semantic vector retrieval is used to supplement the missed memories with low keyword high semantic matching. After three levels of deduplication, the heterogeneous search results are merged. On the basis of coarse recall results, semantic vector retrieval is used to supplement the missed memories with low keyword high semantic matching, covering fuzzy matching scenarios with no clear keywords and abstract sentiment categories, avoiding missed recall of related memories due to differences in expression. After the search results are merged, two levels of deduplication are performed, which, together with the pre-entry homo-source deduplication, constitute a three-level deduplication mechanism. The first level of entry homo-source deduplication is the preprocessing of the memory entry stage. Multiple memories generated by the same event retain only the entry with the highest total saliency score, and the rest are pre-marked as invalid and not included in the search pool. The second level is the semantic deduplication after retrieval. For two memories with a semantic similarity higher than 0.85, only the one with the higher ranking potential is retained. The third level is the upper limit constraint of the same type. At the same memory level, a maximum of 5 similar topics are retained. Excess low-scoring entries are directly removed. Finally, the heterogeneous search results are merged.
[0037] For example, if a user describes feeling down and lacking energy, but the statement lacks explicit emotional entity keywords, the initial recall phase will yield few matches. Semantic vector retrieval, by calculating semantic similarity, supplements the recall with historical records of comforting the user when they experienced similar abstract feelings of depression, thus expanding the candidate set coverage. After merging, a two-stage deduplication process is performed to remove duplicate entries and excessive memories of the same topic, resulting in a refined matching candidate set.
[0038] The merged candidate set is fed into a cross-encoder for refined semantic re-scoring to correct vector bias. A comprehensive ranking score is generated by overlaying semantic matching, keyword hit, timeliness and freshness, confidence, task relevance, and conflict risk. This score is then further refined by combining intimacy, soothing effectiveness, and emotional scene tags. After phased pruning based on quantity and token budget, prioritizing the retention of resident memories, the final memory injection candidate set is output. Alternatively, the merged candidate set is first pruned to 60 entries to control computational cost, then fed into a cross-encoder for refined semantic re-scoring to correct vector bias. A comprehensive ranking score is generated by overlaying six dimensions: semantic matching, keyword hit, timeliness and freshness, confidence, task relevance, and conflict risk. This score is then further refined by combining intimacy, soothing effectiveness, and emotional scene tags. After phased pruning based on quantity and token budget, prioritizing the retention of resident memories, the final memory injection candidate set is output. The overall ranking score is calculated by weighting five positive dimensions and one negative dimension. The semantic weight baseline value is 0.32, the keyword weight baseline value is 0.28, the timeliness weight baseline value is 0.20, the confidence weight baseline value is 0.12, the task relevance weight baseline value is 0.08, and the conflict penalty coefficient baseline value is 0.35. Each weight can be dynamically adjusted according to the scenario within the corresponding adjustable range.
[0039] The ranking correction rules are as follows: the higher the intimacy level, the higher the ranking bonus for older memories; validated and effective soothing strategies have higher ranking priority; and memories that match the current emotional scene tag are ranked higher under the same score. The final pruning process implements dual constraints: a maximum of 12 memories are retained for wake-up and neutral small talk scenarios, and a maximum of 20 memories are retained for emotional soothing scenarios. If the concatenated structured memories exceed the global context token limit of 900, then low-scoring entries in the scenario event and soothing strategy categories are prioritized for pruning, while persistent memories such as user profiles and relationship states are permanently retained.
[0040] For example, in an emotional reassurance scenario, the 60 candidate entries are re-scored and corrected for bias using a cross-encoder. A base score is then calculated using a six-dimensional weighted average, further adjusted by intimacy and reassurance effectiveness. The ranking order for entries with equal scores is also adjusted using emotional tags. Finally, the number of entries is pruned to a scenario limit of 20. If the total number of tokens after concatenation exceeds 900, lower-ranked event memories are further deleted. User profiles and relationship state memories are preserved throughout the process, ultimately outputting an injection candidate set that conforms to token constraints.
[0041] S104: Before writing, match historical memories with the same subject and attributes, and classify them into three levels of conflict based on semantic similarity: mild, moderate, and severe. Execute in-situ update, pending confirmation guidance, and dual-version scenario adaptive strategies respectively; retain the complete version tracing link, and prioritize the latest high-confidence memory for secondary verification before injection.
[0042] In one implementation, combining the consistency guarantee of emotional companionship memories with the need to adapt to dynamic changes in user preferences, a three-level conflict quantification judgment, hierarchical resolution, bidirectional version link tracing, and a two-stage verification mechanism for write injection is introduced. The candidate set of historical memories to be compared is located based on a three-level matching rule of memory type-subject-predicate-tag. Based on the three-level matching rule of memory type, subject, predicate, and tag, the range of historical memories to be compared is located from the full memory database, ensuring that subsequent conflict judgments only target memories of the same type and attribute, avoiding invalid comparisons. The matching process is divided into three layers: the first layer is primary key matching, requiring the memory layer type to be completely consistent with the subject field; the second layer is attribute matching, requiring the predicate field to be completely consistent; the third layer is tag matching, requiring at least one intersection of core emotion, time period, and scene tags. Historical memories that pass all three layers of matching are included in the candidate set for comparison; if any layer fails to match, it is determined to be conflict-free, and the subsequent verification process is skipped.
[0043] For example, a new memory to be written belongs to the user profile type, with the subject being the user's sleep preferences, the predicate being sleep time, and tags including nighttime and daily scenarios. The system first matches the user profile type with the sleep preferences subject, filtering out historical memories of the same type and subject; then it matches entries with the predicate "sleep time" to narrow down the candidate range; finally, it checks the tag intersection, retaining historical memories with the tags "nighttime" and "daily scenarios," forming a candidate set to be compared. If the new memory belongs to the situational event type and fails to match the first layer of historical memories in the user profile type, it is directly determined to be conflict-free, requiring no further verification.
[0044] Based on semantic similarity thresholds, two-way confidence scores, and value range differences, conflicts are categorized into three levels: mild, moderate, and severe, with 0.3 and 0.8 as cutoffs. For severe conflicts, an additional constraint is that the confidence scores for both the old and new memories must be no lower than 0.6, thus achieving precise quantitative determination of conflict type. Semantic similarity is calculated using lightweight sentence vector cosine similarity, with a value ranging from 0 to 1. A higher score indicates a greater degree of semantic overlap between the two memories. Minor conflict corresponds to a semantic similarity of no less than 0.8, which means that the two memory segments have different expressions but highly consistent core meanings and no opposing content; moderate conflict corresponds to a semantic similarity of more than 0.3 and less than 0.8, which means that the two memory segments have some overlapping content and some differences in local attributes, but are not completely opposed; severe conflict corresponds to a semantic similarity of no more than 0.3, and additionally, the confidence of both the old and new memories is not less than 0.6, which means that the core meanings of the two memories are completely opposed and the value ranges do not overlap.
[0045] For example, if the old memory states that the user likes to draw, and the new memory states that the user usually enjoys drawing, the semantic similarity between the two is 0.88, which is considered a slight conflict. If the old memory states that the user likes both blue and red, and the new memory states that the user only likes blue, the semantic similarity between the two is 0.52, which is considered a moderate conflict. If the old memory states that the user is accustomed to going to bed early and waking up early, and the new memory states that the user is accustomed to staying up late, the semantic similarity between the two is 0.21, and the confidence scores for both the old and new memories are 0.78 and 0.72 respectively, both satisfying the constraint of at least 0.6, this is considered a severe conflict.
[0046] A tiered conflict resolution strategy is implemented for different conflict levels. Minor conflicts discard new entries by default, while high-scoring conflicts are updated with confidence and version numbers in place. Medium conflicts are marked for confirmation and the user is interactively guided to verify. Severe conflicts retain both versions and are adaptively weighted and sorted according to the scenario. A three-branch secondary judgment rule (confirmation / denial / no response) is provided to achieve differentiated closed-loop conflict handling.
[0047] The rules for resolving minor conflicts are as follows: by default, the new memory entry is discarded directly without creating a new independent memory; if the confidence and salience scores of the new memory are higher than those of the old memory, the confidence, timeliness score, and version number of the old memory are updated in place, with the version number incremented by 1, and no version replacement chain is generated. For example, if a user repeatedly mentions that they like drawing, and the new memory has a higher salience score, the system will determine it as a minor conflict and will not create a new duplicate preference entry. Instead, it will only update the confidence value and version number of the existing memory, preserving the unique identifier of the original memory.
[0048] The rules for resolving medium-level conflicts are as follows: the new memory is normally added to the database and a new version number is generated; the old memory is marked as pending confirmation; and the association information of the old memory is written into the replacement association field of the new memory. Both memories participate in the current round of prompt word injection simultaneously, and a standardized confirmation message is inserted at the end of the generated reply to guide the user to verify the change in preference. For example, if a user mentions that they now only like blue, and the old memory states that they like both blue and red, the system determines this as a medium-level conflict, adds the new memory to the database and marks it with the corresponding status, and the current reply references the content of both memories, asking the user at the end of the reply whether they now only prefer blue and no longer like red.
[0049] The rules for resolving severe conflicts are as follows: both old and new versions of the memory are stored in parallel in the cloud. The old memory is marked as archived and stored in the version chain, but is not directly deleted. The retrieval and sorting process incorporates a scenario-adaptive weight: the overall ranking score of memories matching the current time period and emotional scenario increases by 0.2, while the overall ranking score of memories not matching the scenario decreases by 0.2, achieving the effect of calling the corresponding version of the memory in different scenarios. Before clear confirmation through multiple rounds of interaction, the two versions of the memory alternately participate in the generation process. For example, if the old memory is that the user is afraid of the dark and needs to sleep with the lights on, while the new memory is that the user is not afraid of the dark and can sleep with the lights off, the system determines this as a severe conflict and retains both versions of the memory. In the nighttime bedtime scenario, the ranking weight of the new memory increases by 0.2, and it is called first; in the daytime casual conversation scenario, the two memories have equal weight and are both included in the candidate range.
[0050] All memories marked as pending confirmation are subject to a three-branch, two-stage judgment rule. If the user explicitly confirms the new memory content, the new memory is marked as officially effective, and the old memory is marked as replaced, fully stored in the version chain, with only the effective version being called subsequently. If the user explicitly denies the new memory content, the new memory is marked as archived and no longer participates in retrieval, while the old memory is restored to its officially effective state. If the user does not provide a positive or negative response in three consecutive rounds of interaction, the system automatically switches to a dual-version parallel mode, using a scenario-weighted approach based on the severe conflict rule, and no longer proactively initiates confirmation inquiries. Memories marked as pending confirmation that have not received user feedback for more than 7 days are automatically transferred to an archived state, and the confirmation process is no longer proactively triggered.
[0051] For example, if the system asks a user if they only prefer blue and the user answers affirmatively, the system sets this "only blue" memory as the only valid version, while the original memory of liking both blue and red is stored in the history of color preferences. If the user answers negatively, the system archives the new memory while retaining the original preference record. If the user does not respond to the relevant questions for three consecutive rounds, the system will no longer proactively ask, and subsequent scenarios involving color preferences will be processed using a weighted dual-version approach.
[0052] A complete traceability chain is maintained through version numbers and bidirectional replacement association fields. Old memories are synchronously marked with multiple states: effective, pending confirmation, and archived. A second conflict check is performed before prompt word injection, prioritizing the latest memory with the highest confidence and scenario matching. If a decision cannot be made, it is marked as pending confirmation. The final output is a consistent and conflict-free effective memory entry. The complete change traceability chain of memories is maintained through version numbers and bidirectional replacement association fields. Old memories are synchronously marked with three states: effective, pending confirmation, and archived. Combined with a two-stage verification mechanism before writing and before injection, this ensures that the memory content of the final injected prompt words is consistent and conflict-free. Each memory carries a globally auto-incrementing version number, with the new version number always higher than the old version. A bidirectional association field is also configured: the forward field records the identifier of the old memory replaced by the current memory, and the reverse field records the identifier of the new memory replacing the current memory. All historical versions of memories are not physically deleted but are fully stored in cloud storage, supporting two types of traceability query modes. One type is single-record traceability query, which recursively reads bidirectional related fields by inputting any memory identifier, outputting the complete change chain from the initial version to the current effective version, for manual auditing and user preference verification; the other type is session scenario backtracking retrieval, which allows specifying a time node to read all historical memories before that time, for comparing changes in long-term user preferences. The client-side cache only synchronizes the currently effective highest version memory, while all historical versions are stored in the cloud, without consuming terminal storage resources.
[0053] The two-stage verification consists of a write stage verification and an injection stage verification. The write stage verification is performed before new memories are written to the database, completing conflict determination and resolution to ensure that the memories being written to the database conform to the version rules. The injection stage verification is performed before the prompt words are constructed, performing a second conflict verification on the memories in the candidate set, prioritizing the memory entries with the latest version, the highest confidence, and the highest scenario matching degree; if multiple versions exist and their priorities cannot be determined, they are marked as pending confirmation, and the effective version content is called first to avoid injecting contradictory content into the prompt words.
[0054] For example, if a user's preferred form of address has changed three times, the version chain can be used to trace the complete change trajectory from the initial form of address to intermediate versions and then to the current version. It can also be used to look up the replacement version for any older version. Before constructing the prompt, the system performs a second check on the candidate memory, discovering two versions of sleep preferences. Based on the current nighttime scenario's matching degree, the latest and most confident version of the late-night preference is selected for the prompt, ensuring that the generated content matches the user's current preference.
[0055] S105 performs compression distillation and structured encoding on candidate memories, dynamically injecting memory blocks according to four stages: awakening, understanding, soothing, and expression; high-frequency memories are synchronized to the end side via network connection, offline degradation is triggered when the network is disconnected, and updates are made upon network reconnection; based on soothing effects and multi-dimensional index iteration strategies, the system achieves self-evolution.
[0056] In one implementation, considering the constraints of ESP32-S3 hardware resources, the continuity of weak network support, and the need for autonomous system iteration, a memory compression distillation, differentiated emotion attenuation, staged structured injection, edge-cloud collaborative degradation, and closed-loop evaluation mechanism for soothing effects are introduced. A full-link emotional memory management system is constructed based on an edge-cloud layered memory architecture. According to token overhead constraints and hardware bandwidth adaptation standards, four types of compression processing are performed on candidate memories: similar event merging, natural language key-value conversion, extraction of stable preferences into rules, and interaction pipeline compression. Multi-dimensional metadata such as time, source, and confidence are added, completing structured encoding and short-format conversion adapted to ESP32-S3 packet length limitations. This reduces data volume while fully preserving core information, simultaneously reducing token consumption after prompt injection, enhancing the boundary controllability of memory content, and adapting to limited storage, transmission, and computing resources on the edge. Similar events are grouped together, and multiple event memories with consistent themes, emotions, and feedback results are merged into a single summary record, eliminating duplicate storage; Natural language key-value conversion refines the preferences and strategies described in long texts into a concise structure of subject, attribute, and value, compressing redundant expressions; Stable preferences are refined into rules, solidifying user habits that have been verified in multiple rounds into judgment rules that can be directly invoked, without the need for re-parsing each time inference; Interaction flow compression condenses the multi-round continuous interaction process into core nodes of trigger, action, feedback, and result, retaining the complete logical chain while removing process redundancy.
[0057] The system employs differentiated time-based decay rules for positive emotions (slow decay), negative emotions (fast decay), and neutral emotions (constant decay), dynamically adjusting the memory lifecycle based on intimacy level. Memory carrying positive emotions decays the slowest, maintaining a high recall weight over the long term; memory carrying negative emotions decays the fastest, with recall weight rapidly decreasing over time; neutral daily memories exhibit a normal decay rate. The higher the intimacy value, the slower the decay rate for all types of memories, and the longer the overall effective lifecycle. For example, if a user calms down by listening to light music three times while feeling down, the system first merges the three independent events into a single event for calming down; then, through natural language key-value conversion, it refines the structure into a concise structure: emotion type: down; calming method: light music; calming effect: effective; finally, through interactive pipeline compression, it condenses the core nodes of the user expressing downness, playing light music, and calming down, adding event time, source, and confidence level metadata, and converting it into a short format encoding adapted to the ESP32-S3 package length. This memory corresponds to a scenario of soothing negative emotions, and its recall weight gradually decreases over time according to the rule of rapid decay of negative emotions; the user's intimacy is at a high level, and the decay rate is correspondingly slower, so the effective life cycle of the memory is longer than that of ordinary users.
[0058] Based on token overhead constraints and hardware bandwidth adaptation standards, candidate memories undergo four types of processing: similar event merging, natural language key-value conversion, stable preference extraction into rules, and interaction pipeline compression. Multi-dimensional metadata is added to complete structured encoding and short-format conversion to adapt to ESP32-S3 packet length limitations, reducing data volume while enhancing the controllability of memory content boundaries. Emotional differentiation decay rules are implemented, including positive slow decay, negative fast decay, and neutral constant decay, dynamically adjusting memory recall weights and lifecycles based on intimacy. Prompts are uniformly organized into structured blocks, divided into nine modules: system instruction block, toy character setting block, device capability and status block, user profile memory block, relationship status memory block, related event memory block, current companionship status block, recent dialogue block, and current user input and event block. Each module has clear and independent boundaries, improving the model's understanding and adherence to memory content. Based on this, the system dynamically injects corresponding memory blocks according to four stages of companionship: awakening, understanding, soothing planning, and expression. Each stage only loads the memory content necessary for the current step, ensuring the adaptability of the generated content while avoiding contextual pollution and token waste caused by redundant information. The awakening stage injects three types of memory: device status, recent interaction time, and night mode constraints, to determine the volume, length, and interaction mode of the initial response. The understanding stage injects three types of memory: user profile, relationship status, and emotional cues, to support the analysis of user intent and emotional state. The soothing planning stage injects event memory and soothing strategy memory that match the scenario, to generate an appropriate companionship plan. The expression stage injects three types of memory: user language preferences, tone constraints, and output ability limitations, to control the style and presentation of the final response.
[0059] For example, if a user rubs a toy to express their frustration before bed, the initial response during the wake-up phase is determined by the user's memory of sufficient battery power and night mode being enabled, using a soft, short phrase. The understanding phase incorporates the user's preferred form of address, current intimacy level, and cues related to their frustrated emotions, accurately identifying the user's needs and emotional state. The soothing planning phase integrates historical records of similar frustrations and soothing music strategies to develop a corresponding emotional soothing path. The expression phase incorporates the user's preferred gentle, short phrase style and output length constraints, ultimately generating a nighttime soothing response tailored to the user's habits.
[0060] The system adopts a collaborative architecture with the cloud and the device working together. The cloud is responsible for long-term memory storage, complex retrieval, conflict handling, and strategy optimization, while the ESP32-S3 terminal only maintains a lightweight state cache and offline policy table. The device implements low-power wake-up word local recognition, initiating cloud interaction only after a valid wake-up is detected, reducing terminal standby power consumption. Network status awareness and low-power wake-up on the device enable collaborative scheduling, covering all scenarios including network synchronization, wake-up preloading, network outage degradation, and network retransmission, ensuring a continuous companionship experience across different network environments.
[0061] By leveraging network status awareness and low-power wake-up on the device side, collaborative scheduling is achieved. Five core categories of content—basic address preferences, night mode rules, commonly used soothing phrases, high-success-rate soothing strategies, and relationship status summaries—are synchronized to the device-side cache during network connectivity. During the wake-up phase, frequently accessed memories and basic soothing strategies are pre-loaded locally. When the network is disconnected, offline degradation calls are made to pre-set multimodal feedback and temporarily store three key events: night-triggered events, continuous emotional fluctuations, and multiple soothing interactions. Data is then re-transmitted back to the network to complete memory merging, updates, and conflict checks. Supporting multi-dimensional operational indicators and a closed-loop evaluation system for soothing effectiveness iterates core parameters, ultimately forming a positive data loop to achieve system self-evolution. This collaborative scheduling, utilizing network status awareness and low-power wake-up on the device side, covers all scenarios: network synchronization, wake-up pre-loading, network disconnection degradation, and back-to-network data re-transmission, ensuring the continuity of the companionship experience under different network environments. In network-connected mode, the cloud periodically synchronizes five core categories of content—basic address preferences, night mode rules, commonly used soothing phrases, high-success-rate soothing strategies, and relationship status summaries—to the device-side flash cache, ensuring that frequently accessed core memory data is retained locally. During the wake-up phase, high-frequency memories and basic soothing strategies are preloaded locally, allowing initial response preparation to be completed without waiting for a cloud response, thus reducing wake-up latency.
[0062] When the network is down, an offline degradation mode is triggered, calling pre-set multimodal feedback content on the device, including basic voice, light, music, and motion feedback, to ensure the availability of basic soothing functions. Simultaneously, the device locally stores three types of key events generated during the offline period: nighttime trigger events, continuous emotional fluctuation events, and multiple soothing interaction events, fully recording the core interaction trajectory. These are uploaded uniformly after the network is restored. After the network is restored, the device re-uploads the temporarily stored offline event summary to the cloud. The cloud completes memory merging, updating, and conflict checking, and synchronously refreshes the device's cache content to ensure data consistency between the two ends. For example, under normal network conditions, the cloud synchronizes the user's basic address, nighttime do-not-disturb rules, commonly used soothing phrases, high-success-rate warm light soothing strategies, and current intimacy summary to the device's flash cache. When the user wakes the toy, the device directly loads the address preference and basic soothing phrases locally, providing an initial response without waiting for a return from the cloud. After a network interruption, the system automatically switches to offline degradation mode, calling pre-set soothing voices and warm light effects to respond to the user, while temporarily storing the user's emotional distress event locally. After the network is restored, the client uploads the temporarily stored events to the cloud. After the cloud verifies that there are no conflicts, it updates the corresponding memory entries and refreshes the policy cache data on the client.
[0063] A multi-dimensional operational metric and a closed-loop evaluation mechanism for the effectiveness of appeasement are implemented, continuously iterating core parameters to ultimately form a positive data loop that enables system self-evolution. Operational monitoring covers dozens of metrics, including recall rate, precision, conflict rate, obsolete misuse rate, irrelevant contamination rate, token consumption, response latency, client-side memory usage, power consumption, and number of user corrections, continuously tracking the system's operational status. The effectiveness of appeasement employs a closed-loop evaluation logic, automatically marking the appeasement effect after each interaction. Strategies that calm the user and elicit positive feedback are deemed effective, correspondingly increasing their retrieval weight and synchronization priority, and are prioritized for synchronization to the client side. Strategies that have multiple ineffective uses or elicit negative user feedback are deemed ineffective, correspondingly decreasing their retrieval weight and gradually fading them from the recall scope until they are phased out.
[0064] Based on operational monitoring data and soothing effect evaluation results, the system continuously iterates on core parameters such as memory write gating threshold, retrieval weight allocation, compression strategy granularity, and injection token budget, constantly optimizing the accuracy and resource efficiency of memory management to form a positive closed loop of continuous optimization. For example, after the soothing strategy of warm light paired with soft music was used five times consecutively, users consistently reported emotional calming. The system determined that the strategy was effective, increasing its retrieval weight and client-side synchronization priority, and prioritizing its storage in the client-side cache. Conversely, after repeated use of a certain type of didactic soothing strategy, users consistently gave negative feedback, so the system gradually reduced its weight and eventually excluded it from the recall scope. Combining token consumption data over a period of time, the system appropriately adjusts the token budget for phased injection and optimizes the granularity of the compression strategy, further reducing resource consumption while ensuring the effectiveness of companionship.
[0065] like Figure 2 As shown, a cloud-edge collaborative hierarchical memory injection, dynamic retrieval, and conflict update system suitable for emotional companion toys includes: The layered memory construction module 201 is used to build the foundation for edge-cloud collaborative memory management. It divides the memory into six layers: user profile, scenario events, reassurance strategies, working memory, relationship status, and device status. It is equipped with two types of extended memory: locally solidified scenario silent rules that take effect when the network is disconnected and negative constraint system lessons. It defines differentiated rules for write triggering, retrieval priority, and time decay for each layer. It also has a pre-set ESP32-S3 edge-side Flash resident cache and RAM short-term cache, and solidifies offline constraints and low-power wake-up preloading logic. The memory write gate module 202 is used to receive multimodal interaction data such as voice, touch, and gesture from the terminal, and generate a memory candidate set after cloud parsing; calculate the comprehensive saliency score from seven dimensions, and distribute it to the three-level storage path of short-term cache on the terminal side, session working memory, and long-term memory in the cloud according to the 30 / 60 threshold; for key events that meet the judgment conditions, skip the regular scoring and threshold distribution, and force write to the corresponding memory level after conflict detection; The hybrid retrieval and reordering module 203 is used to identify interaction topics, emotions and scenarios. Pre-existing metadata and time window hard filtering are used to simplify the candidate range. Keyword inversion and relationship graph adjacency dual-channel coarse recall are executed in parallel, and then semantic vector retrieval is used to complete fine matching. Multi-dimensional weights and conflict risk penalty items are superimposed, and the reordering is combined with intimacy and soothing effectiveness. The final memory injection candidate set is output after being pruned according to the token budget. The conflict detection and update module 204 is used to match the historical memory with the same subject and attribute before writing. It divides the conflict into three levels: mild, moderate and severe based on the semantic similarity threshold, and performs in-situ update, pending confirmation guidance and dual-version scenario adaptive hierarchical resolution strategies accordingly. It retains the complete version traceability link, performs secondary verification before the prompt word is injected, and prioritizes the latest high confidence memory entry. The structured injection and collaborative optimization module 205 is used to perform compression distillation and structured encoding on candidate memories, and dynamically inject corresponding memory blocks according to the four companionship stages of awakening, understanding, soothing and expression; it realizes the end-cloud collaborative mechanism of high-frequency memory synchronization on the network, offline degradation triggered by network disconnection, and event update by retransmission when the network returns. Based on the core strategy of soothing effect evaluation and multi-dimensional operation index iteration, a self-evolving data closed loop of the system is formed.
[0066] An end-to-end cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update device for emotional companionship toys is provided. The device is used to execute executable instructions to perform the aforementioned end-to-end cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companionship toys.
[0067] A computing device includes a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to execute any of the end-to-cloud collaborative hierarchical memory injection, dynamic retrieval and conflict update methods applicable to emotional companion toys.
[0068] The methods and / or embodiments in this application can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. When the computer program is executed by a processing unit, it performs the functions defined in the methods of this application.
[0069] It should be noted that the computer-readable medium described in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system or device.
[0070] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application.
Claims
1. A cloud-edge collaborative hierarchical memory injection, dynamic retrieval, and conflict update method suitable for emotional companion toys, characterized in that, include: A six-layer hierarchical memory system and edge-side caching rules are constructed for edge-cloud collaboration. The system is divided into six basic memory layers: user profile, scenario events, reassurance strategies, working memory, relationship status, and device status. It is accompanied by two types of extended memory: locally solidified scenario silent rules that take effect when the network is disconnected and negative constraint system lessons. The system defines write triggering, retrieval priority, and time-limit decay rules for each layer. The system also includes a pre-configured ESP32-S3 edge-side Flash resident cache and RAM short-term cache, and solidified offline constraints and low-power wake-up preloading logic. The terminal collects multimodal interaction data, including voice, touch, gesture, button, and environmental data, and uploads it to the cloud for parsing and generation of memory candidates. The total saliency score is calculated from seven dimensions and distributed to the short-term cache on the device, session working memory, and long-term memory on the cloud according to the 30 / 60 threshold. Key events that meet the judgment conditions skip the scoring and threshold distribution and are forcibly written to the corresponding memory layer after conflict detection. Identify interaction topics, emotions, and scenarios; perform hard filtering with pre-existing metadata and time windows; use parallel keyword inversion and relation graph adjacency coarse recall; and then perform fine matching with semantic vectors. By overlaying multi-dimensional weights and conflict risk penalties, and combining intimacy and appeasement effectiveness for re-ranking, the candidate set is output by pruning according to the token budget. Before writing, match the historical memory of the same subject and the same attribute, and divide it into three levels of conflict according to semantic similarity: mild, moderate and severe. Then execute in-situ update, pending confirmation guidance and dual-version scenario adaptive strategy respectively. Preserve the complete version traceability chain, and prioritize the latest high-confidence memory for the second verification before injection; Candidate memories are compressed, distilled, and structured encoded, and memory blocks are dynamically injected in four stages: awakening, understanding, soothing, and expression. High-frequency memories are synchronized to the edge via the network, and offline degradation and re-upload are triggered when the network is disconnected. The system achieves self-evolution based on soothing effects and multi-dimensional index iteration strategies.
2. The edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys according to claim 1, characterized in that, The terminal collects multimodal interaction data, including voice, touch, gesture, button, and environmental data, and uploads it to the cloud for parsing and generation of memory candidates. The total saliency score is calculated from seven dimensions, and the data is distributed to short-term cache on the device, session working memory, and long-term memory in the cloud based on a 30 / 60 threshold. Critical events that meet the judgment criteria skip scoring and threshold routing, and are forcibly written to the corresponding memory layer after conflict detection, including: Combining the dirty memory interception and end-to-cloud hierarchical storage requirements of the ESP32-S3 emotional companion toy, a multi-dimensional saliency scoring rule and a three-level threshold diversion mechanism are introduced. Based on the multi-modal collection of terminal voice, touch, posture, button and environmental data and cloud structured analysis and screening, a memory candidate set is generated. Based on the long-term value of memory, source credibility and hardware resource compatibility standards, the total significance score is calculated by weighting seven dimensions: active declaration, companionship value, repetition frequency, conflict risk, privacy sensitivity, emotional importance and end-to-cloud compatibility. The three-level value stratification is completed according to the 30 / 60 threshold. Long-term memories that meet the criteria are first subject to conflict detection and then classified into the corresponding memory level. By using five types of key events to force archiving rules, we can skip the regular scoring and threshold diversion. The triggering scenarios include intense emotional fluctuations, major positive commemorative events, long-term touch comforting loops, and major long-term changes in user preferences. After simultaneously performing conflict detection and memory level matching, the data is written to the corresponding repository. Finally, the output results are stored in three levels: short-term cache on the client side, session working memory, and long-term memory in the cloud.
3. The edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys according to claim 1, characterized in that, Identify interaction topics, emotions, and scenarios; perform hard filtering with pre-existing metadata and time windows; use parallel keyword inversion and relation graph adjacency coarse recall; and then perform fine matching with semantic vectors. By overlaying multi-dimensional weights and conflict risk penalties, and re-ranking candidates based on intimacy and appeasement effectiveness, the candidate set is pruned according to the token budget, including: Combining the precise memory retrieval and token cost constraints of the ESP32-S3 emotional companion toy, a four-level retrieval system is built by introducing multi-dimensional hybrid retrieval, cross-encoder correction, dynamic weighted sorting and hierarchical pruning mechanism, including pre-hard filtering, dual-channel coarse retrieval, semantic fine matching and refined re-sorting. Based on memory type, emotion tag, time period and retrieval priority, metadata field matching and dynamically adjustable time window threshold filtering are performed to directly eliminate completely irrelevant memory entries, thus completing the preliminary simplification of the candidate set to reduce subsequent computational overhead. Based on the balance constraints of recall coverage and computing power consumption, a dual-channel parallel coarse recall rule is set up for the relationship graph adjacency of keyword inverted index and 2-hop adjacency range. Then, semantic vector retrieval is used to supplement the missing memory of low keyword high semantic matching. After three levels of deduplication, the heterogeneous retrieval results are merged. The merged candidate set is fed into the cross encoder for refined semantic rescoring to correct vector bias. Semantic matching, keyword hit, timeliness and freshness, confidence, task relevance and conflict risk are superimposed to generate a comprehensive ranking score. The ranking is then corrected by combining intimacy, soothing effectiveness and emotional scene tags. After staged quantity and token budget double pruning, and prioritizing the retention of resident memories, the final memory is output and injected into the candidate set.
4. The edge-cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys according to claim 1, characterized in that, Before writing, match the historical memory of the same subject and the same attribute, and divide it into three levels of conflict according to semantic similarity: mild, moderate and severe. Then execute in-situ update, pending confirmation guidance and dual-version scenario adaptive strategy respectively. To preserve the complete version traceability chain, the second verification before injection prioritizes the latest high-confidence memory, including: Combining the consistency guarantee of emotional companionship memories with the need to adapt to dynamic changes in user preferences, a three-level conflict quantification judgment, hierarchical resolution, two-way version link tracing, and write-injection dual-stage verification mechanism are introduced. Based on the three-level matching rules of memory type-subject-predicate-tag, the candidate set of historical memories to be compared is located. Based on semantic similarity threshold, two-end confidence and value range difference standard, the conflict is divided into three levels: mild, moderate and severe, with 0.3 and 0.8 as the dividing line. For severe conflicts, the confidence of both the old and new memories is not lower than 0.6, so as to complete the accurate quantitative determination of the conflict type. A tiered resolution strategy is implemented for different conflict levels. Minor conflicts discard new entries by default, high-scoring conflicts update confidence and version number in place, medium conflicts are marked for confirmation and the user is guided to verify interactively, and severe conflicts retain both versions and are adaptively weighted and sorted according to the scenario. A three-branch secondary judgment rule of confirmation / denial / no response is provided to achieve differentiated closed-loop processing of conflicts. The complete traceability chain is maintained by using version number and bidirectional replacement association fields. Old memories are synchronously marked as effective / pending confirmation / archived. Secondary conflict verification is performed before the prompt words are injected. The latest memory with the highest confidence and the highest scene matching degree is selected first. If it cannot be determined, it is marked as pending confirmation. Finally, the effective memory entries with consistent and conflict-free output are output.
5. The end-to-end cloud collaborative hierarchical memory injection, dynamic retrieval, and conflict update method for emotional companion toys according to claim 4, characterized in that, Candidate memories are compressed, distilled, and structured encoded, and memory blocks are dynamically injected according to four stages: awakening, understanding, soothing, and expression; high-frequency memories are synchronized to the edge via network, and offline degradation and re-upload are triggered when the network is disconnected. Based on the appeasement effect and a multi-dimensional indicator iterative strategy, the system achieves self-evolution, including: Combining the hardware resource constraints of ESP32-S3, the continuity of weak network companionship, and the system's autonomous iteration requirements, a memory compression distillation, differentiated emotion decay, phased structured injection, end-to-cloud collaborative degradation, and closed-loop evaluation mechanism for soothing effects are introduced. Based on the end-to-cloud layered memory architecture, a full-link emotional memory management system is built. Based on token overhead constraints and hardware bandwidth adaptation standards, candidate memories undergo four types of processing: similar event merging, natural language key-value conversion, stable preference extraction into rules, and interaction pipeline compression. Multi-dimensional meta-information is added to complete structured encoding and short format conversion to adapt to the ESP32-S3 packet length limit, which reduces data volume while enhancing the boundary controllability of memory content. It is equipped with emotion-differentiated time-lapse rules for positive slow decay, negative fast decay, and neutral constant decay, and dynamically adjusts memory recall weight and life cycle in combination with intimacy. By leveraging network state awareness and low-power wake-up on the device side, collaborative scheduling is achieved. Five core contents—basic addressing preferences, night mode rules, commonly used soothing phrases, high-success-rate soothing strategies, and relationship state summaries—are synchronized to the device-side cache. During the wake-up phase, high-frequency memories and basic soothing strategies are preloaded locally. When the network is disconnected, offline degradation calls are made to pre-set multimodal feedback and temporarily store three key events: night-triggered events, continuous emotional fluctuations, and multiple soothing interactions. Data is then transmitted back to the network to complete memory merging, updating, and conflict verification. Supporting multi-dimensional operational indicators and closed-loop evaluation of soothing effectiveness iterates core parameters, ultimately forming a positive data closed loop to achieve system self-evolution.
6. A cloud-edge collaborative hierarchical memory injection, dynamic retrieval, and conflict update system suitable for emotional companion toys, characterized in that: The system is used to execute executable instructions to perform the end-to-cloud collaborative hierarchical memory injection, dynamic retrieval and conflict update method for emotional companion toys as described in any one of claims 1 to 5.
7. A cloud-based collaborative hierarchical memory injection, dynamic retrieval, and conflict update device suitable for emotional companion toys, characterized in that: The device is used to execute executable instructions to perform the end-to-cloud collaborative hierarchical memory injection, dynamic retrieval and conflict update method for emotional companion toys as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, include: First processor; And a memory for storing executable instructions of the first processor; wherein the first processor is configured to execute the end-to-cloud collaborative hierarchical memory injection, dynamic retrieval and conflict update method for emotional companion toys according to any one of claims 1 to 5 by executing the executable instructions.
9. A computing device, the device comprising a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein, When the computer program instructions are executed by the processor, the device is triggered to execute the end-to-cloud collaborative hierarchical memory injection, dynamic retrieval and conflict update method applicable to emotional companion toys as described in any one of claims 1 to 5.
