A fully-fleshed implementation of the Integrated Symbolic Cognition Architecture (ISCA).
This project uses Poetry for dependency management:
# Install Poetry if you don't have it
curl -sSL https://install.python-poetry.org | python -
# Install dependencies
poetry install
# Run training
poetry run python -m src.isca.train
ISCA can work with different base language models:
- Default:
moonshotai/Kimi-VL-A3B-Thinking
- An efficient MoE model with 16B total parameters, activating only 3B during inference, optimized for reasoning - Alternative:
meta-llama/Llama-2-7b-hf
- The original Llama 2 7B model
To change the base model, modify the backbone
parameter in config/default.yaml
.
The training process can be configured through the config/default.yaml
file:
# Run with the default configuration
poetry run python -m src.isca.train
# Run with a custom configuration file
poetry run python -m src.isca.train --config config/custom.yaml
Checkpoints are saved during training based on the following configuration parameters:
train.ckpt_dir
: Directory where checkpoints are saved (default: "checkpoints")train.save_every
: How often to save checkpoints in training steps (default: 2000)
The checkpoints follow the naming pattern isca_{step}.pt
where step
is the training step.
To modify the checkpoint directory or frequency:
-
Edit
config/default.yaml
:train: # Other parameters... ckpt_dir: "my_checkpoints" # Custom checkpoint directory save_every: 1000 # Save checkpoint every 1000 steps
-
Or create a custom config file with your desired settings.
You can find the latest checkpoint by looking at the file with the highest step number in the checkpoint directory:
# List all checkpoints sorted by modification time
ls -lt checkpoints/
# Or find the checkpoint with the highest step number
ls -1 checkpoints/isca_*.pt | sort -V | tail -n 1
ISCA includes a modular evaluation system that supports various types of analysis and benchmarks. The main entry point is the evaluation script in src/isca/eval/main.py
.
# Basic evaluation with a specific checkpoint
poetry run python -m src.isca.eval.main --checkpoint checkpoints/isca_10000.pt
# Run with a specific evaluation type
poetry run python -m src.isca.eval.main --checkpoint checkpoints/isca_10000.pt --eval_type symbolic
# Run with visualization
poetry run python -m src.isca.eval.main --checkpoint checkpoints/isca_10000.pt --visualize --save_plots plots/
# Evaluate on custom data
poetry run python -m src.isca.eval.main --checkpoint checkpoints/isca_10000.pt --eval_data path/to/eval/data.txt
The evaluation system supports multiple types of analysis:
basic
- Standard metrics (loss, perplexity, component-wise losses)centroids
- Attractor centroid visualization using PCAsymbolic
- Symbol assignment analysis (entropy, sparsity)operators
- Operator flow analysis (displacement, consistency)graph
- Graph structure analysismemory
- Graph memory evolution analysisroles
- Role similarity pattern analysismmlu
- MMLU benchmark evaluationmmlu_pro
- MMLU-Pro benchmark evaluationreal_bench
- REAL Bench evaluation for web agentscustom
- Custom evaluation using a specified module
Example:
# Run symbolic representation analysis
poetry run python -m src.isca.eval.main --checkpoint checkpoints/isca_10000.pt --eval_type symbolic --visualize
ISCA supports several standard benchmarks for evaluating model capabilities:
Benchmark | Description | Eval Type |
---|---|---|
MMLU | Multiple-choice questions across 57 subjects (STEM, humanities, etc.) | mmlu |
MMLU-Pro | More challenging variant with 10 options and complex reasoning tasks | mmlu_pro |
REAL Bench | Evaluates web agent capabilities on 11 website replicas | real_bench |
You can evaluate using either the main evaluation script or call the benchmark modules directly for more options:
# Using the main evaluation script
poetry run python -m src.isca.eval.main --checkpoint checkpoints/isca_10000.pt --eval_type mmlu
# Calling the benchmark module directly
poetry run python -m src.isca.eval.benchmarks.mmlu_eval --checkpoint checkpoints/isca_10000.pt \
--subjects high_school_mathematics elementary_mathematics \
--output_file results/mmlu_results.json
When calling benchmark modules directly, you have access to additional options:
--subjects
: Specific subjects to evaluate on--model_type
: Type of model to evaluate (isca, huggingface, openai, anthropic, gemini)--model_name
: Name/path of the model (for non-ISCA models)--output_file
: Path to save results as JSON
--categories
: Specific categories to evaluate on--use_cot
: Whether to use chain-of-thought reasoning (default: True)--max_new_tokens
: Maximum tokens for CoT responses (default: 200)
--websites
: Specific websites to evaluate on--task_types
: Evaluate on specific task types--max_new_tokens
: Maximum tokens per response (default: 1024)--output_dir
: Directory to save detailed results
For all benchmarks, you can specify model type (--model_type
), which supports ISCA models, HuggingFace models, and API-based models (OpenAI, Anthropic, Google Gemini).
The ISCA model includes a HuggingFace wrapper that allows it to be used with the Transformers library ecosystem.
from isca.utils.isca_hf import ISCAConfig, ISCAModelForCausalLM
# Load a trained ISCA model with Kimi-VL-A3B-Thinking backbone
config = ISCAConfig(
backbone="moonshotai/Kimi-VL-A3B-Thinking",
freeze_layers=6,
hidden_dim=3072,
num_centroids=256,
num_operator_flows=32,
flow_depth=2,
tau_role=0.07,
gamma_mem=0.95,
)
model = ISCAModelForCausalLM.from_pretrained("path/to/checkpoint", config=config)
To convert an existing ISCA checkpoint to HuggingFace format, use the conversion script:
# Convert a checkpoint
poetry run python src/isca/utils/convert_checkpoint.py \
--checkpoint checkpoints/isca_10000.pt \
--config config/default.yaml \
--output_dir ./hf_model
# Convert and push to HuggingFace Hub
poetry run python src/isca/utils/convert_checkpoint.py \
--checkpoint checkpoints/isca_10000.pt \
--config config/default.yaml \
--output_dir ./hf_model \
--push_to_hub "your-username/isca-model"
ISCA consists of the following components:
- Attractor Symbol Layer: Learnable set of centroids with differentiable assignment and EMA updates.
- Identity Tracker: Tracks persistence of the 'self' subgraph with spectral-persistence loss.
- Operator Flow: Family of learnable vector-field operators with closure regularization.
- Graph Memory: Evolving graph with decay parameter for bounded effective horizon.
- Role-Similarity Gating: Attention heads repurposed as logic edges for interpretable reasoning paths.
ISCA aligns with "latent cognition" by:
- Treating symbols as manifolds (centroids & attractor assignments)
- Implementing reasoning as flow (operator flows)
- Modeling self as a graph attractor (identity tracker)
- Using memory as an evolving graph
- Using roles to guide attention
No scaffolding or external interpreter needed - the symbolic machinery lives in the weights and activations.