How to use from
SGLang
Install from pip and serve model
# 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
	}'
Use Docker images
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
	}'
Quick Links

SalienceFormer-Gemma2B

PyTorch Transformers Gemma

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.

Model Description

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

Architecture

Input Tokens -> Gemma-2B (frozen + LoRA) -> Hidden States
    -> Salience Gate (importance scoring)
    -> Drift Calibrator (stability)
    -> Memory Buffer (consolidation)
    -> Output Fusion (cross-attention)
    -> Output Logits

Results

Perplexity (WikiText-2)

Model Parameters Perplexity
GPT-2 124M 29.41
Gemma-2B 2B ~18
SalienceFormer 2B + 15M 11.83

Ablation Study

Configuration PPL Impact
Full SalienceFormer 11.83 baseline
No Salience Gate 39.75 +27.92
No Memory Buffer 89.84 +78.01

Brain-Like Behavior

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

Usage

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]))

Training

  • Base Model: Gemma-2B (frozen with LoRA)
  • Dataset: WikiText-2
  • Hardware: NVIDIA RTX 4090 (24GB)
  • Training Time: ~24 hours
  • Best Checkpoint: step-110000

Citation

@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}},
}

Links

License

Apache 2.0

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Gustav-Proxi/SalienceFormer-Gemma2B

Base model

google/gemma-2b
Finetuned
(300)
this model

Dataset used to train Gustav-Proxi/SalienceFormer-Gemma2B