Text Generation
Transformers
Safetensors
PyTorch
English
neollm
causal-lm
research
bf16
attention
normalization
conversational
custom_code
Instructions to use KitsuVp/NeoLLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KitsuVp/NeoLLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KitsuVp/NeoLLM", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("KitsuVp/NeoLLM", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KitsuVp/NeoLLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KitsuVp/NeoLLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KitsuVp/NeoLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/KitsuVp/NeoLLM
- SGLang
How to use KitsuVp/NeoLLM with 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 "KitsuVp/NeoLLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KitsuVp/NeoLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "KitsuVp/NeoLLM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KitsuVp/NeoLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use KitsuVp/NeoLLM with Docker Model Runner:
docker model run hf.co/KitsuVp/NeoLLM
Update configuration_neollm.py
Browse files- configuration_neollm.py +55 -13
configuration_neollm.py
CHANGED
|
@@ -126,6 +126,23 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 126 |
Epsilon for the denominator of the XSA projection to prevent
|
| 127 |
division by zero: ``‖v_ref‖² + xsa_eps``. Ignored when
|
| 128 |
``use_xsa=False``.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
use_stack_memory (:obj:`bool`, *optional*, defaults to ``False``):
|
| 130 |
Enable the StackMemory / STACKTRANS hidden-state stack between
|
| 131 |
decoder layers (Zhang et al., NeurIPS 2025). The module keeps the
|
|
@@ -480,7 +497,8 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 480 |
``0 <= repo_start_layer < num_hidden_layers`` when
|
| 481 |
``use_repo=True``, ``use_repo_grape=True`` or
|
| 482 |
``use_repo_goat_prior=True``.
|
| 483 |
-
- ``use_laurel=True``
|
|
|
|
| 484 |
- When ``use_laurel=True``, at least one of ``use_laurel_rw`` or
|
| 485 |
``use_laurel_lr`` must be ``True``.
|
| 486 |
- ``stack_d_model`` must be divisible by ``num_mem_heads`` when
|
|
@@ -559,6 +577,9 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 559 |
Litman, E. & Guo, G. (2026). *You Need Better Attention Priors.*
|
| 560 |
arXiv:2601.15380.
|
| 561 |
|
|
|
|
|
|
|
|
|
|
| 562 |
Menghani, G., Kumar, R. & Kumar, S. (2025). *LAUREL: Learned Augmented
|
| 563 |
Residual Layer.* ICML 2025. arXiv:2411.07501.
|
| 564 |
"""
|
|
@@ -587,7 +608,7 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 587 |
head_dim=64,
|
| 588 |
use_momentum_attention=True,
|
| 589 |
momentum_gamma=0.10,
|
| 590 |
-
use_mea_attention=
|
| 591 |
mea_component_key_value_heads=None,
|
| 592 |
mea_groupnorm_eps=1e-6,
|
| 593 |
use_lucid_attention=False,
|
|
@@ -603,6 +624,9 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 603 |
# ── Attention Residuals (Kimi Team, 2026) ─────────────────────────
|
| 604 |
use_attn_res=False,
|
| 605 |
attn_res_num_blocks=4,
|
|
|
|
|
|
|
|
|
|
| 606 |
# ── StackMemory / STACKTRANS (Zhang et al., NeurIPS 2025) ───────
|
| 607 |
use_stack_memory=False,
|
| 608 |
stack_d_model=32, # H * d_s = 4 * 16
|
|
@@ -615,7 +639,7 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 615 |
fan_ratio_ffn=0.0625,
|
| 616 |
dropout_rate=0.1,
|
| 617 |
# ── Embedding input normalization ─────────────────────────────────
|
| 618 |
-
use_embedding_input_norm=
|
| 619 |
# ── Leviathan continuous token generator ──────────────────────────
|
| 620 |
use_token_generator=False,
|
| 621 |
generator_d_seed=128,
|
|
@@ -695,6 +719,13 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 695 |
f"got jtokm_top_k={jtokm_top_k}, jtokm_num_experts={jtokm_num_experts}."
|
| 696 |
)
|
| 697 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 698 |
# ── REPO: resolve defaults and validate ───────────────────────────
|
| 699 |
# repo_start_layer defaults to num_hidden_layers // 3, matching the
|
| 700 |
# paper's 1/3-of-depth heuristic (Li et al., 2026, §3).
|
|
@@ -761,18 +792,25 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 761 |
f"`iha_num_pseudo_heads` must be >= 1, got {iha_num_pseudo_heads}."
|
| 762 |
)
|
| 763 |
|
| 764 |
-
# ──
|
| 765 |
-
#
|
| 766 |
-
#
|
| 767 |
-
#
|
| 768 |
-
|
| 769 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 770 |
raise ValueError(
|
| 771 |
-
"
|
| 772 |
-
"
|
| 773 |
-
"
|
| 774 |
-
"scalar/low-rank augmentation in-place. Enable at most one."
|
| 775 |
)
|
|
|
|
|
|
|
| 776 |
if use_laurel and not use_laurel_rw and not use_laurel_lr:
|
| 777 |
raise ValueError(
|
| 778 |
"`use_laurel=True` requires at least one sub-variant to be active. "
|
|
@@ -848,6 +886,10 @@ class NeoLLMConfig(PretrainedConfig):
|
|
| 848 |
self.use_attn_res = use_attn_res
|
| 849 |
self.attn_res_num_blocks = attn_res_num_blocks
|
| 850 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
# ── StackMemory / STACKTRANS ──────────────────────────────────────
|
| 852 |
self.use_stack_memory = use_stack_memory
|
| 853 |
self.stack_d_model = stack_d_model
|
|
|
|
| 126 |
Epsilon for the denominator of the XSA projection to prevent
|
| 127 |
division by zero: ``‖v_ref‖² + xsa_eps``. Ignored when
|
| 128 |
``use_xsa=False``.
|
| 129 |
+
use_dca (:obj:`bool`, *optional*, defaults to ``False``):
|
| 130 |
+
Enable **DeepCrossAttention** (DCA; Heddes et al., 2025). DCA
|
| 131 |
+
replaces the single residual-stream attention input with three
|
| 132 |
+
independent GRN-v3 compositions over previous decoder outputs,
|
| 133 |
+
producing separate q/k/v input streams for the attention module.
|
| 134 |
+
The attention operator itself is left unchanged.
|
| 135 |
+
|
| 136 |
+
Mutually exclusive with ``use_laurel=True``, ``use_attn_res=True``
|
| 137 |
+
and ``use_stack_memory=True`` because all four mechanisms modify
|
| 138 |
+
cross-layer residual flow during training.
|
| 139 |
+
|
| 140 |
+
dca_past_layers_k (:obj:`int`, *optional*, defaults to ``2``):
|
| 141 |
+
Efficient k-DCA stack size. Each layer keeps the model input, a
|
| 142 |
+
summed intermediate residual block, and the last ``k`` decoder
|
| 143 |
+
outputs as explicit GRN sources, following the paper's first/input
|
| 144 |
+
+ intermediate-sum + last-k memory reduction.
|
| 145 |
+
|
| 146 |
use_stack_memory (:obj:`bool`, *optional*, defaults to ``False``):
|
| 147 |
Enable the StackMemory / STACKTRANS hidden-state stack between
|
| 148 |
decoder layers (Zhang et al., NeurIPS 2025). The module keeps the
|
|
|
|
| 497 |
``0 <= repo_start_layer < num_hidden_layers`` when
|
| 498 |
``use_repo=True``, ``use_repo_grape=True`` or
|
| 499 |
``use_repo_goat_prior=True``.
|
| 500 |
+
- At most one of ``use_dca=True``, ``use_laurel=True``, ``use_attn_res=True`` or
|
| 501 |
+
``use_stack_memory=True`` may be active.
|
| 502 |
- When ``use_laurel=True``, at least one of ``use_laurel_rw`` or
|
| 503 |
``use_laurel_lr`` must be ``True``.
|
| 504 |
- ``stack_d_model`` must be divisible by ``num_mem_heads`` when
|
|
|
|
| 577 |
Litman, E. & Guo, G. (2026). *You Need Better Attention Priors.*
|
| 578 |
arXiv:2601.15380.
|
| 579 |
|
| 580 |
+
Heddes, M. et al. (2025). *DeepCrossAttention: Supercharging
|
| 581 |
+
Transformer Residual Connections.* ICML 2025. arXiv:2502.06785.
|
| 582 |
+
|
| 583 |
Menghani, G., Kumar, R. & Kumar, S. (2025). *LAUREL: Learned Augmented
|
| 584 |
Residual Layer.* ICML 2025. arXiv:2411.07501.
|
| 585 |
"""
|
|
|
|
| 608 |
head_dim=64,
|
| 609 |
use_momentum_attention=True,
|
| 610 |
momentum_gamma=0.10,
|
| 611 |
+
use_mea_attention=True,
|
| 612 |
mea_component_key_value_heads=None,
|
| 613 |
mea_groupnorm_eps=1e-6,
|
| 614 |
use_lucid_attention=False,
|
|
|
|
| 624 |
# ── Attention Residuals (Kimi Team, 2026) ─────────────────────────
|
| 625 |
use_attn_res=False,
|
| 626 |
attn_res_num_blocks=4,
|
| 627 |
+
# ── DeepCrossAttention (Heddes et al., ICML 2025) ─────────────────
|
| 628 |
+
use_dca=False,
|
| 629 |
+
dca_past_layers_k=1,
|
| 630 |
# ── StackMemory / STACKTRANS (Zhang et al., NeurIPS 2025) ───────
|
| 631 |
use_stack_memory=False,
|
| 632 |
stack_d_model=32, # H * d_s = 4 * 16
|
|
|
|
| 639 |
fan_ratio_ffn=0.0625,
|
| 640 |
dropout_rate=0.1,
|
| 641 |
# ── Embedding input normalization ─────────────────────────────────
|
| 642 |
+
use_embedding_input_norm=True,
|
| 643 |
# ── Leviathan continuous token generator ──────────────────────────
|
| 644 |
use_token_generator=False,
|
| 645 |
generator_d_seed=128,
|
|
|
|
| 719 |
f"got jtokm_top_k={jtokm_top_k}, jtokm_num_experts={jtokm_num_experts}."
|
| 720 |
)
|
| 721 |
|
| 722 |
+
# ── DCA: validate k-DCA source selection ──────────────────────────
|
| 723 |
+
if use_dca and dca_past_layers_k < 1:
|
| 724 |
+
raise ValueError(
|
| 725 |
+
f"`dca_past_layers_k` must be >= 1 when `use_dca=True`, "
|
| 726 |
+
f"got {dca_past_layers_k}."
|
| 727 |
+
)
|
| 728 |
+
|
| 729 |
# ── REPO: resolve defaults and validate ───────────────────────────
|
| 730 |
# repo_start_layer defaults to num_hidden_layers // 3, matching the
|
| 731 |
# paper's 1/3-of-depth heuristic (Li et al., 2026, §3).
|
|
|
|
| 792 |
f"`iha_num_pseudo_heads` must be >= 1, got {iha_num_pseudo_heads}."
|
| 793 |
)
|
| 794 |
|
| 795 |
+
# ── Residual-flow mechanism mutex ─────────────────────────────────
|
| 796 |
+
# DCA, AttnRes, LAuReL and StackMemory all alter cross-layer residual
|
| 797 |
+
# routing during training. Keep exactly one experimental residual-flow
|
| 798 |
+
# mechanism active at a time so ablations remain interpretable.
|
| 799 |
+
_residual_flow_flags = {
|
| 800 |
+
"use_dca": bool(use_dca),
|
| 801 |
+
"use_laurel": bool(use_laurel),
|
| 802 |
+
"use_attn_res": bool(use_attn_res),
|
| 803 |
+
"use_stack_memory": bool(use_stack_memory),
|
| 804 |
+
}
|
| 805 |
+
_active_residual_flow = [name for name, enabled in _residual_flow_flags.items() if enabled]
|
| 806 |
+
if len(_active_residual_flow) > 1:
|
| 807 |
raise ValueError(
|
| 808 |
+
"Enable at most one residual-flow mechanism among "
|
| 809 |
+
"`use_dca`, `use_laurel`, `use_attn_res`, and `use_stack_memory`. "
|
| 810 |
+
f"Active flags: {_active_residual_flow}."
|
|
|
|
| 811 |
)
|
| 812 |
+
|
| 813 |
+
# ── LAuReL: sub-flag consistency ──────────────────────────────────
|
| 814 |
if use_laurel and not use_laurel_rw and not use_laurel_lr:
|
| 815 |
raise ValueError(
|
| 816 |
"`use_laurel=True` requires at least one sub-variant to be active. "
|
|
|
|
| 886 |
self.use_attn_res = use_attn_res
|
| 887 |
self.attn_res_num_blocks = attn_res_num_blocks
|
| 888 |
|
| 889 |
+
# ── DeepCrossAttention ───────────────────────────────────────────
|
| 890 |
+
self.use_dca = use_dca
|
| 891 |
+
self.dca_past_layers_k = int(dca_past_layers_k)
|
| 892 |
+
|
| 893 |
# ── StackMemory / STACKTRANS ──────────────────────────────────────
|
| 894 |
self.use_stack_memory = use_stack_memory
|
| 895 |
self.stack_d_model = stack_d_model
|