正在加载视频...

视频加载失败

Backpropagation by hand ✍️ ~ 11 steps walkthrough below Backpropagation is the algorithm that actually trains a neural network, and it is where most people stop following along. It is not calculus you cannot do. It is matrix multiplication, working backward, one layer at a time. So I drew...

932,325 次观看 • 3 天前 •via X (Twitter)

0 条评论

暂无评论

原始帖子的评论将显示在这里

相关视频

[RLHF] by Hand ✍️ Yesterday, Jan Leike (Jan Leike) announced he is joining #Anthropic to lead their "super-alignment" mission. He is the co-inventor of Reinforcement Learning with Human Feedback (#RLHF). How does RLHF work? [1] Given ↳ Reward Model (RM) ↳ Large Language Model (LLM) ↳ Two (Prompt, Next) Pairs 🟪 TRAIN RM Goal: Learn to give higher rewards to winners [2] Preferences ↳ A human reviews the two pairs and picks a "winner" ↳ (doc is, him) Embeddings ↳ This prompt has never received human feedback directly ↳ [S] is the special start symbol [11] Transformer ↳ Attention (yellow) ↳ Feed Forward (4x2 weight and bias matrix) ↳ Output: 3 "transformed" feature vector, one per position ↳ More details in my previous post 8. Transformer [] [12] Output Probabilities ↳ Apply a linear layer to map each transformed feature vector to a probability distribution over the vocabulary. [13] Sample ↳ Apply the greedy method, which is to pick the word with the highest score ↳ For output 1 and 2, the model accurately predicts the next word ↳ For 3rd output position, the model's predicts "him" [14] Reward Model ↳ The new pair (CEO is, him) is fed to the reward model ↳ The process is same as [3]-[6] ↳ Output: Reward = 3 [15] Loss Gradient ↳ We set the loss as the negative of the reward. ↳ The loss gradient is simply a constant -1. ↳ Run backpropagation and gradient descent to update LLM's weights and biases (red border)

Tom Yeh

79,758 次观看 • 2 年前

SORA by Hand ✍️ OpenAI’s #SORA took over the Internet when it was announced earlier this year. The technology behind Sora is the Diffusion Transformer (DiT) developed by William Peebles and Shining Xie. How does DiT work? 𝗚𝗼𝗮𝗹: Generate a video conditioned by a text prompt and a series of diffusion steps [1] Given ↳ Video ↳ Prompt: "sora is sky" ↳ Diffusion step: t = 3 [2] Video → Patches ↳ Divide all pixels in all frames into 4 spacetime patches [3] Visual Encoder: Pixels 🟨 → Latent 🟩 ↳ Multiply the patches with weights and biases, followed by ReLU ↳ The result is a latent feature vector per patch ↳ The purpose is dimension reduction from 4 (2x2x1) to 2 (2x1). ↳ In the paper, the reduction is 196,608 (256x256x3)→ 4096 (32x32x4) [4] ⬛ Add Noise ↳ Sample a noise according to the diffusion time step t. Typically, the larger the t, the smaller the noise. ↳ Add the Sampled Noise to latent features to obtain Noised Latent. ↳ The goal is to purposely add noise to a video and ask the model to guess what that noise is. ↳ This is analogous to training a language model by purposely deleting a word in a sentence and ask the model to guess what the deleted word was. [5-7] 🟪 Conditioning by Adaptive Layer Norm [5] Encode Conditions ↳ Encode "sora is sky" into a text embedding vector [0,1,-1]. ↳ Encode t = 3 to as a binary vector [1,1]. ↳ Concatenate the two vectors in to a 5D column vector. [6] Estimate Scale/Shift ↳ Multiply the combined vector with weights and biases ↳ The goal is to estimate the scale [2,-1] and shift [-1,5]. ↳ Copy the result to (X) and (+) [7] Apply Scale/Sift ↳ Scale the noised latent by [2,-1] ↳ Shifted the scaled noised latent by [-1, 5] ↳ The result is "conditioned" noise latent. [8-10] Transformer [8] Self-Attention ↳ Feed the conditioned noised latent to Query-Key function to obtain a self-attention matrix ↳ Value is omitted for simplicity [9] Attention Pooling ↳ Multiply the conditioned noised latent with the self-attention matrix ↳ The result are attention weighted features [10] Pointwise Feed Forward Network ↳ Multiply the attention weighted features with weights and biases ↳ The result is the Predicted Noise 🏋️‍♂️ 𝗧𝗿𝗮𝗶𝗻 [11] ↳ Calculate MSE loss gradients by taking the different between the Predicted Noise and the Sampled Noise (ground truth). ↳ Use the loss gradients to kick off backpropagation to update all learnable parameters (red borders) ↳ Note the visual encoder and decoder's parameters are frozen (blue borders) 🎨 𝗚𝗲𝗻𝗲𝗿𝗮𝘁𝗲 (𝗦𝗮𝗺𝗽𝗹𝗲) [12] Denoise ↳ Subtract the predicted noise from the noised latent to obtain the noise-free latent [13] Visual Decoder: Latent 🟩 → Pixels 🟨 ↳ Multiply the patches with weights and biases, followed by ReLU [14] Patches → Video ↳ Rearrange patches into a sequence of video frames.

