Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct bert_hparams
int32_t n_intermediate = 1536;
int32_t n_head = 12;
int32_t n_layer = 6;
int32_t n_vocab_size = 2;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a break change since new field.
I believe some others will happen in future.
So we may try to shift into GGUF.

https://github.com/philpax/ggml/blob/gguf-spec/docs/gguf.md

int32_t f16 = 1;
};

Expand Down Expand Up @@ -489,11 +490,13 @@ struct bert_ctx * bert_load_from_file(const char *fname)
const int n_intermediate = hparams.n_intermediate;
const int n_max_tokens = hparams.n_max_tokens;
const int n_vocab = hparams.n_vocab;
const int n_vocab_size = hparams.n_vocab_size;


model.layers.resize(n_layer);

model.word_embeddings = ggml_new_tensor_2d(ctx, wtype, n_embd, n_vocab);
model.token_type_embeddings = ggml_new_tensor_2d(ctx, wtype, n_embd, 2);
model.token_type_embeddings = ggml_new_tensor_2d(ctx, wtype, n_embd, n_vocab_size);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skeskinen
here is a change since the tensor is related to n_vocab_size.
for many case, it is 2, but not a const.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model.position_embeddings = ggml_new_tensor_2d(ctx, wtype, n_embd, n_max_tokens);

model.ln_e_w = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, n_embd);
Expand Down
1 change: 1 addition & 0 deletions models/convert-to-ggml.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
fout.write(struct.pack("i", hparams["intermediate_size"]))
fout.write(struct.pack("i", hparams["num_attention_heads"]))
fout.write(struct.pack("i", hparams["num_hidden_layers"]))
fout.write(struct.pack("i", hparams["type_vocab_size"]))
fout.write(struct.pack("i", ftype))

for i in range(hparams["vocab_size"]):
Expand Down