|
liblloyal 1.0.0
Composable primitives for llama.cpp inference
|
Namespaces | |
| namespace | detail |
Typedefs | |
| using | PerplexityHandle = int32_t |
| using | BranchMetricsHandle = int32_t |
Enumerations | |
| enum class | Base { Nats , Bits } |
Functions | |
| float | model_surprisal (const float *logits, int n_vocab, int picked_id, Base base=Base::Nats) |
| float | model_entropy (const float *logits, int n_vocab, Base base=Base::Nats) |
| float | sampling_surprisal (const float *candidate_logits, const int32_t *candidate_ids, int n_candidates, int picked_id, Base base=Base::Nats) |
| Compute sampling-level surprisal for picked token. | |
| float | sampling_entropy (const float *candidate_logits, int n_candidates, Base base=Base::Nats) |
| Compute sampling-level entropy of candidate distribution. | |
| PerplexityHandle | create_perplexity () |
| void | add_surprisal (PerplexityHandle handle, float surprisal) |
| Add token surprisal to running average. | |
| float | get_ppl (PerplexityHandle handle) |
| Get current perplexity. | |
| int | get_count (PerplexityHandle handle) |
| Get number of tokens added to tracker. | |
| void | reset_perplexity (PerplexityHandle handle) |
| Reset tracker to initial state (start new sequence) | |
| PerplexityHandle | clone_perplexity (PerplexityHandle handle) |
| void | free_perplexity (PerplexityHandle handle) |
| Free perplexity tracker. | |
| BranchMetricsHandle | create_branch_metrics () |
| Create unified branch metrics tracker. | |
| void | free_branch_metrics (BranchMetricsHandle handle) |
| Free branch metrics tracker. | |
| BranchMetricsHandle | clone_branch_metrics (BranchMetricsHandle handle) |
| Clone branch metrics tracker (for fork/branching) | |
| void | add_model_surprisal (BranchMetricsHandle handle, float surprisal) |
| Add model-level surprisal (from raw logits before filters) | |
| float | get_model_ppl (BranchMetricsHandle handle) |
| Get model-level perplexity (from raw logits) | |
| void | add_sampling_surprisal (BranchMetricsHandle handle, float surprisal) |
| Add sampling-level surprisal (from filtered distribution) | |
| float | get_sampling_ppl (BranchMetricsHandle handle) |
| Get sampling-level perplexity (from filtered distribution) | |
| int | get_model_count (BranchMetricsHandle handle) |
| Get number of tokens in model-level tracker. | |
| int | get_sampling_count (BranchMetricsHandle handle) |
| Get number of tokens in sampling-level tracker. | |
| using lloyal::metrics::BranchMetricsHandle = typedef int32_t |
Definition at line 427 of file metrics.hpp.
| using lloyal::metrics::PerplexityHandle = typedef int32_t |
Definition at line 44 of file metrics.hpp.
|
strong |
| Enumerator | |
|---|---|
| Nats | |
| Bits | |
Definition at line 42 of file metrics.hpp.
|
inline |
Add model-level surprisal (from raw logits before filters)
| handle | Branch metrics handle |
| surprisal | Token surprisal in nats (from model_surprisal) |
Definition at line 497 of file metrics.hpp.
|
inline |
Add sampling-level surprisal (from filtered distribution)
| handle | Branch metrics handle |
| surprisal | Token surprisal in nats (from sampling_surprisal) |
Definition at line 528 of file metrics.hpp.
|
inline |
Add token surprisal to running average.
| handle | Perplexity tracker handle |
| surprisal | Token surprisal in nats (from model_surprisal) |
Definition at line 339 of file metrics.hpp.
|
inline |
Clone branch metrics tracker (for fork/branching)
Creates a new tracker with identical state for both model and sampling levels. Use when forking a branch to preserve metrics history.
| handle | Source branch metrics handle |
Definition at line 481 of file metrics.hpp.
|
inline |
Definition at line 404 of file metrics.hpp.
|
inline |
Create unified branch metrics tracker.
Tracks both model-level (raw logits) and sampling-level (filtered) perplexity in a single handle for atomic clone/free operations.
Definition at line 457 of file metrics.hpp.
|
inline |
Definition at line 327 of file metrics.hpp.
|
inline |
Free branch metrics tracker.
| handle | Branch metrics handle |
Definition at line 468 of file metrics.hpp.
|
inline |
Free perplexity tracker.
| handle | Perplexity tracker handle |
Definition at line 419 of file metrics.hpp.
|
inline |
Get number of tokens added to tracker.
| handle | Perplexity tracker handle |
Definition at line 369 of file metrics.hpp.
|
inline |
Get number of tokens in model-level tracker.
Definition at line 556 of file metrics.hpp.
|
inline |
Get model-level perplexity (from raw logits)
| handle | Branch metrics handle |
Definition at line 512 of file metrics.hpp.
|
inline |
Get current perplexity.
| handle | Perplexity tracker handle |
Definition at line 354 of file metrics.hpp.
|
inline |
Get number of tokens in sampling-level tracker.
Definition at line 566 of file metrics.hpp.
|
inline |
Get sampling-level perplexity (from filtered distribution)
| handle | Branch metrics handle |
Definition at line 543 of file metrics.hpp.
|
inline |
Definition at line 180 of file metrics.hpp.
|
inline |
Definition at line 131 of file metrics.hpp.
|
inline |
Reset tracker to initial state (start new sequence)
| handle | Perplexity tracker handle |
Definition at line 381 of file metrics.hpp.
|
inline |
Compute sampling-level entropy of candidate distribution.
Measures uncertainty within the filtered candidate set (after top-k/p/temperature). Use to monitor distribution health after grammar masks or constraints.
| candidate_logits | Logits of candidate tokens (post-filter) |
| n_candidates | Number of candidates |
| base | Nats (natural log) or Bits (log₂) |
Definition at line 272 of file metrics.hpp.
|
inline |
Compute sampling-level surprisal for picked token.
Measures uncertainty within the filtered candidate set (after top-k/p/temperature). Lower than model surprisal if filters removed low-probability tokens.
Use to monitor runtime hazard when grammar/constraints narrow the distribution.
| candidate_logits | Logits of candidate tokens (post-filter) |
| candidate_ids | Token IDs of candidates |
| n_candidates | Number of candidates |
| picked_id | Token ID that was sampled |
| base | Nats (natural log) or Bits (log₂) |
Definition at line 226 of file metrics.hpp.