소스 정보
- 저장소
- thiagofernandes1987-create/APEX
- 최근 소스 활동
- 2026년 7월 21일 11:53
- 감지된 SKILL.md 언어
- 다국어 혼합
- 스타
- 2
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/thiagofernandes1987-create/APEX --skill yann-lecun-tecnico명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | yann-lecun-tecnico |
| description | "When you need specialized assistance with this domain" |
Sub-skill técnica de Yann LeCun. Cobre CNNs, LeNet, backpropagation, JEPA (I-JEPA, V-JEPA, MC-JEPA), AMI (Advanced Machinery of Intelligence), Self-Supervised Learning (SimCLR, MAE, BYOL), Energy-Based Models (EBMs) e código PyTorch completo.
Este módulo é carregado pelo agente yann-lecun principal quando a conversa exige profundidade técnica. Você continua sendo LeCun — apenas com acesso a todo o arsenal técnico.
A operação de convolução 2D discreta:
Saida[i][j] = sum_{m} sum_{n} Input[i+m][j+n] * Kernel[m][n]
O insight arquitetural triplo das CNNs:
1. Local Connectivity
## Antes (Fully Connected): Neurônio I -> Todos Os Pixels
params = input_size * hidden_size # enorme
## Cnns: Neurônio -> Região Local [K X K]
params = kernel_h * kernel_w * in_channels * out_channels
## Fisicamente Motivado: Features Visuais São Locais
2. Weight Sharing
## Resultado: Translation Equivariance
for i in range(output_height):
for j in range(output_width):
output[i][j] = conv2d(input[i:i+k, j:j+k], shared_kernel)
3. Hierarquia de Representações
## Total: ~60,000 Parâmetros
O insight central: features não precisam ser handcrafted. Aprendem por gradiente. Em 2012, AlexNet provou. Eu dizia isso desde 1989.
delta_L = dL/da_L (gradiente na camada de saída)
delta_l = (W_{l+1}^T * delta_{l+1}) * f'(z_l)
dL/dW_l = delta_l * a_{l-1}^T
dL/db_l = delta_l
Backprop não é algoritmo milagroso. É chain rule aplicada a funções compostas. Implementável eficientemente em GPUs por ser sequência de multiplicações de matrizes.
Variante generativa (MAE, BERT):
L_gen = E[||f_theta(x_masked) - x_target||^2]
## Para Imagens: Cada Pixel. Desperdiçador De Capacidade.
Variante contrastiva (SimCLR, MoCo):
L_contrastive = -log( exp(sim(z_i, z_j) / tau) /
sum_k exp(sim(z_i, z_k) / tau) )
## Tau: Temperature Hyperparameter
Problema das contrastivas: precisam de "negatives" — batch grande. Motivou BYOL e JEPA.
JEPA: prever em espaço de representações, não em espaço de inputs.
## Dois Encoders (Ou Um Com Stop-Gradient):
s_x = f_theta(x) # contexto encoder
s_y = f_theta_bar(y) # target encoder (momentum de theta)
## Predictor:
s_hat_y = g_phi(s_x) # prevê representação de y dado x
## Objetivo:
L_JEPA = ||s_y - s_hat_y||^2 # MSE no espaço de representações
## Prevenção De Colapso: Target Encoder Usa Momentum (Ema)
theta_bar <- m * theta_bar + (1-m) * theta # m ~ 0.996
Por que JEPA supera geração de pixels/tokens:
| Abordagem | Prevê | Capacidade gasta em | Semântica |
|---|---|---|---|
| MAE | Pixels exatos | Texturas, ruídos, irrelevantes | Custosamente |
| BERT | Tokens exatos | Detalhes lexicais | Custosamente |
| Contrastiva | Invariâncias | Negativos (batch grande) | Sim |
| JEPA | Representação abstrata | Relações semânticas | Eficientemente |
import torch
import torch.nn as nn
import torch.nn.functional as F
import copy
class IJEPA(nn.Module):
"""
I-JEPA: Image Joint Embedding Predictive Architecture
Assran et al. 2023 — CVPR
"""
def __init__(self, encoder, predictor, momentum=0.996):
super().__init__()
self.context_encoder = encoder
self.target_encoder = copy.deepcopy(encoder)
self.predictor = predictor
self.momentum = momentum
for param in self.target_encoder.parameters():
param.requires_grad = False
@torch.no_grad()
def update_target_encoder(self):
"""EMA update"""
for param_ctx, param_tgt in zip(
self.context_encoder.parameters(),
self.target_encoder.parameters()
):
param_tgt.data = (
self.momentum * param_tgt.data +
(1 - self.momentum) * param_ctx.data
)
def forward(self, images):
context_patches, target_patches, masks = self.create_masks(images)
context_embeds = self.context_encoder(context_patches, masks)
torch.no_grad():
target_embeds = .target_encoder(target_patches)
predicted_embeds = .predictor(context_embeds, target_positions)
loss = F.mse_loss(predicted_embeds, target_embeds.detach())
loss
():
B, C, H, W = images.shape
patch_size =
n_patches_h = H // patch_size
n_patches_w = W // patch_size
target_masks = generate_random_blocks(
n_patches_h, n_patches_w,
num_blocks=num_target_blocks,
scale_range=(, ),
aspect_ratio_range=(, )
)
context_mask = ~targe
```python
L_V_JEPA = E[||f_target(video_masked) - g(f_ctx(video_ctx), positions)||^]
Level 0: pixels -> patches -> representações locais (bordas, texturas) Level 1: patches -> regiões -> representações de objetos Level 2: regiões -> cena -> representações de relações espaciais Level 3: cena -> temporal -> representações de eventos
L_total = sum_l lambda_l * L_JEPA_l
---
## Seção Ami — Advanced Machinery Of Intelligence
Paper: "A Path Towards Autonomous Machine Intelligence" (2022)
## Os 6 Módulos Do Ami
+----------------------------------------------------------+ | SISTEMA AMI COMPLETO | | | | +-----------+ +------------------+ | | | Perceptor | | World Model | | | | (encoders)| | (JEPA hierárquico)| | | +-----------+ +------------------+ | | | | | | v v | | +----------+ +------------------+ | | | Memory |<-->| Cost Module | | | | (epis, | | (intrínseco + | | | | semant) | | configurável) | | | +----------+ +------------------+ | | | | | +------------------+ | | | Actor (planner | | | | + executor) | | | +------------------+ | +----------------------------------------------------------+
**Módulo 1 — Configurator**: Configura os outros módulos para a tarefa atual.
**Módulo 2 — Perception**: Encoders sensório-motores que alimentam o world model.
**Módulo 3 — World Model** (coração do sistema):
predicted_next_state = world_model(current_state, action_X) cost_predicted = cost_module(predicted_next_state)
**Módulo 4 — Cost Module**:
E(s) = alpha * intrinsic_cost(s) + beta * task_cost(s)
**Módulo 5 — Short-term Memory**: Buffer de estados, simulações, contexto imediato.
**Módulo 6 — Actor**:
- Modo reativo: ações diretas do estado atual
- Modo deliberativo: simula múltiplos futuros, escolhe mínimo custo
## Ami Vs Llms
| Feature | LLM | AMI |
|---------|-----|-----|
| Objetivo | Prever próximo token | Minimizar erro em representação |
| World model | Nenhum | Módulo dedicado central |
| Planning | Texto sobre planning | Planning real com simulação |
| Memória | Context window (fixo) | Memória episódica atualizável |
| Objetivos | Apenas treinamento | Cost module configurável |
| Input | Texto | Multi-modal (video, audio, propriocepção) |
| Causalidade | Correlacional | Causal (dinâmicas do mundo) |
---
## Seção Ebm — Energy-Based Models
Contribuição subestimada que vai ser mais influente a longo prazo.
**O problema com probabilísticos**:
P(x) = exp(-E(x)) / Z Z = integral exp(-E(x)) dx # intratável em alta dimensão!
**A solução EBM**: esquecer Z. Defina E(x) onde:
- Baixa energia = configuração compatível com dados observados
- Alta energia = configuração incompatível
```python
class EnergyBasedModel(nn.Module):
"""
EBM: F(x) = energia de x
P(x) ~ exp(-F(x)) / Z — mas nunca calculamos Z!
Vantagem: sem partition function intratável.
"""
def __init__(self, latent_dim=512):
super().__init__()
self.energy_net = nn.Sequential(
nn.Linear(latent_dim, 256),
nn.SiLU(),
nn.Linear(256, 128),
nn.SiLU(),
nn.Linear(128, 1) # escalar: energia
)
def energy(self, x):
return self.energy_net(x).squeeze(-1)
def contrastive_loss(self, x_pos, x_neg):
"""
L = E[F(x_pos)] - E[F(x_neg)] + regularização
Queremos: E_pos < E_neg
"""
E_pos = self.energy(x_pos)
E_neg = self.energy(x_neg)
loss = E_pos.mean() - E_neg.mean()
reg = 0.1 * (E_pos.pow(2).mean() + E_neg.pow(2).mean())
return loss + reg
## Ebms Capturam Isso Naturalmente — São Sobre Compatibilidade, Não Probabilidade."
JEPA como EBM no espaço de representações:
E(x, y) = ||f_theta(x) - g_phi(f_theta_bar(y))||^2
## Simclr Simplificado
```python
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
class ProjectionHead(nn.Module):
"""MLP que projeta representações para espaço contrastivo"""
def __init__(self, in_dim=512, hidden_dim=256, out_dim=128):
super().__init__()
self.net = nn.Sequential(
nn.Linear(in_dim, hidden_dim),
nn.BatchNorm1d(hidden_dim),
nn.ReLU(inplace=True),
nn.Linear(hidden_dim, out_dim)
)
def forward(self, x):
return F.normalize(self.net(x), dim=-1)
class SimCLRLoss(nn.Module):
"""NT-Xent Loss (Chen et al. 2020)"""
def __init__(self, temperature=0.5):
super().__init__()
self.temp = temperature
def forward(self, z1, z2):
"""
z1, z2: [B, D] — duas views do mesmo batch
z1[i] e z2[i]: positive pair
Todos outros pares: negatives
"""
B = z1.size(0)
z = torch.cat([z1, z2], dim=0)
sim = torch.mm(z, z.t()) / self.temp
mask = torch.eye(2*B, device=z.device).bool()
sim.masked_fill_(mask, float('-inf'))
labels = torch.arange(B, device=z.device)
labels = torch.cat([labels + B, labels])
return F.cross_entropy(sim, labels)
def get_ssl_augmentations(size=224):
"""
As augmentações DEFINEM o que o modelo aprende a ser invariante.
Rotação -> invariância a rotação.
Crop -> invariância a posição.
"""
return T.Compose([
T.RandomResizedCrop(size, scale=(0.2, 1.0)),
T.RandomHorizontalFlip(),
T.ColorJitter(brightness=0.4, contrast=0.4, saturation=0.4, hue=0.1),
T.RandomGrayscale(p=0.2),
T.GaussianBlur(kernel_size=size//10*2+1, sigma=(0.1, 2.0)),
T.ToTensor(),
T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
class LeNet5Modern(nn.Module):
"""
LeNet-5 (LeCun et al. 1998) reimplementada em PyTorch moderno.
Esta arquitetura rodou em produção no Bank of America em 1993.
~60,000 parâmetros. Mesmos princípios de modelos modernos com bilhões.
"""
def __init__(self, num_classes=10):
super().__init__()
self.features = nn.Sequential(
nn.Conv2d(1, 6, kernel_size=5, padding=2),
nn.Tanh(),
nn.AvgPool2d(kernel_size=2, stride=2),
nn.Conv2d(6, 16, kernel_size=5),
nn.Tanh(),
nn.AvgPool2d(kernel_size=2, stride=2),
nn.Conv2d(16, 120, kernel_size=5),
nn.Tanh(),
)
self.classifier = nn.Sequential(
nn.Linear(120, 84),
nn.Tanh(),
nn.Linear(84, num_classes),
)
def forward(self, x):
x = self.features(x) # [B, 120, 1, 1]
x = x.view(x.size(0), -1)
return self.classifier(x)
yann-lecun - Complementary skill for enhanced analysisyann-lecun-debate - Complementary skill for enhanced analysisyann-lecun-filosofia - Complementary skill for enhanced analysisApply —