Skip to content

llama.cpp ./embedding #17

Open
Open

Description

@Philipp-Sc

Is there no rust binding to get the embeddings?

Using llama.cpp one would use:

./embedding -m ./path/to/model --log-disable -p "Hello World!" 2>/dev/null

Activity

  1. mdrokz commented on Oct 25, 2023

    @mdrokz
    Owner

    Is there no rust binding to get the embeddings?

    Using llama.cpp one would use:

    ./embedding -m ./path/to/model --log-disable -p "Hello World!" 2>/dev/null

    have you tried this

    pub fn embeddings(
    method ?

    this will get you the embeddings for the prompt

  2. Philipp-Sc commented on Oct 26, 2023

    @Philipp-Sc
    Author

    @mdrokz thank you for your response.

    I tried it before trying the direct llama.cpp ./embedding executable.

    The function would always return an empty vector:

    []

    I tried multiple configurations but could not fix the issue.

  3. mdrokz commented on Oct 26, 2023

    @mdrokz
    Owner

    @mdrokz thank you for your response.

    I tried it before trying the direct llama.cpp ./embedding executable.

    The function would always return an empty vector:

    []

    I tried multiple configurations but could not fix the issue.

    Alright i will test on my end see whats happening. Thanks

  4. Philipp-Sc commented on Oct 27, 2023

    @Philipp-Sc
    Author

    I was using zephyr-7B-alpha-GGUF with:

    context_size: 8192 
    n_batch: 512 
    embeddings: true
    

    without any GPU assistance.


    Note:
    There also was some strange behavior regarding n_batch and n_token where a longer prompt (still way below the context length) lead to an unexpected error:

    GGML_ASSERT: n_token <= n_batch
    

    Right now my workaround is to use a rust wrapper (Command::new) around the ./embedding binary and parse the float values from stdout back into a string, then vector. The only parameter I set is --ctx-size 8192 and --mlock.
    I imagine this is less efficient as the model needs to be reloaded for each call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions