tahamajs/DGM / PaperSLecturs /LLM_Codes /BitNet /transformer_example.py
tahamajs's picture
download
raw
646 Bytes
# Import the necessary libraries
import torch
from bitnet import BitNetTransformer
# Create a random tensor of integers
x = torch.randint(0, 20000, (1, 1024))
# Initialize the BitNetTransformer model
bitnet = BitNetTransformer(
num_tokens=20000, # Number of unique tokens in the input
dim=1024, # Dimension of the input and output embeddings
depth=6, # Number of transformer layers
heads=8, # Number of attention heads
ff_mult=4, # Multiplier for the hidden dimension in the feed-forward network
)
# Pass the tensor through the transformer model
logits = bitnet(x)
# Print the shape of the output
print(logits.shape)

Xet Storage Details

Size:
646 Bytes
·
Xet hash:
150cb95dbea689358bc51804abb67b8b0a368921787edbe108ecfe65d3812636

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.