Skip to content

Commit

Permalink
add 128k yarn context for Qwen
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiemu committed Dec 6, 2024
1 parent c5ede38 commit b8c3607
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions convert_hf_to_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,15 @@ def set_vocab(self):
except FileNotFoundError:
self._set_vocab_gpt2()

def set_gguf_parameters(self):
super().set_gguf_parameters()
if self.hparams.get("rope_scaling") is not None and "factor" in self.hparams["rope_scaling"]:
if self.hparams["rope_scaling"].get("type") == "yarn":
self.gguf_writer.add_rope_scaling_type(gguf.RopeScalingType.YARN)
self.gguf_writer.add_rope_scaling_factor(self.hparams["rope_scaling"]["factor"])
self.gguf_writer.add_rope_scaling_orig_ctx_len(self.hparams["rope_scaling"]["original_max_position_embeddings"])
self.gguf_writer.add_rope_scaling_yarn_log_mul(0.1)


@Model.register("Qwen2MoeForCausalLM")
class Qwen2MoeModel(Model):
Expand Down

0 comments on commit b8c3607

Please sign in to comment.