Skip to content

Set embeddings as an input to LLM models #9984

Answered by slaren
KonstantinSelyuk asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you have to initialize the rest of the fields of llama_batch. Unfortunately that's requires a bit more time to explain and I don't think there are any good and simple examples that show how to do it. However, for single sequence use, instead of using llama_batch_init, you should also be able to use this instead:

llama_batch batch = {
    /*n_tokens       =*/ tokens_count,
    /*tokens         =*/ nullptr,
    /*embd           =*/ some_tmp_emb.data(),
    /*pos            =*/ nullptr,
    /*n_seq_id       =*/ nullptr,
    /*seq_id         =*/ nullptr,
    /*logits         =*/ nullptr,
};

This should work in a similar way to llama_batch_get_one, and you don't have to figure the values …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@KonstantinSelyuk
Comment options

@slaren
Comment options

Answer selected by KonstantinSelyuk
@KonstantinSelyuk
Comment options

@slaren
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants