{"id":27666,"library":"cortexcore","title":"CortexCore","description":"CortexCore is a modular library for building recurrent backbones and agent memory systems. It provides building blocks for stateful neural architectures, including LSTM, GRU, and attention-based memory modules, with a focus on composability and runtime efficiency. The current version is 0.1.6, targeting Python >= 3.12, with a monthly release cadence.","status":"active","version":"0.1.6","language":"python","source_language":"en","source_url":"https://github.com/Metta-AI/metta/tree/main/packages/cortex","tags":["recurrent-neural-networks","memory-systems","deep-learning","pytorch","stateful-models"],"install":[{"cmd":"pip install cortexcore","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for tensor operations and neural network modules.","package":"torch","optional":false},{"reason":"Used for numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Used for tensor rearrangement and Einstein summation.","package":"einops","optional":true}],"imports":[{"note":"The top-level package is 'cortexcore', not 'cortex'.","wrong":"from cortex import CortexBase","symbol":"CortexBase","correct":"from cortexcore import CortexBase"},{"note":"Cell implementations are in the submodule 'cells'.","wrong":"from cortexcore import LSTMCell","symbol":"LSTMCell","correct":"from cortexcore.cells import LSTMCell"},{"note":"Memory modules are in the submodule 'memory'.","wrong":"from cortexcore import MemoryModule","symbol":"MemoryModule","correct":"from cortexcore.memory import MemoryModule"}],"quickstart":{"code":"import torch\nfrom cortexcore import CortexBase\nfrom cortexcore.cells import LSTMCell\n\n# Create a simple recurrent backbone\ncell = LSTMCell(input_size=10, hidden_size=20)\nbase = CortexBase(cell, stateful=True)\n\n# Process a sequence\nx = torch.randn(5, 10)  # sequence length 5, batch size 1\noutput, hidden = base(x)\nprint(output.shape)  # torch.Size([5, 20])\n\n# Reset state for new sequence\nbase.reset_state()","lang":"python","description":"Minimal example creating a recurrent backbone using an LSTM cell and processing a sequence."},"warnings":[{"fix":"Use `CortexBase(cell, stateful=True)` instead of `CortexBase(cell, True)`.","message":"In version 0.1.6, the 'stateful' parameter of CortexBase must be passed as a keyword argument; positional usage is removed.","severity":"breaking","affected_versions":">=0.1.6"},{"fix":"Run `pip install cortexcore`.","message":"The package name is 'cortexcore' on PyPI, but the GitHub repository is under the 'metta' monorepo. Ensure you use 'cortexcore' in pip install, not 'metta-cortex'.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `import cortexcore` instead of `import CortexCore`.","message":"The alias 'CortexCore' (CamelCase) for the module is deprecated in favor of 'cortexcore' (all lowercase).","severity":"deprecated","affected_versions":"<0.2.0"},{"fix":"Always call `model.reset_state()` before a new sequence when `stateful=True`.","message":"When using stateful mode, you must manually call `reset_state()` before processing a new independent sequence, otherwise the hidden state carries over.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install and import `cortexcore`: `pip install cortexcore` then `import cortexcore`.","cause":"Trying to import 'cortex' instead of 'cortexcore'.","error":"ModuleNotFoundError: No module named 'cortex'"},{"fix":"Use `from cortexcore import CortexBase`.","cause":"CortexBase is not a top-level attribute; it must be imported explicitly.","error":"AttributeError: module 'cortexcore' has no attribute 'CortexBase'"},{"fix":"Ensure 'stateful' is passed only as a keyword argument: `CortexBase(cell, stateful=True)`.","cause":"Passing 'stateful' as a positional argument and keyword argument simultaneously.","error":"TypeError: CortexBase.__init__() got multiple values for argument 'stateful'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}