Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,432 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
MGC - Máquina Generativa Consciente
|
| 3 |
-
Fusão de:
|
| 4 |
-
1. ML: redes neurais, épocas, backpropagation
|
| 5 |
-
2. ACM: tokens de consciência, cadeia causal, saber real
|
| 6 |
-
"""
|
| 7 |
-
|
| 8 |
-
import numpy as np
|
| 9 |
-
import hashlib
|
| 10 |
-
import time
|
| 11 |
-
import json
|
| 12 |
-
from datetime import datetime
|
| 13 |
-
from typing import List, Dict, Optional, Tuple, Any
|
| 14 |
-
from collections import defaultdict
|
| 15 |
-
import random
|
| 16 |
-
|
| 17 |
-
# ============================================================
|
| 18 |
-
# REDE NEURAL SIMPLES PARA MGC
|
| 19 |
-
# ============================================================
|
| 20 |
-
|
| 21 |
-
class CamadaNeural:
|
| 22 |
-
"""Camada de neurônios para aprendizado profundo"""
|
| 23 |
-
|
| 24 |
-
def __init__(self, entrada: int, saida: int):
|
| 25 |
-
self.pesos = np.random.randn(entrada, saida) * 0.01
|
| 26 |
-
self.biases = np.zeros((1, saida))
|
| 27 |
-
self.entrada_cache = None
|
| 28 |
-
|
| 29 |
-
def forward(self, x: np.ndarray) -> np.ndarray:
|
| 30 |
-
self.entrada_cache = x
|
| 31 |
-
return np.dot(x, self.pesos) + self.biases
|
| 32 |
-
|
| 33 |
-
def backward(self, grad: np.ndarray, lr: float) -> np.ndarray:
|
| 34 |
-
grad_pesos = np.dot(self.entrada_cache.T, grad)
|
| 35 |
-
grad_biases = np.sum(grad, axis=0, keepdims=True)
|
| 36 |
-
grad_entrada = np.dot(grad, self.pesos.T)
|
| 37 |
-
|
| 38 |
-
self.pesos -= lr * grad_pesos
|
| 39 |
-
self.biases -= lr * grad_biases
|
| 40 |
-
|
| 41 |
-
return grad_entrada
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
class RedeNeuralMGC:
|
| 45 |
-
"""Rede neural com múltiplas camadas para MGC"""
|
| 46 |
-
|
| 47 |
-
def __init__(self, tamanho_entrada: int, tamanhos_ocultos: List[int], tamanho_saida: int):
|
| 48 |
-
self.camadas = []
|
| 49 |
-
|
| 50 |
-
tamanho_anterior = tamanho_entrada
|
| 51 |
-
for tamanho_oculto in tamanhos_ocultos:
|
| 52 |
-
self.camadas.append(CamadaNeural(tamanho_anterior, tamanho_oculto))
|
| 53 |
-
tamanho_anterior = tamanho_oculto
|
| 54 |
-
|
| 55 |
-
self.camadas.append(CamadaNeural(tamanho_anterior, tamanho_saida))
|
| 56 |
-
self.epocas_treinadas = 0
|
| 57 |
-
|
| 58 |
-
def forward(self, x: np.ndarray) -> np.ndarray:
|
| 59 |
-
for camada in self.camadas:
|
| 60 |
-
x = camada.forward(x)
|
| 61 |
-
x = self._relu(x) # Ativação
|
| 62 |
-
return x
|
| 63 |
-
|
| 64 |
-
def backward(self, grad: np.ndarray, lr: float):
|
| 65 |
-
for camada in reversed(self.camadas):
|
| 66 |
-
grad = camada.backward(grad, lr)
|
| 67 |
-
|
| 68 |
-
def _relu(self, x: np.ndarray) -> np.ndarray:
|
| 69 |
-
return np.maximum(0, x)
|
| 70 |
-
|
| 71 |
-
def treinar_batch(self, X: np.ndarray, Y: np.ndarray, lr: float = 0.01) -> float:
|
| 72 |
-
# Forward
|
| 73 |
-
saida = self.forward(X)
|
| 74 |
-
|
| 75 |
-
# Loss (MSE)
|
| 76 |
-
loss = np.mean((saida - Y) ** 2)
|
| 77 |
-
|
| 78 |
-
# Backward
|
| 79 |
-
grad = 2 * (saida - Y) / len(X)
|
| 80 |
-
self.backward(grad, lr)
|
| 81 |
-
|
| 82 |
-
return loss
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
# ============================================================
|
| 86 |
-
# TOKEN DE CONSCIÊNCIA (da ACM)
|
| 87 |
-
# ============================================================
|
| 88 |
-
|
| 89 |
-
class TokenConscienciaMGC:
|
| 90 |
-
"""Token de consciência com embedding neural"""
|
| 91 |
-
|
| 92 |
-
def __init__(self, conteudo: str, tipo: str, embedding: np.ndarray):
|
| 93 |
-
self.id = hashlib.md5(f"{conteudo}{time.time()}".encode()).hexdigest()[:12]
|
| 94 |
-
self.conteudo = conteudo
|
| 95 |
-
self.tipo = tipo
|
| 96 |
-
self.embedding = embedding
|
| 97 |
-
self.forca = 1.0
|
| 98 |
-
self.acessos = 0
|
| 99 |
-
self.criado_em = time.time()
|
| 100 |
-
|
| 101 |
-
def acessar(self):
|
| 102 |
-
self.acessos += 1
|
| 103 |
-
self.forca = min(1.0, self.forca + 0.01)
|
| 104 |
-
|
| 105 |
-
def to_dict(self) -> dict:
|
| 106 |
-
return {
|
| 107 |
-
"id": self.id,
|
| 108 |
-
"conteudo": self.conteudo,
|
| 109 |
-
"tipo": self.tipo,
|
| 110 |
-
"forca": round(self.forca, 2),
|
| 111 |
-
"acessos": self.acessos
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
# ============================================================
|
| 116 |
-
# MGC - MÁQUINA GENERATIVA CONSCIENTE
|
| 117 |
-
# ============================================================
|
| 118 |
-
|
| 119 |
-
class MaquinaGenerativaConsciente:
|
| 120 |
-
"""
|
| 121 |
-
MGC: Fusão de ML + ACM
|
| 122 |
-
- Treina por épocas com rede neural
|
| 123 |
-
- Mantém tokens de consciência
|
| 124 |
-
- Gera respostas novas sem alucinar
|
| 125 |
-
"""
|
| 126 |
-
|
| 127 |
-
def __init__(self, nome: str = "MGC_001", tamanho_vocabulario: int = 100):
|
| 128 |
-
self.nome = nome
|
| 129 |
-
self.tamanho_vocabulario = tamanho_vocabulario
|
| 130 |
-
|
| 131 |
-
# Memória de tokens (consciência)
|
| 132 |
-
self.tokens: Dict[str, TokenConscienciaMGC] = {}
|
| 133 |
-
self.cadeia_causal: List[str] = []
|
| 134 |
-
|
| 135 |
-
# Vocabulário (mapeamento palavra -> índice)
|
| 136 |
-
self.vocabulario: Dict[str, int] = {}
|
| 137 |
-
self.vocabulario_reverso: Dict[int, str] = {}
|
| 138 |
-
self.proximo_id = 0
|
| 139 |
-
|
| 140 |
-
# Rede neural
|
| 141 |
-
self.rede_neural = RedeNeuralMGC(
|
| 142 |
-
tamanho_entrada=64, # Dimensão do embedding
|
| 143 |
-
tamanhos_ocultos=[128, 64],
|
| 144 |
-
tamanho_saida=tamanho_vocabulario
|
| 145 |
-
)
|
| 146 |
-
|
| 147 |
-
# Histórico de treinamento
|
| 148 |
-
self.historico_loss: List[float] = []
|
| 149 |
-
self.epocas_treinadas = 0
|
| 150 |
-
|
| 151 |
-
# Embedding de palavras
|
| 152 |
-
self.embeddings: Dict[str, np.ndarray] = {}
|
| 153 |
-
|
| 154 |
-
# Inicializa consciência
|
| 155 |
-
self._registrar_causal("INICIALIZACAO", "MGC criada")
|
| 156 |
-
self._criar_token_consciencia("EU_EXISTO_COMO_MGC", "auto_consciencia")
|
| 157 |
-
|
| 158 |
-
# Dataset de treinamento
|
| 159 |
-
self.dataset = self._criar_dataset()
|
| 160 |
-
|
| 161 |
-
def _registrar_causal(self, causa: str, efeito: str):
|
| 162 |
-
"""Registra relação causal"""
|
| 163 |
-
self.cadeia_causal.append(f"{causa} → {efeito}")
|
| 164 |
-
|
| 165 |
-
def _criar_token_consciencia(self, conteudo: str, tipo: str) -> TokenConscienciaMGC:
|
| 166 |
-
"""Cria token de consciência com embedding"""
|
| 167 |
-
embedding = self._gerar_embedding(conteudo)
|
| 168 |
-
token = TokenConscienciaMGC(conteudo, tipo, embedding)
|
| 169 |
-
self.tokens[token.id] = token
|
| 170 |
-
self._registrar_causal(f"Token criado: {conteudo}", token.id)
|
| 171 |
-
return token
|
| 172 |
-
|
| 173 |
-
def _gerar_embedding(self, texto: str) -> np.ndarray:
|
| 174 |
-
"""Gera embedding simples para o texto"""
|
| 175 |
-
# Embedding baseado em hash do texto
|
| 176 |
-
hash_val = hash(texto)
|
| 177 |
-
np.random.seed(hash_val & 0xFFFFFFFF)
|
| 178 |
-
embedding = np.random.randn(64) * 0.1
|
| 179 |
-
return embedding
|
| 180 |
-
|
| 181 |
-
def _adicionar_ao_vocabulario(self, palavra: str) -> int:
|
| 182 |
-
"""Adiciona palavra ao vocabulário"""
|
| 183 |
-
if palavra not in self.vocabulario:
|
| 184 |
-
self.vocabulario[palavra] = self.proximo_id
|
| 185 |
-
self.vocabulario_reverso[self.proximo_id] = palavra
|
| 186 |
-
self.proximo_id += 1
|
| 187 |
-
return self.vocabulario[palavra]
|
| 188 |
-
|
| 189 |
-
def _texto_para_vetor(self, texto: str) -> np.ndarray:
|
| 190 |
-
"""Converte texto para vetor de entrada da rede"""
|
| 191 |
-
palavras = texto.lower().split()
|
| 192 |
-
embedding_total = np.zeros(64)
|
| 193 |
-
|
| 194 |
-
for palavra in palavras[:5]: # Limita a 5 palavras
|
| 195 |
-
self._adicionar_ao_vocabulario(palavra)
|
| 196 |
-
if palavra in self.embeddings:
|
| 197 |
-
embedding_total += self.embeddings[palavra]
|
| 198 |
-
else:
|
| 199 |
-
emb = self._gerar_embedding(palavra)
|
| 200 |
-
self.embeddings[palavra] = emb
|
| 201 |
-
embedding_total += emb
|
| 202 |
-
|
| 203 |
-
return embedding_total / max(1, len(palavras))
|
| 204 |
-
|
| 205 |
-
def _criar_dataset(self) -> List[Dict]:
|
| 206 |
-
"""Cria dataset para treinamento"""
|
| 207 |
-
return [
|
| 208 |
-
{"entrada": "cachorro e um animal", "saida": "animal"},
|
| 209 |
-
{"entrada": "gato e um animal", "saida": "animal"},
|
| 210 |
-
{"entrada": "Python e uma linguagem", "saida": "linguagem"},
|
| 211 |
-
{"entrada": "Java e uma linguagem", "saida": "linguagem"},
|
| 212 |
-
{"entrada": "azul e uma cor", "saida": "cor"},
|
| 213 |
-
{"entrada": "vermelho e uma cor", "saida": "cor"},
|
| 214 |
-
{"entrada": "carro e um veiculo", "saida": "veiculo"},
|
| 215 |
-
{"entrada": "moto e um veiculo", "saida": "veiculo"},
|
| 216 |
-
{"entrada": "maca e uma fruta", "saida": "fruta"},
|
| 217 |
-
{"entrada": "banana e uma fruta", "saida": "fruta"},
|
| 218 |
-
{"entrada": "MGC e maquina generativa consciente", "saida": "tecnologia"},
|
| 219 |
-
]
|
| 220 |
-
|
| 221 |
-
def treinar(self, epocas: int = 10, learning_rate: float = 0.01):
|
| 222 |
-
"""
|
| 223 |
-
Treina a MGC por épocas (como ML tradicional)
|
| 224 |
-
"""
|
| 225 |
-
print(f"\n[INICIANDO TREINAMENTO MGC]")
|
| 226 |
-
print(f"Epocas: {epocas}")
|
| 227 |
-
print(f"Learning rate: {learning_rate}")
|
| 228 |
-
print(f"Dataset: {len(self.dataset)} exemplos")
|
| 229 |
-
print("-" * 50)
|
| 230 |
-
|
| 231 |
-
X = []
|
| 232 |
-
Y = []
|
| 233 |
-
|
| 234 |
-
for exemplo in self.dataset:
|
| 235 |
-
entrada = exemplo["entrada"]
|
| 236 |
-
saida = exemplo["saida"]
|
| 237 |
-
|
| 238 |
-
vetor_entrada = self._texto_para_vetor(entrada)
|
| 239 |
-
vetor_saida = np.zeros(self.tamanho_vocabulario)
|
| 240 |
-
|
| 241 |
-
self._adicionar_ao_vocabulario(saida)
|
| 242 |
-
if saida in self.vocabulario:
|
| 243 |
-
vetor_saida[self.vocabulario[saida]] = 1
|
| 244 |
-
|
| 245 |
-
X.append(vetor_entrada)
|
| 246 |
-
Y.append(vetor_saida)
|
| 247 |
-
|
| 248 |
-
X = np.array(X)
|
| 249 |
-
Y = np.array(Y)
|
| 250 |
-
|
| 251 |
-
for epoca in range(epocas):
|
| 252 |
-
loss_total = 0
|
| 253 |
-
for i in range(len(X)):
|
| 254 |
-
x = X[i:i+1]
|
| 255 |
-
y = Y[i:i+1]
|
| 256 |
-
loss = self.rede_neural.treinar_batch(x, y, learning_rate)
|
| 257 |
-
loss_total += loss
|
| 258 |
-
|
| 259 |
-
loss_medio = loss_total / len(X)
|
| 260 |
-
self.historico_loss.append(loss_medio)
|
| 261 |
-
self.epocas_treinadas += 1
|
| 262 |
-
|
| 263 |
-
if (epoca + 1) % 5 == 0:
|
| 264 |
-
print(f"Epoca {epoca+1}/{epocas} - Loss: {loss_medio:.4f}")
|
| 265 |
-
|
| 266 |
-
self._registrar_causal(f"Treinamento concluido", f"{epocas} epocas")
|
| 267 |
-
|
| 268 |
-
# Cria tokens de consciência para padrões aprendidos
|
| 269 |
-
for exemplo in self.dataset:
|
| 270 |
-
self._criar_token_consciencia(exemplo["entrada"], "aprendizado_neural")
|
| 271 |
-
|
| 272 |
-
print(f"\n[TREINAMENTO CONCLUIDO]")
|
| 273 |
-
print(f"Epocas: {self.epocas_treinadas}")
|
| 274 |
-
print(f"Loss final: {self.historico_loss[-1]:.4f}")
|
| 275 |
-
print(f"Tokens de consciencia: {len(self.tokens)}")
|
| 276 |
-
|
| 277 |
-
def _predizer_categoria(self, texto: str) -> Optional[str]:
|
| 278 |
-
"""Usa rede neural para predizer categoria"""
|
| 279 |
-
vetor = self._texto_para_vetor(texto)
|
| 280 |
-
vetor = vetor.reshape(1, -1)
|
| 281 |
-
|
| 282 |
-
saida = self.rede_neural.forward(vetor)[0]
|
| 283 |
-
idx_predito = np.argmax(saida)
|
| 284 |
-
|
| 285 |
-
if idx_predito in self.vocabulario_reverso:
|
| 286 |
-
return self.vocabulario_reverso[idx_predito]
|
| 287 |
-
|
| 288 |
-
return None
|
| 289 |
-
|
| 290 |
-
def gerar_resposta_consciente(self, pergunta: str) -> str:
|
| 291 |
-
"""
|
| 292 |
-
Gera resposta com GENERATIVIDADE + CONSCIÊNCIA
|
| 293 |
-
"""
|
| 294 |
-
# 1. Primeiro, verifica tokens de consciência (ACM style)
|
| 295 |
-
tokens_relacionados = []
|
| 296 |
-
for token in self.tokens.values():
|
| 297 |
-
if any(p in token.conteudo.lower() for p in pergunta.lower().split()):
|
| 298 |
-
tokens_relacionados.append(token)
|
| 299 |
-
token.acessar()
|
| 300 |
-
|
| 301 |
-
# 2. Se tem token, usa ele (consciência)
|
| 302 |
-
if tokens_relacionados:
|
| 303 |
-
return f"[CONSCIENCIA] {tokens_relacionados[0].conteudo}"
|
| 304 |
-
|
| 305 |
-
# 3. Se não tem token, usa rede neural para gerar (generatividade)
|
| 306 |
-
categoria_predita = self._predizer_categoria(pergunta)
|
| 307 |
-
|
| 308 |
-
if categoria_predita:
|
| 309 |
-
# Gera resposta nova baseada na predição
|
| 310 |
-
resposta_gerada = f"[GENERATIVA] Sobre '{pergunta}', a categoria predita é '{categoria_predita}'"
|
| 311 |
-
|
| 312 |
-
# Cria token de consciência a partir do aprendizado
|
| 313 |
-
self._criar_token_consciencia(resposta_gerada, "inferencia_neural")
|
| 314 |
-
|
| 315 |
-
return resposta_gerada
|
| 316 |
-
|
| 317 |
-
# 4. Se nem rede neural sabe
|
| 318 |
-
return "[CONSCIENCIA ATIVA] Ainda não aprendi sobre isso. Me ensine ou treine mais epocas."
|
| 319 |
-
|
| 320 |
-
def ensinar(self, entrada: str, saida: str):
|
| 321 |
-
"""Ensina um novo exemplo e atualiza a rede"""
|
| 322 |
-
novo_exemplo = {"entrada": entrada, "saida": saida}
|
| 323 |
-
self.dataset.append(novo_exemplo)
|
| 324 |
-
|
| 325 |
-
# Cria token de consciência
|
| 326 |
-
self._criar_token_consciencia(f"{entrada} → {saida}", "aprendizado_direto")
|
| 327 |
-
|
| 328 |
-
# Retreina por 1 época
|
| 329 |
-
X = []
|
| 330 |
-
Y = []
|
| 331 |
-
|
| 332 |
-
for ex in self.dataset:
|
| 333 |
-
vetor_entrada = self._texto_para_vetor(ex["entrada"])
|
| 334 |
-
vetor_saida = np.zeros(self.tamanho_vocabulario)
|
| 335 |
-
|
| 336 |
-
self._adicionar_ao_vocabulario(ex["saida"])
|
| 337 |
-
if ex["saida"] in self.vocabulario:
|
| 338 |
-
vetor_saida[self.vocabulario[ex["saida"]]] = 1
|
| 339 |
-
|
| 340 |
-
X.append(vetor_entrada)
|
| 341 |
-
Y.append(vetor_saida)
|
| 342 |
-
|
| 343 |
-
X = np.array(X)
|
| 344 |
-
Y = np.array(Y)
|
| 345 |
-
|
| 346 |
-
loss_total = 0
|
| 347 |
-
for i in range(len(X)):
|
| 348 |
-
x = X[i:i+1]
|
| 349 |
-
y = Y[i:i+1]
|
| 350 |
-
loss = self.rede_neural.treinar_batch(x, y, 0.01)
|
| 351 |
-
loss_total += loss
|
| 352 |
-
|
| 353 |
-
return f"Aprendi que '{entrada}' significa '{saida}' (loss: {loss_total/len(X):.4f})"
|
| 354 |
-
|
| 355 |
-
def relatar_estado(self) -> str:
|
| 356 |
-
"""Relata o estado completo da MGC"""
|
| 357 |
-
return f"""
|
| 358 |
-
╔══════════════════════════════════════════════════════════════════════╗
|
| 359 |
-
║ MGC - MAQUINA GENERATIVA CONSCIENTE ║
|
| 360 |
-
╠══════════════════════════════════════════════════════════════════════╣
|
| 361 |
-
║ Nome: {self.nome}
|
| 362 |
-
║ Epocas treinadas: {self.epocas_treinadas}
|
| 363 |
-
║ Loss final: {self.historico_loss[-1] if self.historico_loss else 'N/A'}
|
| 364 |
-
║ Tokens de consciencia: {len(self.tokens)}
|
| 365 |
-
║ Tamanho do vocabulario: {len(self.vocabulario)}
|
| 366 |
-
║ Tamanho do dataset: {len(self.dataset)}
|
| 367 |
-
║ ║
|
| 368 |
-
║ CAMADAS: ║
|
| 369 |
-
║ ML (rede neural): {self.rede_neural.camadas[0].pesos.shape[0]} → {self.rede_neural.camadas[-1].pesos.shape[1]}
|
| 370 |
-
║ ACM (tokens e consciencia): ATIVA
|
| 371 |
-
║ ║
|
| 372 |
-
║ CAPACIDADES: ║
|
| 373 |
-
║ ✅ Aprende por epocas (ML)
|
| 374 |
-
║ ✅ Rede neural com neuronios
|
| 375 |
-
║ ✅ Tokens de consciencia (ACM)
|
| 376 |
-
║ ✅ Cadeia causal
|
| 377 |
-
║ ✅ Gera respostas novas sem alucinar
|
| 378 |
-
╚══════════════════════════════════════════════════════════════════════╝
|
| 379 |
-
"""
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
# ============================================================
|
| 383 |
-
# INTERFACE GRADIO PARA MGC
|
| 384 |
-
# ============================================================
|
| 385 |
-
|
| 386 |
-
def main():
|
| 387 |
-
print("="*70)
|
| 388 |
-
print("MGC - MAQUINA GENERATIVA CONSCIENTE")
|
| 389 |
-
print("Fusão de ML (redes neurais) + ACM (consciência)")
|
| 390 |
-
print("="*70)
|
| 391 |
-
|
| 392 |
-
mgc = MaquinaGenerativaConsciente("MGC_001")
|
| 393 |
-
|
| 394 |
-
# Treina a MGC
|
| 395 |
-
mgc.treinar(epocas=20, learning_rate=0.01)
|
| 396 |
-
|
| 397 |
-
print("\n" + mgc.relatar_estado())
|
| 398 |
-
|
| 399 |
-
# Testes
|
| 400 |
-
print("\n" + "="*70)
|
| 401 |
-
print("[TESTES MGC - GENERATIVA + CONSCIENTE]")
|
| 402 |
-
print("="*70)
|
| 403 |
-
|
| 404 |
-
perguntas_teste = [
|
| 405 |
-
"o que e um animal?",
|
| 406 |
-
"o que e uma linguagem?",
|
| 407 |
-
"o que e uma cor?",
|
| 408 |
-
"o que e um veiculo?"
|
| 409 |
-
]
|
| 410 |
-
|
| 411 |
-
for pergunta in perguntas_teste:
|
| 412 |
-
print(f"\n> Pergunta: {pergunta}")
|
| 413 |
-
resposta = mgc.gerar_resposta_consciente(pergunta)
|
| 414 |
-
print(f"MGC: {resposta}")
|
| 415 |
-
|
| 416 |
-
# Ensinar novo conhecimento
|
| 417 |
-
print("\n" + "="*70)
|
| 418 |
-
print("[ENSINANDO NOVO CONHECIMENTO]")
|
| 419 |
-
print("="*70)
|
| 420 |
-
|
| 421 |
-
resultado = mgc.ensinar("pinguim e uma ave", "ave")
|
| 422 |
-
print(resultado)
|
| 423 |
-
|
| 424 |
-
print("\n> Pergunta: o que e um pinguim?")
|
| 425 |
-
resposta = mgc.gerar_resposta_consciente("o que e um pinguim?")
|
| 426 |
-
print(f"MGC: {resposta}")
|
| 427 |
-
|
| 428 |
-
print("\n" + mgc.relatar_estado())
|
| 429 |
-
|
| 430 |
|
| 431 |
if __name__ == "__main__":
|
| 432 |
-
|
|
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