Tom Yeh

238,166 次观看 • 2 年前

What if #AI became as decentralized as #Bitcoin? We sat down with our new friend 3700 from Bitcoin Virtual Machine to hear what their incredible team of anons are working on - "Truly Open AI." Full interview here:👇 1: What positive impact will Layer 2s have on Bitcoin? Layer 2s on Bitcoin open up opportunities for innovation, allowing developers to build dApps and smart contracts on top of Bitcoin, expanding its utility and use cases. By submitting transactions for final settlement on the Bitcoin network, Bitcoin Layer 2 networks claim to achieve the same (or close to) level of security and decentralization as the Bitcoin blockchain. Building a separate execution layer allows them the freedom to employ several technologies (such as rollups). Layer 2 can significantly improve Bitcoin's scalability by processing transactions off-chain, reducing congestion on the main blockchain. Overall, Layer 2s on Bitcoin have the potential to address some of Bitcoin's key limitations, making it more efficient, accessible, and versatile in the long run. 2: What does the ETF approval mean for Layer 2 on Bitcoin? The approval of ETF could potentially have several implications for Layer 2 on Bitcoin: Innovation and Development: With a growing interest in Bitcoin spurred by ETF approval, there could be a surge in research and development efforts focused on enhancing Layer 2. Developers and projects may be incentivized to create new and improved Layer 2 protocols to meet the evolving needs of the expanding Bitcoin ecosystem. An ETF approval could boost mainstream Bitcoin adoption and liquidity. This influx of users may also drive interest in Layer 2 on Bitcoin as a means to enhance the scalability and functionality of Bitcoin. 3: What are the primary challenges facing L2s on Bitcoin? The interoperability of different Layer 2s and their compatibility with Bitcoin's main blockchain can be a challenge. Ensuring seamless interaction between various Layer 2 networks and the Bitcoin blockchain is essential for a cohesive and efficient ecosystem. Some Layer 2s may introduce centralization risks if they rely heavily on centralized entities or trusted intermediaries. Maintaining decentralization and censorship resistance, which are core tenets of Bitcoin, while scaling with Layer 2s is a challenge. 4: What aspects of Layer 2 solutions for Bitcoin are you most enthusiastic about? AI represents one of the cornerstones of our modern era. However, achieving a decentralized AI infrastructure, owned and managed by users, has posed significant challenges. The primary obstacle has been the limited capacity to store and execute AI models due to size and computational limitations. To address this challenge, we propose a new blockchain architecture enabling developers to deploy their own Bitcoin Layer 2 solutions tailored specifically for AI tasks, called Truly Open AI. These Layer 2 blockchains are optimized to handle computationally intensive tasks, such as matrix multiplication, directly on-chain. These Bitcoin Layer 2 solutions offer exceptional throughput, minimal latency, and cost-effectiveness. AI dApps are programmed as Solidity smart contracts, ensuring they operate precisely as intended, free from interference or manipulation. Our BVM AI Contracts Library simplifies the integration of neural networks into dApps, empowering developers to embed AI seamlessly. In summary, I'm particularly enthusiastic about the potential of Layer 2 solutions for Bitcoin to revolutionize decentralized AI by providing scalability, security, and accessibility. 5: How is your Layer 2 different from others being built? BVM distinguishes itself as a Modular infrastructure that empowers thousands of distinct Bitcoin Layer 2 networks, spanning Gaming, DeFi, Social, and AI applications. We're continuously enriching the BVM Module Store with new modules to enhance its capabilities. With each new module, builders gain access to a wider array of tools to explore different use cases on the Bitcoin network. Recent additions include the Filecoin module for affordable storage and the AI Contracts Library for constructing AI-powered Bitcoin Layer 2 chains. We're also gearing up to release a ZK roll-up module in the coming weeks to offer an alternative to the standard optimistic roll-up. We aim to simplify the process of launching a Bitcoin Layer 2 network customized to specific requirements. Think of it as a SaaS offering with predefined best practices. Whether it's a DeFi Bitcoin Layer 2 or a GameFi Bitcoin Layer 2, we provide default solutions tailored to each use case. We're dedicated to expanding the BVM ecosystem by incentivizing more builders to join the Bitcoin network. Through various programs and grants, we support builders in covering their operational costs for Bitcoin Layer 2. Additionally, we offer rewards akin to 'L2 mining' to those who contribute to expanding the user base and total value locked on the network. In summary, BVM stands out with its modular infrastructure, tailored solutions, and efforts to grow the Bitcoin ecosystem.

