Salesforce/wikitext
Viewer • Updated • 3.71M • 1.35M • 694
How to use Gustav-Proxi/SalienceFormer-Gemma2B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Gustav-Proxi/SalienceFormer-Gemma2B") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Gustav-Proxi/SalienceFormer-Gemma2B", dtype="auto")How to use Gustav-Proxi/SalienceFormer-Gemma2B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Gustav-Proxi/SalienceFormer-Gemma2B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Gustav-Proxi/SalienceFormer-Gemma2B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Gustav-Proxi/SalienceFormer-Gemma2B
How to use Gustav-Proxi/SalienceFormer-Gemma2B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Gustav-Proxi/SalienceFormer-Gemma2B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Gustav-Proxi/SalienceFormer-Gemma2B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "Gustav-Proxi/SalienceFormer-Gemma2B" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Gustav-Proxi/SalienceFormer-Gemma2B",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Gustav-Proxi/SalienceFormer-Gemma2B with Docker Model Runner:
docker model run hf.co/Gustav-Proxi/SalienceFormer-Gemma2B
SalienceFormer is a biologically-inspired memory architecture that brings hippocampal memory consolidation to large language models. This model integrates hippocampal mechanisms directly into the Gemma-2B transformer.
SalienceFormer adds three key components inspired by how the human hippocampus processes memories:
| Component | Inspiration | Function |
|---|---|---|
| Salience Gate | Sharp Wave Ripples (SPW-Rs) | Dual-pathway importance scoring |
| Memory Buffer | Sleep Replay | Priority-based consolidation |
| Drift Calibrator | Synaptic Homeostasis | Embedding stability |
Input Tokens -> Gemma-2B (frozen + LoRA) -> Hidden States
-> Salience Gate (importance scoring)
-> Drift Calibrator (stability)
-> Memory Buffer (consolidation)
-> Output Fusion (cross-attention)
-> Output Logits
| Model | Parameters | Perplexity |
|---|---|---|
| GPT-2 | 124M | 29.41 |
| Gemma-2B | 2B | ~18 |
| SalienceFormer | 2B + 15M | 11.83 |
| Configuration | PPL | Impact |
|---|---|---|
| Full SalienceFormer | 11.83 | baseline |
| No Salience Gate | 39.75 | +27.92 |
| No Memory Buffer | 89.84 | +78.01 |
| Metric | Value | Interpretation |
|---|---|---|
| Content/Function Ratio | 2.11x | Selective memory (content words tagged more) |
| Long-Range Benefit | +6.95 PPL | Better context retention |
| Buffer Priority | 4.9/5.0 | High-importance retention |
from salienceformer import SalienceFormer, SalienceFormerConfig
from huggingface_hub import hf_hub_download
import torch
# Download checkpoint
ckpt_path = hf_hub_download(
repo_id="Gustav-Proxi/SalienceFormer-Gemma2B",
filename="pytorch_model.pt"
)
# Initialize model
config = SalienceFormerConfig(
base_model_name="google/gemma-2b",
freeze_base=True,
use_lora=True,
)
model = SalienceFormer(config)
# Load weights
ckpt = torch.load(ckpt_path, map_location="cpu")
model.load_state_dict(ckpt["model_state_dict"], strict=False)
# Generate
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2b")
inputs = tokenizer("The capital of France is", return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_new_tokens=20)
print(tokenizer.decode(outputs[0]))
@misc{salienceformer2025,
title={SalienceFormer: Salience-Gated Memory Consolidation for Transformers},
author={Vaishak Girish Kumar and Sanika},
year={2025},
howpublished={\url{https://github.com/Gustav-Proxi/SalienceFormer}},
}
Apache 2.0
Base model
google/gemma-2b