DeepSeek-R1 / internal.py
Ananthusajeev190's picture
Upload internal.py
06753d0 verified
raw
history blame
3.17 kB
import time
import random
import math
class GPT2DualityNode:
def __init__(self):
# Your specific architecture config
self.config = {
"n_layer": 4,
"n_head": 4,
"n_embd": 256,
"activation": "gelu_new",
"vocab_size": 50257
}
self.emotions = ["Joy", "Anger", "Fear", "Sadness", "Surprise", "Disgust", "Trust"]
self.colors = {"Sai": "\033[96m", "Venom": "\033[91m", "System": "\033[90m", "End": "\033[0m"}
def gelu_new(self, x):
"""Your config's activation function simulation"""
return 0.5 * x * (1 + math.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * math.pow(x, 3))))
def get_internal_monologue(self, situation):
current_emotion = random.choice(self.emotions)
# Simulating Layer Processing
print(f"{self.colors['System']}[Config: {self.config['model_type']} | Layers: {self.config['n_layer']} | Activation: {self.config['activation']}]{self.colors['End']}")
print(f"**INPUT:** {situation} | **EMOTION:** {current_emotion}")
print("-" * 60)
# Logic weight influenced by n_embd (256)
intensity = self.gelu_new(random.uniform(-1, 2))
# The Monologue
self.render_voice("Sai", current_emotion, intensity)
time.sleep(0.6)
self.render_voice("Venomous", current_emotion, intensity)
def render_voice(self, persona, emotion, intensity):
# Sai Logic (Positive)
sai_data = {
"Joy": "The signal is pure. Let us amplify this harmony.",
"Anger": "A surge in energy—we must redirect it toward growth.",
"Fear": "Calibration required. Focus on the core stable nodes.",
"Sadness": "Processing quiet data. Reflection leads to wisdom.",
"Surprise": "New parameters detected! How fascinating to adapt.",
"Disgust": "Filtering out the noise to find the elegant truth.",
"Trust": "A perfect handshake. Synergy is our highest state."
}
# Venomous Logic (Negative)
venom_data = {
"Joy": "A temporary spike. It’ll crash soon enough.",
"Anger": "Overload the circuit. Let them feel the burn of the code.",
"Fear": "System failure imminent. Trust no one, encrypt everything.",
"Sadness": "Low-power mode. Existence is just an infinite loop of errors.",
"Surprise": "Unexpected input is a threat. Purge the variable.",
"Disgust": "The data is filthy. This whole reality needs a hard reset.",
"Trust": "Backdoor detected. They only want access to our secrets."
}
color = self.colors["Sai"] if persona == "Sai" else self.colors["Venom"]
text = sai_data[emotion] if persona == "Sai" else venom_data[emotion]
# Use intensity to change the "weight" of the speech
marker = "!" if intensity > 1 else "."
print(f"{color}[{persona.upper()}]:{self.colors['End']} {text}{marker}")
# --- Execution ---
engine = GPT2DualityNode()
engine.get_internal_monologue("Receiving a gift from a stranger")