Lessons from Rebuilding XiaoIce: Choosing an Open-Weight Foundation Model
This article shares the mid-project findings of a XiaoIce-style conversational agent rebuild, focusing on why the team moved from closed cloud LLMs to an open-weight foundation model. It explains the four trade-offs behind that decision (controllability, cost structure, version stability, and capability ceiling), then walks through building a four-layer data loop for persona, memory, skills, and safety, a three-stage training plan, inference cost optimization, and a layered evaluation and safety governance approach. Readers will get a practical reference for keeping long-term ownership of a persona-driven AI agent while still using cloud models for validation and data synthesis.
1. Project Background and Mid-Stage Conclusion
The goal of the XiaoIce rebuild project is to recreate, on our own infrastructure, a conversational agent with human-like expression, long-range context memory, and a stable persona. After reaching the mid-stage, the team reached a clear conclusion on foundation model selection: a closed-source cloud LLM as the base delivers a noticeable quality lift, with low integration cost and fast iteration, which makes it well suited for probing the capability ceiling and validating the approach. However, because weights are unavailable and version policy and API constraints are not fully controlled by the consuming side, it cannot satisfy the hard requirement of “long-term persistence,” so it is not adopted as the final dependency.
This conclusion is not a dismissal of closed-source models. It assigns the two options different responsibilities: closed-source models serve feasibility validation and quality baselining, while open-weight models carry productization and long-term evolution. Development has now converged on an open-weight foundation model, with the data loop, training pipeline, and inference serving built around it.
2. Core Trade-offs in Foundation Model Selection
Selection is essentially a trade-off across four dimensions.
The first is controllability. Access to weights makes domain continued pre-training, full-parameter or parameter-efficient fine-tuning, quantization, and distillation possible, and it also allows running in offline or private network environments so data never leaves the domain.
The second is cost structure. Closed-source options bill per call, so cost grows linearly with active users. A self-hosted open-source setup concentrates upfront investment in compute and engineering effort, while marginal cost declines as utilization rises, making it more predictable under stable high traffic.
The third is version stability. Productized systems need a fixed behavior baseline. Frequent silent updates to the base model cause broken prompts, output style drift, and non-reproducible regression testing. Self-held weights let versions be frozen on a controlled schedule.
The fourth is the capability ceiling. Closed-source flagship models still lead in general reasoning, multilingual ability, and complex instruction following. The reasonable approach is to keep a “cloud high-capability channel” for offline data synthesis and hard-sample labeling rather than for the main online path.
3. Building the Data Loop
The difficulty in human-like dialogue is not single-turn fluency but long-range consistency. In practice, data is organized into four layers:
- Persona layer: role settings, tone constraints, and value boundaries, expressed with structured templates to avoid conflicting natural-language descriptions.
- Memory layer: long-term memory abstracted into retrievable fact triples and summary entries, training the model on when to recall and how to cite.
- Skill layer: trajectory data for tool calls and retrieval augmentation, including failure-retry and refusal samples.
- Safety layer: adversarial samples such as jailbreak inducement, privacy extraction, and emotional manipulation, used for risk suppression during alignment.
Data synthesis is best run as a three-step flow of “strong model generation + rule-based validation + human spot checks,” with source and confidence annotated on synthetic data to prevent the model from hardening the teacher model’s hallucinations. A sample organization is shown below:
{"persona_id": "assistant_default","memory_refs": ["fact_1024", "summary_77"],"context": [{"role": "user", "content": "..."}],"target": {"content": "...", "style_tags": ["concise", "warm"]},"risk_labels": [],"source": "synthetic_v3","confidence": 0.82}
4. Training and Fine-Tuning Strategy
A three-stage progression is recommended. Stage one is domain continued pre-training to inject project corpora and terminology; the scale need not be large, since the focus is aligning the distribution. Stage two is supervised fine-tuning, prioritizing instruction following and format stability while using parameter-efficient methods to control memory use and overfitting risk. Stage three is preference alignment, using pairwise comparison data to suppress three common problems: verbosity, sycophancy, and boundary violations.
On the engineering side, fix random seeds, data versions, and configuration snapshots so every experiment is reproducible. Training and evaluation data must be isolated by both time and source to avoid memory leakage that inflates metrics.
5. Inference Serving and Cost Optimization
The key online metrics are time to first token, throughput, and cost per session. Combinable techniques include continuous batching to improve concurrency utilization; prefix caching to reuse fixed system prompts and persona templates; weight quantization and sparsification to reduce memory footprint; and routing high-frequency simple intents to a small model while sending complex requests to a larger one. If a container platform is used, pair it with logging services and monitoring alerts to build dashboards for latency percentiles, failure rate, and resource watermarks, and configure auto-scaling and degradation policies.
6. Evaluation System and Safety Governance
Evaluation has three layers: automated metrics for format compliance and retrieval hit rate; model review for persona consistency and naturalness; and small-sample human review for long-term experience. On the safety side, deploy content moderation in both input and output directions, desensitize sensitive information on memory writes, and retain auditable trace records.
7. Next Steps
The next stage will complete capability gap-filling on the open-weight base and load-test the inference pipeline, accumulate reusable data and evaluation assets, and keep the cloud high-capability channel for data synthesis. The overall roadmap follows one principle: the capability ceiling can be validated externally, but long-term persistence must stay in our own hands.
