class TransformerBlock(nn.Module): def init(self, args: ModelArgs): super().init()…
- User
class TransformerBlock(nn.Module): def init(self, args: ModelArgs): super().init() self.n_heads = args.n_heads self.dim = args.dim self.attention = Attention(args) self.feed_forward = FeedForward(args=args) self.attention_norm = RMSNorm(args.dim, eps=args.norm_eps) self.ffn_norm = RMSNorm(args.dim, eps=args.norm_eps) self.args = args
codedef forward( self, x: torch.Tensor, freqs_cis: torch.Tensor, cache: Optional[CacheView] ) -> torch.Tensor: r = self.attention.forward(self.attention_norm(x), freqs_cis, cache) h = x + r r = self.feed_forward.forward(self.ffn_norm(h)) out = h + r return outexplaing thius in details
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.