verbose flag for an LLMChain instance to inspect its internal steps—prompt formatting, input handling, and output generation—without enabling global debug mode.
Why Use verbose=True?
By setting verbose=True on a specific chain, you can:
- Trace how input variables populate your prompt.
- See intermediate formatting before the LLM is called.
- Log only the components you’re interested in, keeping other logs clean.
Verbose mode is ideal for local debugging and development. For production workloads, consider disabling verbosity to reduce log noise and potential exposure of sensitive data.
Step-by-Step Example
Sample Console Output
The chain prints a JSON-like debug trace along with your final output:- Entering
LLMChainwith input arguments. - Formatted prompt after variable substitution.
- Exiting
LLMChainwith generated output.
Verbose vs. Global Debug
| Mode | Scope | Output |
|---|---|---|
verbose=True | Single chain | Chain-specific debug messages |
Global logging.DEBUG | Entire application | All debug logs across components |
Avoid using global debug in production, as it can generate excessive logs and potentially expose secrets. Use
verbose=True on only those chains you need to inspect.