-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
61 lines (53 loc) · 1.42 KB
/
index.ts
File metadata and controls
61 lines (53 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* TypeScript Sampling Library
*
* Pure TS implementations of sampling algorithms.
* Designed for OTA updates, custom strategies, and transparency.
*
* Performance: ~0.5-1.0ms per token (vs ~0.1-0.3ms native)
* Trade-off: <2% overhead for full flexibility + debuggability
*/
// Core sampling strategies
export { greedy } from './greedy.js';
export { softmax } from './softmax.js';
// Combined strategies
export { sampleWithStrategy, getTopCandidates, type SamplerMode, type SamplingParams, type SampleOptions } from './strategies.js';
// Functional filters (for advanced use / testing)
export {
applyTopK,
applyTypicalP,
applyTopP,
applyMinP,
applyTopNSigma,
applyTemperature,
sampleFromSet,
candidateSetFromFullLogits,
CandidateSet,
} from './filters.js';
// Penalties
export {
TokenHistoryTracker,
applyRepetitionPenalty,
applyFrequencyPenalty,
applyPresencePenalty,
applyPenalties,
} from './penalties.js';
// PRNG (deterministic random number generation)
export {
Xoroshiro128Plus,
initializePRNG,
random,
resetPRNG,
} from './prng.js';
// Native fast path (opt-in)
// Utilities
export { SamplerWorkspace, selectTopK, requiredKcap, DEFAULT_KCAP, TYPICAL_P_KCAP } from './utils.js';
// Metrics (for Test-Time Alignment)
export {
computeModelSurprisal,
computeSamplingSurprisal,
computeModelEntropy,
computeSamplingEntropy,
RollingPerplexity,
type SurprisalBase,
} from './metrics.js';