Skip to content

Instantly share code, notes, and snippets.

View LevanKvirkvelia's full-sized avatar
🎯
F

Levan Kvirkvelia LevanKvirkvelia

🎯
F
View GitHub Profile
@LevanKvirkvelia
LevanKvirkvelia / nanoBERT.py
Last active February 14, 2024 23:25
nanoBERT, inspired by @karpathy's nanoGPT
import torch.nn as nn
import torch.nn.functional as F
import math
from typing import Optional, Tuple
class BertSelfAttention(nn.Module):
def __init__(self, config):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0: