Action-augmented cloned HMMs for higher-order sequence learning and cognitive map formation
This repository implements Clone-Structured Cognitive Graphs (CSCG), a probabilistic framework for learning cognitive maps from sequential observations and actions. CSCGs build on Cloned Hidden Markov Models (CHMM), which are sparse HMMs where each hidden state emits a single observation deterministically, with multiple "clones" per observation enabling context-dependent representations based on sequential context. CSCGs extend cloned HMMs by augmenting transitions with actions, enabling spatial/temporal/relational learning and vicarious evaluation (planning without execution) through message-passing inference.
Cognitive maps emerge naturally from latent higher-order sequence learningโorganisms learn space by treating it as a sequence.
cscg_toolkit/
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ julia/ # Julia implementation (reference)
โ โโโ Project.toml
โ โโโ src/ # Core CSCG library
โ โโโ test/ # Unit & integration tests
โ โโโ scripts/ # Example scripts
โ โโโ test_data/ # Test fixtures
โโโ jax/ # JAX implementation (active development)
โ โโโ chmm_jax/ # Core package
โ โโโ tests/ # Test suite
โ โโโ examples/ # Usage examples
โ โโโ README.md # JAX-specific docs
โโโ papers/ # Reference papers and summaries
โ โโโ pdf/ # Original papers (PDFs)
โ โโโ md/ # Markdown conversions
โ โโโ summaries/ # Deep technical summaries with LaTeX
โโโ python/ # Python reference implementation (legacy)
โโโ chmm_actions.py
โโโ intro.ipynb
โโโ README.md
A Cloned Hidden Markov Model is a sparse HMM where each hidden state emits a single observation deterministically. Multiple hidden states ("clones") can emit the same observation, enabling context-dependent representations:
Observations: [x_0, x_1, x_2, ...]
โ โ โ
Hidden States: [z_0,z_1,z_2] [z_3,z_4,z_5] [z_6,z_7,z_8] ... (3 clones per observation)
Key advantages:
- Context-dependent representations: Same observation splits into different latent states based on sequential context
- Variable-order dependencies: Efficiently learns higher-order sequential structure without exponential state explosion
- Computational efficiency: Block-structured transitions exploit emission sparsity
Clone-Structured Cognitive Graphs extend cloned HMMs by augmenting state transitions with actions. This enables:
- Spatial/temporal learning: Cognitive maps emerge from sequential experience with actions
- Vicarious evaluation: Message-passing inference enables planning without execution
- Flexible structure: Learns graphs from severely aliased observations (same visual input at multiple locations)
The Baum-Welch algorithm takes a simpler form for cloned HMMs due to emission sparsity:
-
Forward pass: ฮฑ(n+1)แต = ฮฑ(n)แต T(xโ, aโ, xโโโ) Computes ฮฑ(n) = P(xโ:โ, aโ:โโโ, zโ) using only MรM blocks
-
Backward pass: ฮฒ(n) = T(xโ, aโ, xโโโ) ฮฒ(n+1) Computes ฮฒ(n) = P(xโโโ:N, aโ:Nโโ | zโ) using only MรM blocks
-
E-step: ฮพแตขโโฑผ(n) = [ฮฑ(n) โ T(i,aโ,j) โ ฮฒ(n+1)แต] / [ฮฑ(n)แต T(i,aโ,j) ฮฒ(n+1)] Expected transition counts from clone-set i via action k to clone-set j
-
M-step: T(i,k,j) = ฮฃโ ฮพแตขโโฑผ(n) / ฮฃโโฒ,โฑผโฒ,โ ฮพแตขโโฒโฑผโฒ(n) Normalize expected counts to probability distributions
Key insight: Only compute blocks T(xโ, aโ, xโโโ) appearing in observed sequence, yielding O(Mยฒ|ฮฃ|ยฒTN_a) complexity instead of O((M|ฮฃ|)ยฒTN_a) for standard HMM.
Alternatives:
- Viterbi training: Hard assignment (argmax) instead of soft expectations for faster convergence
- Pseudocount smoothing: Add ฮบ > 0 to all counts for regularization and preventing zero probabilities
- Gradient descent (future): Planned enhancement for end-to-end integration with neural networks
This repository contains multiple implementations:
- Julia (reference): See julia/README.md for installation, usage, and testing
- JAX (active development): See jax/README.md for installation and PyTorch integration
- Python (legacy): See python/README.md
This is a research project. Contributions are welcome!
Priority areas:
- Gradient descent training via Flux.jl
- GPU acceleration
- Pytorch
- Jax
- Performance optimizations
- Additional test coverage
- Documentation improvements
Workflow:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass (
julia --project=julia test/runtests.jl) - Submit a pull request
This implementation is based on the following research:
- Dedieu, A., Gothoskar, N., Swingle, S., Lehrach, W., Lรกzaro-Gredilla, M., & George, D. (2019). Learning higher-order sequential structure with cloned HMMs. arXiv:1905.00507
- Provides theoretical convergence guarantees, demonstrates 10% improvement over LSTMs on language modeling
- George, D., Rikhye, R.V., Gothoskar, N., Guntupalli, J.S., Dedieu, A., & Lรกzaro-Gredilla, M. (2021). Clone-structured graph representations enable flexible learning and vicarious evaluation of cognitive maps. Nature Communications, 12(1), 2392
- Extends CHMMs with actions, explains hippocampal splitter cells, route encoding, remapping phenomena
- Raju, R.V., Guntupalli, J.S., Zhou, G., Lรกzaro-Gredilla, M., & George, D. (2022). Space is a latent sequence: Structured sequence learning as a unified theory of representation in the hippocampus. arXiv:2212.01508 (published Science Advances, 2024)
- Explains dozen+ hippocampal phenomena with single mechanism: latent higher-order sequence learning
- Kansky, K., et al. (2017). Schema networks: Zero-shot transfer with a generative causal model of intuitive physics. arXiv:1706.04317
- Lรกzaro-Gredilla, M., et al. (2018). Beyond imitation: Zero-shot task transfer on robots by learning concepts as cognitive programs. arXiv:1812.02788 (Science Robotics)
Comprehensive paper summaries available in:
- Synthesis:
papers/summaries/README.md- Cross-paper evolution and unified framework - Neuroscience:
papers/summaries/00_neuroscience_connections.md- Hippocampal phenomena explained (place cells, remapping, splitter cells) - Individual papers:
papers/summaries/- Deep dive into each paper's methods and results
MIT License - see LICENSE for details
Last updated: 2025-11-02
