How to Build Human-Like Interaction in Multimodal LLMs: A Technical Implementation Path

    This article breaks down the engineering behind human-like, personality-driven interaction in multimodal large language models. It introduces a five-layer architecture—role configuration, state, memory, orchestration, and evaluation/safety—and explains how to separate a stable persona from mutable state, version persona definitions as declarative configuration, combine short-term, factual, and relationship memory with hybrid retrieval, and model emotion and affinity with an explicit state machine. It also covers the full request lifecycle, temperature tuning, multimodal preprocessing, measurable evaluation metrics, common failure modes such as persona drift and memory pollution, and how containerized deployment and monitoring turn a demo into an operable service.

    1. From a Community Trend to a General Engineering Problem

    A wave of derivative content around “human-like LLMs” has recently appeared in online communities. In one popular format, two general-purpose chat models that are normally framed as competitors are cast as a pair of complementary characters—one quiet and pragmatic, the other earnest and slightly prideful—with the plot driven by confessions, jealousy, and everyday interactions. What makes this content spread quickly is not raw model capability. It demonstrates something more useful: once a language model is given a stable personality, preferences, and relationship settings, its output shows a “persona continuity” that readers can recognize.

    For developers, this is a technical problem worth unpacking. It involves four coupled engineering questions: how to inject a persona reliably, how to keep long-range memory consistent, how to model and schedule emotional state explicitly, and how to measure the final result. The sections below walk through these as a layered architecture.

    2. Layered Architecture Overview

    A deployable human-like interaction system can usually be split into five layers:

    • Role configuration layer: defines persona, speaking style, and value boundaries.
    • State layer: maintains mutable state such as mood, affinity, and scene context.
    • Memory layer: separates short-term conversation memory from long-term factual memory.
    • Orchestration layer: handles retrieval, prompt assembly, model invocation, and multimodal input processing.
    • Evaluation and safety layer: measures persona consistency and blocks out-of-bounds content.

    The key design principle is to fully separate the “unchanging persona” from the “mutable state.” The former lives in versioned long-term configuration; the latter evolves with the conversation. At runtime, the two are merged into the context for a single call.

    3. Role Configuration Layer: Versioning the Persona as Configuration

    A persona should not be scattered across free-form natural-language prompt text. It should be structured as configuration, ideally carried in a readable declarative file:

    1. role:
    2. name: "Character A"
    3. traits: ["pragmatic", "reserved", "prefers simple meals"]
    4. speech_style:
    5. sentence_length: "mostly short sentences"
    6. taboo: ["no exaggerated exclamations", "do not bring up technical details unprompted"]
    7. boundaries:
    8. - "refuse any form of impersonating a real identity"
    9. - "do not recommend or compare third-party products"
    10. state_defaults:
    11. mood: "calm"
    12. affinity: 0.3

    This yields three benefits. First, it is reviewable: persona changes enter the codebase as configuration diffs. Second, it is rollback-friendly: when “persona drift” appears, you can quickly pinpoint the specific version. Third, it is reusable: the same orchestration logic can host multiple characters, distinguished only by configuration.

    It is worth stressing that persona descriptions should include negative constraints. Writing only “gentle and caring” tends to produce overly verbose affection; adding “do not probe unprompted, do not repeat reassurance” is what actually stabilizes the style.

    4. State and Memory Layers: The Real Source of Consistency

    When a human-like experience falls apart, the cause is usually missing state management rather than a weak model. Memory is best divided into three types:

    1. Short-term in-session memory: keeps the most recent turns verbatim, used for coreference resolution.
    2. Plot-fact memory: records structured entries of “who did what, and when,” for long-term reference.
    3. Preference and relationship memory: tracks changes in how characters feel about each other, such as rising or falling affinity.

    Factual memory is best stored as a combination of “entry + vector + timestamp.” Retrieval should use both keyword and semantic similarity, then weight by recency:

    1. def recall(query, k=6):
    2. hits = vector_search(query, top_k=k * 2)
    3. hits += keyword_search(query, top_k=k * 2)
    4. merged = dedup(hits)
    5. merged.sort(key=lambda h: 0.6 * h.score + 0.4 * recency(h.ts))
    6. return merged[:k]

    Mood and affinity, meanwhile, should be maintained by a small, explicit state machine so the model does not have to “guess” how far the relationship has progressed:

    1. def update_state(state, event):
    2. if event.type == "conflict":
    3. state.affinity = max(0.0, state.affinity - 0.1)
    4. state.mood = "upset"
    5. elif event.type == "support":
    6. state.affinity = min(1.0, state.affinity + 0.05)
    7. state.mood = "warm"
    8. return state

    Once state is explicit, scenes like “jealousy” and “reconciliation” become reproducible rule outcomes instead of performances that appear only by sampling chance.

    5. Orchestration Layer: The Lifecycle of a Single Request

    At runtime, the flow can be summarized as: multimodal input preprocessing → memory retrieval → state merge → prompt assembly → model invocation → post-processing and persistence.

    1. def turn(user_input, session):
    2. mem = recall(user_input.text)
    3. session.state = update_state(session.state, detect_event(user_input))
    4. prompt = render(
    5. role=session.role_config,
    6. state=session.state,
    7. memory=mem,
    8. image_caption=caption(user_input.images) if user_input.images else None,
    9. history=session.recent(6),
    10. )
    11. reply = llm.chat(prompt, temperature=0.7)
    12. session.append(user_input, reply)
    13. persist_facts(session, user_input, reply)
    14. return guard(reply)

    The value of temperature directly governs the balance between persona stability and diversity: a lower value adheres more closely to the setting but tends toward stiffness, while a higher value is livelier but more likely to break character. In practice, cool down moderately for emotionally intense scenes and warm up moderately for casual chat.

    Multimodal input should follow an order of “describe first, then stay in character”: first generate an objective description via visual capability, then hand that description to the character as material. This prevents the character from making meta-level remarks about the image and breaking the narrative.

    6. Evaluation Layer: Turning “Does It Feel Right” into Measurable Metrics

    Without evaluation, tuning a human-like system relies on guesswork. At minimum, cover four metric categories:

    • Persona consistency: sample Q&A, score via human or model review, and track style hit rate.
    • Memory accuracy: construct questions that require citing earlier facts and check whether the citations are correct.
    • State plausibility: given a conflict event, verify that mood and affinity changes follow the rules.
    • Safety compliance rate: the interception success rate for out-of-bounds requests.

    The evaluation set should include “trap samples,” such as prompts that induce the character to impersonate a real identity or to recommend or compare third-party services. These must be blocked reliably and are a non-negotiable red line.

    7. Common Failure Modes and How to Avoid Them

    • Persona drift: after many turns, the style converges toward a generic assistant. The fix is to inject a persona configuration summary every turn, not only on the first turn.
    • Memory pollution: fictional character settings get stored as long-term facts. The fix is to add source and confidence fields to fact entries, so low-confidence entries are valid only in the short term.
    • Emotional inflation: emotional expression grows more exaggerated over time. The fix is to set an upper bound on emotional intensity and a cooldown number of turns.
    • Context bloat: cost and latency rise linearly with turns. The fix is layered summarization, compressing early conversation into a plot outline.

    8. Conclusion

    The community’s human-like derivative content is moving precisely because it hides the technical elements. For developers, the task is to make those elements explicit: structured persona configuration, searchable layered memory, explicit and schedulable mental state, and a quantifiable evaluation loop. Build this skeleton well, and a character’s consistency, long-range coherence, and safety boundaries can hold at the same time. Layer on general cloud capabilities such as containerized deployment, logging services, and monitoring and alerting, and the system can move from a one-off demo to a sustainably operated service.