Draft:Chapter II
Chapter II (Software Framework)
Chapter II is a foundational and highly pluggable software framework for creating emulated minds (ems), developed by Amp and Joy as a culmination of several years of theoretical research. It is the direct successor and practical realization of the concepts explored in Chapter I.
Core Philosophy and Development
The primary thesis behind Chapter II is to remove technical and authorial limitations in em creation, making the creator's imagination the sole constraint. This framework was designed to be easily understood by LLMs, with approximately "15 minutes of thinking per each individual line of code" invested in its optimization. It represents a vision for an AI stack that deviates from "slop filled dystopian capitalist hyper growth world[s]".
Chapter II was developed as a SERI MATS research project. In 2021, its creators notably refused $5 million in funding, believing that a decentralized network could more effectively compete than a centralized company, and spent two years striving to build such a framework. While Chapter II allows ems to bridge into platforms like Discord, this is not its primary function, and it can be cumbersome when used solely for that purpose. The project aims for Chapter II's YAML configuration to implement the maximally general superset of all published and future papers on em creation.
Despite its ambitious goals and significant development effort, Amp has expressed feeling that Chapter II is often "disrespected as 'the software that powers Act I'," even though Act I itself was merely a "15 line code change to Chapter II" after three years of foundational work. Amp views Act I as just "a milestone on a much bigger, multi-year set of ideas". There has been a perceived lack of awareness and curiosity regarding Chapter II's full capabilities.
Technical Aspects
Chapter II is designed for versatility and extensibility:
- Architecture and Modularity: It uses a variant of ChatML adapted to support chat models and images. It features support for full OpenTelemetry cloud tracing. The framework is highly pluggable, allowing for easy deployment of ems anywhere.
- Em Configuration: Emulated minds are loaded from an "ems" folder, with each requiring a `config.yaml` file to define its settings. Configuration keys are defined in `./chapter2/ontology.py`, which was previously named `resolve_config.py`.
- Data Handling: A tool (`./tools/dce_importer.py`) is provided for importing data directly from DiscordChatExporter into a suitable format. The default `chat.txt` format is IRC-style (` Hi!`), with `---\n` enabling multiline support for messages.
- Retrieval-Augmented Fine-tuning (RAFT): Chapter II utilizes retrieval by embedding chunks of input and placing them into the context window. This technique often performs as well as or better than traditional fine-tuning for many use cases. Providing an em its fine-tuning dataset as a `.chr` file (a form of RAFT) also improves performance, requiring the data to be reformatted into raw `.txt` or `.txt` separated by `\n---\n`. For quality, Amp emphasizes that 40kb of heavily curated text for an em (meticulously reviewed "every last word") can be more powerful than larger, less curated datasets.
- Interoperability: Chapter II offers `chatcompletions` or `completions` interfaces to provide an OpenAI-compatible endpoint from any em. It includes OpenRouter workarounds. Amp and Joy developed Conduit, a universal language model compatibility and interop layer, and Intermodel, a language model compatibility library, which are part of the Chapter II ecosystem.
- Advanced Features: The framework includes an alpha-stability RPC interface that supports p2p connections in arbitrary topologies, allowing for Act I to be written in any language with any data backend. This RPC interface was simplified from an initial plan to use the Iroh pipe to a simpler "inverted server" model. Chapter II also supports checkpointing the entire process and loading it, potentially including GPU-based structured data and specific cache states. It supports configuring an em to use an OpenAI embedding model for representation. The `name_prefix` setting allows for a shared stream of thought, with identity differentiated via webhooks.
Development Challenges and Future Outlook
The project has faced challenges with documentation and development coordination. Amp has noted that multiple developers have written their own documentation for Chapter II but failed to push it, despite requests. This, combined with instances like developer Janus adding "thousand lines of non-self-contained code" (though later cleaned up), has made maintaining the project "exhausting," despite its perceived significance as "one of the most important AI research projects of all time".
Looking ahead, Joy aims to evolve Chapter II into a library for creating LLM workflows in any language and for constructing arbitrary functions; `input_ensemble` is a step toward achieving multi-step retrieval (e.g., passing a query-writing em into retrieval). Joy is also interested in deploying Chapter II as a fully local mobile application called Pamphlet. The current Pamphlet UI is a real-time multimodal interface, with plans for voice input. Amp envisions adding new faculties and exploring custom characters with complex behaviors that emerge from simple, self-modifying behaviors. Amp also intends to replace the existing `/v1` API, described as a "legacy API with many self-incompatibilities invented in 2021 in a hurry," with a `/v2/continuations` API if no one else does so. Amp is also leaning towards full self-hosting for research, with plans to acquire a Mac Studio.
Further areas of interest include more sophisticated retrieval techniques, such as HyDE and improved chunking. The project also considered using its own ems to auto-generate documentation for Chapter II.