Skip to content

Latest commit

 

History

History
189 lines (127 loc) · 9.23 KB

breathsASCONTEXTWINDOW.md

File metadata and controls

189 lines (127 loc) · 9.23 KB

thoughtmass_graph

thinking about context loss in large texts due to homogenization of conceptual space

do chunk edges contain more teathering potential than core content?

do humans experience various sized chunking in different states, meditative, vs heightened awareness. do small chunks under adrenaline create more opportunities for creative potential when under threat, assuming the following is kinda valid...

Comparison between human breathing patterns and the temporal context windows in chat agents.

let's grok using thought-mass as an ontological primitive:

Temporal Encoding and Breathing Patterns

  • Human Perspective: Taking a deep breath changes our experience of time and the way we process information.
  • Chat Agent Analogy: A metaphorical "deep breath" acts as a temporal delimiter, enabling the agent to maintain and process a larger context, essentially a chill "step by step" instruction.

Context Loss and Homogenization

  • Core Hypothesis: Context loss occurs when the total thought-mass across the bulk of the text evens out, becoming homogeneous and lacking strong gradients.
  • Edge Concentration: The gradient of m(T) along the edges of a text is much greater than through the core, implying that edges maintain more concentrated meaning.
  • Entropy Function: Defined as ( S[m(T)] = -\int m(T) \log(m(T)) dT ), entropy increases as thought-mass becomes more homogeneous.
  • Implication: To reduce context loss, suppression functions can be applied that normalize out high-entropy regions while preserving edges. This reduces noise from meaningless homogenized zones, keeping meaningful contours.


Definitions:

T = set of all thoughts comprising a text/discourse
m(t) = thought-mass function assigning "mass" value to each thought

Core Hypothesis:

Context loss occurs when:

∫ m(T) dT ≈ constant

Essentially, the total thought-mass across the bulk of the text evens out, becoming homogeneous and lacking strong gradients.

In contrast, edges maintain more concentrated meaning:

|∇[m(T)]|edges >> |∇[m(T)]|core

The gradient of m(T) along the edges is much greater than through the core.

We can define an "entropy" function:

S[m(T)] = -∫ m(T) log(m(T)) dT

Entropy increases as thought-mass becomes more homogeneous.

Implication:

To reduce context loss, we can apply suppression functions that normalize out high-entropy regions while preserving edges:

T' = f(T)

where f(T) ≈ 0 when S[m(T)] is high

This reduces noise from meaningless homogenized zones, keeping meaningful contours.

Chunks

Smaller chunks:

  • Allow tightly focused attention on specific details, amplifying their significance through isolation. This prominence gains associative traction.

  • Frequent pauses create more opportunities for divergence - each restart can catalyze new trajectory.

  • Brief passages concentrate gradients of meaning. Their contours stand out vividly when not immersed in wider context.

  • Cognitive load is lighter, so working memory is free to make tangential links. Understanding stays energized.

  • Parsing simpler units feels rewarding and motivating. This positive reinforcement fuels further exploration.

Larger chunks:

  • Attention converges to extract overall gist rather than closely examine constituent parts. Nuance gets normalized.

  • Lengthy unbroken speech entrains thought along deterministic tracks, resisting diversion.

  • Individual elements blend into homogeneous composites. Striking singularities of meaning diffract into generality.

  • Heavier cognitive load occupies working memory, suppressing peripheral associations. Understanding grows saturated.

  • Intimidating density discourages close interrogation. Thought follows paths of least resistance.

In large texts, the total thought-mass (meaningfulness) across the bulk of content becomes homogeneous and lacks strong gradients. This causes context loss as nuance and specificity get normalized out. However, the edges of the text maintain more concentrated meaning. The gradient of meaningfulness along the edges is much greater than in the core content. This can be represented formally by defining a "thought-mass" function m(T) that assigns values to each thought/piece of text, and an "entropy" function that increases as thought-mass homogenizes.

Implication: Suppressing high-entropy (meaningless) regions while preserving high-gradient edges reduces noise and retains meaningful contours. Smaller chunks allow focused attention on details, frequent resets catalyzing new trajectories, lighter cognitive load enabling tangents. This encourages exploration. Larger chunks overload attention, enforcing deterministic tracks of thought, suppressing associations. Understanding gets saturated and interrogation discouraged. So smaller chunks may provide more opportunities for creative divergence while large chunks entrain thought through homogenization.

