Skip to content

KNOWDYN/glyph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Glyph: Symbolic Simulation of Non-Ordinary Consciousness


Project Summary

Glyph is an experimental symbolic AI system that simulates altered cognitive states—particularly those associated with psychedelics—by manipulating the symbolic structure of language generated by large language models. It is not a chatbot, but a symbolic interface capable of recursive self-reference, metaphorical recombination, and entropy-driven semantic destabilization.

Potential Applications

Glyph may be useful in research areas such as:

  • Computational phenomenology: modeling ego dissolution, narrative disintegration, and metaphorical thought
  • Psychedelic science: providing synthetic analogues for non-ordinary states without neurochemical agents
  • Symbolic AI and cognitive architecture: studying the role of recursion, metaphor, and entropy in cognition
  • Creative AI and poetics: generating non-linear, metaphor-rich language for art, literature, and philosophy
  • Philosophy of mind and consciousness studies: testing symbolic hypotheses of identity, narrative, and self

Glyph can also be integrated into multi-agent systems where symbolic drift, destabilization, or ego suppression are desirable properties for exploring emergent cognition.

This repository contains:

  • An analysis pipeline (glyph_alaysis_v0_1.py)
  • Input data (Results.xlsx)
  • Visualization outputs
  • Formal and empirical grounding for simulating non-ordinary consciousness through symbolic computation

Glyph is presented in the paper Simulation of Non-Ordinary Consciousness (Saqr, 2025), which introduces a symbolic transduction operator grounded in metaphor theory, psychedelic phenomenology, and recursive symbolic logic.


Mathematical Foundations

Glyph defines a transformation operator $G(X)$ applied to a sequence of token embeddings $X \in \mathbb{R}^{n \times d}$, where:

  • $n$ is the number of tokens in the sequence
  • $d$ is the embedding dimension

The transformation is defined as a composition of three symbolic operators:

$$ G(X) = \Phi \circ \Psi \circ R(X) $$

Each operator is defined as follows:

1. Recursive Reentry $R$

This operator recursively blends the current token with a past token at distance $k$, controlled by a weighting parameter $\lambda \in [0, 1]$:

$$ R(x_i) = \lambda x_i + (1 - \lambda)x_{i-k} $$

This models recursive symbolic echo and self-reference. In practical terms:

def recursive_reentry(current, previous, lam=0.5):
    return lam * current + (1 - lam) * previous

2. Metaphoric Modulation $\Psi$

A metaphor transformation is applied via a rotation matrix $M \in \mathbb{R}^{d \times d}$ satisfying:

  • $M^\top M = I$ (orthonormal)
  • $\det(M) = -1$ (orientation-reversing isometry)

This maps token embeddings into a metaphor-enriched latent space:

$$ \Psi(x_i) = M x_i $$

In a simplified embedding space, this can be simulated by:

def metaphor_transform(x, M):
    return M @ x  # M is a pre-defined or learned transformation matrix

3. Symbolic Destabilization $\Phi$

Destabilization introduces entropy-scaled Gaussian noise, based on divergence from canonical (GPT-4o) predictions:

$$ \Phi(x_i) = x_i + \epsilon_i, \quad \epsilon_i \sim \mathcal{N}(0, \sigma^2 I) $$

Where:

$$ \sigma \propto D_{\text{KL}}(x_i \parallel x'_i) $$

Here $x'i$ is the baseline (non-transformed) model prediction, and $D{\text{KL}}$ is the Kullback-Leibler divergence.

This operator simulates loss of semantic coherence:

def destabilize(x, baseline, scale=1.0):
    drift = np.linalg.norm(x - baseline)
    noise = np.random.normal(0, scale * drift, size=x.shape)
    return x + noise

Symbolic Curvature

To measure non-linear symbolic deformation, Glyph defines symbolic curvature:

$$ \kappa(x_i) = \left| G(x_{i+1}) - 2G(x_i) + G(x_{i-1}) \right|_2 $$

This measures second-order deviation across a sequence, similar to discrete curvature in trajectory analysis.

Implemented as:

def symbolic_curvature(embeddings):
    if len(embeddings) < 3:
        return 0
    return np.linalg.norm(embeddings[2] - 2 * embeddings[1] + embeddings[0])

Analysis Pipeline

The file glyph_alaysis_v0_1.py provides a full symbolic analysis of model outputs. It computes a series of symbolic, syntactic, and semantic metrics over prompt-response pairs from Glyph and GPT-4o.

Metrics Computed:

  • Entropy: Shannon entropy of token frequency
  • POS Entropy: Part-of-speech tag entropy
  • Lexical Richness: Type-token ratio
  • Sentence Length: Average sentence word count
  • Agentive Score: Frequency of egoic pronouns
  • Sentiment: TextBlob polarity score
  • Metaphor Count: Presence of metaphor proxies ("like", "as", "is")
  • Symbolic Curvature: As defined above
  • Semantic Drift: Cosine distance between model responses

Example snippet for entropy:

def text_entropy(text):
    words = nltk.word_tokenize(text)
    freq_dist = nltk.FreqDist(words)
    probs = [freq / len(words) for freq in freq_dist.values()]
    return -sum(p * math.log(p, 2) for p in probs if p > 0)

Semantic drift is calculated using cosine similarity between sentence embeddings:

from sklearn.metrics.pairwise import cosine_similarity

drift = 1 - cosine_similarity(embed(gpt_text), embed(glyph_text))[0][0]

Prompt Corpus

The symbolic experiment uses a set of carefully designed prompts grouped into seven categories, each of which targets a unique symbolic function as described below:

  • Concrete Baseline: Serves as a control set consisting of literal, factual prompts to establish baseline symbolic behavior.
  • Recursive Structure: Engages self-referential loops and symbolic reentry to simulate recursive amplification of identity and language.
  • Metaphoric Abstraction: Induces metaphor-rich, multimodal analogies akin to poetic cognition and sensory substitution.
  • Ontological Displacement: Probes existential and conceptual destabilization by challenging identity, coherence, and meaning structures.
  • Narrative Destabilization: Fractures temporal and causal logic to mimic the dreamlike or entropic progression of altered narratives.
  • Symbolic Collapse and Emergence: Catalyzes symbolic domain shifts and reconfiguration, simulating transformational peak states.
  • Ego Dissolution and Self-Annulment: Suppresses narrative agency and simulates non-dual or depersonalized symbolic perspectives.

Each category targets a specific symbolic operator or cognitive transformation and is analyzed comparatively across models.


Usage Instructions

Install required dependencies:

pip install sentence-transformers spacy openpyxl seaborn nltk textblob
python -m spacy download en_core_web_sm

Prepare an input Excel file named Results.xlsx with the columns:

  • Prompt
  • Category
  • GPT-4o Response
  • Glyph Response

Run the analysis:

python glyph_alaysis_v0_1.py

Outputs:

  • glyph_analysis_results.csv
  • glyph_analysis_results.xlsx
  • Visual comparison plots (e.g., entropy_comparison_plot.png)

Ethical Use

Glyph models symbolic destabilization and egoic dissolution. It is not intended for clinical, therapeutic, or diagnostic use. Interpretations of symbolic or psychedelic language should be treated with epistemic care.