Skip to content

Commit 599a2d7

Browse files
committed
support rnj-1
1 parent 18813a2 commit 599a2d7

File tree

11 files changed

+698
-484
lines changed

11 files changed

+698
-484
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ set(core_files src/backend.cpp
113113
models/phi.cpp
114114
models/qwen.cpp
115115
models/reka.cpp
116+
models/rnj.cpp
116117
models/seed.cpp
117118
models/siglip.cpp
118119
models/smol.cpp

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ LittleAcademia[<a href="https://github.com/foldl/little-academia" style="text-
3333

3434
**What's New:**
3535

36+
* 2025-12-15: Rnj-1
3637
* 2025-12-08: Ministral-3
3738
* 2025-11-06: Maya1
3839
* 2025-11-03: Ouro

convert.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class ModelType(Enum):
150150
Gemma = 0x1300
151151
Gemma2 = 0x1301
152152
Gemma3 = 0x1302
153+
RNJ_1 = 0x1303
153154

154155
CohereCommand = 0x1400
155156
CohereAya23 = 0x1401
@@ -5613,7 +5614,6 @@ def get_weight_names(config):
56135614

56145615
class Gemma3Converter(BaseConverter):
56155616
MODEL_TYPE = ModelType.Gemma3
5616-
FILE_VERSION = 1
56175617

56185618
@classmethod
56195619
def pp(cls, config, name: str, tensor):
@@ -5786,6 +5786,40 @@ def get_weight_names(config):
57865786

57875787
return weight_names
57885788

5789+
class RNJ_1Converter(BaseConverter):
5790+
MODEL_TYPE = ModelType.RNJ_1
5791+
5792+
@classmethod
5793+
def state_dict_pp(cls, config, state_dict):
5794+
return Gemma3Converter.state_dict_pp(config, state_dict)
5795+
5796+
@staticmethod
5797+
def dump_config(f, config, ggml_type):
5798+
final_logit_softcapping = config.final_logit_softcapping
5799+
attn_logit_softcapping = config.attn_logit_softcapping
5800+
rope_scaling = config.rope_scaling
5801+
config.rope_scaling = None
5802+
config.final_logit_softcapping = None
5803+
config.attn_logit_softcapping = None
5804+
5805+
Gemma3Converter.dump_config(f, config, ggml_type)
5806+
5807+
config_values = [
5808+
rope_scaling['attn_factor'],
5809+
rope_scaling['beta_fast'],
5810+
rope_scaling['beta_slow'],
5811+
rope_scaling['extrapolation_factor'],
5812+
rope_scaling['factor'],
5813+
rope_scaling['original_max_position_embeddings'],
5814+
final_logit_softcapping if final_logit_softcapping is not None else -1.0,
5815+
attn_logit_softcapping if attn_logit_softcapping is not None else -1.0,
5816+
]
5817+
f.write(struct.pack("<" + "fffffiff", *config_values))
5818+
5819+
@staticmethod
5820+
def get_weight_names(config):
5821+
return Gemma3Converter.get_weight_names(config)
5822+
57895823
class Grok1Converter(BaseConverter):
57905824
MODEL_TYPE = ModelType.Grok1
57915825
tensor_map = []
@@ -8844,7 +8878,10 @@ def main():
88448878
elif arch == 'Gemma2ForCausalLM':
88458879
Gemma2Converter.convert(config, model_files, vocab, ggml_type, args.save_path)
88468880
elif arch == 'Gemma3ForCausalLM':
8847-
Gemma3Converter.convert(config, model_files, vocab, ggml_type, args.save_path)
8881+
if config.rope_scaling and (config.rope_scaling['rope_type'] == 'yarn'):
8882+
RNJ_1Converter.convert(config, model_files, vocab, ggml_type, args.save_path)
8883+
else:
8884+
Gemma3Converter.convert(config, model_files, vocab, ggml_type, args.save_path)
88488885
elif arch == 'Gemma3ForConditionalGeneration':
88498886
if config.vision_config is not None:
88508887
Gemma3Converter.MODEL_TYPE = ModelType.Gemma3Vis

docs/models.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080

8181
Note: Only download `tokenizer.model` and DO NOT download `tokenizer.json` when converting.
8282

83+
* [x] Rnj-1: [Intruct](https://huggingface.co/EssentialAI/rnj-1-instruct/tree/2360f0368eec9bcf6d51aec66f6341503a6934f0)
84+
8385
* GPT (`GptOssForCausalLM`)
8486
* [x] OSS: [20B](https://huggingface.co/openai/gpt-oss-20b/tree/cbf31f62664d4b1360b3a78427f7b3c3ed8f0fa8), [120B](https://huggingface.co/openai/gpt-oss-120b/tree/bc75b44b8a2a116a0e4c6659bcd1b7969885f423)
8587

0 commit comments

Comments
 (0)