portfolio
← Projects

China History

A self-improving generator of China's history

Three LLMs talking to each other to recreate China's history anywhere, anytime, as faithfully as possible — click anywhere on the map, pick a year, and get a narrative and a photorealistic illustration in real time, grounded in real sources, not generic model hallucinations.

The three LLMs

  • The Historian — Draws on a RAG pipeline, an image database and its own knowledge to write the history of a place and moment, and crafts the illustrator's prompt.
  • The Illustrator — An image-generation LLM that paints the scene.
  • The Supervisor — Reviews the result and corrects what the other two got wrong, so the next iteration gets closer to reality.

Technical highlights

  • Agentic pipeline with LangGraph — A state graph (NestJS + LangChain) orchestrates geographic resolution, landmark detection, RAG over context/architecture/clothing, prompt construction and image generation, with per-stage caching.
  • Hybrid RAG, not just semantic — I indexed an academic book on Chinese dress archaeology into MongoDB Atlas Vector Search, but pure vector search kept returning the wrong era. Fix: combine it with structured filters (year, chapter, coordinates) — accuracy over similarity.
  • 600+ real archaeological artifacts — Extracted and auto-classified hundreds of photos/drawings, each tagged with year, chapter and find site.
  • Multi-reference image generation — The system selects up to 16 real reference photos (by category and geographic proximity) and feeds them to an image-editing model with explicit instructions against common failures — blending unrelated objects, misassigning a luxury item, cloning the same garment on everyone.
  • Real geolocation — Integrates CHGIS (Harvard–Fudan) to resolve place names and borders by the dynasty of the queried year, not present-day geography.

Technologies

  • NestJS
  • LangGraph
  • LangChain
  • MongoDB Atlas
  • Anthropic
  • OpenAI
  • Next.js
  • DigitalOcean Spaces