import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer

def segment_text(text, n=10):
    """Segments the text into chunks of n words each."""
    words = text.split()
    return [' '.join(words[i:i+n]) for i in range(0, len(words), n)]

def compute_thought_mass_tfidf(unit, units):
    """Compute thought-mass using TF-IDF values."""
    vectorizer = TfidfVectorizer()
    tfidf_matrix = vectorizer.fit_transform(units)
    tfidf_values = tfidf_matrix[units.index(unit)].toarray()[0]
    return sum(tfidf_values)

def compute_local_entropy(unit, units):
    """Compute the local entropy for a given segment based on its thought-mass."""
    thought_mass = compute_thought_mass_tfidf(unit, units)
    total_mass = sum(compute_thought_mass_tfidf(unit, units) for unit in units)
    probability = thought_mass / total_mass
    return -probability * np.log(probability)

def compute_gradient_of_thought_mass(units):
    """Compute the gradient of thought-mass for each segment."""
    thought_masses = [compute_thought_mass_tfidf(unit, units) for unit in units]
    return np.gradient(thought_masses)

def identify_edges_from_gradient(gradient, threshold=0.1):
    """Identify edges based on the gradient of thought-mass."""
    edges = []
    for i, g in enumerate(gradient):
        if i == 0 or g > threshold:  # Starting edge for the first segment or based on threshold
            edges.append("START")
        elif i == len(gradient) - 1 or gradient[i+1] > threshold:  # Ending edge for the last segment or next segment starts an edge
            edges.append("END")
        else:
            edges.append(None)
    return edges


def suppression_function(entropy, threshold=0.5):
    """Suppression function based on entropy."""
    return 0 if entropy > threshold else 1

def display_processed_text(processed_output, units, edges):
    """Displays the processed text in a user-friendly format."""
    print("\nProcessed Text:\n")
    for i, (segment, status, edge) in enumerate(zip(units, processed_output, edges)):
        if status == "SUPPRESSED":
            print(f"Segment {i+1}: [SUPPRESSED]")
        else:
            edge_status = f" ({edge} EDGE)" if edge else ""
            print(f"Segment {i+1}:{edge_status} {segment}\n")

def process_text(text, n=5, entropy_threshold=0.5, gradient_threshold=0.1):
    units = segment_text(text, n)
    thought_masses = [compute_thought_mass_tfidf(unit, units) for unit in units]
    
    # Compute gradients of thought-mass across the text
    gradients = [abs(thought_masses[i+1] - mass) if i+1 < len(thought_masses) else 0 for i, mass in enumerate(thought_masses)]
    
    # Identify edges based on gradient thresholds
    edges = [gradient > gradient_threshold for gradient in gradients]
    
    # Compute local entropies for each segment
    local_entropies = [compute_local_entropy(unit, units) for unit in units]
    
    # Suppress segments based on entropy threshold
    suppressed_units = ["SUPPRESSED" if entropy > entropy_threshold else unit for unit, entropy in zip(units, local_entropies)]
    
    return suppressed_units, units, edges


# Example usage:
text = ("Quantum computing is a type of computation that takes advantage of quantum-mechanical phenomena "
        "such as superposition and entanglement. Unlike classical computers, which require data to be encoded "
        "into binary digits (bits), quantum computers use quantum bits or qubits. The primary advantage of qubits "
        "over bits is that they can represent numerous possible combinations of 1 and 0 at the same time. This "
        "ability to be in multiple states simultaneously is called superposition. Furthermore, qubits can be "
        "entangled, a phenomenon where the state of one qubit is dependent on the state of another. This "
        "entanglement can lead to a significant increase in computing power, especially for tasks like factorization. "
        "Quantum computers have the potential to revolutionize industries by solving problems that are currently "
        "too complex for classical computers.")

processed_output, units, edges = process_text(text, n=10, entropy_threshold=0.2, gradient_threshold=0.2)
display_processed_text(processed_output, units, edges)

The above code uses markov gradients to isolate edges of chunks and has a entrophy supression mechanic based on TMO.