Supra

83,516 次观看 • 2 年前

Jensen Huang told a room of global investors that AI is not one industry. It is five stacked on top of each other. Most people are investing in layer four and ignoring layers one through three entirely. He called it the five-layer cake. Layer one is energy. Jensen said this is the single greatest opportunity for the energy industry in a hundred years. The first time in a century that the grid in most countries can actually attract serious capital. Nuclear, solar, wind, hydrogen, it does not matter what form. If it produces energy, it gets funded. Siemens, GE Vernova, Mitsubishi. That is why they are all doing so well right now. Layer two is chips, computers, networking, and silicon photonics. Everything that processes the intelligence. Layer three is infrastructure. Land, power, buildings, data center operations. Every single one in short supply today. Layer four is the model layer. OpenAI, Anthropic. The layer everyone talks about. Layer five is applications. Every startup applying AI to financial services, legal, healthcare, logistics, transportation. Last year alone, a hundred billion dollars of venture capital went into this layer. The single largest VC year in the history of humanity. Then he said the number that stopped me cold. We are putting one trillion dollars into this five-layer cake this year. That sounds enormous. Jensen thinks the AI industry will eventually run at twenty trillion dollars per year. We are one trillion in of a twenty trillion dollar per year ecosystem. Most people watching AI are staring at layer four. Jensen was describing layers one through five as a single compounding system where every layer feeds the one above it. The people who understand that will invest differently than the people who do not.

Ihtesham Ali

97,713 次观看 • 1 个月前

