Skip to content

Text Generation Parameters

Complete reference for all text generation parameters.

Basic Parameters

ParameterTypeDefaultRangeDescription
inputstringrequired-Input text to continue
modelTextModel'llama-3-erato-v1'-Model to use
maxLengthnumber401-2048Maximum tokens to generate
minLengthnumber11-2048Minimum tokens to generate
generateUntilSentenceboolean--Generate until sentence end

Sampling Parameters

Temperature

Controls randomness. Higher values produce more varied output.

typescript
temperature: 1.0  // Default, balanced
temperature: 0.5  // More focused
temperature: 5.0  // More creative
ValueEffect
0.1-1.0Focused, deterministic
1.0-2.0Balanced
2.0+Creative, varied

Range: 0.1-100

Top-K Sampling

Limits vocabulary to top K most likely tokens.

typescript
topK: 0    // Disabled (default)
topK: 50   // Consider only top 50 tokens
topK: 100  // Consider only top 100 tokens

Top-P (Nucleus) Sampling

Limits vocabulary to tokens comprising top P probability mass.

typescript
topP: 1.0  // Disabled (default)
topP: 0.9  // Consider tokens in top 90% probability
topP: 0.5  // More restrictive

Range: 0.0-1.0

Top-A Sampling

Alternative sampling method based on probability ratios.

typescript
topA: 0    // Disabled (default)
topA: 0.1  // Light filtering

Typical P Sampling

Filters tokens based on "typicality" of their probability.

typescript
typicalP: 1.0  // Disabled (default)
typicalP: 0.9  // Typical sampling enabled

Tail-Free Sampling (TFS)

Removes low-probability tail tokens.

typescript
tailFreeSampling: 1.0  // Disabled (default)
tailFreeSampling: 0.9  // Light tail removal

Range: 0.0-1.0

Min-P Sampling

Sampling method based on minimum probability threshold.

typescript
minP: 0    // Disabled (default)
minP: 0.1  // Filter tokens below 10% of top probability

Range: 0.0-1.0

Top-G Sampling

Group-based sampling method.

typescript
topG: 0  // Disabled (default)

Range: 0-65536

Mirostat Parameters

Mirostat is an adaptive sampling algorithm that maintains stable perplexity in output.

ParameterTypeDescription
mirostatTaunumberTarget perplexity. 0 = disabled
mirostatLrnumberLearning rate (0.0-1.0)
typescript
{
  mirostatTau: 5.0,  // Target perplexity
  mirostatLr: 0.1,   // Learning rate
}

Unified Sampling Parameters

Unified sampling is an advanced sampling method.

ParameterTypeDescription
unifiedLinearnumberLinear parameter
unifiedQuadnumberQuadratic parameter
unifiedConfnumberEntropy scale parameter

Repetition Penalty

Basic Penalty

Penalizes repeated tokens to reduce repetition.

typescript
repetitionPenalty: 1.0  // Disabled (default)
repetitionPenalty: 1.1  // Light penalty
repetitionPenalty: 1.5  // Strong penalty

Penalty Range

How far back to look for repetitions.

typescript
repetitionPenaltyRange: 0     // Full context (default)
repetitionPenaltyRange: 512   // Last 512 tokens
repetitionPenaltyRange: 1024  // Last 1024 tokens

Range: 0-8192

Frequency Penalty

Penalizes based on how often a token appears.

typescript
repetitionPenaltyFrequency: 0    // Disabled (default)
repetitionPenaltyFrequency: 0.1  // Light frequency penalty

Range: -16 to 16

Presence Penalty

Penalizes tokens that have appeared at all.

typescript
repetitionPenaltyPresence: 0    // Disabled (default)
repetitionPenaltyPresence: 0.1  // Light presence penalty

Range: -16 to 16

Penalty Slope

Controls how quickly penalty decays with distance.

typescript
repetitionPenaltySlope: 0    // Disabled (default)
repetitionPenaltySlope: 0.5  // Light slope

Range: 0-10

Phrase Repetition Penalty

Preset phrase repetition penalty modes.

typescript
phraseRepPen: 'off'        // Disabled
phraseRepPen: 'very_light'
phraseRepPen: 'light'
phraseRepPen: 'medium'
phraseRepPen: 'aggressive'
phraseRepPen: 'very_aggressive'

CFG (Classifier-Free Guidance)

CFG can enhance consistency between generated content and the prompt.

ParameterTypeDescription
cfgScalenumberCFG strength. 0 = disabled
cfgUcstringNegative prompt
typescript
{
  cfgScale: 1.5,
  cfgUc: 'boring, repetitive',
}

Sequence Control

Stop Sequences

Generation stops when any of these sequences is produced.

typescript
stopSequences: ['\n\n', 'THE END', '***']

Note: This triggers tokenization via the token-count endpoint before the request, which adds extra network calls and a small delay. The model parameter is used for tokenization.

Ban Sequences

These sequences are prevented from appearing in output.

typescript
banSequences: ['forbidden', 'unwanted']

Note: This also triggers token-count tokenization (extra requests).

Logit Bias

Adjust the probability of specific tokens.

typescript
logitBias: [
  { token: 'the', bias: -0.5 },   // Less likely
  { token: 'magic', bias: 1.0 },  // More likely
]

Other Parameters

ParameterTypeDescription
numLogprobsnumberNumber of logprobs to return (0-30)
bracketBanbooleanBan bracket tokens
prefixstringPrefix/module to use
ordernumber[]Sampler order

Complete Example

typescript
const text = await client.text.generate({
  input: 'The wizard raised his staff and',
  model: 'llama-3-erato-v1',
  
  // Length
  maxLength: 100,
  minLength: 20,
  
  // Sampling
  temperature: 1.1,
  topK: 50,
  topP: 0.95,
  typicalP: 1.0,
  tailFreeSampling: 0.95,
  minP: 0.05,
  
  // Repetition
  repetitionPenalty: 1.15,
  repetitionPenaltyRange: 512,
  repetitionPenaltyFrequency: 0.02,
  repetitionPenaltyPresence: 0.0,
  
  // Sequences
  stopSequences: ['\n\n', '***'],
  banSequences: [],
  
  // Bias
  logitBias: [
    { token: 'magic', bias: 0.5 },
  ],
});

Creative Writing

typescript
{
  temperature: 1.2,
  topP: 0.95,
  repetitionPenalty: 1.1,
  repetitionPenaltyRange: 512,
}

Focused/Factual

typescript
{
  temperature: 0.7,
  topK: 40,
  repetitionPenalty: 1.0,
}

Dialogue

typescript
{
  temperature: 1.0,
  topP: 0.9,
  repetitionPenalty: 1.05,
  stopSequences: ['\n\n'],
}

Released under the MIT License.