All models

diffllama

A Llama decoder whose attention is the difference of two softmax maps, from the Differential Transformer paper.

Language · 1,324 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (38 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
1.2B
Operations
1,324
Framework
PyTorch
Recurrent
No
Published
2024
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m4300
Graph hash
aa9ecc27e45a3629fefb8178316f62ccee68b9332f44849704e63f59e2dc466a
Skeleton hash
53bc67ef067ff695dc9d7abb4cec9aeaeced42b17f56f54eafa6695fd0463330
Architecture hash
341d06c9830e21c3923d3805c2af782c56c0db60fdcabd3fb13cb660435f8e22
Diagram SHA-256
30aed92669a209e72607e52ae4a81a2673fbbd75c938f66e022d76e674b03277
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

transformers.AutoModelForCausalLM.from_config()

What it is

DiffLlama combines the Llama model with the attention of the Differential Transformer.

The Differential Transformer paper starts from the observation that a Transformer tends to overallocate attention to irrelevant context. Its differential attention mechanism calculates attention scores as the difference between two separate softmax attention maps, and the subtraction cancels noise and promotes sparse attention patterns. The paper reports that Diff Transformer outperforms Transformer in language modeling across settings of model size and training tokens, with advantages in long-context modeling, key information retrieval, hallucination mitigation, in-context learning and reduction of activation outliers.

In the Transformers library the hyperparameters of DiffLlama are the same as the Llama model, and the member traced here is the causal language model built from a default configuration.

Key idea. Differential attention, the difference of two softmax attention maps, inside a Llama-style decoder.

  • diffllama
  • diff llama
  • differential transformer
  • diff transformer
  • differential attention
  • llama
  • causal language model
  • text generation
  • kazuma matsumoto

AI-written summary, based on the model's documentation and checked automatically against it; not reviewed by a person. Corrections welcome.