Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update _llama_cpp.py based on new contract of llama_get_logits #769

Merged
merged 3 commits into from
Apr 23, 2024
Merged

Update _llama_cpp.py based on new contract of llama_get_logits #769

merged 3 commits into from
Apr 23, 2024

Conversation

czoccolo
Copy link
Contributor

The new documentation for llama_get_logits is:

// Token logits obtained from the last call to llama_decode()
// The logits for which llama_batch.logits[i] != 0 are stored contiguously
// in the order they have appeared in the batch.
// Rows: number of tokens for which llama_batch.logits[i] != 0
// Cols: n_vocab
LLAMA_API float * llama_get_logits(struct llama_context * ctx);

Since we set llama_batch.logits[i] to true only for the last token, llama_get_logits already returns only the desired slice.

The new documentation for llama_get_logits is:

    // Token logits obtained from the last call to llama_decode()
    // The logits for which llama_batch.logits[i] != 0 are stored contiguously
    // in the order they have appeared in the batch.
    // Rows: number of tokens for which llama_batch.logits[i] != 0
    // Cols: n_vocab
    LLAMA_API float * llama_get_logits(struct llama_context * ctx);

Since we set llama_batch.logits[i] to true only for the last token, llama_get_logits already returns only the desired slice.
@codecov-commenter
Copy link

codecov-commenter commented Apr 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.50%. Comparing base (8cf29c2) to head (8de01b4).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #769      +/-   ##
==========================================
- Coverage   68.97%   62.50%   -6.48%     
==========================================
  Files          55       55              
  Lines        4058     4059       +1     
==========================================
- Hits         2799     2537     -262     
- Misses       1259     1522     +263     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@paulbkoch
Copy link
Collaborator

Thanks @czoccolo! This was a great find, and would have taken me a long time to figure out myself, so I'm really glad you submitted this as a PR.

@paulbkoch paulbkoch merged commit 0d06746 into guidance-ai:main Apr 23, 2024
96 checks passed
@czoccolo czoccolo deleted the patch-1 branch April 24, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants