Skip to content

Commit

Permalink
patch from #1711
Browse files Browse the repository at this point in the history
  • Loading branch information
hkwon committed Sep 13, 2024
1 parent 3bd5219 commit 3f90226
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion python/ctranslate2/converters/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,17 @@ def set_attention(self, spec, attention, self_attention=False):
self.set_linear(spec.linear[-1], attention.out_proj)

def set_common_layers(self, spec, module):
spec.scale_embeddings = module.embed_scale
import math

if not hasattr(module, "embed_scale"):
embed_scale = (
math.sqrt(module.config.d_model)
if module.config.scale_embedding
else 1.0
)
else:
embed_scale = module.embed_scale
spec.scale_embeddings = embed_scale
self.set_position_encodings(spec.position_encodings, module.embed_positions)
self.set_embeddings(
(
Expand Down

0 comments on commit 3f90226

Please sign in to comment.