Skip to content

Commit f0762dd

Browse files
authored
[Example] ggml: fix embedding example, increase output buffer size (#138)
1 parent 613dcae commit f0762dd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

wasmedge-ggml/embedding/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ fn set_metadata_to_context(
4949
}
5050

5151
fn get_data_from_context(context: &GraphExecutionContext, index: usize) -> String {
52-
// Preserve for 4096 tokens with average token length 15
53-
const MAX_OUTPUT_BUFFER_SIZE: usize = 4096 * 15 + 128;
52+
// Preserve for 4096 embedding size and each embedding number is length 20,
53+
// and add 128 bytes for other information such as "n_embedding" of other symbols.
54+
const MAX_OUTPUT_BUFFER_SIZE: usize = 4096 * 20 + 128;
5455
let mut output_buffer = vec![0u8; MAX_OUTPUT_BUFFER_SIZE];
5556
let mut output_size = context.get_output(index, &mut output_buffer).unwrap();
5657
output_size = std::cmp::min(MAX_OUTPUT_BUFFER_SIZE, output_size);
-424 KB
Binary file not shown.

0 commit comments

Comments
 (0)