Text Generation
Transformers
Safetensors
laguna
laguna-xs-2.1
vllm
conversational
custom_code
Eval Results
Instructions to use poolside/Laguna-XS-2.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use poolside/Laguna-XS-2.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="poolside/Laguna-XS-2.1", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("poolside/Laguna-XS-2.1", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("poolside/Laguna-XS-2.1", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use poolside/Laguna-XS-2.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "poolside/Laguna-XS-2.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "poolside/Laguna-XS-2.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/poolside/Laguna-XS-2.1
- SGLang
How to use poolside/Laguna-XS-2.1 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 "poolside/Laguna-XS-2.1" \ --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": "poolside/Laguna-XS-2.1", "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 "poolside/Laguna-XS-2.1" \ --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": "poolside/Laguna-XS-2.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use poolside/Laguna-XS-2.1 with Docker Model Runner:
docker model run hf.co/poolside/Laguna-XS-2.1
Updated cookbook
#2
by Jiminator - opened
- README.md +14 -18
- chat_template.jinja +95 -56
- config.json +2 -2
- configuration_laguna.py +0 -6
- generation_config.json +0 -1
- modeling_laguna.py +2 -19
- tokenizer_config.json +2 -3
README.md
CHANGED
|
@@ -32,7 +32,7 @@ Laguna XS 2.1 is a 33B total parameter Mixture-of-Experts model with 3B activate
|
|
| 32 |
- **Mixed SWA and global attention layout**: Laguna XS 2.1 uses sigmoid gating with per-layer rotary scales, enabling mixed SWA (Sliding Window Attention) and global attention layers in a 3:1 ratio (across 40 total layers)
|
| 33 |
- **KV cache in FP8**: KV cache quantized to FP8, reducing memory per token
|
| 34 |
- **Native reasoning support**: Interleaved thinking between tool calls with support for enabling and disabling thinking per-request
|
| 35 |
-
- **Local-ready**: At 33B total parameters and 3B activated, Laguna XS 2.1 is compact enough to run on a Mac with 36 GB of RAM. Available on [Ollama](https://ollama.com/library/laguna-xs
|
| 36 |
- **OpenMDW-1.1 license**: Use and modify the model and associated materials freely for commercial and non-commercial purposes ([learn more about OpenMDW](https://openmdw.ai/))
|
| 37 |
|
| 38 |
---
|
|
@@ -118,8 +118,8 @@ pool acp setup --editor zed|jetbrains
|
|
| 118 |
Use pool with Ollama with one-command setup:
|
| 119 |
|
| 120 |
```shell
|
| 121 |
-
ollama pull laguna-xs
|
| 122 |
-
ollama launch pool --model laguna-xs
|
| 123 |
```
|
| 124 |
|
| 125 |
#### Feedback and issues
|
|
@@ -137,9 +137,6 @@ Serve Laguna XS 2.1 locally with vLLM and query it from any OpenAI-compatible cl
|
|
| 137 |
> [!NOTE]
|
| 138 |
> Laguna XS 2.1 support is available in vLLM 0.21.0 and later ([vllm-project/vllm#41129](https://github.com/vllm-project/vllm/pull/41129)).
|
| 139 |
|
| 140 |
-
> [!IMPORTANT]
|
| 141 |
-
> Use a vLLM build that includes [vllm-project/vllm#47311](https://github.com/vllm-project/vllm/pull/47311). Without that fix, the `poolside_v1` tool parser silently drops Laguna XS 2.1 tool calls that have no newline after the function name, and the raw tool-call markup leaks into the response. On an older build, pass `--tool-call-parser glm47` (the GLM 4.7 parser) instead.
|
| 142 |
-
|
| 143 |
```shell
|
| 144 |
pip install 'vllm>=0.21.0'
|
| 145 |
|
|
@@ -268,12 +265,12 @@ The same recipe works for the [FP8](https://huggingface.co/poolside/Laguna-XS-2.
|
|
| 268 |
> [!NOTE]
|
| 269 |
> **Optional: speculative decoding with DFlash.** The [DFlash speculator](https://huggingface.co/poolside/Laguna-XS-2.1-DFlash) can be paired with Laguna XS 2.1 for lower latency. TRT-LLM support is in progress in [NVIDIA/TensorRT-LLM#15666](https://github.com/NVIDIA/TensorRT-LLM/pull/15666).
|
| 270 |
|
| 271 |
-
####
|
| 272 |
|
| 273 |
> [!NOTE]
|
| 274 |
> Requires building llama.cpp from the upstream PR that adds Laguna XS 2.1 support until it lands ([ggml-org/llama.cpp#25165](https://github.com/ggml-org/llama.cpp/pull/25165)).
|
| 275 |
|
| 276 |
-
|
| 277 |
|
| 278 |
```shell
|
| 279 |
# Build llama.cpp from the PR branch
|
|
@@ -288,20 +285,19 @@ huggingface-cli download poolside/Laguna-XS-2.1-GGUF Laguna-XS-2.1-Q4_K_M.gguf -
|
|
| 288 |
|
| 289 |
#### Ollama
|
| 290 |
|
| 291 |
-
Available on the
|
| 292 |
|
| 293 |
-
ollama run laguna-xs
|
| 294 |
-
ollama run laguna-xs
|
| 295 |
-
ollama run laguna-xs
|
| 296 |
|
| 297 |
Reasoning and tool-calling work out of the box via the built-in `laguna` template.
|
| 298 |
|
| 299 |
-
>
|
| 300 |
-
>
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
Laguna XS 2.1 is also available in [Atomic Chat](https://atomic.chat/), a desktop app for running local models with a simple chat UI. To try it, download Atomic Chat, open the app, and choose Laguna XS 2.1 from the recommended models.
|
| 305 |
|
| 306 |
## Controlling reasoning
|
| 307 |
|
|
|
|
| 32 |
- **Mixed SWA and global attention layout**: Laguna XS 2.1 uses sigmoid gating with per-layer rotary scales, enabling mixed SWA (Sliding Window Attention) and global attention layers in a 3:1 ratio (across 40 total layers)
|
| 33 |
- **KV cache in FP8**: KV cache quantized to FP8, reducing memory per token
|
| 34 |
- **Native reasoning support**: Interleaved thinking between tool calls with support for enabling and disabling thinking per-request
|
| 35 |
+
- **Local-ready**: At 33B total parameters and 3B activated, Laguna XS 2.1 is compact enough to run on a Mac with 36 GB of RAM. Available on [Ollama](https://ollama.com/library/laguna-xs.2.1) and [llama.cpp](https://github.com/ggml-org/llama.cpp/pull/25165). High-quality FP8, NVFP4 and INT4 quantized variants available ([see the collection](https://huggingface.co/collections/poolside/laguna-xs-21))
|
| 36 |
- **OpenMDW-1.1 license**: Use and modify the model and associated materials freely for commercial and non-commercial purposes ([learn more about OpenMDW](https://openmdw.ai/))
|
| 37 |
|
| 38 |
---
|
|
|
|
| 118 |
Use pool with Ollama with one-command setup:
|
| 119 |
|
| 120 |
```shell
|
| 121 |
+
ollama pull laguna-xs.2.1
|
| 122 |
+
ollama launch pool --model laguna-xs.2.1
|
| 123 |
```
|
| 124 |
|
| 125 |
#### Feedback and issues
|
|
|
|
| 137 |
> [!NOTE]
|
| 138 |
> Laguna XS 2.1 support is available in vLLM 0.21.0 and later ([vllm-project/vllm#41129](https://github.com/vllm-project/vllm/pull/41129)).
|
| 139 |
|
|
|
|
|
|
|
|
|
|
| 140 |
```shell
|
| 141 |
pip install 'vllm>=0.21.0'
|
| 142 |
|
|
|
|
| 265 |
> [!NOTE]
|
| 266 |
> **Optional: speculative decoding with DFlash.** The [DFlash speculator](https://huggingface.co/poolside/Laguna-XS-2.1-DFlash) can be paired with Laguna XS 2.1 for lower latency. TRT-LLM support is in progress in [NVIDIA/TensorRT-LLM#15666](https://github.com/NVIDIA/TensorRT-LLM/pull/15666).
|
| 267 |
|
| 268 |
+
#### Llama.cpp
|
| 269 |
|
| 270 |
> [!NOTE]
|
| 271 |
> Requires building llama.cpp from the upstream PR that adds Laguna XS 2.1 support until it lands ([ggml-org/llama.cpp#25165](https://github.com/ggml-org/llama.cpp/pull/25165)).
|
| 272 |
|
| 273 |
+
GGUF weights (BF16 and Q4\_K\_M) are available at [poolside/Laguna-XS-2.1-GGUF](https://huggingface.co/poolside/Laguna-XS-2.1-GGUF).
|
| 274 |
|
| 275 |
```shell
|
| 276 |
# Build llama.cpp from the PR branch
|
|
|
|
| 285 |
|
| 286 |
#### Ollama
|
| 287 |
|
| 288 |
+
Available on the Ollama library:
|
| 289 |
|
| 290 |
+
ollama run laguna-xs.2.1 # default — Q4_K_M (imatrix)
|
| 291 |
+
ollama run laguna-xs.2.1:q8_0 # higher precision
|
| 292 |
+
ollama run laguna-xs.2.1:bf16 # full precision
|
| 293 |
|
| 294 |
Reasoning and tool-calling work out of the box via the built-in `laguna` template.
|
| 295 |
|
| 296 |
+
> **macOS (Metal) note:** Chat (`ollama run` / `/api/chat`) works on Linux/CUDA —
|
| 297 |
+
> coherent output with reasoning and tool-calling intact. On macOS/Metal it may
|
| 298 |
+
> currently return empty output; the root cause is not yet fully understood and
|
| 299 |
+
> we're investigating it with the Ollama team. On a Mac, use a Linux/CUDA host, or
|
| 300 |
+
> the `/api/generate` endpoint with `"raw": true`.
|
|
|
|
| 301 |
|
| 302 |
## Controlling reasoning
|
| 303 |
|
chat_template.jinja
CHANGED
|
@@ -1,93 +1,132 @@
|
|
| 1 |
-
{#-
|
| 2 |
-
{#-
|
| 3 |
{{- "〈|EOS|〉" -}}
|
| 4 |
{%- set enable_thinking = enable_thinking | default(false) -%}
|
|
|
|
| 5 |
{%- set add_generation_prompt = add_generation_prompt | default(false) -%}
|
| 6 |
|
| 7 |
{#- ───── header (system message) ───── -#}
|
| 8 |
-
{
|
| 9 |
-
{%- set system_message = "You are a helpful, conversationally-fluent assistant made by Poolside. You are here to be helpful to users through natural language conversations." -%}
|
| 10 |
{%- if messages and messages[0].role == "system" -%}
|
| 11 |
{%- set system_message = messages[0].content -%}
|
| 12 |
-
{%- set messages = messages[1:] -%}
|
| 13 |
{%- endif -%}
|
| 14 |
|
| 15 |
-
{%-
|
| 16 |
-
{
|
| 17 |
-
{{- "<system>" -}}
|
| 18 |
|
| 19 |
-
{%- if
|
|
|
|
| 20 |
{{- system_message.rstrip() -}}
|
| 21 |
-
{%- if tools -%}{{- "\n\n" -}}{%- endif -%}
|
| 22 |
{%- endif -%}
|
| 23 |
|
| 24 |
{%- if tools -%}
|
| 25 |
-
{{- "### Tools\n\n" -}}
|
| 26 |
-
{
|
| 27 |
-
|
| 28 |
-
|
| 29 |
{%- for tool in tools -%}
|
| 30 |
-
{
|
| 31 |
{%- endfor -%}
|
| 32 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
{%- endif -%}
|
| 34 |
|
| 35 |
-
{{- "</system>\n" -}}
|
| 36 |
{%- endif -%}
|
| 37 |
|
| 38 |
{#- ───── main loop ───── -#}
|
| 39 |
{%- for message in messages -%}
|
| 40 |
{%- set content = message.content if message.content is string else "" -%}
|
| 41 |
{%- if message.role == "user" -%}
|
| 42 |
-
{{- "<user>" + content + "</user>\n" -}}
|
| 43 |
{%- elif message.role == "assistant" -%}
|
| 44 |
{%- generation -%}
|
| 45 |
-
{{- "<assistant>" -}}
|
| 46 |
-
{
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
{
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
{#- Display main content (trailing newline only when no tool_calls follow) -#}
|
| 60 |
-
{%- if content -%}
|
| 61 |
{{- content -}}
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
{%- endfor -%}
|
| 72 |
-
|
| 73 |
-
{
|
| 74 |
{%- endif -%}
|
| 75 |
-
{{- "</assistant>\n" -}}
|
| 76 |
{%- endgeneration -%}
|
| 77 |
{%- elif message.role == "tool" -%}
|
| 78 |
-
{{- "<tool_response>" + content + "</tool_response>\n" -}}
|
| 79 |
-
{%- elif message.role == "system" -%}
|
| 80 |
-
{#- Render additional system messages (the first one
|
| 81 |
-
{{- "<system>" + content + "</system>\n" -}}
|
| 82 |
{%- endif -%}
|
| 83 |
{%- endfor -%}
|
| 84 |
{#- ───── generation prompt ───── -#}
|
| 85 |
{%- if add_generation_prompt -%}
|
| 86 |
-
{{- "<assistant>" -}}
|
| 87 |
{#- ───── Include reasoning mode directive ───── -#}
|
| 88 |
-
{%- if enable_thinking
|
| 89 |
-
{{- '<think>' -}}
|
| 90 |
-
{%- else -%}
|
| 91 |
{{- '</think>' -}}
|
| 92 |
-
{%-
|
| 93 |
-
{
|
|
|
|
|
|
|
|
|
| 1 |
+
{#- Copied from laguna_glm_thinking_v4/chat_template.jinja -#}
|
| 2 |
+
{#- Removes prefix that references <think> token, and replaces message.reasoning_content reference with message.reasoning -#}
|
| 3 |
{{- "〈|EOS|〉" -}}
|
| 4 |
{%- set enable_thinking = enable_thinking | default(false) -%}
|
| 5 |
+
{%- set render_assistant_messages_raw = render_assistant_messages_raw | default(false) -%}
|
| 6 |
{%- set add_generation_prompt = add_generation_prompt | default(false) -%}
|
| 7 |
|
| 8 |
{#- ───── header (system message) ───── -#}
|
| 9 |
+
{%- set system_message = "" -%}
|
|
|
|
| 10 |
{%- if messages and messages[0].role == "system" -%}
|
| 11 |
{%- set system_message = messages[0].content -%}
|
|
|
|
| 12 |
{%- endif -%}
|
| 13 |
|
| 14 |
+
{%- if (system_message and system_message.strip()) or tools -%}
|
| 15 |
+
{{- "<system>\n" -}}
|
|
|
|
| 16 |
|
| 17 |
+
{%- if system_message and system_message.strip() -%}
|
| 18 |
+
{{- "\n" -}}
|
| 19 |
{{- system_message.rstrip() -}}
|
|
|
|
| 20 |
{%- endif -%}
|
| 21 |
|
| 22 |
{%- if tools -%}
|
| 23 |
+
{{- "\n\n### Tools\n\n" -}}
|
| 24 |
+
{%- set ns = namespace(tool_string="You may call functions to assist with the user query.\n"
|
| 25 |
+
~ "All available function signatures are listed below:\n"
|
| 26 |
+
~ "<available_tools>\n") -%}
|
| 27 |
{%- for tool in tools -%}
|
| 28 |
+
{%- set ns.tool_string = ns.tool_string ~ (tool | tojson) ~ "\n" -%}
|
| 29 |
{%- endfor -%}
|
| 30 |
+
{%- if enable_thinking -%}
|
| 31 |
+
{%- set tool_string = ns.tool_string + "</available_tools>\n\n" ~
|
| 32 |
+
"Wrap your thinking in '<think>', '</think>' tags, followed by a function call. For each function call, return an unescaped XML-like object with function name and arguments within '<tool_call>' and '</tool_call>' tags, like here:\n" ~
|
| 33 |
+
"<think> your thoughts here </think>\n" ~
|
| 34 |
+
"<tool_call>function-name\n<arg_key>argument-key</arg_key>\n<arg_value>value-of-argument-key</arg_value>\n" ~
|
| 35 |
+
"</tool_call>" -%}
|
| 36 |
+
{%- else -%}
|
| 37 |
+
{%- set tool_string = ns.tool_string + "</available_tools>\n\n" ~
|
| 38 |
+
"For each function call, return an unescaped XML-like object " ~
|
| 39 |
+
"with function name and arguments within '<tool_call>' and '</tool_call>' tags, like here:\n" ~
|
| 40 |
+
"<tool_call>function-name\n<arg_key>argument-key</arg_key>\n<arg_value>value-of-argument-key</arg_value>\n" ~
|
| 41 |
+
"</tool_call>" -%}
|
| 42 |
+
{%- endif -%}
|
| 43 |
+
{{- tool_string -}}
|
| 44 |
{%- endif -%}
|
| 45 |
|
| 46 |
+
{{- "\n</system>\n" -}}
|
| 47 |
{%- endif -%}
|
| 48 |
|
| 49 |
{#- ───── main loop ───── -#}
|
| 50 |
{%- for message in messages -%}
|
| 51 |
{%- set content = message.content if message.content is string else "" -%}
|
| 52 |
{%- if message.role == "user" -%}
|
| 53 |
+
{{- "<user>\n" + content + "\n</user>\n" -}}
|
| 54 |
{%- elif message.role == "assistant" -%}
|
| 55 |
{%- generation -%}
|
| 56 |
+
{{- "<assistant>\n" -}}
|
| 57 |
+
{%- if render_assistant_messages_raw -%}
|
| 58 |
+
{#- Raw mode: prepend the generation prompt token, then dump content verbatim. -#}
|
| 59 |
+
{#- The generation prompt is <think> when enable_thinking, </think> otherwise. -#}
|
| 60 |
+
{#- Only prepend if content doesn't already start with it. -#}
|
| 61 |
+
{%- if enable_thinking -%}
|
| 62 |
+
{%- if not content.startswith('<think>') -%}
|
| 63 |
+
{{- '<think>' -}}
|
| 64 |
+
{%- endif -%}
|
| 65 |
+
{%- else -%}
|
| 66 |
+
{%- if not content.startswith('</think>') -%}
|
| 67 |
+
{{- '</think>' -}}
|
| 68 |
+
{%- endif -%}
|
| 69 |
+
{%- endif -%}
|
|
|
|
|
|
|
| 70 |
{{- content -}}
|
| 71 |
+
{#- Append closing tag if content doesn't already end with it. -#}
|
| 72 |
+
{%- if not content.endswith('</assistant>\n') and not content.endswith('</assistant>') -%}
|
| 73 |
+
{{- '\n</assistant>' -}}
|
| 74 |
+
{%- endif -%}
|
| 75 |
+
{{- "\n" -}}
|
| 76 |
+
{%- else -%}
|
| 77 |
+
{#- Extract reasoning content from message.reasoning (vLLM field name) or message.reasoning_content, or from <think> tags -#}
|
| 78 |
+
{%- set reasoning_content = '' %}
|
| 79 |
+
{%- if message.reasoning is string %}
|
| 80 |
+
{%- set reasoning_content = message.reasoning %}
|
| 81 |
+
{%- elif message.reasoning_content is string %}
|
| 82 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 83 |
+
{%- endif %}
|
| 84 |
+
{#- Always strip <think> tags from content if present to avoid duplication -#}
|
| 85 |
+
{%- if '</think>' in content %}
|
| 86 |
+
{%- if not reasoning_content %}
|
| 87 |
+
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
| 88 |
+
{%- endif %}
|
| 89 |
+
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 90 |
+
{%- endif %}
|
| 91 |
+
{#- Display reasoning content for all messages -#}
|
| 92 |
+
{%- if reasoning_content -%}
|
| 93 |
+
{{- '<think>\n' + reasoning_content.strip() + '\n</think>\n' -}}
|
| 94 |
+
{%- else -%}
|
| 95 |
+
{{- '</think>\n' -}}
|
| 96 |
+
{%- endif -%}
|
| 97 |
+
{#- Display main content -#}
|
| 98 |
+
{%- if content.strip() -%}
|
| 99 |
+
{{- content.strip() ~ "\n" -}}
|
| 100 |
+
{%- endif -%}
|
| 101 |
+
{%- if message.tool_calls -%}
|
| 102 |
+
{%- for tool_call in message.tool_calls -%}
|
| 103 |
+
{%- set function_data = tool_call.function -%}
|
| 104 |
+
{{- '<tool_call>' + function_data.name }}
|
| 105 |
+
{% set _args = function_data.arguments %}
|
| 106 |
+
{%- for k, v in _args.items() -%}
|
| 107 |
+
{{- "<arg_key>" ~ k ~ "</arg_key>\n" -}}
|
| 108 |
+
{{- "<arg_value>"}}{{ v | tojson(ensure_ascii=False) if v is not string else v }}{{ "</arg_value>\n" -}}
|
| 109 |
+
{%- endfor -%}
|
| 110 |
+
{{- "</tool_call>\n" -}}
|
| 111 |
{%- endfor -%}
|
| 112 |
+
{%- endif -%}
|
| 113 |
+
{{- "</assistant>\n" -}}
|
| 114 |
{%- endif -%}
|
|
|
|
| 115 |
{%- endgeneration -%}
|
| 116 |
{%- elif message.role == "tool" -%}
|
| 117 |
+
{{- "<tool_response>\n" + content + "\n</tool_response>\n" -}}
|
| 118 |
+
{%- elif message.role == "system" and loop.index0 != 0 -%}
|
| 119 |
+
{#- Render additional system messages (skip the first one which is handled separately in the header) -#}
|
| 120 |
+
{{- "<system>\n" + content + "\n</system>\n" -}}
|
| 121 |
{%- endif -%}
|
| 122 |
{%- endfor -%}
|
| 123 |
{#- ───── generation prompt ───── -#}
|
| 124 |
{%- if add_generation_prompt -%}
|
| 125 |
+
{{- "<assistant>\n" -}}
|
| 126 |
{#- ───── Include reasoning mode directive ───── -#}
|
| 127 |
+
{%- if not enable_thinking %}
|
|
|
|
|
|
|
| 128 |
{{- '</think>' -}}
|
| 129 |
+
{%- else %}
|
| 130 |
+
{{- '<think>' -}}
|
| 131 |
+
{%- endif %}
|
| 132 |
+
{%- endif -%}
|
config.json
CHANGED
|
@@ -47,7 +47,7 @@
|
|
| 47 |
"original_max_position_embeddings": 8192,
|
| 48 |
"beta_slow": 1.0,
|
| 49 |
"beta_fast": 64.0,
|
| 50 |
-
"attention_factor": 1.
|
| 51 |
"partial_rotary_factor": 0.5
|
| 52 |
},
|
| 53 |
"sliding_attention": {
|
|
@@ -226,4 +226,4 @@
|
|
| 226 |
64,
|
| 227 |
64
|
| 228 |
]
|
| 229 |
-
}
|
|
|
|
| 47 |
"original_max_position_embeddings": 8192,
|
| 48 |
"beta_slow": 1.0,
|
| 49 |
"beta_fast": 64.0,
|
| 50 |
+
"attention_factor": 1.0,
|
| 51 |
"partial_rotary_factor": 0.5
|
| 52 |
},
|
| 53 |
"sliding_attention": {
|
|
|
|
| 226 |
64,
|
| 227 |
64
|
| 228 |
]
|
| 229 |
+
}
|
configuration_laguna.py
CHANGED
|
@@ -186,12 +186,6 @@ class LagunaConfig(PreTrainedConfig):
|
|
| 186 |
if rope_parameters is None:
|
| 187 |
rope_parameters = {"rope_type": "default", "rope_theta": 500000.0}
|
| 188 |
|
| 189 |
-
# config.json stores SWA rope nested in rope_parameters["sliding_attention"]
|
| 190 |
-
# and carries no top-level swa_rope_parameters. Derive it here, else the
|
| 191 |
-
# sliding-window layers silently reuse the full-attention rope.
|
| 192 |
-
if swa_rope_parameters is None and isinstance(rope_parameters, dict):
|
| 193 |
-
swa_rope_parameters = rope_parameters.get("sliding_attention")
|
| 194 |
-
|
| 195 |
# If ``partial_rotary_factor`` is set at the top level, inject it into any
|
| 196 |
# rope dict that does not already carry one so the rotary embedding picks
|
| 197 |
# it up consistently for both full-attention and SWA layers.
|
|
|
|
| 186 |
if rope_parameters is None:
|
| 187 |
rope_parameters = {"rope_type": "default", "rope_theta": 500000.0}
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
# If ``partial_rotary_factor`` is set at the top level, inject it into any
|
| 190 |
# rope dict that does not already carry one so the rotary embedding picks
|
| 191 |
# it up consistently for both full-attention and SWA layers.
|
generation_config.json
CHANGED
|
@@ -10,7 +10,6 @@
|
|
| 10 |
"temperature": 1.0,
|
| 11 |
"top_p": 1.0,
|
| 12 |
"min_p": 0.0,
|
| 13 |
-
"top_k": 20,
|
| 14 |
"speculative_config": {
|
| 15 |
"method": "dflash",
|
| 16 |
"source": "huggingface",
|
|
|
|
| 10 |
"temperature": 1.0,
|
| 11 |
"top_p": 1.0,
|
| 12 |
"min_p": 0.0,
|
|
|
|
| 13 |
"speculative_config": {
|
| 14 |
"method": "dflash",
|
| 15 |
"source": "huggingface",
|
modeling_laguna.py
CHANGED
|
@@ -633,8 +633,8 @@ class LagunaModel(LagunaPreTrainedModel):
|
|
| 633 |
use_cache: bool | None = None,
|
| 634 |
**kwargs: Unpack[TransformersKwargs],
|
| 635 |
) -> MoeModelOutputWithPast:
|
| 636 |
-
from
|
| 637 |
-
from
|
| 638 |
|
| 639 |
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 640 |
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
|
@@ -877,20 +877,3 @@ class LagunaForCausalLM(LagunaPreTrainedModel, GenerationMixin):
|
|
| 877 |
|
| 878 |
|
| 879 |
__all__ = ["LagunaForCausalLM", "LagunaModel", "LagunaPreTrainedModel"]
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
# --- Added: register the native Laguna checkpoint-conversion for trust_remote_code loads.
|
| 883 |
-
# transformers >=5.12 skips checkpoint-conversion mappings for custom (remote) code
|
| 884 |
-
# unless explicitly registered, which broke loading the shipped per-expert MoE weights.
|
| 885 |
-
try:
|
| 886 |
-
from transformers.conversion_mapping import (
|
| 887 |
-
get_checkpoint_conversion_mapping as _lg_get,
|
| 888 |
-
register_checkpoint_conversion_mapping as _lg_reg,
|
| 889 |
-
USER_REGISTERED_MAPPINGS as _lg_user,
|
| 890 |
-
)
|
| 891 |
-
if "laguna" not in _lg_user:
|
| 892 |
-
_lg_m = _lg_get("laguna")
|
| 893 |
-
if _lg_m is not None:
|
| 894 |
-
_lg_reg("laguna", _lg_m, overwrite=True)
|
| 895 |
-
except Exception:
|
| 896 |
-
pass
|
|
|
|
| 633 |
use_cache: bool | None = None,
|
| 634 |
**kwargs: Unpack[TransformersKwargs],
|
| 635 |
) -> MoeModelOutputWithPast:
|
| 636 |
+
from ...cache_utils import DynamicCache
|
| 637 |
+
from ...masking_utils import create_causal_mask, create_sliding_window_causal_mask
|
| 638 |
|
| 639 |
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 640 |
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
|
|
|
| 877 |
|
| 878 |
|
| 879 |
__all__ = ["LagunaForCausalLM", "LagunaModel", "LagunaPreTrainedModel"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tokenizer_config.json
CHANGED
|
@@ -571,6 +571,5 @@
|
|
| 571 |
"pad_token": "〈|PAD|〉",
|
| 572 |
"sep_token": "〈|SEP|〉",
|
| 573 |
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 574 |
-
"unk_token": "〈|UNK|〉"
|
| 575 |
-
|
| 576 |
-
}
|
|
|
|
| 571 |
"pad_token": "〈|PAD|〉",
|
| 572 |
"sep_token": "〈|SEP|〉",
|
| 573 |
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 574 |
+
"unk_token": "〈|UNK|〉"
|
| 575 |
+
}
|
|
|