Entropic 2.9.4
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::LlamaCppSamplerFactory Class Reference

Factory that builds entropic's canonical llama_sampler chain. More...

#include </home/runner/work/entropic/entropic/src/inference/llama_cpp_sampler.h>

Inheritance diagram for entropic::LlamaCppSamplerFactory:
Collaboration diagram for entropic::LlamaCppSamplerFactory:

Public Member Functions

 LlamaCppSamplerFactory (llama_context *ctx, const llama_vocab *vocab)
 Construct with borrowed context + vocab pointers.
 
std::unique_ptr< Samplercreate (const GenerationParams &params) override
 Build the v2.3.10 sampler chain from GenerationParams.
 

Detailed Description

Factory that builds entropic's canonical llama_sampler chain.

Chain order (must remain stable for output reproducibility): grammar → penalties → temperature → top-k → top-p → min-p → dist

Gating semantics:

  • grammar: appended only when params.grammar is non-empty (and llama_sampler_init_grammar returns non-null).
  • penalties: appended when params.repeat_penalty != 1.0f.
  • temperature: appended when params.temperature > 0.0f (temperature == 0 ⇒ greedy mode; the chain skips the temp sampler entirely).
  • top-k: appended when params.top_k > 0.
  • top-p: appended when params.top_p < 1.0f.
  • min-p (v2.3.10, gh#23): appended when params.min_p > 0.0f. Default 0.0f preserves pre-v2.3.10 chain shape.
  • dist: always appended last; seed resolves via LLAMA_DEFAULT_SEED when params.seed < 0. (P2-14)

Definition at line 118 of file llama_cpp_sampler.h.

Constructor & Destructor Documentation

◆ LlamaCppSamplerFactory()

entropic::LlamaCppSamplerFactory::LlamaCppSamplerFactory ( llama_context *  ctx,
const llama_vocab *  vocab 
)

Construct with borrowed context + vocab pointers.

Construct a factory bound to a llama_context + vocab.

Parameters
ctxActive llama_context (must outlive this factory).
vocabVocab pointer (must outlive this factory).
Version
2.3.10

Definition at line 164 of file llama_cpp_sampler.cpp.

Member Function Documentation

◆ create()

std::unique_ptr< Sampler > entropic::LlamaCppSamplerFactory::create ( const GenerationParams params)
overridevirtual

Build the v2.3.10 sampler chain from GenerationParams.

Chain order: grammar → penalties → temperature → top-k → top-p → min-p → dist. Each stage is gated by its parameter so the default chain stays bit-identical to pre-v2.3.10.

Parameters
paramsGeneration parameters driving each stage's gate.
Returns
Owned Sampler that wraps the constructed llama.cpp chain.

Implements entropic::SamplerFactory.

Definition at line 179 of file llama_cpp_sampler.cpp.


The documentation for this class was generated from the following files: