Skip to content

feat: Add extended sampling API with candidate token lists #14612 #14765

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

baonudesifeizhai
Copy link

This commit implements the feature requested in issue #14612, adding an extended sampling API that provides detailed information about the sampling process.

Key changes:

  • Add llama_sampling_result struct to include/llama.h
  • Add llama_sampler_sample_with_candidates function
  • Add llama_sampling_result_free function for memory management
  • Update README.md with comprehensive API documentation

The new API allows developers to:

  • Access selected token ID, logit, and probability
  • Get a list of candidate tokens with their probabilities
  • Debug sampling strategies and analyze model behavior
  • Build applications with insight into model decision-making

Resolves: #14612

Make sure to read the contributing guidelines before submitting a PR

This commit implements the feature requested in issue ggml-org#14612, adding an extended sampling API that provides detailed information about the sampling process.

Key changes:
- Add llama_sampling_result struct to include/llama.h
- Add llama_sampler_sample_with_candidates function
- Add llama_sampling_result_free function for memory management
- Update README.md with comprehensive API documentation

The new API allows developers to:
- Access selected token ID, logit, and probability
- Get a list of candidate tokens with their probabilities
- Debug sampling strategies and analyze model behavior
- Build applications with insight into model decision-making

Resolves: ggml-org#14612
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.

Feature Request: Improve Sampling API: Expose Top‑K/Top‑P Candidate Token Lists in C API
1 participant