Downloads · 30 days
9
11% of all-time downloads
dogeplusplus/duo-laguna-adapter-rosy-energy-5-preview
duo-laguna-adapter-rosy-energy-5-preview is a text generation model from dogeplusplus. Use it when you need the model to write or continue text. It is set up for transformers.
This repository contains learned DuoAttention attention-head weights and custom loading code for poolside/Laguna-XS.2. It intentionally does not include the full Laguna base-model weights or tokenizer files.
Downloads · 30 days
9
11% of all-time downloads
All-time downloads
85
Public
Repo size
1.8 MB
Likes
0
Public
Click a slice to open those files.
.jpg1.8 MB · 93%
From the Hugging Face model README
This repository contains learned DuoAttention attention-head weights and custom
loading code for poolside/Laguna-XS.2. It intentionally does not include the full
Laguna base-model weights or tokenizer files.
DuoAttention is a KV-cache reduction method for long-context decoder models. It learns which KV heads need full-context memory for retrieval-heavy behavior and lets the remaining heads use a streaming cache made from a fixed sink window and a recent-token window. The idea is simple: not every attention head needs to carry the whole past sequence. Keeping full history only for the heads that use it preserves the parts of the model most responsible for long-range retrieval, while reducing KV-cache growth for the rest.
For this adapter, the learned head mask is packaged separately from the base
Laguna weights. At load time, the custom model code reads
duo_attention/full_attention_heads.pt, patches the Laguna attention modules,
and enables DuoAttention inference with sink size 64 and recent size
256.
trust_remote_code loading that applies the Laguna patch
automatically.Selected figures from the DuoAttention paper show the method, cache tradeoff, and latency motivation. The final figure is Laguna-specific and visualizes the optimized gating values learned for this adapter.
<img src="figures/method1.jpg" alt="DuoAttention retrieval and streaming head split" width="820"> <img src="figures/method2.jpg" alt="DuoAttention full and streaming KV-cache pattern" width="820"> <img src="figures/kv_capacity.jpg" alt="DuoAttention KV-cache capacity comparison" width="620"> <img src="figures/efficiency_prefilling.jpg" alt="DuoAttention prefilling efficiency" width="820"> <img src="figures/efficiency_decoding.jpg" alt="DuoAttention decoding efficiency" width="820"> <img src="figures/laguna_optimized_gate_values_booksum.png" alt="Laguna optimized DuoAttention gating values" width="420">Paper reference: DuoAttention: Efficient Long-Context LLM Inference with Retrieval and Streaming Heads.
The adapter is produced by training per-layer, per-KV-head DuoAttention scores
on long-context retrieval-style data. During training, the model learns which KV
heads should remain full-context. The final artifact stores the learned
full_attention_heads tensor and a small duo_attention config block with the
base model id, sink/recent sizes, and custom-code metadata.
This package contains adapter state only:
duo_attention/full_attention_heads.ptconfig.json with the DuoAttention metadata and remote-code mappingrequirements.txtEngineering changes:
AutoModelForCausalLM loading via trust_remote_code=True.Laguna-specific / novel changes:
Install optional tokenizer dependencies if needed:
pip install sentencepiece tiktoken
Load the tokenizer from the base Laguna model and the patched model from this adapter repository:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
adapter_repo = "dogeplusplus/duo-laguna-adapter-rosy-energy-5-preview"
base_model = "poolside/Laguna-XS.2"
tokenizer = AutoTokenizer.from_pretrained(
base_model,
trust_remote_code=True,
token=True,
)
model = AutoModelForCausalLM.from_pretrained(
adapter_repo,
trust_remote_code=True,
token=True,
torch_dtype="auto",
device_map="auto",
)
prompt = "The capital of France is"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
generated = model.generate(**inputs, max_new_tokens=32)
print(tokenizer.decode(generated[0], skip_special_tokens=True))
Use token=True after running hf auth login, or pass a token string directly
when loading private or gated repositories.