[CLIP] by Hand ✍️ The CLIP (Contrastive Language–Image Pre-training) model, a groundbreaking work by OpenAI, redefines the intersection of computer vision and natural language processing. It is the basis of all the multi-modal foundation models we see today. How does CLIP work? Goal: 🟨 Learn a shared embedding space for text and image [1] Given ↳ A mini batch of 3 text-image pairs ↳ OpenAI used 400 million text-image pairs to train its original CLIP model. Process 1st pair: "big table" [2] 🟪 Text → 2 Vectors (3D) ↳ Look up word embedding vectors using word2vec. [3] 🟩 Image → 2 Vectors (4D) ↳ Divide the image into two patches. ↳ Flatten each patch [4] Process other pairs ↳ Repeat [2]-[3] [5] 🟪 Text Encoder & 🟩 Image Encoder ↳ Encode input vectors into feature vectors ↳ Here, both encoders are simple one layer perceptron (linear + ReLU) ↳ In practice, the encoders are usually transformer models. [6] 🟪 🟩 Mean Pooling: 2 → 1 vector ↳ Average 2 feature vectors into a single vector by averaging across the columns ↳ The goal is to have one vector to represent each image or text [7] 🟪 🟩 -> 🟨 Projection ↳ Note that the text and image feature vectors from the encoders have different dimensions (3D vs. 4D). ↳ Use a linear layer to project image and text vectors to a 2D shared embedding space. 🏋️ Contrastive Pre-training 🏋️ [8] Prepare for MatMul ↳ Copy text vectors (T1,T2,T3) ↳ Copy the transpose of image vectors (I1,I2,I3) ↳ They are all in the 2D shared embedding space. [9] 🟦 MatMul ↳ Multiply T and I matrices. ↳ This is equivalent to taking dot product between every pair of image and text vectors. ↳ The purpose is to use dot product to estimate the similarity between a pair of image-text. [10] 🟦 Softmax: e^x ↳ Raise e to the power of the number in each cell ↳ To simplify hand calculation, we approximate e^□ with 3^□. [11] 🟦 Softmax: ∑ ↳ Sum each row for 🟩 image→🟪 text ↳ Sum each column for 🟪 text→ 🟩 image [12] 🟦 Softmax: 1 / sum ↳ Divide each element by the column sum to obtain a similarity matrix for 🟪 text→🟩 image ↳ Divide each element by the row sum to obtain a similarity matrix for 🟩 image→🟪 text [13] 🟥 Loss Gradients ↳ The "Targets" for the similarity matrices are Identity Matrices. ↳ Why? If I and T come from the same pair (i=j), we want the highest value, which is 1, and 0 otherwise. ↳ Apply the simple equation of [Similarity - Target] to compute gradients of for both directions. ↳ Why so simple? Because when Softmax and Cross-Entropy Loss are used together, the math magically works out that way. ↳ These gradients kick off the backpropagation process to update weights and biases of the encoders and projection layers (red borders).

Tom Yeh

67,834 次观看 • 2 年前

🎓Learn how to create a powerful Torn Fabric smart material in a matter of seconds in my latest video series (AAA) Pro Tips! This smart material can be used on virtually any 3D asset. ____________________________________________________ In this video, the steps are as follows: 1. Create a base fill layer containing no information. We will use this layer to call out the core effects. Add a black mask to this layer and inside that mask add a paint layer and draw a simple pill shape. 2. Next, add a blur directional and be sure the direction is the same direction that your fabric is flowing to. 3. Add a UV border generator set to subtract to mask out any uv seams followed by an anchorpoint. Additionally, add a messy Fibers 3 fill layer set to overlay. 4. Use a levels to adjust the mask along with a sharpen filter. A warp filter should also be added to introduce some randomness. Add an anchor point at the top of the mask as well. 5. Create another fill layer with its opacity channel set to black and apply a black mask to the fill layer. Inside its mask retrieve the anchorpoint information from the previous fill layer. 6. Create an additional fill layer with a bright diffuse color along with a black mask applied to it. Add the anchorpoint information from the previous mask into its mask as well and this should give us some white fibers on the edges. Now we have a torn fabric effect wherever we paint using the paint layer created inside the callout mask! ____________________________________________________ More AAA Game Dev Tips can be found on my YouTube channel here: Stay tuned for more weekly Tips! Happy Texturing!💚 #gamedev #gameart #tutorial #3dmodeling #hardsurface #texturing

Cohen Brawley

78,798 次观看 • 2 年前

