How to Customize the LLM Temperature Setting in Litho: A Complete Guide

You can customize the LLM temperature setting in Litho using the --temperature CLI flag or by setting the temperature field in your litho.toml configuration file, with values ranging from 0.0 (deterministic) to 1.0 (creative).

When working with the sopaco/deepwiki-rs repository (Litho), controlling the randomness of LLM outputs is essential for generating consistent documentation or creative content. This guide explains how to customize the LLM temperature setting in Litho through multiple configuration layers, from command-line flags to programmatic Rust APIs.

Understanding LLM Temperature in Litho

Temperature controls how deterministic the model's output is. Lower values (0.0–0.2) produce more focused, deterministic responses ideal for technical documentation, while higher values (0.7–1.0) increase creativity and variability suitable for brainstorming or diverse content generation.

Configuration Methods for LLM Temperature

The litho.toml Configuration File

The primary configuration file defines the LLMConfig struct with an optional temperature field. In src/config.rs (lines 56–58), the struct includes temperature: Option<f64>, allowing you to set a default value that persists across sessions.

[llm]
provider = "ollama"
api_base_url = "http://localhost:11434"
model_efficient = "llama3.1:8b"
max_tokens = 2048

# Optional temperature (0.0 – 1.0)

temperature = 0.4

Command-Line Interface Flags

For ad-hoc adjustments, the CLI exposes a --temperature flag. In src/cli.rs (lines 70–84), the argument parsing logic captures the optional float value and propagates it through Args::to_config(), overriding any file-based configuration.

litho --temperature 0.7 --model-efficient llama3.1:8b

Programmatic Configuration in Rust

When embedding Litho as a library, you can construct the configuration directly:

use deepwiki_rs::config::Config;
use deepwiki_rs::cli::Args;

// Parse arguments including --temperature
let args = Args::parse();
let config = args.to_config();
// Temperature is now set in config.llm.temperature

How Temperature Flows Through the Codebase

The temperature value follows a three-stage pipeline:

  1. Definition: The LLMConfig struct in src/config.rs (lines 56–58) declares temperature as Option<f64>, defaulting to None when unspecified.

  2. CLI Integration: In src/cli.rs (lines 70–84), the --temperature flag is parsed and merged into the configuration via Args::to_config().

  3. Provider Application: In src/llm/client/providers.rs, each provider's builder checks config.temperature. For example, lines 99–101 show the OpenAI implementation calling .temperature() on the builder when the value is present. Similar blocks exist for Ollama, Anthropic, and other providers.

Summary

  • Customize the LLM temperature setting in Litho using either the litho.toml configuration file or the --temperature CLI flag.
  • Valid values range from 0.0 (deterministic) to 1.0 (creative), with 0.2–0.4 recommended for technical documentation.
  • The configuration flows from src/config.rs through src/cli.rs to src/llm/client/providers.rs, where provider-specific builders apply the setting.
  • When unspecified, the underlying LLM provider uses its default temperature value.

Frequently Asked Questions

What is the default temperature if I don't specify one?

If you omit the temperature setting in both litho.toml and CLI arguments, the LLMConfig struct in src/config.rs stores None for the optional field. Each provider in src/llm/client/providers.rs then falls back to its own default value, typically 0.7 for OpenAI or provider-specific defaults.

Can I set different temperatures for different LLM providers?

Currently, the LLMConfig structure maintains a single temperature field that applies globally to whichever provider is active. To use different temperatures for different providers, you must maintain separate configuration files or invoke Litho with different --temperature values for each provider-specific run.

What temperature value should I use for code generation tasks?

For technical documentation and code generation within the sopaco/deepwiki-rs ecosystem, temperature values between 0.0 and 0.3 produce the most deterministic, accurate outputs. Values above 0.5 may introduce unnecessary variability in API documentation or code examples, while 0.0 ensures reproducible results across multiple runs.

How do I verify that my temperature setting is being applied?

You can verify the active configuration by enabling debug logging or inspecting the provider request logs. When using the CLI, run Litho with the --temperature flag and check that the value appears in the initialization logs. In src/llm/client/providers.rs, the temperature is explicitly set on the builder only when config.temperature is Some(f64), so a None value indicates the provider default is in use.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →