Skip to content

Commit b359533

Browse files
committed
[fix] fix for eog token
1 parent c72e399 commit b359533

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

convert_hf_to_gguf.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7860,14 +7860,6 @@ def set_gguf_parameters(self):
78607860

78617861
_experts: list[dict[str, Tensor]] | None = None
78627862

7863-
@staticmethod
7864-
def permute(weights: Tensor, n_head: int, n_head_kv: int | None):
7865-
if n_head_kv is not None and n_head != n_head_kv:
7866-
n_head = n_head_kv
7867-
return (weights.reshape(n_head, 2, weights.shape[0] // n_head // 2, *weights.shape[1:])
7868-
.swapaxes(1, 2)
7869-
.reshape(weights.shape))
7870-
78717863
def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
78727864
if name.endswith("query_key_value.weight"):
78737865
n_head = self.hparams["num_attention_heads"]
@@ -7878,8 +7870,8 @@ def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iter
78787870
q, k, v = data_torch.split([n_head * head_dim, n_kv_head * head_dim, n_kv_head * head_dim], dim=-2)
78797871

78807872
return [
7881-
(self.format_tensor_name(gguf.MODEL_TENSOR.ATTN_Q, bid), self.permute(q, n_head, n_head)),
7882-
(self.format_tensor_name(gguf.MODEL_TENSOR.ATTN_K, bid), self.permute(k, n_head, n_kv_head)),
7873+
(self.format_tensor_name(gguf.MODEL_TENSOR.ATTN_Q, bid), q),
7874+
(self.format_tensor_name(gguf.MODEL_TENSOR.ATTN_K, bid), k),
78837875
(self.format_tensor_name(gguf.MODEL_TENSOR.ATTN_V, bid), v)
78847876
]
78857877
elif name.find("mlp.experts") != -1:

src/llama-vocab.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,7 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
23272327
|| t.first == "_<EOT>"
23282328
|| t.first == "<|end_of_text|>"
23292329
|| t.first == "<end_of_utterance>" // smoldocling
2330+
|| t.first == "<|role_end|>" // Ling v2
23302331
) {
23312332
special_eog_ids.insert(t.second);
23322333
if ((id_to_token[t.second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {

0 commit comments

Comments
 (0)