piyush メ (@TheEigenNerd) header
piyush メ (@TheEigenNerd) profile picture

22 • Physical AI • Inference

Joined January 2024
just published FeedbackNet V1: Enhancing Transformers with Feedback Loops on @ZENODO_ORG this work introduces a feedback transformer for iterative reasoning tasks, showing preliminary improvements over standard transformers. paper: doi.org/10.5281/zenodo.17189… #MachineLearning
almost done... here's a tiny sneak peak. 🦇
2
1
35
4,026
at money expo 2026.
1
13
314
piyush メ retweeted
Everyone should have at least one skill that makes no money and takes ten years to master
404
308
111
5,026
260,021
piyush メ retweeted
"I'M VENGEANCE" 🦇🔥
11
253
9
2,274
47,652
piyush メ retweeted
(1) Today we're releasing Muse Spark 1.1 -- a strong agentic and coding model at a very low price. It's available through our new Meta Model API and in Meta AI.
5,312
3,533
3,601
45,141
23,724,321
piyush メ retweeted
Replying to @iam_smx
*trillioniare
12,462
18,070
4,976
214,516
17,704,290
piyush メ retweeted
Replying to @narendramodi
Congratulations! 🇮🇳
690
4,038
187
30,490
1,056,724
Causal (Masked) Self-Attention Causal (Masked) Self-Attention is a special form of self-attention used when a model must predict the next word based only on past words, not future ones. It enforces the natural left-to-right flow of language. In normal self-attention, every word can look at every other word in the sentence. But in causal attention, each word is only allowed to attend to: • Itself • Words that come before it Words are not allowed to look at future words. This is done using a mask that blocks attention to later positions. Why this is important: • Prevents the model from “cheating” by seeing future words during training. • Makes the model behave like real text generation, where future words are unknown. • Ensures correct learning for tasks like text generation and autocomplete. Key characteristics: • Maintains autoregressive behavior (predicting one token at a time). • Preserves the temporal order of language. • Still allows parallel processing during training (unlike RNNs). Used in: • Decoder-only models like GPT. • Language generation, chatbots, story writing, and code completion. source code: github.com/piyushdev04/LLM-N…
12
124
3,701
Multi-Head Self-Attention Multi-Head Self-Attention is an extension of self-attention that allows a model to look at the same sentence in multiple ways at the same time. Instead of using a single attention mechanism, it uses several attention “heads” in parallel, each focusing on different types of relationships. Self-attention means every word can attend to every other word in the same sentence, including itself. This helps the model understand context, meaning, and structure without processing words sequentially. Multi-head means: • Each head learns a different perspective of the sentence. • One head might focus on grammar (like subject–verb relationships). • Another might focus on meaning (like synonyms or topic words). • Another might capture long-distance dependencies. All these views are then combined to form a richer and more informative representation of each word. Key benefits: • Captures multiple types of relationships simultaneously. • Improves understanding of complex language patterns. • Makes the model more expressive and powerful than single-head attention. Why it matters: • A single attention view is limited. • Multiple heads allow the model to see the same data in different ways, leading to better learning and performance. Multi-Head Self-Attention is a core component of the Transformer architecture and is essential for models like BERT, GPT, and T5, enabling them to understand language deeply and efficiently. source code: github.com/piyushdev04/LLM-N…
4
23
216
8,490
Scaled Dot-Product Attention Scaled Dot-Product Attention is a mechanism that allows a model to decide which parts of a sentence are most relevant when processing a particular word. Instead of reading words one by one, the model looks at the entire sequence at once and assigns importance to each word based on how much it should influence the current word. At a high level, each word in the input is represented in three different ways: • One representation asks a question (Query), • One represents what the word contains (Key), • One represents the actual information to pass forward (Value). The attention mechanism compares these representations to determine how strongly each word is related to every other word. Words that are more relevant receive higher importance, and their information is emphasized in the final representation. The term “scaled” means the raw similarity scores are adjusted so they stay within a reasonable range. This prevents any one word from dominating too much and helps the model learn more stably and effectively during training. Unlike traditional models that only look at nearby words, scaled dot-product attention allows each word to: • Attend to any other word in the sentence, • Capture long-distance relationships, • Understand meaning based on global context, not just local neighbors. This mechanism is: • Parallelizable (all words processed at once), • Efficient for large sequences, • The foundation of self-attention in Transformers. In short, scaled dot-product attention is how Transformers learn what to focus on, how strongly, and from where, enabling deep understanding of language structure and meaning without relying on sequential processing. source code: github.com/piyushdev04/LLM-N…
4
19
236
10,206
Building Neural Language Model (MLP-based) from Scratch • A Neural Language Model (MLP-based) uses a feedforward neural network to predict the next word. • It replaces count-based n-gram tables with learned word embeddings and neural weights. Core idea • Given the previous k words, the model predicts the next word. • Words are first converted into vectors (embeddings). • These vectors are concatenated and passed through an MLP (Multi-Layer Perceptron). Architecture 1. Input: last k words → token IDs 2. Embedding layer → dense vectors 3. Concatenation of embeddings 4. Hidden layer(s) with activation (ReLU, tanh, etc.) 5. Output layer → softmax over vocabulary Advantages • Handles data sparsity better than n-grams. • Learns semantic relationships via embeddings. • More accurate than count-based models. Disadvantages • Still has a fixed context window. • Cannot model long-range dependencies well. • Slower than simple n-gram models. Used in • Early neural NLP models. • Foundations for RNNs, LSTMs, and Transformers. • Educational implementations of neural language modeling. source code: github.com/piyushdev04/LLM-N…
7
170
piyush メ retweeted
strong men creates C language. C creates goodtimes. goodtimes creates python, python creates ai, ai creates vibe coding, vibe coding creates weak men, weak men creates bad times, bad times creates strong men
279
1,304
103
12,395
409,295
Implementing Unigram Language Model from scratch • A Unigram Language Model assumes that each word/token appears independently of others. • The probability of a sentence is the product of individual word probabilities. Core idea • Each token has a probability based only on its frequency in the corpus. • No context or word order is considered. Advantages • Very simple and fast. • Easy to implement and understand. • Good baseline model. Disadvantages • Ignores word order and context. • Produces unrealistic sentences. • Low accuracy compared to n-gram or neural models. Used in • Basic NLP education. • Tokenizer training (Unigram LM tokenizer). • Baseline language modeling experiments. source code: github.com/piyushdev04/LLM-N…
10
167
piyush メ retweeted
I saw this meme and updated it a little.
36
113
12
1,508
62,555
82
1,531
17
50,864
1,557,935
piyush メ retweeted
Anyone else out there vibe circuit-building?
566
2,438
363
39,926
1,386,676
Tokenizer Serialization & Reload System • Serialization means saving a trained tokenizer to a file. • Reloading means loading it back later to use again. • This ensures consistent tokenization across training and deployment. Why it’s important • Models expect the same tokenizer used during training. • Prevents mismatched token IDs. • Allows reuse without retraining. What gets saved • Vocabulary (token → ID mapping). • Special tokens (<pad>, <unk>, etc.). • Normalization rules (Unicode, casing). • Tokenization rules (BPE, WordPiece, Unigram, etc.). Common file formats • JSON (tokenizer.json, vocab.json) • TXT (vocab.txt) • Model files (.model for SentencePiece) Example workflow 1. Train tokenizer. 2. Save it to disk. 3. Load it in another script or system. 4. Use it to encode/decode text. Advantages • Ensures reproducibility. • Simplifies deployment. • Supports versioning and sharing. Used in • Hugging Face tokenizers. • SentencePiece. • Production NLP pipelines. source code: github.com/piyushdev04/LLM-N…
14
338
Vocabulary Construction & Pruning System • A vocabulary is the list of all tokens a tokenizer can use. • Construction means building this list from training data. • Pruning means removing less useful tokens to keep the vocabulary efficient. 1. Vocabulary Construction • Collect text from the training dataset. • Apply normalization (Unicode, casing, etc.). • Generate initial tokens: • Characters, words, or subwords. • Count how often each token appears. • Assign a unique ID to each token. 2. Vocabulary Pruning • Remove tokens that: • Appear very rarely. • Are too long or noisy. • Do not improve model performance. • Keep only the top N most useful tokens. Why pruning is important • Reduces memory usage. • Speeds up training and inference. • Prevents overfitting to rare or noisy tokens. Example • Initial tokens: ["hello", "world", "!", "@@@", "qzxy"] • After pruning: ["hello", "world", "!"] Special tokens (always kept) • <pad> – padding • <unk> – unknown token • <bos> – beginning of sentence • <eos> – end of sentence Advantages • Creates a compact, high-quality vocabulary. • Improves tokenizer and model efficiency. • Works with WordPiece, BPE, Unigram, and SentencePiece. When to use • During tokenizer training. • When optimizing model size and speed. • For multilingual or large-scale NLP systems. source code: github.com/piyushdev04/LLM-N…
2
14
212
Token Normalization Pipeline (Unicode, Casing) • A token normalization pipeline cleans and standardizes text before tokenization. • This helps make tokenization consistent and reliable. 1. Unicode Normalization • Converts text into a standard Unicode form (usually NFC or NFKC). • Fixes issues where the same character has multiple representations. Example: • "é" → "é" • "ABC" → "ABC" Why important: • Prevents duplicate tokens for visually identical characters. • Improves vocabulary quality. 2. Casing Normalization • Controls how uppercase and lowercase letters are handled. Common strategies: • Lowercasing: Convert everything to lowercase. • "Hello World" → "hello world" • Cased models: Keep original casing. • "Hello World" stays "Hello World" Why important: • Lowercasing reduces vocabulary size. • Keeping case preserves meaning (e.g., "Apple" vs "apple"). Other common normalization steps • Remove or normalize punctuation. • Normalize whitespace. • Replace special characters or emojis. Advantages • Makes tokenization cleaner and more consistent. • Reduces noise and unnecessary vocabulary growth. • Improves model performance and generalization. Used in • WordPiece, BPE, Unigram, and SentencePiece tokenizers. • Almost all modern NLP preprocessing pipelines. source code: github.com/piyushdev04/LLM-N…
2
3
40
1,341
Implementing SentencePiece-Style Tokenizer from scratch • A SentencePiece-style tokenizer treats text as a raw sequence of characters. • It does not require pre-tokenized text (no spaces, no word boundaries). Key idea • Spaces are handled as a special character (often shown as ▁). • This allows the model to learn word boundaries automatically. How it works • Input text is taken as-is, including spaces. • A subword algorithm is applied: • Unigram LM (most common) • or BPE • A fixed-size subword vocabulary is learned. Example • Text: "I love NLP" • Tokens: ["▁I", "▁love", "▁N", "LP"] • ▁ indicates the start of a word (space before it). Tokenization steps • Replace spaces with a special symbol (▁). • Split text into subwords based on learned probabilities or merges. • Output subword tokens with no need for extra word splitting. Special tokens • Common special tokens: • <unk> – unknown • <pad> – padding • <bos> – beginning of sentence • <eos> – end of sentence Advantages • Language-independent (works well for multilingual data). • No need for external tokenizers. • Handles spaces, punctuation, and rare words cleanly. Disadvantages • Tokens may look less human-readable. • Slight learning curve for understanding ▁ symbol. • Training can be computationally heavy. When to use • Multilingual or cross-language models. • End-to-end NLP pipelines. • When consistent tokenization across languages is needed. Used in • SentencePiece library. • Models like T5, ALBERT, mBART, and many multilingual LLMs. source code: github.com/piyushdev04/LLM-N…
1
2
25
732