[PR #13354] [MERGED] model: add rnj-1 inference support #40049

Closed
opened 2026-04-23 01:03:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13354
Author: @jmorganca
Created: 12/6/2025
Status: Merged
Merged: 12/9/2025
Merged by: @jmorganca

Base: mainHead: jmorganca/rnj1


📝 Commits (1)

  • 7198273 model: add rnj-1 inference support

📊 Changes

6 files changed (+208 additions, -69 deletions)

View changed files

📝 convert/convert_gemma3.go (+52 -12)
📝 ml/nn/rope/options.go (+12 -0)
📝 model/models/gemma3/model.go (+38 -19)
📝 model/models/gemma3/model_text.go (+68 -26)
📝 parser/parser.go (+7 -12)
📝 parser/parser_test.go (+31 -0)

📄 Description

Adds support for the new rnj-1 ("Range-1") model

This also fixes an issue in the conversion where the BPE tokenizer was getting instantiated instead of a Sentencepiece tokenizer, by sending both tokenizer.json and tokenizer.model, even fi both exist – our conversion code on Ollama's server handles (and even expects?) this case

Example Modelfile:

FROM .

PARAMETER stop "<|start_header_id|>"
PARAMETER stop "<|end_header_id|>"
PARAMETER stop "<|eot_id|>"

TEMPLATE """
{{- /* Build system content: base system + user system + tools preface */ -}}
{{- $system := "You are rnj-1, a foundation model trained by Essential AI." -}}
{{- if and .System (not .Tools) }}{{ $system = printf "%s\n\n%s" $system .System }}{{ end -}}
{{- if .Tools }}
{{- $toolsPreface := "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" -}}
{{- range .Tools }}
{{- $toolsPreface = printf "%s\n%s" $toolsPreface (json .) -}}
{{- end -}}
{{- $toolsPreface = printf "%s\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" $toolsPreface -}}
{{- if .System }}{{ $system = printf "%s\n\n%s\n\n%s" $system .System $toolsPreface }}{{ else }}{{ $system = printf "%s\n\n%s" $system $toolsPreface }}{{ end -}}
{{- end -}}
<|start_header_id|>system<|end_header_id|>
{{ $system }}<|eot_id|>
{{- range $i, $_ := .Messages }}
{{- if eq .Role "system" }}{{ continue }}{{ end -}}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|start_header_id|>user<|end_header_id|>
{{ .Content }}<|eot_id|>
{{- else if eq .Role "assistant" }}<|start_header_id|>assistant<|end_header_id|>
{{ if .Content }}{{ .Content }}{{ end }}
{{- if .ToolCalls }}
{{- range .ToolCalls }}
<tool_call>
{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
</tool_call>
{{- end }}
{{- end }}{{ if not $last }}<|eot_id|>{{ end }}
{{- else if eq .Role "tool" }}<|start_header_id|>user<|end_header_id|>
<tool_response>
{{ .Content }}
</tool_response><|eot_id|>
{{- end }}
{{- if and (ne .Role "assistant") $last }}<|start_header_id|>assistant<|end_header_id|>
{{ end }}
{{- end }}"""

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13354 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 12/6/2025 **Status:** ✅ Merged **Merged:** 12/9/2025 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `jmorganca/rnj1` --- ### 📝 Commits (1) - [`7198273`](https://github.com/ollama/ollama/commit/71982739e04580ed806b38270eb73ee41b940c00) model: add rnj-1 inference support ### 📊 Changes **6 files changed** (+208 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `convert/convert_gemma3.go` (+52 -12) 📝 `ml/nn/rope/options.go` (+12 -0) 📝 `model/models/gemma3/model.go` (+38 -19) 📝 `model/models/gemma3/model_text.go` (+68 -26) 📝 `parser/parser.go` (+7 -12) 📝 `parser/parser_test.go` (+31 -0) </details> ### 📄 Description Adds support for the new rnj-1 ("Range-1") model * Blog post: https://essential.ai/research/rnj-1 * Weights: https://huggingface.co/EssentialAI/rnj-1-instruct This also fixes an issue in the conversion where the BPE tokenizer was getting instantiated instead of a Sentencepiece tokenizer, by sending both `tokenizer.json` and `tokenizer.model`, even fi both exist – our conversion code on Ollama's server handles (and even expects?) this case Example Modelfile: ``` FROM . PARAMETER stop "<|start_header_id|>" PARAMETER stop "<|end_header_id|>" PARAMETER stop "<|eot_id|>" TEMPLATE """ {{- /* Build system content: base system + user system + tools preface */ -}} {{- $system := "You are rnj-1, a foundation model trained by Essential AI." -}} {{- if and .System (not .Tools) }}{{ $system = printf "%s\n\n%s" $system .System }}{{ end -}} {{- if .Tools }} {{- $toolsPreface := "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" -}} {{- range .Tools }} {{- $toolsPreface = printf "%s\n%s" $toolsPreface (json .) -}} {{- end -}} {{- $toolsPreface = printf "%s\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" $toolsPreface -}} {{- if .System }}{{ $system = printf "%s\n\n%s\n\n%s" $system .System $toolsPreface }}{{ else }}{{ $system = printf "%s\n\n%s" $system $toolsPreface }}{{ end -}} {{- end -}} <|start_header_id|>system<|end_header_id|> {{ $system }}<|eot_id|> {{- range $i, $_ := .Messages }} {{- if eq .Role "system" }}{{ continue }}{{ end -}} {{- $last := eq (len (slice $.Messages $i)) 1 -}} {{- if eq .Role "user" }}<|start_header_id|>user<|end_header_id|> {{ .Content }}<|eot_id|> {{- else if eq .Role "assistant" }}<|start_header_id|>assistant<|end_header_id|> {{ if .Content }}{{ .Content }}{{ end }} {{- if .ToolCalls }} {{- range .ToolCalls }} <tool_call> {"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}} </tool_call> {{- end }} {{- end }}{{ if not $last }}<|eot_id|>{{ end }} {{- else if eq .Role "tool" }}<|start_header_id|>user<|end_header_id|> <tool_response> {{ .Content }} </tool_response><|eot_id|> {{- end }} {{- if and (ne .Role "assistant") $last }}<|start_header_id|>assistant<|end_header_id|> {{ end }} {{- end }}""" ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 01:03:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#40049