Version: v1.2.3 | Status: Active | Last Updated: March 2026
Provides sampling strategies for language model outputs including temperature scaling, top-k filtering, nucleus (top-p) sampling, and repetition penalty. Implements a composable processor pipeline for token sampling.
- Temperature scaling for controlling output diversity
- Top-k filtering to restrict sampling to the k most likely tokens
- Nucleus (top-p) sampling with cumulative probability threshold
- Repetition penalty to discourage previously generated tokens
from codomyrmex.logit_processor import TemperatureProcessor, TopKProcessor, TopPProcessor, LogitProcessorList, sample_token
processors = LogitProcessorList([TemperatureProcessor(0.8), TopKProcessor(50)])
token_id = sample_token(logits, temperature=0.8, top_k=50)LogitProcessor, LogitProcessorList, TemperatureProcessor, TopKProcessor, TopPProcessor, RepetitionPenaltyProcessor, greedy_decode, sample_token