🎓Learn how to create a powerful Worn Leather smart material in a matter of seconds in my latest video series (AAA) Pro Tips! This smart material can be used on virtually any 3D asset. ____________________________________________________ In this video, the steps are as follows: 1. Create a fill layer with a black mask applied. Inside its mask paint a simple pill shape and use a blur slope filter to introduce some random shapes. Apply a marble veins fill layer on top with its blending mode set to color burn. Apply a warp filter as well to introduce some randomness followed by an anchorpoint. 2. Create another fill layer using the same technique to apply some dirt in the crevices of the wear. 3. Next, Inside the main fill layer apply a tiling raw leather texture to its Color and roughness channel 4. Create an additional fill layer up top and apply a black mask to it.Inside this mask retrieve the anchorpoint information followed by a blur filter with a value of 6. Use a levels to increase the spread of the mask. Apply another marble veins matching the values of the marble veins fill layer that we previously added and set its blending mode to multiply. Lastly retrieve the anchorpoint information from the previous fill layer again but this time set its blending mode to subtract. This fill layers properties should have a dark diffuse color and a matte roughness. 5. Add another fill layer with a bright diffuse and height properties with a black mask applied to it. Inside its mask retrieve the anchorpoint information again followed by a blur slope. Apply the anchorpoint information again but this time set its blending mode to subtract. Now we have a worn leather effect wherever we paint using the paint layer created inside the callout mask! ____________________________________________________ More AAA Game Dev Tips can be found on my YouTube channel here: Stay tuned for more weekly Tips! Happy Texturing!💚 #gamedev #gameart #3dmodeling #3dartist #texturing #UE5 #unity #artstation

Cohen Brawley

88,602 次观看 • 2 年前

[Self-Attention] by Hand ✍️ Self-attention is what enables LLMs to understand context. How does it work? This exercise demonstrates how to calculate a 6-3 attention head by hand. Note that if we have two instances of this, we get 6-6 attention (i.e., multi-head attention, n=2). -- 𝗚𝗼𝗮𝗹 -- Transform [6D Features 🟧] to [3D Attention Weighted Features 🟦] -- 𝗪𝗮𝗹𝗸𝘁𝗵𝗿𝗼𝘂𝗴𝗵 -- [1] Given ↳ A set of 4 feature vectors (6-D): x1,x2,x3,x4 [2] Query, Key, Value ↳ Multiply features x's with linear transformation matrices WQ, WK, and WV, to obtain query vectors (q1,q2,q3,q4), key vectors (k1,k2,k3,k4), and value vectors (v1,v2,v3,v4). ↳ "Self" refers to the fact that both queries and keys are derived from the same set of features. [3] 🟪 Prepare for MatMul ↳ Copy query vectors ↳ Copy the transpose of key vectors [4] 🟪 MatMul ↳ Multiply K^T and Q ↳ This is equivalent to taking dot product between every pair of query and key vectors. ↳ The purpose is to use dot product as an estimate of the "matching score" between every key-value pair. ↳ This estimate makes sense because dot product is the numerator of Cosine Similarity between two vectors. [5] 🟨 Scale ↳ Scale each element by the square root of dk, which is the dimension of key vectors (dk=3). ↳ The purpose is to normalize the impact of the dk on matching scores, even if we scale dk to 32, 64, or 128. ↳ To simplify hand calculation, we approximate [ □/sqrt(3) ] with [ floor(□/2) ]. [6] 🟩 Softmax: e^x ↳ Raise e to the power of the number in each cell ↳ To simplify hand calculation, we approximate e^□ with 3^□. [7] 🟩 Softmax: ∑ ↳ Sum across each column [8] 🟩 Softmax: 1 / sum ↳ For each column, divide each element by the column sum ↳ The purpose is normalize each column so that the numbers sum to 1. In other words, each column is a probability distribution of attention, and we have four of them. ↳ The result is the Attention Weight Matrix (A) (yellow) [9] 🟦 MatMul ↳ Multiply the value vectors (Vs) with the Attention Weight Matrix (A) ↳ The results are the attention weighted features Zs. ↳ They are fed to the position-wise feed forward network in the next layer.

Tom Yeh

101,010 次观看 • 2 年前