Kernel width is the scaling parameter of the exponential kernel function that defines the locality of a LIME explanation. It governs the radius of the neighborhood around the instance being explained, assigning a weight of 1.0 to the original instance and exponentially smaller weights to perturbed samples as their distance increases. A smaller kernel width enforces strict locality, fitting the surrogate model to only the most similar samples, while a larger width smooths the explanation over a broader region of the local decision boundary.
Glossary
Kernel Width

What is Kernel Width?
Kernel width is a hyperparameter in Local Interpretable Model-agnostic Explanations (LIME) that controls the effective size of the local neighborhood by determining how quickly sample weights decay with distance from the original instance.
Selecting the optimal kernel width involves balancing the fidelity-interpretability trade-off. An excessively narrow width can produce unstable, high-variance explanations that change dramatically across runs due to insufficient sampling density. Conversely, an overly wide kernel violates the locality assumption, causing the linear surrogate to approximate a non-linear decision surface poorly and reducing local fidelity. Frameworks like OptiLIME automate this selection by optimizing for explanation stability while maintaining predictive accuracy.
Key Characteristics of Kernel Width
The kernel width hyperparameter defines the effective radius of the local neighborhood in LIME, directly controlling the bias-variance trade-off between explanation stability and fidelity to the black-box model's decision boundary.
Neighborhood Radius Definition
Kernel width determines how quickly sample weights decay with cosine distance or Euclidean distance from the original instance. A small kernel width creates a tight, highly local neighborhood where only very similar perturbed samples receive significant weight. A large kernel width flattens the weighting function, allowing more distant samples to influence the surrogate model training. This parameter effectively defines what 'local' means for a specific explanation, controlling the scope of the local decision boundary being approximated.
Fidelity-Interpretability Trade-off
Kernel width directly mediates the fidelity-interpretability trade-off in local explanations:
- Narrow kernel: Captures highly local, non-linear decision boundaries with greater precision but produces unstable explanations sensitive to sampling noise
- Wide kernel: Produces smoother, more stable explanations that approximate global behavior but may miss critical local variations
- Optimal selection: Requires balancing the complexity of the underlying model's decision surface against the need for reproducible explanations The choice fundamentally determines whether the explanation captures genuine local structure or averages over a broader region.
Exponential Kernel Function
LIME employs an exponential kernel to convert distances into sample weights: weight = exp(-D(x, z)² / σ²), where σ (sigma) is the kernel width and D(x, z) is the distance between the original instance and a perturbed sample. This function ensures:
- Samples identical to the original receive maximum weight of 1.0
- Weights decay smoothly and exponentially with increasing distance
- The rate of decay is controlled entirely by the kernel width parameter
- Very distant samples receive near-zero weight, effectively excluding them from surrogate model training
Explanation Stability Control
Kernel width is the primary control for explanation stability across multiple runs with different random seeds. A kernel that is too narrow causes the explanation to overfit to the specific random perturbation samples generated in each run, producing inconsistent feature importance rankings. A kernel that is too wide produces stable but potentially misleading explanations that fail to capture local nuances. OptiLIME addresses this by automatically selecting the kernel width that maximizes stability while maintaining a minimum fidelity threshold, ensuring reproducible explanations.
Modality-Specific Tuning
Optimal kernel width varies significantly by data modality and feature representation:
- Text data: Typically uses larger kernel widths due to the high-dimensional, sparse nature of TF-IDF or embedding representations where cosine distances can be large
- Image data: Requires careful tuning against superpixel segmentation granularity, as the distance between superpixel masks affects neighborhood density
- Tabular data: Depends on feature scaling and the density of the perturbation sampling strategy around the instance
- Categorical features: May require specialized distance metrics that account for non-numeric feature spaces
Bayesian Uncertainty Integration
Bayesian LIME extends kernel width selection by incorporating uncertainty quantification. Rather than using a fixed kernel width, Bayesian approaches treat it as a random variable with a prior distribution, allowing the explanation to express confidence intervals around feature importance scores. This integration reveals when the chosen kernel width may be inappropriate—wide confidence intervals suggest the explanation is sensitive to the kernel width choice, indicating potential instability in the local approximation that practitioners should investigate before trusting the explanation.
Small vs. Large Kernel Width
Trade-offs between narrow and wide kernel width settings in LIME explanations, controlling how quickly sample weights decay with distance from the target instance.
| Characteristic | Small Kernel Width | Medium Kernel Width | Large Kernel Width |
|---|---|---|---|
Locality Scope | Highly local | Moderately local | Near-global |
Sample Weight Decay | Rapid (steep drop-off) | Gradual | Very slow (flat weights) |
Local Fidelity | High (tight fit) | Balanced | Low (blurred fit) |
Explanation Stability | Low (high variance) | Moderate | High (low variance) |
Sensitivity to Noise | High | Moderate | Low |
Risk of Overfitting | High | Moderate | Low |
Risk of Underfitting | Low | Moderate | High |
Decision Boundary Approximation | Captures fine local curvature | Balanced approximation | Captures only broad trends |
Typical Use Case | Debugging a single anomalous prediction | General-purpose explanation | Understanding regional model behavior |
Distance Metric Impact | Highly sensitive | Moderately sensitive | Minimally sensitive |
Surrogate Model Complexity Required | Simpler model sufficient | Moderate complexity | More complex model may be needed |
Equivalent Kernel Shape | Narrow Gaussian | Moderate Gaussian | Wide, near-uniform Gaussian |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Precise answers to the most common technical questions about the kernel width hyperparameter in Local Interpretable Model-agnostic Explanations (LIME), covering its role in defining locality, its impact on explanation stability, and practical tuning strategies.
Kernel width is a hyperparameter that controls the effective radius of the local neighborhood around the instance being explained by determining how quickly sample weights decay with distance. In the LIME framework, an exponential kernel (often a Radial Basis Function or RBF kernel) is applied to the perturbed samples: $weight = \exp(-\frac{distance^2}{kernel_width^2})$. A small kernel width assigns significant weight only to samples very close to the original instance, enforcing strict local fidelity but potentially introducing instability due to a sparse neighborhood. A large kernel width creates a broader, smoother weighting scheme that may capture more global behavior at the expense of local precision. The kernel width directly shapes the local decision boundary that the interpretable surrogate model approximates.
Related Terms
Understanding kernel width requires familiarity with the core components of the LIME framework and the statistical concepts that govern local explanation fidelity.
Exponential Kernel
The weighting function that operationalizes kernel width. It assigns a proximity weight to each perturbed sample using the formula exp(-D(x, z)^2 / sigma^2), where sigma is the kernel width. Samples closer to the original instance receive weights approaching 1.0, while distant samples decay exponentially toward zero. This enforces the locality constraint, ensuring the surrogate model prioritizes fitting the immediate neighborhood.
Cosine Distance
The proximity metric used in LIME for text data. It measures the angle between TF-IDF vector representations of the original document and perturbed samples, producing a value between 0 (identical) and 1 (orthogonal). Unlike Euclidean distance, cosine distance ignores document length differences, making it robust for comparing texts of varying sizes after token masking perturbations.
Explanation Stability
The property that feature importance rankings remain consistent across multiple runs with different random seeds. An excessively narrow kernel width produces unstable explanations because the surrogate model overfits to a tiny, noisy neighborhood. Widening the kernel increases stability by incorporating more samples, but risks violating the local fidelity assumption if the decision boundary is highly non-linear.
Locally Weighted Regression
The statistical backbone of LIME. This non-parametric method fits a simple model to a localized subset of data, weighting each training point by its proximity to the query instance. The kernel width directly controls the bandwidth of this regression: a small bandwidth captures fine-grained local structure but suffers high variance, while a large bandwidth produces smoother, lower-variance estimates that may miss sharp decision boundaries.
Fidelity-Interpretability Trade-off
The fundamental balancing act that kernel width mediates. A narrow kernel yields high local fidelity because the surrogate only needs to be accurate in a tiny region, but the explanation may be unstable and fail to capture broader patterns. A wide kernel produces more globally representative explanations but may smooth over critical local decision boundary details. The optimal width is instance-dependent and reflects the local curvature of the model's prediction function.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us