Understanding valid parameters of ollama
Detailed Parameter Descriptions and Use Cases
1. mirostat
- Description: Enables Mirostat sampling, which helps control the perplexity of the generated text. This is important for maintaining the quality and coherence of the output.
- Value Type: Integer
- Possible Values:
0
: Disabled1
: Mirostat2
: Mirostat 2.0
- Example Usage:
mirostat 1
- Use Case: Use Mirostat when you want to dynamically adjust the generation process based on the complexity of the text, ensuring that the output remains coherent while still being creative.
2. mirostat_eta
- Description: Influences the learning rate of the Mirostat algorithm. A lower value results in slower adjustments to the generated text, while a higher value makes the algorithm more responsive to feedback.
- Value Type: Float
- Default Value:
0.1
- Example Usage:
mirostat_eta 0.1
- Use Case: Set a higher
mirostat_eta
if you want the model to quickly adapt to the style and tone of the text being generated, which is useful in interactive applications like chatbots.
3. mirostat_tau
- Description: Controls the balance between coherence and diversity in the generated output. A lower value leads to more focused and coherent text, while a higher value allows for more diverse responses.
- Value Type: Float
- Default Value:
5.0
- Example Usage:
mirostat_tau 5.0
- Use Case: Use a lower
mirostat_tau
in applications where clarity and coherence are critical, such as summarization tasks, and a higher value for creative writing tasks where diversity is desired.
4. num_ctx
- Description: Sets the size of the context window used to generate the next token. A larger context window allows the model to consider more previous tokens, improving coherence.
- Value Type: Integer
- Default Value:
2048
- Example Usage:
num_ctx 4096
- Use Case: Increase
num_ctx
for complex tasks that require understanding of longer contexts, such as story generation or dialogue systems.
5. repeat_last_n
- Description: Determines how far back the model looks to prevent repetition in the output. A value of
0
disables this feature, while-1
sets it to the context size. - Value Type: Integer
- Default Value:
64
- Example Usage:
repeat_last_n 64
- Use Case: Use this parameter to avoid repetitive phrases in creative writing or dialogue generation, ensuring more engaging and varied output.
6. repeat_penalty
- Description: Sets the strength of the penalty applied to repeated tokens. A higher value penalizes repetitions more strongly, while a lower value is more lenient.
- Value Type: Float
- Default Value:
1.1
- Example Usage:
repeat_penalty 1.1
- Use Case: Increase
repeat_penalty
in scenarios where you want to ensure unique and diverse responses, such as in creative writing or generating dialogue for characters.
7. temperature
- Description: Controls the randomness of the model’s output. A higher temperature leads to more creative and varied responses, while a lower temperature yields more deterministic outputs.
- Value Type: Float
- Default Value:
0.8
- Example Usage:
temperature 0.7
- Use Case: Use a higher temperature for brainstorming sessions or creative writing, and a lower temperature for tasks requiring precision, like coding assistance or factual responses.
8. seed
- Description: Sets the random number seed for generation. Using a specific seed allows for reproducible results, meaning the same input will yield the same output each time.
- Value Type: Integer
- Default Value:
0
- Example Usage:
seed 42
- Use Case: Set a specific seed when testing or debugging to ensure consistent results across runs, which is particularly useful in research and development.
9. stop
- Description: Defines stop sequences that, when encountered, will halt the text generation process. Multiple stop patterns can be specified.
- Value Type: String
- Example Usage:
stop "AI assistant:"
- Use Case: Use stop sequences in interactive applications to control when the model should stop generating text, such as in chatbots or interactive storytelling.
10. tfs_z
- Description: Tail-free sampling reduces the influence of less probable tokens in the output. A higher value reduces this impact, while a value of
1.0
disables the feature. - Value Type: Float
- Default Value:
1
- Example Usage:
tfs_z 1.5
- Use Case: Adjust
tfs_z
when you want to focus on generating higher-quality text by filtering out less likely tokens, which can be beneficial in formal writing or technical documentation.
11. num_predict
- Description: Specifies the maximum number of tokens to predict during text generation. A value of
-1
allows for infinite generation, while-2
fills the context. - Value Type: Integer
- Default Value:
128
- Example Usage:
num_predict 42
- Use Case: Set this parameter to control the length of generated responses, such as limiting answers in a Q&A system or extending responses in creative writing.
12. top_k
- Description: Reduces the probability of generating nonsensical outputs by limiting the number of tokens considered. A higher value allows for more diverse answers, while a lower value is more conservative.
- Value Type: Integer
- Default Value:
40
- Example Usage:
top_k 100
- Use Case: Use a higher
top_k
for creative tasks where diversity is desired, and a lower value for tasks requiring more focused and coherent responses.
13. top_p
- Description: Works in conjunction with
top_k
to control the diversity of the text generated. A higher value results in more varied outputs, while a lower value yields more focused responses. - Value Type: Float
- Default Value:
0.9
- Example Usage:
top_p 0.95
- Use Case: Adjust
top_p
for applications needing a balance between creativity and coherence, such as dialogue generation or storytelling.
14. min_p
- Description: An alternative to
top_p
, this parameter ensures a balance between quality and variety by filtering out tokens below a certain probability threshold. - Value Type: Float
- Default Value:
0.0
- Example Usage:
min_p 0.05
- Use Case: Use
min_p
when you want to ensure that only high-probability tokens are considered, which can be beneficial in applications requiring high-quality outputs, like formal writing or technical documentation.
Conclusion
These parameters provide fine control over the behavior of language models, allowing users to tailor the output to their specific needs. Adjusting these settings can significantly impact the quality, coherence, and creativity of the generated text. For further insights, you may want to check the video you referenced, which likely provides additional context and examples on how these parameters affect model performance.
This post is licensed under CC BY 4.0 by the author.