Skip to content

Commit

Permalink
[Example] ggml: fix embedding example, increase output buffer size (#138
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dm4 authored May 7, 2024
1 parent 613dcae commit f0762dd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions wasmedge-ggml/embedding/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ fn set_metadata_to_context(
}

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

0 comments on commit f0762dd

Please sign in to comment.